Browse Source

UI: Fix widget labels pattern processing.

pull/9060/head
Igor Kulikov 3 years ago
parent
commit
2ed3d47952
  1. 2
      ui-ngx/src/app/core/api/widget-api.models.ts
  2. 10
      ui-ngx/src/app/core/api/widget-subscription.ts
  3. 5
      ui-ngx/src/app/modules/home/models/widget-component.models.ts

2
ui-ngx/src/app/core/api/widget-api.models.ts

@ -284,6 +284,8 @@ export interface IWidgetSubscription {
legendData: LegendData; legendData: LegendData;
readonly firstDatasource?: Datasource;
datasourcePages?: PageData<Datasource>[]; datasourcePages?: PageData<Datasource>[];
dataPages?: PageData<Array<DatasourceData>>[]; dataPages?: PageData<Array<DatasourceData>>[];
datasources?: Array<Datasource>; datasources?: Array<Datasource>;

10
ui-ngx/src/app/core/api/widget-subscription.ts

@ -160,6 +160,16 @@ export class WidgetSubscription implements IWidgetSubscription {
warnOnPageDataOverflow: boolean; warnOnPageDataOverflow: boolean;
ignoreDataUpdateOnIntervalTick: boolean; ignoreDataUpdateOnIntervalTick: boolean;
get firstDatasource(): Datasource {
if (this.type === widgetType.alarm) {
return this.alarmSource;
} else if (this.datasources?.length) {
return this.datasources[0];
} else {
return null;
}
}
datasourcePages: PageData<Datasource>[]; datasourcePages: PageData<Datasource>[];
dataPages: PageData<Array<DatasourceData>>[]; dataPages: PageData<Array<DatasourceData>>[];
entityDataListeners: Array<EntityDataListener>; entityDataListeners: Array<EntityDataListener>;

5
ui-ngx/src/app/modules/home/models/widget-component.models.ts

@ -477,8 +477,9 @@ export class LabelVariablePattern {
update() { update() {
let label = this.pattern; let label = this.pattern;
if (this.hasVariables && this.ctx.defaultSubscription?.datasources?.length) { const datasource = this.ctx.defaultSubscription?.firstDatasource;
label = createLabelFromDatasource(this.ctx.defaultSubscription.datasources[0], label); if (this.hasVariables && datasource) {
label = createLabelFromDatasource(datasource, label);
} }
if (this.labelSubject.value !== label) { if (this.labelSubject.value !== label) {
this.labelSubject.next(label); this.labelSubject.next(label);

Loading…
Cancel
Save