|
|
|
@ -28,6 +28,7 @@ import { |
|
|
|
DataSetHolder, |
|
|
|
Datasource, |
|
|
|
DatasourceData, |
|
|
|
datasourcesHasAggregation, |
|
|
|
DatasourceType, |
|
|
|
LegendConfig, |
|
|
|
LegendData, |
|
|
|
@ -95,6 +96,7 @@ export class WidgetSubscription implements IWidgetSubscription { |
|
|
|
timezone: string; |
|
|
|
subscriptionTimewindow: SubscriptionTimewindow; |
|
|
|
useDashboardTimewindow: boolean; |
|
|
|
useTimewindow: boolean; |
|
|
|
tsOffset = 0; |
|
|
|
|
|
|
|
hasDataPageLink: boolean; |
|
|
|
@ -200,6 +202,7 @@ export class WidgetSubscription implements IWidgetSubscription { |
|
|
|
this.originalTimewindow = null; |
|
|
|
this.timeWindow = {}; |
|
|
|
this.useDashboardTimewindow = options.useDashboardTimewindow; |
|
|
|
this.useTimewindow = true; |
|
|
|
if (this.useDashboardTimewindow) { |
|
|
|
this.timeWindowConfig = deepClone(options.dashboardTimewindow); |
|
|
|
} else { |
|
|
|
@ -245,15 +248,16 @@ export class WidgetSubscription implements IWidgetSubscription { |
|
|
|
this.timeWindow = {}; |
|
|
|
this.useDashboardTimewindow = options.useDashboardTimewindow; |
|
|
|
this.stateData = options.stateData; |
|
|
|
if (this.type === widgetType.latest) { |
|
|
|
this.timezone = options.dashboardTimewindow.timezone; |
|
|
|
this.updateTsOffset(); |
|
|
|
} |
|
|
|
this.useTimewindow = this.type === widgetType.timeseries || datasourcesHasAggregation(this.configuredDatasources); |
|
|
|
if (this.useDashboardTimewindow) { |
|
|
|
this.timeWindowConfig = deepClone(options.dashboardTimewindow); |
|
|
|
} else { |
|
|
|
this.timeWindowConfig = deepClone(options.timeWindowConfig); |
|
|
|
} |
|
|
|
if (this.type === widgetType.latest) { |
|
|
|
this.timezone = this.useTimewindow ? this.timeWindowConfig.timezone : options.dashboardTimewindow.timezone; |
|
|
|
this.updateTsOffset(); |
|
|
|
} |
|
|
|
|
|
|
|
this.subscriptionTimewindow = null; |
|
|
|
this.comparisonEnabled = options.comparisonEnabled && isHistoryTypeTimewindow(this.timeWindowConfig); |
|
|
|
@ -443,6 +447,7 @@ export class WidgetSubscription implements IWidgetSubscription { |
|
|
|
const resolveResultObservables = this.configuredDatasources.map((datasource, index) => { |
|
|
|
const listener: EntityDataListener = { |
|
|
|
subscriptionType: this.type, |
|
|
|
useTimewindow: this.useTimewindow, |
|
|
|
configDatasource: datasource, |
|
|
|
configDatasourceIndex: index, |
|
|
|
dataLoaded: (pageData, data1, datasourceIndex, pageLink) => { |
|
|
|
@ -626,22 +631,31 @@ export class WidgetSubscription implements IWidgetSubscription { |
|
|
|
} |
|
|
|
|
|
|
|
onDashboardTimewindowChanged(newDashboardTimewindow: Timewindow) { |
|
|
|
if (this.type === widgetType.timeseries || this.type === widgetType.alarm) { |
|
|
|
let doUpdate = false; |
|
|
|
let isTimewindowTypeChanged = false; |
|
|
|
if (this.useTimewindow) { |
|
|
|
if (this.useDashboardTimewindow) { |
|
|
|
if (this.type === widgetType.latest) { |
|
|
|
if (newDashboardTimewindow && this.timezone !== newDashboardTimewindow.timezone) { |
|
|
|
this.timezone = newDashboardTimewindow.timezone; |
|
|
|
doUpdate = this.updateTsOffset(); |
|
|
|
} |
|
|
|
} |
|
|
|
if (!isEqual(this.timeWindowConfig, newDashboardTimewindow) && newDashboardTimewindow) { |
|
|
|
const isTimewindowTypeChanged = timewindowTypeChanged(this.timeWindowConfig, newDashboardTimewindow); |
|
|
|
isTimewindowTypeChanged = timewindowTypeChanged(this.timeWindowConfig, newDashboardTimewindow); |
|
|
|
this.timeWindowConfig = deepClone(newDashboardTimewindow); |
|
|
|
this.update(isTimewindowTypeChanged); |
|
|
|
doUpdate = true; |
|
|
|
} |
|
|
|
} |
|
|
|
} else if (this.type === widgetType.latest) { |
|
|
|
if (newDashboardTimewindow && this.timezone !== newDashboardTimewindow.timezone) { |
|
|
|
this.timezone = newDashboardTimewindow.timezone; |
|
|
|
if (this.updateTsOffset()) { |
|
|
|
this.update(); |
|
|
|
} |
|
|
|
doUpdate = this.updateTsOffset(); |
|
|
|
} |
|
|
|
} |
|
|
|
if (doUpdate) { |
|
|
|
this.update(isTimewindowTypeChanged); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
updateDataVisibility(index: number): void { |
|
|
|
@ -660,6 +674,12 @@ export class WidgetSubscription implements IWidgetSubscription { |
|
|
|
|
|
|
|
updateTimewindowConfig(newTimewindow: Timewindow): void { |
|
|
|
if (!this.useDashboardTimewindow) { |
|
|
|
if (this.type === widgetType.latest) { |
|
|
|
if (newTimewindow && this.timezone !== newTimewindow.timezone) { |
|
|
|
this.timezone = newTimewindow.timezone; |
|
|
|
this.updateTsOffset(); |
|
|
|
} |
|
|
|
} |
|
|
|
const isTimewindowTypeChanged = timewindowTypeChanged(this.timeWindowConfig, newTimewindow); |
|
|
|
this.timeWindowConfig = newTimewindow; |
|
|
|
this.update(isTimewindowTypeChanged); |
|
|
|
@ -874,11 +894,12 @@ export class WidgetSubscription implements IWidgetSubscription { |
|
|
|
} |
|
|
|
const datasource = this.configuredDatasources[datasourceIndex]; |
|
|
|
if (datasource) { |
|
|
|
if (this.type === widgetType.timeseries && this.timeWindowConfig) { |
|
|
|
if (this.useTimewindow && this.timeWindowConfig) { |
|
|
|
this.updateRealtimeSubscription(); |
|
|
|
} |
|
|
|
entityDataListener = { |
|
|
|
subscriptionType: this.type, |
|
|
|
useTimewindow: this.useTimewindow, |
|
|
|
configDatasource: datasource, |
|
|
|
configDatasourceIndex: datasourceIndex, |
|
|
|
subscriptionTimewindow: this.subscriptionTimewindow, |
|
|
|
@ -940,7 +961,7 @@ export class WidgetSubscription implements IWidgetSubscription { |
|
|
|
|
|
|
|
private updateDataTimewindow() { |
|
|
|
if (!this.hasDataPageLink) { |
|
|
|
if (this.type === widgetType.timeseries && this.timeWindowConfig) { |
|
|
|
if (this.useTimewindow && this.timeWindowConfig) { |
|
|
|
this.updateRealtimeSubscription(); |
|
|
|
if (this.comparisonEnabled) { |
|
|
|
this.updateSubscriptionForComparison(); |
|
|
|
@ -952,11 +973,11 @@ export class WidgetSubscription implements IWidgetSubscription { |
|
|
|
private dataSubscribe() { |
|
|
|
this.updateDataTimewindow(); |
|
|
|
if (!this.hasDataPageLink) { |
|
|
|
if (this.type === widgetType.timeseries && this.timeWindowConfig && this.subscriptionTimewindow.fixedWindow) { |
|
|
|
if (this.useTimewindow && this.timeWindowConfig && this.subscriptionTimewindow.fixedWindow) { |
|
|
|
this.onDataUpdated(); |
|
|
|
} |
|
|
|
const forceUpdate = !this.datasources.length; |
|
|
|
const notifyDataLoaded = !this.entityDataListeners.filter((listener) => listener.subscription ? true : false).length; |
|
|
|
const notifyDataLoaded = !this.entityDataListeners.filter((listener) => !!listener.subscription).length; |
|
|
|
this.entityDataListeners.forEach((listener) => { |
|
|
|
if (this.comparisonEnabled && listener.configDatasource.isAdditional) { |
|
|
|
listener.subscriptionTimewindow = this.timewindowForComparison; |
|
|
|
|