diff --git a/ui-ngx/package-lock.json b/ui-ngx/package-lock.json index d4b7aa7e59..2ff4ae7175 100644 --- a/ui-ngx/package-lock.json +++ b/ui-ngx/package-lock.json @@ -8997,10 +8997,10 @@ "integrity": "sha512-4O3GWAYJaauMCILm07weko2rHA8a4kjn7+8Lg4s1d7SxwS/3IpkVD/GljbRrIJ1c1W/XGJ3GbuK7RyYZEJChhw==" }, "ngx-flowchart": { - "version": "git://github.com/thingsboard/ngx-flowchart.git#a4157b0eef2eb3646ef920447c7b06b39d54f87f", + "version": "git://github.com/thingsboard/ngx-flowchart.git#7a02f4748b5e7821a883c903107af5f20415d026", "from": "git://github.com/thingsboard/ngx-flowchart.git#master", "requires": { - "tslib": "^1.10.0" + "tslib": "^1.13.0" }, "dependencies": { "tslib": { diff --git a/ui-ngx/src/app/core/api/widget-subscription.ts b/ui-ngx/src/app/core/api/widget-subscription.ts index 54988774aa..eb5b5cd780 100644 --- a/ui-ngx/src/app/core/api/widget-subscription.ts +++ b/ui-ngx/src/app/core/api/widget-subscription.ts @@ -337,6 +337,7 @@ export class WidgetSubscription implements IWidgetSubscription { } private initDataSubscription(): Observable { + this.notifyDataLoading(); const initDataSubscriptionSubject = new ReplaySubject(1); this.loadStDiff().subscribe(() => { if (!this.ctx.aliasController) { @@ -431,6 +432,7 @@ export class WidgetSubscription implements IWidgetSubscription { }); this.configureLoadedData(); this.hasResolvedData = this.datasources.length > 0; + this.updateDataTimewindow(); this.notifyDataLoaded(); this.onDataUpdated(true); }) @@ -731,6 +733,7 @@ export class WidgetSubscription implements IWidgetSubscription { if (this.type === widgetType.alarm) { this.updateAlarmDataSubscription(); } else { + this.notifyDataLoading(); this.dataSubscribe(); } } @@ -831,13 +834,21 @@ export class WidgetSubscription implements IWidgetSubscription { } } - private dataSubscribe() { + private updateDataTimewindow() { if (!this.hasDataPageLink) { if (this.type === widgetType.timeseries && this.timeWindowConfig) { this.updateRealtimeSubscription(); if (this.comparisonEnabled) { this.updateSubscriptionForComparison(); } + } + } + } + + private dataSubscribe() { + if (!this.hasDataPageLink) { + if (this.type === widgetType.timeseries && this.timeWindowConfig) { + this.updateDataTimewindow(); if (this.subscriptionTimewindow.fixedWindow) { this.onDataUpdated(); } @@ -1025,6 +1036,11 @@ export class WidgetSubscription implements IWidgetSubscription { } } + private notifyDataLoading() { + this.loadingData = true; + this.callbacks.dataLoading(this); + } + private notifyDataLoaded() { this.loadingData = false; this.callbacks.dataLoading(this); @@ -1268,6 +1284,7 @@ export class WidgetSubscription implements IWidgetSubscription { if (this.caulculateLegendData) { this.updateLegend(index, data.data, detectChanges); } + this.notifyDataLoaded(); this.onDataUpdated(detectChanges); } } diff --git a/ui-ngx/src/app/modules/home/components/widget/lib/alarms-table-widget.component.ts b/ui-ngx/src/app/modules/home/components/widget/lib/alarms-table-widget.component.ts index 4ba0aed569..c88d23fa10 100644 --- a/ui-ngx/src/app/modules/home/components/widget/lib/alarms-table-widget.component.ts +++ b/ui-ngx/src/app/modules/home/components/widget/lib/alarms-table-widget.component.ts @@ -330,7 +330,7 @@ export class AlarmsTableWidgetComponent extends PageComponent implements OnInit, this.defaultPageSize = pageSize; } this.pageSizeOptions = [this.defaultPageSize, this.defaultPageSize * 2, this.defaultPageSize * 3]; - this.pageLink.pageSize = this.displayPagination ? this.defaultPageSize : Number.POSITIVE_INFINITY; + this.pageLink.pageSize = this.displayPagination ? this.defaultPageSize : 1024; this.pageLink.searchPropagatedAlarms = isDefined(this.widgetConfig.searchPropagatedAlarms) ? this.widgetConfig.searchPropagatedAlarms : true; @@ -535,10 +535,15 @@ export class AlarmsTableWidgetComponent extends PageComponent implements OnInit, } else { this.pageLink.page = 0; } - this.pageLink.sortOrder = { - key: findEntityKeyByColumnDef(this.sort.active, this.columns), - direction: Direction[this.sort.direction.toUpperCase()] - }; + const key = findEntityKeyByColumnDef(this.sort.active, this.columns); + if (key) { + this.pageLink.sortOrder = { + key, + direction: Direction[this.sort.direction.toUpperCase()] + }; + } else { + this.pageLink.sortOrder = null; + } const sortOrderLabel = fromEntityColumnDef(this.sort.active, this.columns); const keyFilters: KeyFilter[] = null; // TODO: this.alarmsDatasource.loadAlarms(this.pageLink, sortOrderLabel, keyFilters); diff --git a/ui-ngx/src/app/modules/home/components/widget/lib/entities-table-widget.component.ts b/ui-ngx/src/app/modules/home/components/widget/lib/entities-table-widget.component.ts index 5bf040ed0d..77aff9c658 100644 --- a/ui-ngx/src/app/modules/home/components/widget/lib/entities-table-widget.component.ts +++ b/ui-ngx/src/app/modules/home/components/widget/lib/entities-table-widget.component.ts @@ -240,7 +240,7 @@ export class EntitiesTableWidgetComponent extends PageComponent implements OnIni this.defaultPageSize = pageSize; } this.pageSizeOptions = [this.defaultPageSize, this.defaultPageSize * 2, this.defaultPageSize * 3]; - this.pageLink.pageSize = this.displayPagination ? this.defaultPageSize : Number.POSITIVE_INFINITY; + this.pageLink.pageSize = this.displayPagination ? this.defaultPageSize : 1024; const cssString = constructTableCssString(this.widgetConfig); const cssParser = new cssjs(); @@ -460,10 +460,15 @@ export class EntitiesTableWidgetComponent extends PageComponent implements OnIni } else { this.pageLink.page = 0; } - this.pageLink.sortOrder = { - key: findEntityKeyByColumnDef(this.sort.active, this.columns), - direction: Direction[this.sort.direction.toUpperCase()] - }; + const key = findEntityKeyByColumnDef(this.sort.active, this.columns); + if (key) { + this.pageLink.sortOrder = { + key, + direction: Direction[this.sort.direction.toUpperCase()] + }; + } else { + this.pageLink.sortOrder = null; + } const sortOrderLabel = fromEntityColumnDef(this.sort.active, this.columns); const keyFilters: KeyFilter[] = null; // TODO: this.entityDatasource.loadEntities(this.pageLink, sortOrderLabel, keyFilters); diff --git a/ui-ngx/src/app/modules/home/components/widget/lib/maps/maps-utils.ts b/ui-ngx/src/app/modules/home/components/widget/lib/maps/maps-utils.ts index 0dad455478..576e594df6 100644 --- a/ui-ngx/src/app/modules/home/components/widget/lib/maps/maps-utils.ts +++ b/ui-ngx/src/app/modules/home/components/widget/lib/maps/maps-utils.ts @@ -159,7 +159,7 @@ function parseTemplate(template: string, data: { $datasource?: Datasource, [key: } template = createLabelFromDatasource(data.$datasource, template); - let match = varsRegex.exec(template); + let match = /\${([^}]*)}/g.exec(template); while (match !== null) { const variable = match[0]; let label = match[1]; @@ -186,7 +186,7 @@ function parseTemplate(template: string, data: { $datasource?: Datasource, [key: textValue = value; } template = template.split(variable).join(textValue); - match = varsRegex.exec(template); + match = /\${([^}]*)}/g.exec(template); } let actionTags: string; diff --git a/ui-ngx/src/app/modules/home/components/widget/lib/table-widget.models.ts b/ui-ngx/src/app/modules/home/components/widget/lib/table-widget.models.ts index dd295da76d..a6edfb86a5 100644 --- a/ui-ngx/src/app/modules/home/components/widget/lib/table-widget.models.ts +++ b/ui-ngx/src/app/modules/home/components/widget/lib/table-widget.models.ts @@ -96,7 +96,10 @@ export function entityDataSortOrderFromString(strSortOrder: string, columns: Ent if (!property && !property.length) { return null; } - const column = findColumnByLabel(property, columns); + let column = findColumnByLabel(property, columns); + if (!column) { + column = findColumnByName(property, columns); + } if (column && column.entityKey) { return {key: column.entityKey, direction}; } @@ -113,13 +116,22 @@ export function findColumnByEntityKey(key: EntityKey, columns: EntityColumn[]): } export function findEntityKeyByColumnDef(def: string, columns: EntityColumn[]): EntityKey { - return findColumnByDef(def, columns).entityKey; + if (def) { + const column = findColumnByDef(def, columns); + return column ? column.entityKey : null; + } else { + return null; + } } export function findColumn(searchProperty: string, searchValue: string, columns: EntityColumn[]): EntityColumn { return columns.find(theColumn => theColumn[searchProperty] === searchValue); } +export function findColumnByName(name: string, columns: EntityColumn[]): EntityColumn { + return findColumn('name', name, columns); +} + export function findColumnByLabel(label: string, columns: EntityColumn[]): EntityColumn { let column: EntityColumn; const alarmColumns = columns.filter(c => c.type === DataKeyType.alarm);