From 53598ac49c1c1a4a3a0eb3cabf676a68307f2ebc Mon Sep 17 00:00:00 2001 From: Maksym Tsymbarov Date: Tue, 25 Nov 2025 16:43:37 +0200 Subject: [PATCH] updated api usage dashboard --- ...eseries-table-widget-settings.component.ts | 2 +- .../lib/timeseries-table-widget.component.ts | 22 ++++++------------- ui-ngx/src/assets/dashboard/api_usage.json | 5 ++++- 3 files changed, 12 insertions(+), 17 deletions(-) diff --git a/ui-ngx/src/app/modules/home/components/widget/lib/settings/cards/timeseries-table-widget-settings.component.ts b/ui-ngx/src/app/modules/home/components/widget/lib/settings/cards/timeseries-table-widget-settings.component.ts index d501d581c9..3911506be7 100644 --- a/ui-ngx/src/app/modules/home/components/widget/lib/settings/cards/timeseries-table-widget-settings.component.ts +++ b/ui-ngx/src/app/modules/home/components/widget/lib/settings/cards/timeseries-table-widget-settings.component.ts @@ -65,7 +65,7 @@ export class TimeseriesTableWidgetSettingsComponent extends WidgetSettingsCompon useRowStyleFunction: false, rowStyleFunction: '', sortOrder: { - property: this.entityFields.name.keyName, + property: this.entityFields.createdTime.keyName, direction: Direction.DESC } }; diff --git a/ui-ngx/src/app/modules/home/components/widget/lib/timeseries-table-widget.component.ts b/ui-ngx/src/app/modules/home/components/widget/lib/timeseries-table-widget.component.ts index 47322aaed1..282fab9a3e 100644 --- a/ui-ngx/src/app/modules/home/components/widget/lib/timeseries-table-widget.component.ts +++ b/ui-ngx/src/app/modules/home/components/widget/lib/timeseries-table-widget.component.ts @@ -395,21 +395,15 @@ export class TimeseriesTableWidgetComponent extends PageComponent implements OnI this.updateDatasources(); } - private getTabLabel(source: Datasource, entityLabelCache:Map):string { - if (entityLabelCache.has(source.entityId)) { - return entityLabelCache.get(source.entityId); - } - + private getTabLabel(source: Datasource):string { const value = this.useEntityLabel ? (source.entityLabel || source.entityName) : source.entityName; - const translated = this.utils.customTranslation(value); - entityLabelCache.set(source.entityId, translated); - return translated; + return this.utils.customTranslation(value); } - private sortDatasources(source: TimeseriesTableSource[], entityLabelCache: Map) { + private sortDatasources(source: TimeseriesTableSource[]) { const property = this.settings?.sortOrder?.property; const direction = this.settings?.sortOrder?.direction; const isAsc = direction === Direction.ASC; @@ -422,8 +416,8 @@ export class TimeseriesTableWidgetComponent extends PageComponent implements OnI }); source.sort((a, b) => { - const valueA = entityLabelCache.get(a.datasource.entityId) || ''; - const valueB = entityLabelCache.get(b.datasource.entityId) || ''; + const valueA = a.displayName || ''; + const valueB = b.displayName || ''; return isAsc ? collator.compare(valueA, valueB) @@ -441,10 +435,8 @@ export class TimeseriesTableWidgetComponent extends PageComponent implements OnI this.sourceIndex = 0; let keyOffset = 0; let latestKeyOffset = 0; - const entityLabelCache = new Map(); const pageSize = this.displayPagination ? this.defaultPageSize : Number.POSITIVE_INFINITY; if (this.datasources) { - this.datasources.forEach(ds => this.getTabLabel(ds, entityLabelCache)); for (const datasource of this.datasources) { const sortOrder: SortOrder = sortOrderFromString(this.defaultSortOrder); const source = {} as TimeseriesTableSource; @@ -462,7 +454,7 @@ export class TimeseriesTableWidgetComponent extends PageComponent implements OnI source.pageLink = new PageLink(pageSize, 0, null, sortOrder); source.rowDataTemplate = {}; source.rowDataTemplate.Timestamp = null; - source.displayName = entityLabelCache.get(datasource.entityId); + source.displayName = this.getTabLabel(datasource); if (this.showTimestamp) { source.displayedColumns.push('0'); } @@ -482,7 +474,7 @@ export class TimeseriesTableWidgetComponent extends PageComponent implements OnI } } if (this.sources.length) { - this.sortDatasources(this.sources, entityLabelCache); + this.sortDatasources(this.sources); this.sources.forEach((source, index) => { this.prepareDisplayedColumn(index); source.displayedColumns = this.displayedColumns[index].filter(value => value.display).map(value => value.def); diff --git a/ui-ngx/src/assets/dashboard/api_usage.json b/ui-ngx/src/assets/dashboard/api_usage.json index 994b431ade..e45e9a59fa 100644 --- a/ui-ngx/src/assets/dashboard/api_usage.json +++ b/ui-ngx/src/assets/dashboard/api_usage.json @@ -99,7 +99,10 @@ "showTimestamp": true, "displayPagination": true, "defaultPageSize": 10, - "tabSortKey": "NAME_ASC" + "sortOrder": { + "property": "createdTime", + "direction": "DESC" + } }, "title": "{i18n:api-usage.exceptions}", "dropShadow": true,