Browse Source

Merge pull request #14435 from ChantsovaEkaterina/improvement/clear-dashboard-timewindow-config

Dashboard timewindow: remove unused parameters on creating/editing dashboard
pull/14454/head
Vladyslav Prykhodko 6 months ago
committed by GitHub
parent
commit
c3a0efc0fa
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
  1. 5
      ui-ngx/src/app/core/services/dashboard-utils.service.ts
  2. 7
      ui-ngx/src/app/modules/home/components/dashboard/dashboard.component.ts
  3. 5
      ui-ngx/src/app/shared/models/time/time.models.ts

5
ui-ngx/src/app/core/services/dashboard-utils.service.ts

@ -168,9 +168,8 @@ export class DashboardUtilsService {
dashboard.configuration.filters = {};
}
if (isUndefined(dashboard.configuration.timewindow)) {
dashboard.configuration.timewindow = this.timeService.defaultTimewindow(true);
}
dashboard.configuration.timewindow = initModelFromDefaultTimewindow(dashboard.configuration.timewindow,
false, false, this.timeService, true, true);
if (isUndefined(dashboard.configuration.settings)) {
dashboard.configuration.settings = {};
dashboard.configuration.settings.stateControllerId = 'entity';

7
ui-ngx/src/app/modules/home/components/dashboard/dashboard.component.ts

@ -34,7 +34,7 @@ import { AppState } from '@core/core.state';
import { PageComponent } from '@shared/components/page.component';
import { AuthUser } from '@shared/models/user.model';
import { getCurrentAuthUser } from '@core/auth/auth.selectors';
import { Timewindow, toHistoryTimewindow } from '@shared/models/time/time.models';
import { initModelFromDefaultTimewindow, Timewindow, toHistoryTimewindow } from '@shared/models/time/time.models';
import { TimeService } from '@core/services/time.service';
import { GridsterComponent, GridsterConfig, GridType } from 'angular-gridster2';
import {
@ -223,9 +223,8 @@ export class DashboardComponent extends PageComponent implements IDashboardCompo
ngOnInit(): void {
this.dashboardWidgets.parentDashboard = this.parentDashboard;
this.dashboardWidgets.popoverComponent = this.popoverComponent;
if (!this.dashboardTimewindow) {
this.dashboardTimewindow = this.timeService.defaultTimewindow(true);
}
this.dashboardTimewindow = initModelFromDefaultTimewindow(this.dashboardTimewindow,
false, false, this.timeService, true, true);
this.gridsterOpts = {
gridType: this.gridType || GridType.ScrollVertical,
keepFixedHeightInMobile: true,

5
ui-ngx/src/app/shared/models/time/time.models.ts

@ -315,8 +315,9 @@ const getTimewindowType = (timewindow: Timewindow): TimewindowType => {
};
export const initModelFromDefaultTimewindow = (value: Timewindow, quickIntervalOnly: boolean,
historyOnly: boolean, timeService: TimeService, hasAggregation: boolean): Timewindow => {
const model = defaultTimewindow(timeService);
historyOnly: boolean, timeService: TimeService, hasAggregation: boolean,
isDashboard = false): Timewindow => {
const model = defaultTimewindow(timeService, isDashboard);
if (value) {
if (value.allowedAggTypes?.length) {
model.allowedAggTypes = value.allowedAggTypes;

Loading…
Cancel
Save