Commit 4f3e29b43339f44189fe4ea7a906326823468e3f
1 parent
2ca2b1b1
UI: Fix pageLink without pagination. Minor fixes
Showing
6 changed files
with
56 additions
and
17 deletions
... | ... | @@ -8997,10 +8997,10 @@ |
8997 | 8997 | "integrity": "sha512-4O3GWAYJaauMCILm07weko2rHA8a4kjn7+8Lg4s1d7SxwS/3IpkVD/GljbRrIJ1c1W/XGJ3GbuK7RyYZEJChhw==" |
8998 | 8998 | }, |
8999 | 8999 | "ngx-flowchart": { |
9000 | - "version": "git://github.com/thingsboard/ngx-flowchart.git#a4157b0eef2eb3646ef920447c7b06b39d54f87f", | |
9000 | + "version": "git://github.com/thingsboard/ngx-flowchart.git#7a02f4748b5e7821a883c903107af5f20415d026", | |
9001 | 9001 | "from": "git://github.com/thingsboard/ngx-flowchart.git#master", |
9002 | 9002 | "requires": { |
9003 | - "tslib": "^1.10.0" | |
9003 | + "tslib": "^1.13.0" | |
9004 | 9004 | }, |
9005 | 9005 | "dependencies": { |
9006 | 9006 | "tslib": { | ... | ... |
... | ... | @@ -337,6 +337,7 @@ export class WidgetSubscription implements IWidgetSubscription { |
337 | 337 | } |
338 | 338 | |
339 | 339 | private initDataSubscription(): Observable<any> { |
340 | + this.notifyDataLoading(); | |
340 | 341 | const initDataSubscriptionSubject = new ReplaySubject(1); |
341 | 342 | this.loadStDiff().subscribe(() => { |
342 | 343 | if (!this.ctx.aliasController) { |
... | ... | @@ -431,6 +432,7 @@ export class WidgetSubscription implements IWidgetSubscription { |
431 | 432 | }); |
432 | 433 | this.configureLoadedData(); |
433 | 434 | this.hasResolvedData = this.datasources.length > 0; |
435 | + this.updateDataTimewindow(); | |
434 | 436 | this.notifyDataLoaded(); |
435 | 437 | this.onDataUpdated(true); |
436 | 438 | }) |
... | ... | @@ -731,6 +733,7 @@ export class WidgetSubscription implements IWidgetSubscription { |
731 | 733 | if (this.type === widgetType.alarm) { |
732 | 734 | this.updateAlarmDataSubscription(); |
733 | 735 | } else { |
736 | + this.notifyDataLoading(); | |
734 | 737 | this.dataSubscribe(); |
735 | 738 | } |
736 | 739 | } |
... | ... | @@ -831,13 +834,21 @@ export class WidgetSubscription implements IWidgetSubscription { |
831 | 834 | } |
832 | 835 | } |
833 | 836 | |
834 | - private dataSubscribe() { | |
837 | + private updateDataTimewindow() { | |
835 | 838 | if (!this.hasDataPageLink) { |
836 | 839 | if (this.type === widgetType.timeseries && this.timeWindowConfig) { |
837 | 840 | this.updateRealtimeSubscription(); |
838 | 841 | if (this.comparisonEnabled) { |
839 | 842 | this.updateSubscriptionForComparison(); |
840 | 843 | } |
844 | + } | |
845 | + } | |
846 | + } | |
847 | + | |
848 | + private dataSubscribe() { | |
849 | + if (!this.hasDataPageLink) { | |
850 | + if (this.type === widgetType.timeseries && this.timeWindowConfig) { | |
851 | + this.updateDataTimewindow(); | |
841 | 852 | if (this.subscriptionTimewindow.fixedWindow) { |
842 | 853 | this.onDataUpdated(); |
843 | 854 | } |
... | ... | @@ -1025,6 +1036,11 @@ export class WidgetSubscription implements IWidgetSubscription { |
1025 | 1036 | } |
1026 | 1037 | } |
1027 | 1038 | |
1039 | + private notifyDataLoading() { | |
1040 | + this.loadingData = true; | |
1041 | + this.callbacks.dataLoading(this); | |
1042 | + } | |
1043 | + | |
1028 | 1044 | private notifyDataLoaded() { |
1029 | 1045 | this.loadingData = false; |
1030 | 1046 | this.callbacks.dataLoading(this); |
... | ... | @@ -1268,6 +1284,7 @@ export class WidgetSubscription implements IWidgetSubscription { |
1268 | 1284 | if (this.caulculateLegendData) { |
1269 | 1285 | this.updateLegend(index, data.data, detectChanges); |
1270 | 1286 | } |
1287 | + this.notifyDataLoaded(); | |
1271 | 1288 | this.onDataUpdated(detectChanges); |
1272 | 1289 | } |
1273 | 1290 | } | ... | ... |
... | ... | @@ -330,7 +330,7 @@ export class AlarmsTableWidgetComponent extends PageComponent implements OnInit, |
330 | 330 | this.defaultPageSize = pageSize; |
331 | 331 | } |
332 | 332 | this.pageSizeOptions = [this.defaultPageSize, this.defaultPageSize * 2, this.defaultPageSize * 3]; |
333 | - this.pageLink.pageSize = this.displayPagination ? this.defaultPageSize : Number.POSITIVE_INFINITY; | |
333 | + this.pageLink.pageSize = this.displayPagination ? this.defaultPageSize : 1024; | |
334 | 334 | |
335 | 335 | this.pageLink.searchPropagatedAlarms = isDefined(this.widgetConfig.searchPropagatedAlarms) |
336 | 336 | ? this.widgetConfig.searchPropagatedAlarms : true; |
... | ... | @@ -535,10 +535,15 @@ export class AlarmsTableWidgetComponent extends PageComponent implements OnInit, |
535 | 535 | } else { |
536 | 536 | this.pageLink.page = 0; |
537 | 537 | } |
538 | - this.pageLink.sortOrder = { | |
539 | - key: findEntityKeyByColumnDef(this.sort.active, this.columns), | |
540 | - direction: Direction[this.sort.direction.toUpperCase()] | |
541 | - }; | |
538 | + const key = findEntityKeyByColumnDef(this.sort.active, this.columns); | |
539 | + if (key) { | |
540 | + this.pageLink.sortOrder = { | |
541 | + key, | |
542 | + direction: Direction[this.sort.direction.toUpperCase()] | |
543 | + }; | |
544 | + } else { | |
545 | + this.pageLink.sortOrder = null; | |
546 | + } | |
542 | 547 | const sortOrderLabel = fromEntityColumnDef(this.sort.active, this.columns); |
543 | 548 | const keyFilters: KeyFilter[] = null; // TODO: |
544 | 549 | this.alarmsDatasource.loadAlarms(this.pageLink, sortOrderLabel, keyFilters); | ... | ... |
... | ... | @@ -240,7 +240,7 @@ export class EntitiesTableWidgetComponent extends PageComponent implements OnIni |
240 | 240 | this.defaultPageSize = pageSize; |
241 | 241 | } |
242 | 242 | this.pageSizeOptions = [this.defaultPageSize, this.defaultPageSize * 2, this.defaultPageSize * 3]; |
243 | - this.pageLink.pageSize = this.displayPagination ? this.defaultPageSize : Number.POSITIVE_INFINITY; | |
243 | + this.pageLink.pageSize = this.displayPagination ? this.defaultPageSize : 1024; | |
244 | 244 | |
245 | 245 | const cssString = constructTableCssString(this.widgetConfig); |
246 | 246 | const cssParser = new cssjs(); |
... | ... | @@ -460,10 +460,15 @@ export class EntitiesTableWidgetComponent extends PageComponent implements OnIni |
460 | 460 | } else { |
461 | 461 | this.pageLink.page = 0; |
462 | 462 | } |
463 | - this.pageLink.sortOrder = { | |
464 | - key: findEntityKeyByColumnDef(this.sort.active, this.columns), | |
465 | - direction: Direction[this.sort.direction.toUpperCase()] | |
466 | - }; | |
463 | + const key = findEntityKeyByColumnDef(this.sort.active, this.columns); | |
464 | + if (key) { | |
465 | + this.pageLink.sortOrder = { | |
466 | + key, | |
467 | + direction: Direction[this.sort.direction.toUpperCase()] | |
468 | + }; | |
469 | + } else { | |
470 | + this.pageLink.sortOrder = null; | |
471 | + } | |
467 | 472 | const sortOrderLabel = fromEntityColumnDef(this.sort.active, this.columns); |
468 | 473 | const keyFilters: KeyFilter[] = null; // TODO: |
469 | 474 | this.entityDatasource.loadEntities(this.pageLink, sortOrderLabel, keyFilters); | ... | ... |
... | ... | @@ -159,7 +159,7 @@ function parseTemplate(template: string, data: { $datasource?: Datasource, [key: |
159 | 159 | } |
160 | 160 | template = createLabelFromDatasource(data.$datasource, template); |
161 | 161 | |
162 | - let match = varsRegex.exec(template); | |
162 | + let match = /\${([^}]*)}/g.exec(template); | |
163 | 163 | while (match !== null) { |
164 | 164 | const variable = match[0]; |
165 | 165 | let label = match[1]; |
... | ... | @@ -186,7 +186,7 @@ function parseTemplate(template: string, data: { $datasource?: Datasource, [key: |
186 | 186 | textValue = value; |
187 | 187 | } |
188 | 188 | template = template.split(variable).join(textValue); |
189 | - match = varsRegex.exec(template); | |
189 | + match = /\${([^}]*)}/g.exec(template); | |
190 | 190 | } |
191 | 191 | |
192 | 192 | let actionTags: string; | ... | ... |
... | ... | @@ -96,7 +96,10 @@ export function entityDataSortOrderFromString(strSortOrder: string, columns: Ent |
96 | 96 | if (!property && !property.length) { |
97 | 97 | return null; |
98 | 98 | } |
99 | - const column = findColumnByLabel(property, columns); | |
99 | + let column = findColumnByLabel(property, columns); | |
100 | + if (!column) { | |
101 | + column = findColumnByName(property, columns); | |
102 | + } | |
100 | 103 | if (column && column.entityKey) { |
101 | 104 | return {key: column.entityKey, direction}; |
102 | 105 | } |
... | ... | @@ -113,13 +116,22 @@ export function findColumnByEntityKey(key: EntityKey, columns: EntityColumn[]): |
113 | 116 | } |
114 | 117 | |
115 | 118 | export function findEntityKeyByColumnDef(def: string, columns: EntityColumn[]): EntityKey { |
116 | - return findColumnByDef(def, columns).entityKey; | |
119 | + if (def) { | |
120 | + const column = findColumnByDef(def, columns); | |
121 | + return column ? column.entityKey : null; | |
122 | + } else { | |
123 | + return null; | |
124 | + } | |
117 | 125 | } |
118 | 126 | |
119 | 127 | export function findColumn(searchProperty: string, searchValue: string, columns: EntityColumn[]): EntityColumn { |
120 | 128 | return columns.find(theColumn => theColumn[searchProperty] === searchValue); |
121 | 129 | } |
122 | 130 | |
131 | +export function findColumnByName(name: string, columns: EntityColumn[]): EntityColumn { | |
132 | + return findColumn('name', name, columns); | |
133 | +} | |
134 | + | |
123 | 135 | export function findColumnByLabel(label: string, columns: EntityColumn[]): EntityColumn { |
124 | 136 | let column: EntityColumn; |
125 | 137 | const alarmColumns = columns.filter(c => c.type === DataKeyType.alarm); | ... | ... |