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,
rowStyleFunction: '',
sortOrder: {
property: this.entityFields.name.keyName,
property: this.entityFields.createdTime.keyName,
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();
}
private getTabLabel(source: Datasource, entityLabelCache:Map<string,string>):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<string, string>) {
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<string,string>();
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);

5
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,

Loading…
Cancel
Save