From 5239891a4ee9ad3a9598a0cc35967443df0db64f Mon Sep 17 00:00:00 2001
From: Hristo Iankov <35353708+hristoiankov@users.noreply.github.com>
Date: Fri, 21 Jul 2023 21:06:16 -0400
Subject: [PATCH 1/5] table stats
---
cider-app/src/app/entity-table/entity-table.component.html | 4 ++++
cider-app/src/app/entity-table/entity-table.component.ts | 1 +
2 files changed, 5 insertions(+)
diff --git a/cider-app/src/app/entity-table/entity-table.component.html b/cider-app/src/app/entity-table/entity-table.component.html
index f7bdf80..1c55712 100644
--- a/cider-app/src/app/entity-table/entity-table.component.html
+++ b/cider-app/src/app/entity-table/entity-table.component.html
@@ -9,6 +9,10 @@
+
+
+
diff --git a/cider-app/src/app/entity-table/entity-table.component.ts b/cider-app/src/app/entity-table/entity-table.component.ts
index bcf7822..b431e23 100644
--- a/cider-app/src/app/entity-table/entity-table.component.ts
+++ b/cider-app/src/app/entity-table/entity-table.component.ts
@@ -27,6 +27,7 @@ export class EntityTableComponent im
@Input() lazy: boolean = true;
@Input() showActions: boolean = true;
@Input() showInlineEditor: boolean = true;
+ @Input() showStats: boolean = false;
@Input() saveToService: boolean = true;
@Output() selectionChange: EventEmitter = new EventEmitter();
FieldType = FieldType;
From 30ed17d988aab3f624da643eded941273c4a2df0 Mon Sep 17 00:00:00 2001
From: Hristo Iankov <35353708+hristoiankov@users.noreply.github.com>
Date: Sat, 22 Jul 2023 00:54:41 -0400
Subject: [PATCH 2/5] token stats all
---
cider-app/src/app/cards/cards.component.html | 2 +-
.../entity-table/entity-table.component.html | 35 +++++++++++-
.../entity-table/entity-table.component.scss | 14 +++++
.../entity-table/entity-table.component.ts | 54 +++++++++++++++++++
.../src/app/entity-table/table-stat.type.ts | 19 +++++++
5 files changed, 121 insertions(+), 3 deletions(-)
create mode 100644 cider-app/src/app/entity-table/table-stat.type.ts
diff --git a/cider-app/src/app/cards/cards.component.html b/cider-app/src/app/cards/cards.component.html
index 4a21d22..1791218 100644
--- a/cider-app/src/app/cards/cards.component.html
+++ b/cider-app/src/app/cards/cards.component.html
@@ -1,5 +1,5 @@
-
+
\ No newline at end of file
diff --git a/cider-app/src/app/entity-table/entity-table.component.html b/cider-app/src/app/entity-table/entity-table.component.html
index 1c55712..c7eb759 100644
--- a/cider-app/src/app/entity-table/entity-table.component.html
+++ b/cider-app/src/app/entity-table/entity-table.component.html
@@ -10,8 +10,8 @@
-
+
+
+
+
+
+
+
+
{{stat.header}}
+
+
+
+
+
+
+
+
{{token.token}}
+
{{token.count}}
+
{{token.copiesCount}}
+
+
+
+
+
+
+
+
+
diff --git a/cider-app/src/app/entity-table/entity-table.component.scss b/cider-app/src/app/entity-table/entity-table.component.scss
index ddc3ddd..3b787df 100644
--- a/cider-app/src/app/entity-table/entity-table.component.scss
+++ b/cider-app/src/app/entity-table/entity-table.component.scss
@@ -139,4 +139,18 @@
:host ::ng-deep .p-datatable .p-datatable-tbody > tr.p-highlight {
background: var(--surface-d);
color: var(--text-color);
+}
+
+.token-stats {
+ .token-row {
+ display: table-row;
+ &.token-header {
+ color: #5c7089;
+ }
+ & > div {
+ display: table-cell;
+ padding-left: 5px;
+ padding-right: 5px;
+ }
+ }
}
\ No newline at end of file
diff --git a/cider-app/src/app/entity-table/entity-table.component.ts b/cider-app/src/app/entity-table/entity-table.component.ts
index b431e23..206b9d5 100644
--- a/cider-app/src/app/entity-table/entity-table.component.ts
+++ b/cider-app/src/app/entity-table/entity-table.component.ts
@@ -7,6 +7,7 @@ import { FieldType } from '../data-services/types/field-type.type';
import { SortDirection } from '../data-services/types/search-sort.type';
import XlsxUtils from '../shared/utils/xlsx-utils';
import { Subject, debounceTime } from 'rxjs';
+import { TableStat, TokenStat } from './table-stat.type';
@Component({
selector: 'app-entity-table',
@@ -38,6 +39,8 @@ export class EntityTableComponent im
idField?: string;
lookups: Map, Map> = new Map();
importVisible: boolean = false;
+ statsVisible: boolean = false;
+ stats: TableStat[] = [];
importFile: File | undefined = undefined;
saveSubject: Subject = new Subject();
optionsCache: Map, any[]>;
@@ -151,6 +154,57 @@ export class EntityTableComponent im
});
}
+ public openStatsDialog() {
+ // calculate the stats
+ //
+ // field-name:
+ // token-name token-count token-copies-count
+ // token-name-2 token-count-2 token-copies-count-2
+ // ...
+ // ...
+ //
+ // text = 'text',
+ // textArea = 'text-area',
+ // number = 'number',
+ // file = 'file',
+ // option = 'option',
+ // optionList = 'optionList'
+ //
+ const stats = this.columns.filter(column => !column.hidden).map(column => {
+ const tokenStats = new Map();
+ this.records.forEach(record => {
+ const copies = (record as any)['count'] || 1;
+ const value = record[column.field];
+ if (value) {
+ const strValue = '' + value;
+ strValue.replace(/[<][^>]*[>]/, '').split(/ /).filter(str => str).forEach(token => {
+ const tokenStat = tokenStats.get(token);
+ if (tokenStat) {
+ tokenStats.set(token,
+ {token: token, count: tokenStat.count + 1,
+ copiesCount: tokenStat.copiesCount + copies} as TokenStat);
+ } else {
+ tokenStats.set(token,
+ {token: token, count: 1, copiesCount: copies} as TokenStat);
+ }
+ });
+ }
+ });
+ const tokens = Array.from(tokenStats.values()).sort((a, b) => b.count - a.count);
+ console.log('tokens:', tokens);
+ return {
+ header: column.header,
+ tokens: tokens
+ } as TableStat;
+ });
+ this.stats = stats;
+ this.statsVisible = true;
+ }
+
+ public closeStatsDialog() {
+ this.statsVisible = false;
+ }
+
public openCreateNew() {
this.entity = {} as Entity;
this.dialogVisible = true;
diff --git a/cider-app/src/app/entity-table/table-stat.type.ts b/cider-app/src/app/entity-table/table-stat.type.ts
new file mode 100644
index 0000000..e99bc6c
--- /dev/null
+++ b/cider-app/src/app/entity-table/table-stat.type.ts
@@ -0,0 +1,19 @@
+
+ // TableStat
+ //
+ // field-name:
+ // token-name token-count token-copies-count
+ // token-name-2 token-count-2 token-copies-count-2
+ // ...
+ // ...
+
+ export interface TableStat {
+ header: string;
+ tokens: TokenStat[];
+ }
+
+ export interface TokenStat {
+ token: string;
+ count: number;
+ copiesCount: number;
+ }
\ No newline at end of file
From 4739cfac13dbb1d904682ac531a696c988730886 Mon Sep 17 00:00:00 2001
From: Hristo Iankov <35353708+hristoiankov@users.noreply.github.com>
Date: Sat, 22 Jul 2023 01:02:38 -0400
Subject: [PATCH 3/5] top 20 stats
---
cider-app/src/app/entity-table/entity-table.component.html | 2 +-
cider-app/src/app/entity-table/entity-table.component.ts | 3 ++-
2 files changed, 3 insertions(+), 2 deletions(-)
diff --git a/cider-app/src/app/entity-table/entity-table.component.html b/cider-app/src/app/entity-table/entity-table.component.html
index c7eb759..aedb5c4 100644
--- a/cider-app/src/app/entity-table/entity-table.component.html
+++ b/cider-app/src/app/entity-table/entity-table.component.html
@@ -194,7 +194,7 @@
-
+