Browse Source

Improve optional datasources handling

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

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

@ -235,6 +235,7 @@ export interface WidgetSubscriptionOptions {
stateData?: boolean;
alarmSource?: Datasource;
datasources?: Array<Datasource>;
datasourcesOptional?: boolean;
hasDataPageLink?: boolean;
singleEntity?: boolean;
warnOnPageDataOverflow?: boolean;

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

@ -106,6 +106,7 @@ export class WidgetSubscription implements IWidgetSubscription {
caulculateLegendData: boolean;
displayLegend: boolean;
stateData: boolean;
datasourcesOptional: boolean;
decimals: number;
units: string;
comparisonEnabled: boolean;
@ -181,6 +182,7 @@ export class WidgetSubscription implements IWidgetSubscription {
this.callbacks.dataLoading = this.callbacks.dataLoading || (() => {});
this.callbacks.timeWindowUpdated = this.callbacks.timeWindowUpdated || (() => {});
this.alarmSource = options.alarmSource;
this.datasourcesOptional = options.datasourcesOptional;
this.alarmDataListener = null;
this.alarms = emptyPageData();
this.originalTimewindow = null;
@ -212,6 +214,7 @@ export class WidgetSubscription implements IWidgetSubscription {
this.callbacks.timeWindowUpdated = this.callbacks.timeWindowUpdated || (() => {});
this.configuredDatasources = this.ctx.utils.validateDatasources(options.datasources);
this.datasourcesOptional = options.datasourcesOptional;
this.entityDataListeners = [];
this.hasDataPageLink = options.hasDataPageLink;
this.singleEntity = options.singleEntity;
@ -448,7 +451,7 @@ export class WidgetSubscription implements IWidgetSubscription {
}
});
this.configureLoadedData();
this.hasResolvedData = this.datasources.length > 0;
this.hasResolvedData = this.datasources.length > 0 || this.datasourcesOptional;
this.updateDataTimewindow();
this.notifyDataLoaded();
this.onDataUpdated(true);

1
ui-ngx/src/app/modules/home/components/widget/widget.component.ts

@ -936,6 +936,7 @@ export class WidgetComponent extends PageComponent implements OnInit, AfterViewI
options = {
type: this.widget.type,
stateData: this.typeParameters.stateData,
datasourcesOptional: this.typeParameters.datasourcesOptional,
hasDataPageLink: this.typeParameters.hasDataPageLink,
singleEntity: this.typeParameters.singleEntity,
warnOnPageDataOverflow: this.typeParameters.warnOnPageDataOverflow,

Loading…
Cancel
Save