Browse Source

updated api usage dashboard

pull/14412/head
Maksym Tsymbarov 9 months ago
parent
commit
53598ac49c
  1. 2
      ui-ngx/src/app/modules/home/components/widget/lib/settings/cards/timeseries-table-widget-settings.component.ts
  2. 22
      ui-ngx/src/app/modules/home/components/widget/lib/timeseries-table-widget.component.ts
  3. 5
      ui-ngx/src/assets/dashboard/api_usage.json

2
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, useRowStyleFunction: false,
rowStyleFunction: '', rowStyleFunction: '',
sortOrder: { sortOrder: {
property: this.entityFields.name.keyName, property: this.entityFields.createdTime.keyName,
direction: Direction.DESC direction: Direction.DESC
} }
}; };

22
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(); this.updateDatasources();
} }
private getTabLabel(source: Datasource, entityLabelCache:Map<string,string>):string { private getTabLabel(source: Datasource):string {
if (entityLabelCache.has(source.entityId)) {
return entityLabelCache.get(source.entityId);
}
const value = this.useEntityLabel const value = this.useEntityLabel
? (source.entityLabel || source.entityName) ? (source.entityLabel || source.entityName)
: source.entityName; : source.entityName;
const translated = this.utils.customTranslation(value); return this.utils.customTranslation(value);
entityLabelCache.set(source.entityId, translated);
return translated;
} }
private sortDatasources(source: TimeseriesTableSource[], entityLabelCache: Map<string, string>) { private sortDatasources(source: TimeseriesTableSource[]) {
const property = this.settings?.sortOrder?.property; const property = this.settings?.sortOrder?.property;
const direction = this.settings?.sortOrder?.direction; const direction = this.settings?.sortOrder?.direction;
const isAsc = direction === Direction.ASC; const isAsc = direction === Direction.ASC;
@ -422,8 +416,8 @@ export class TimeseriesTableWidgetComponent extends PageComponent implements OnI
}); });
source.sort((a, b) => { source.sort((a, b) => {
const valueA = entityLabelCache.get(a.datasource.entityId) || ''; const valueA = a.displayName || '';
const valueB = entityLabelCache.get(b.datasource.entityId) || ''; const valueB = b.displayName || '';
return isAsc return isAsc
? collator.compare(valueA, valueB) ? collator.compare(valueA, valueB)
@ -441,10 +435,8 @@ export class TimeseriesTableWidgetComponent extends PageComponent implements OnI
this.sourceIndex = 0; this.sourceIndex = 0;
let keyOffset = 0; let keyOffset = 0;
let latestKeyOffset = 0; let latestKeyOffset = 0;
const entityLabelCache = new Map<string,string>();
const pageSize = this.displayPagination ? this.defaultPageSize : Number.POSITIVE_INFINITY; const pageSize = this.displayPagination ? this.defaultPageSize : Number.POSITIVE_INFINITY;
if (this.datasources) { if (this.datasources) {
this.datasources.forEach(ds => this.getTabLabel(ds, entityLabelCache));
for (const datasource of this.datasources) { for (const datasource of this.datasources) {
const sortOrder: SortOrder = sortOrderFromString(this.defaultSortOrder); const sortOrder: SortOrder = sortOrderFromString(this.defaultSortOrder);
const source = {} as TimeseriesTableSource; const source = {} as TimeseriesTableSource;
@ -462,7 +454,7 @@ export class TimeseriesTableWidgetComponent extends PageComponent implements OnI
source.pageLink = new PageLink(pageSize, 0, null, sortOrder); source.pageLink = new PageLink(pageSize, 0, null, sortOrder);
source.rowDataTemplate = {}; source.rowDataTemplate = {};
source.rowDataTemplate.Timestamp = null; source.rowDataTemplate.Timestamp = null;
source.displayName = entityLabelCache.get(datasource.entityId); source.displayName = this.getTabLabel(datasource);
if (this.showTimestamp) { if (this.showTimestamp) {
source.displayedColumns.push('0'); source.displayedColumns.push('0');
} }
@ -482,7 +474,7 @@ export class TimeseriesTableWidgetComponent extends PageComponent implements OnI
} }
} }
if (this.sources.length) { if (this.sources.length) {
this.sortDatasources(this.sources, entityLabelCache); this.sortDatasources(this.sources);
this.sources.forEach((source, index) => { this.sources.forEach((source, index) => {
this.prepareDisplayedColumn(index); this.prepareDisplayedColumn(index);
source.displayedColumns = this.displayedColumns[index].filter(value => value.display).map(value => value.def); source.displayedColumns = this.displayedColumns[index].filter(value => value.display).map(value => value.def);

5
ui-ngx/src/assets/dashboard/api_usage.json

@ -99,7 +99,10 @@
"showTimestamp": true, "showTimestamp": true,
"displayPagination": true, "displayPagination": true,
"defaultPageSize": 10, "defaultPageSize": 10,
"tabSortKey": "NAME_ASC" "sortOrder": {
"property": "createdTime",
"direction": "DESC"
}
}, },
"title": "{i18n:api-usage.exceptions}", "title": "{i18n:api-usage.exceptions}",
"dropShadow": true, "dropShadow": true,

Loading…
Cancel
Save