From bc6f380cc1b718c18f979a62214e51bf4b9f8d52 Mon Sep 17 00:00:00 2001 From: Ekaterina Chantsova Date: Mon, 8 Dec 2025 19:28:25 +0200 Subject: [PATCH] Map widget: enable quick-interval-only mode when aggregation is enabled for latest key --- .../widget/widget-config.component.ts | 11 ++++++++--- .../home/models/dashboard-component.models.ts | 19 ++++++++----------- .../models/widget/widget-model.definition.ts | 17 +++++++++++++++++ 3 files changed, 33 insertions(+), 14 deletions(-) diff --git a/ui-ngx/src/app/modules/home/components/widget/widget-config.component.ts b/ui-ngx/src/app/modules/home/components/widget/widget-config.component.ts index deb7ae07d1..6e43f1055d 100644 --- a/ui-ngx/src/app/modules/home/components/widget/widget-config.component.ts +++ b/ui-ngx/src/app/modules/home/components/widget/widget-config.component.ts @@ -741,7 +741,7 @@ export class WidgetConfigComponent extends PageComponent implements OnInit, OnDe } else if (this.widgetType === widgetType.latest) { const widgetDefinition = findWidgetModelDefinition(this.widget); if (widgetDefinition) { - return widgetDefinition.hasTimewindow(this.widget); + return widgetDefinition.datasourcesHasAggregation(this.widget); } else { const datasources = this.dataSettings.get('datasources').value; return datasourcesHasAggregation(datasources); @@ -768,8 +768,13 @@ export class WidgetConfigComponent extends PageComponent implements OnInit, OnDe public onlyHistoryTimewindow(): boolean { if (this.widgetType === widgetType.latest) { - const datasources = this.dataSettings.get('datasources').value; - return datasourcesHasOnlyComparisonAggregation(datasources); + const widgetDefinition = findWidgetModelDefinition(this.widget); + if (widgetDefinition) { + return widgetDefinition.datasourcesHasOnlyComparisonAggregation(this.widget); + } else { + const datasources = this.dataSettings.get('datasources').value; + return datasourcesHasOnlyComparisonAggregation(datasources); + } } else { return false; } diff --git a/ui-ngx/src/app/modules/home/models/dashboard-component.models.ts b/ui-ngx/src/app/modules/home/models/dashboard-component.models.ts index 71f5aaaf72..dbdf31a2c8 100644 --- a/ui-ngx/src/app/modules/home/models/dashboard-component.models.ts +++ b/ui-ngx/src/app/modules/home/models/dashboard-component.models.ts @@ -15,14 +15,7 @@ /// import { GridsterComponent, GridsterConfig, GridsterItem, GridsterItemComponentInterface } from 'angular-gridster2'; -import { - datasourcesHasAggregation, - datasourcesHasOnlyComparisonAggregation, - FormattedData, - Widget, - WidgetPosition, - widgetType -} from '@app/shared/models/widget.models'; +import { FormattedData, Widget, WidgetPosition, widgetType } from '@app/shared/models/widget.models'; import { WidgetLayout, WidgetLayouts } from '@app/shared/models/dashboard.models'; import { IDashboardWidget, WidgetAction, WidgetContext, WidgetHeaderAction } from './widget-component.models'; import { Timewindow } from '@shared/models/time/time.models'; @@ -43,7 +36,11 @@ import { UtilsService } from '@core/services/utils.service'; import { TbPopoverComponent } from '@shared/components/popover.component'; import { ComponentStyle, iconStyle, textStyle } from '@shared/models/widget-settings.models'; import { TbContextMenuEvent } from '@shared/models/jquery-event.models'; -import { widgetHasTimewindow } from '@shared/models/widget/widget-model.definition'; +import { + widgetDatasourcesHasAggregation, + widgetDatasourcesHasOnlyComparisonAggregation, + widgetHasTimewindow +} from '@shared/models/widget/widget-model.definition'; export interface WidgetsData { widgets: Array; @@ -621,9 +618,9 @@ export class DashboardWidget implements GridsterItem, IDashboardWidget { let onlyQuickInterval = false; let onlyHistoryTimewindow = false; if (this.widget.type === widgetType.latest) { - onlyQuickInterval = datasourcesHasAggregation(this.widget.config.datasources); + onlyQuickInterval = widgetDatasourcesHasAggregation(this.widget); if (canHaveTimewindow) { - onlyHistoryTimewindow = datasourcesHasOnlyComparisonAggregation(this.widget.config.datasources); + onlyHistoryTimewindow = widgetDatasourcesHasOnlyComparisonAggregation(this.widget); } } diff --git a/ui-ngx/src/app/shared/models/widget/widget-model.definition.ts b/ui-ngx/src/app/shared/models/widget/widget-model.definition.ts index 6b7b547b40..c585268234 100644 --- a/ui-ngx/src/app/shared/models/widget/widget-model.definition.ts +++ b/ui-ngx/src/app/shared/models/widget/widget-model.definition.ts @@ -17,6 +17,7 @@ import { Datasource, datasourcesHasAggregation, + datasourcesHasOnlyComparisonAggregation, Widget, widgetType, widgetTypeHasTimewindow @@ -54,3 +55,19 @@ export const widgetHasTimewindow = (widget: Widget): boolean => { return widgetTypeHasTimewindow(widget.type) || (widget.type === widgetType.latest && datasourcesHasAggregation(widget.config.datasources)); }; + +export const widgetDatasourcesHasAggregation = (widget: Widget): boolean => { + const widgetDefinition = findWidgetModelDefinition(widget); + if (widgetDefinition) { + return widgetDefinition.datasourcesHasAggregation(widget); + } + return widget.type === widgetType.latest && datasourcesHasAggregation(widget.config.datasources); +}; + +export const widgetDatasourcesHasOnlyComparisonAggregation = (widget: Widget): boolean => { + const widgetDefinition = findWidgetModelDefinition(widget); + if (widgetDefinition) { + return widgetDefinition.datasourcesHasOnlyComparisonAggregation(widget); + } + return widget.type === widgetType.latest && datasourcesHasOnlyComparisonAggregation(widget.config.datasources); +};