Browse Source

Merge pull request #7267 from Terny22/feature/on-tw-change-function-settins

[3.4.2] UI: Added new widget-subscription setting - "onTimewindowChangeFunction"
pull/7514/head
Andrew Shvayka 4 years ago
committed by GitHub
parent
commit
bcfd128a4e
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      ui-ngx/src/app/core/api/widget-api.models.ts
  2. 2
      ui-ngx/src/app/core/api/widget-subscription.ts
  3. 2
      ui-ngx/src/app/modules/home/components/widget/widget.component.ts

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

@ -252,6 +252,7 @@ export interface WidgetSubscriptionOptions {
displayTimewindow?: boolean;
timeWindowConfig?: Timewindow;
dashboardTimewindow?: Timewindow;
onTimewindowChangeFunction?: (timewindow: Timewindow) => Timewindow;
legendConfig?: LegendConfig;
comparisonEnabled?: boolean;
timeForComparison?: moment_.unitOfTime.DurationConstructor;
@ -290,6 +291,7 @@ export interface IWidgetSubscription {
hiddenData?: Array<{data: DataSet}>;
timeWindowConfig?: Timewindow;
timeWindow?: WidgetTimewindow;
onTimewindowChangeFunction?: (timewindow: Timewindow) => Timewindow;
widgetTimewindowChanged$: Observable<WidgetTimewindow>;
comparisonEnabled?: boolean;
comparisonTimeWindow?: WidgetTimewindow;

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

@ -97,6 +97,7 @@ export class WidgetSubscription implements IWidgetSubscription {
subscriptionTimewindow: SubscriptionTimewindow;
useDashboardTimewindow: boolean;
useTimewindow: boolean;
onTimewindowChangeFunction: (timewindow: Timewindow) => Timewindow;
tsOffset = 0;
hasDataPageLink: boolean;
@ -247,6 +248,7 @@ export class WidgetSubscription implements IWidgetSubscription {
this.originalTimewindow = null;
this.timeWindow = {};
this.useDashboardTimewindow = options.useDashboardTimewindow;
this.onTimewindowChangeFunction = options.onTimewindowChangeFunction || ((timewindow) => timewindow);
this.stateData = options.stateData;
this.useTimewindow = this.type === widgetType.timeseries || datasourcesHasAggregation(this.configuredDatasources);
if (this.useDashboardTimewindow) {

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

@ -453,7 +453,7 @@ export class WidgetComponent extends PageComponent implements OnInit, AfterViewI
for (const id of Object.keys(this.widgetContext.subscriptions)) {
const subscription = this.widgetContext.subscriptions[id];
if (!subscription.useDashboardTimewindow) {
subscription.updateTimewindowConfig(timewindow);
subscription.updateTimewindowConfig(subscription.onTimewindowChangeFunction(timewindow));
}
}
}

Loading…
Cancel
Save