Browse Source

Merge pull request #3606 from vvlladd28/improvement/table-alarm

UI: Improvement alarm widget and fixed timeseries
pull/3638/head
Igor Kulikov 6 years ago
committed by GitHub
parent
commit
55f26ebf13
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 9
      ui-ngx/src/app/modules/home/components/widget/lib/alarms-table-widget.component.ts
  2. 2
      ui-ngx/src/app/modules/home/components/widget/lib/table-widget.models.ts
  3. 22
      ui-ngx/src/app/modules/home/components/widget/lib/timeseries-table-widget.component.ts

9
ui-ngx/src/app/modules/home/components/widget/lib/alarms-table-widget.component.ts

@ -29,7 +29,7 @@ import { PageComponent } from '@shared/components/page.component';
import { Store } from '@ngrx/store';
import { AppState } from '@core/core.state';
import { WidgetAction, WidgetContext } from '@home/models/widget-component.models';
import { DataKey, Datasource, WidgetActionDescriptor, WidgetConfig } from '@shared/models/widget.models';
import { DataKey, WidgetActionDescriptor, WidgetConfig } from '@shared/models/widget.models';
import { IWidgetSubscription } from '@core/api/widget-api.models';
import { UtilsService } from '@core/services/utils.service';
import { TranslateService } from '@ngx-translate/core';
@ -371,7 +371,8 @@ export class AlarmsTableWidgetComponent extends PageComponent implements OnInit,
this.subscription.alarmSource.dataKeys.forEach((alarmDataKey) => {
const dataKey: EntityColumn = deepClone(alarmDataKey) as EntityColumn;
dataKey.entityKey = dataKeyToEntityKey(alarmDataKey);
dataKey.title = this.utils.customTranslation(dataKey.label, dataKey.label);
dataKey.label = this.utils.customTranslation(dataKey.label, dataKey.label);
dataKey.title = dataKey.label;
dataKey.def = 'def' + this.columns.length;
const keySettings: TableWidgetDataKeySettings = dataKey.settings;
if (dataKey.type === DataKeyType.alarm && !isDefined(keySettings.columnWidth)) {
@ -394,7 +395,7 @@ export class AlarmsTableWidgetComponent extends PageComponent implements OnInit,
this.displayedColumns.push(...this.columns.map(column => column.def));
}
if (this.settings.defaultSortOrder && this.settings.defaultSortOrder.length) {
this.defaultSortOrder = this.settings.defaultSortOrder;
this.defaultSortOrder = this.utils.customTranslation(this.settings.defaultSortOrder, this.settings.defaultSortOrder);
}
this.pageLink.sortOrder = entityDataSortOrderFromString(this.defaultSortOrder, this.columns);
let sortColumn: EntityColumn;
@ -959,7 +960,7 @@ class AlarmsDatasource implements DataSource<AlarmDataInfo> {
}
}
}
alarm[dataKey.name] = value;
alarm[dataKey.label] = value;
});
return alarm;
}

2
ui-ngx/src/app/modules/home/components/widget/lib/table-widget.models.ts

@ -189,7 +189,7 @@ export function getAlarmValue(alarm: AlarmDataInfo, key: EntityColumn) {
if (alarmField) {
return getDescendantProp(alarm, alarmField.value);
} else {
return getDescendantProp(alarm, key.name);
return getDescendantProp(alarm, key.label);
}
}

22
ui-ngx/src/app/modules/home/components/widget/lib/timeseries-table-widget.component.ts

@ -524,16 +524,22 @@ class TimeseriesDatasource implements DataSource<TimeseriesRow> {
});
}
const rows: TimeseriesRow[] = [];
for (const value of Object.values(rowsMap)) {
if (this.hideEmptyLines && isDefinedAndNotNull(value[1])) {
rows.push(value);
} else {
rows.push(value);
let rows: TimeseriesRow[] = [];
if (this.hideEmptyLines) {
for (const t of Object.keys(rowsMap)) {
let hideLine = true;
for (let c = 0; (c < data.length) && hideLine; c++) {
if (rowsMap[t][c + 1]) {
hideLine = false;
}
}
if (!hideLine) {
rows.push(rowsMap[t]);
}
}
} else {
rows = Object.values(rowsMap);
}
return rows;
}

Loading…
Cancel
Save