Timewindow: display full interval options list for customization
This commit is contained in:
parent
aff0adbfa7
commit
7e8ea0775e
@ -17,7 +17,7 @@
|
|||||||
-->
|
-->
|
||||||
<mat-form-field [formGroup]="aggregationTypeFormGroup"
|
<mat-form-field [formGroup]="aggregationTypeFormGroup"
|
||||||
[subscriptSizing]="subscriptSizing" [appearance]="appearance"
|
[subscriptSizing]="subscriptSizing" [appearance]="appearance"
|
||||||
class="mat-block">
|
class="flex flex-1">
|
||||||
<mat-label *ngIf="displayLabel">{{ label }}</mat-label>
|
<mat-label *ngIf="displayLabel">{{ label }}</mat-label>
|
||||||
<mat-select [required]="required" formControlName="aggregationType">
|
<mat-select [required]="required" formControlName="aggregationType">
|
||||||
<mat-option *ngFor="let type of aggregationTypes" [value]="type">
|
<mat-option *ngFor="let type of aggregationTypes" [value]="type">
|
||||||
|
|||||||
@ -15,22 +15,32 @@
|
|||||||
limitations under the License.
|
limitations under the License.
|
||||||
|
|
||||||
-->
|
-->
|
||||||
<form [formGroup]="intervalOptionsConfigForm" class="tb-interval-options-form tb-form-panel no-border">
|
<form [formGroup]="intervalOptionsConfigForm" class="tb-interval-options-form tb-form-panel no-border"
|
||||||
|
[style]="aggregation ? {maxWidth: '600px'} : {maxWidth: '350px'}">
|
||||||
<div class="tb-form-panel-title">{{ 'timewindow.edit-intervals-list' | translate }}</div>
|
<div class="tb-form-panel-title">{{ 'timewindow.edit-intervals-list' | translate }}</div>
|
||||||
<div class="tb-form-hint tb-primary-fill">{{ 'timewindow.edit-intervals-list-hint' | translate }}</div>
|
<div class="tb-form-hint tb-primary-fill">
|
||||||
|
{{ 'timewindow.edit-intervals-list-hint' | translate }} {{ aggregation ? ('timewindow.edit-grouping-intervals-list-hint' | translate) : '' }}
|
||||||
|
</div>
|
||||||
<div class="tb-form-table no-gap no-padding">
|
<div class="tb-form-table no-gap no-padding">
|
||||||
<div class="tb-form-table-header">
|
<div class="tb-form-table-header">
|
||||||
<div class="tb-form-table-header-cell">{{"timewindow.interval" | translate }}</div>
|
<div class="tb-form-table-header-cell">{{"timewindow.interval" | translate }}</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="tb-form-table-body">
|
<div class="tb-form-table-body">
|
||||||
<mat-selection-list formControlName="allowedIntervals">
|
<mat-selection-list formControlName="allowedIntervals">
|
||||||
<mat-list-option *ngFor="let interval of intervals" [value]="interval.value" togglePosition="before">
|
<mat-list-option *ngFor="let interval of allIntervals" [value]="interval.value" togglePosition="before">
|
||||||
{{ interval.name | translate:interval.translateParams }}
|
{{ interval.name | translate:interval.translateParams }}
|
||||||
</mat-list-option>
|
</mat-list-option>
|
||||||
</mat-selection-list>
|
</mat-selection-list>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="tb-flex flex-end no-gap">
|
<div class="flex flex-row gap-2 items-center">
|
||||||
|
<button type="button"
|
||||||
|
mat-button
|
||||||
|
color="primary"
|
||||||
|
(click)="reset()">
|
||||||
|
{{ 'action.reset' | translate }}
|
||||||
|
</button>
|
||||||
|
<span class="flex-1"></span>
|
||||||
<button type="button"
|
<button type="button"
|
||||||
mat-button
|
mat-button
|
||||||
(click)="cancel()">
|
(click)="cancel()">
|
||||||
|
|||||||
@ -16,7 +16,6 @@
|
|||||||
:host {
|
:host {
|
||||||
.tb-interval-options-form {
|
.tb-interval-options-form {
|
||||||
height: 100%;
|
height: 100%;
|
||||||
max-width: 600px;
|
|
||||||
|
|
||||||
.tb-form-table {
|
.tb-form-table {
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
|
|||||||
@ -15,9 +15,18 @@
|
|||||||
///
|
///
|
||||||
|
|
||||||
import { Component, Input, OnInit } from '@angular/core';
|
import { Component, Input, OnInit } from '@angular/core';
|
||||||
import { HistoryWindowType, RealtimeWindowType, TimewindowType } from '@shared/models/time/time.models';
|
import {
|
||||||
|
HistoryWindowType,
|
||||||
|
QuickTimeInterval,
|
||||||
|
QuickTimeIntervalTranslationMap,
|
||||||
|
RealtimeWindowType,
|
||||||
|
TimewindowIntervalOption,
|
||||||
|
TimewindowType
|
||||||
|
} from '@shared/models/time/time.models';
|
||||||
import { FormBuilder, FormGroup } from '@angular/forms';
|
import { FormBuilder, FormGroup } from '@angular/forms';
|
||||||
import { TbPopoverComponent } from '@shared/components/popover.component';
|
import { TbPopoverComponent } from '@shared/components/popover.component';
|
||||||
|
import { TimeService } from '@core/services/time.service';
|
||||||
|
import { coerceBoolean } from '@shared/decorators/coercion';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'tb-interval-options-config-panel',
|
selector: 'tb-interval-options-config-panel',
|
||||||
@ -26,6 +35,10 @@ import { TbPopoverComponent } from '@shared/components/popover.component';
|
|||||||
})
|
})
|
||||||
export class IntervalOptionsConfigPanelComponent implements OnInit {
|
export class IntervalOptionsConfigPanelComponent implements OnInit {
|
||||||
|
|
||||||
|
@Input()
|
||||||
|
@coerceBoolean()
|
||||||
|
aggregation = false;
|
||||||
|
|
||||||
@Input()
|
@Input()
|
||||||
allowedIntervals: Array<any>;
|
allowedIntervals: Array<any>;
|
||||||
|
|
||||||
@ -43,11 +56,25 @@ export class IntervalOptionsConfigPanelComponent implements OnInit {
|
|||||||
|
|
||||||
intervalOptionsConfigForm: FormGroup;
|
intervalOptionsConfigForm: FormGroup;
|
||||||
|
|
||||||
intervals = [];
|
allIntervals: Array<TimewindowIntervalOption>;
|
||||||
|
|
||||||
constructor(private fb: FormBuilder) {}
|
private timeIntervalTranslationMap = QuickTimeIntervalTranslationMap;
|
||||||
|
|
||||||
|
constructor(private fb: FormBuilder,
|
||||||
|
private timeService: TimeService) {}
|
||||||
|
|
||||||
ngOnInit(): void {
|
ngOnInit(): void {
|
||||||
|
if (this.intervalType === RealtimeWindowType.LAST_INTERVAL ||
|
||||||
|
this.intervalType === HistoryWindowType.LAST_INTERVAL) {
|
||||||
|
this.allIntervals = this.timeService.getIntervals(undefined, undefined, false);
|
||||||
|
} else {
|
||||||
|
const quickIntervals = this.getQuickIntervals();
|
||||||
|
this.allIntervals = quickIntervals.map(interval => ({
|
||||||
|
name: this.timeIntervalTranslationMap.get(interval),
|
||||||
|
value: interval
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
|
||||||
this.intervalOptionsConfigForm = this.fb.group({
|
this.intervalOptionsConfigForm = this.fb.group({
|
||||||
allowedIntervals: [this.allowedIntervals]
|
allowedIntervals: [this.allowedIntervals]
|
||||||
});
|
});
|
||||||
@ -55,7 +82,9 @@ export class IntervalOptionsConfigPanelComponent implements OnInit {
|
|||||||
|
|
||||||
update() {
|
update() {
|
||||||
if (this.onClose) {
|
if (this.onClose) {
|
||||||
this.onClose([]);
|
const allowedIntervals = this.intervalOptionsConfigForm.get('allowedIntervals').value;
|
||||||
|
// if full list selected returns empty for optimization
|
||||||
|
this.onClose(allowedIntervals?.length < this.allIntervals.length ? allowedIntervals : []);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -65,4 +94,17 @@ export class IntervalOptionsConfigPanelComponent implements OnInit {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
reset() {
|
||||||
|
this.intervalOptionsConfigForm.reset();
|
||||||
|
this.intervalOptionsConfigForm.markAsDirty();
|
||||||
|
}
|
||||||
|
|
||||||
|
private getQuickIntervals() {
|
||||||
|
const allQuickIntervals = Object.values(QuickTimeInterval);
|
||||||
|
if (this.timewindowType === TimewindowType.REALTIME) {
|
||||||
|
return allQuickIntervals.filter(interval => interval.startsWith('CURRENT_'));
|
||||||
|
}
|
||||||
|
return allQuickIntervals;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -20,6 +20,8 @@ import {
|
|||||||
DAY,
|
DAY,
|
||||||
HistoryWindowType,
|
HistoryWindowType,
|
||||||
historyWindowTypeTranslations,
|
historyWindowTypeTranslations,
|
||||||
|
Interval,
|
||||||
|
QuickTimeInterval,
|
||||||
quickTimeIntervalPeriod,
|
quickTimeIntervalPeriod,
|
||||||
RealtimeWindowType,
|
RealtimeWindowType,
|
||||||
realtimeWindowTypeTranslations,
|
realtimeWindowTypeTranslations,
|
||||||
@ -148,6 +150,10 @@ export class TimewindowConfigDialogComponent extends PageComponent implements On
|
|||||||
timewindowMs: [ isDefined(realtime?.timewindowMs) ? this.timewindow.realtime.timewindowMs : null ],
|
timewindowMs: [ isDefined(realtime?.timewindowMs) ? this.timewindow.realtime.timewindowMs : null ],
|
||||||
interval: [ isDefined(realtime?.interval) ? this.timewindow.realtime.interval : null ],
|
interval: [ isDefined(realtime?.interval) ? this.timewindow.realtime.interval : null ],
|
||||||
quickInterval: [ isDefined(realtime?.quickInterval) ? this.timewindow.realtime.quickInterval : null ],
|
quickInterval: [ isDefined(realtime?.quickInterval) ? this.timewindow.realtime.quickInterval : null ],
|
||||||
|
allowedLastIntervals: [ isDefinedAndNotNull(this.timewindow.realtime?.allowedLastIntervals)
|
||||||
|
? this.timewindow.realtime?.allowedLastIntervals : null ],
|
||||||
|
allowedQuickIntervals: [ isDefinedAndNotNull(this.timewindow.realtime?.allowedQuickIntervals)
|
||||||
|
? this.timewindow.realtime?.allowedQuickIntervals : null ],
|
||||||
disableCustomInterval: [ isDefinedAndNotNull(this.timewindow.realtime?.disableCustomInterval)
|
disableCustomInterval: [ isDefinedAndNotNull(this.timewindow.realtime?.disableCustomInterval)
|
||||||
? this.timewindow.realtime?.disableCustomInterval : false ],
|
? this.timewindow.realtime?.disableCustomInterval : false ],
|
||||||
disableCustomGroupInterval: [ isDefinedAndNotNull(this.timewindow.realtime?.disableCustomGroupInterval)
|
disableCustomGroupInterval: [ isDefinedAndNotNull(this.timewindow.realtime?.disableCustomGroupInterval)
|
||||||
@ -171,6 +177,10 @@ export class TimewindowConfigDialogComponent extends PageComponent implements On
|
|||||||
interval: [ isDefined(history?.interval) ? this.timewindow.history.interval : null ],
|
interval: [ isDefined(history?.interval) ? this.timewindow.history.interval : null ],
|
||||||
fixedTimewindow: [ isDefined(history?.fixedTimewindow) ? this.timewindow.history.fixedTimewindow : null ],
|
fixedTimewindow: [ isDefined(history?.fixedTimewindow) ? this.timewindow.history.fixedTimewindow : null ],
|
||||||
quickInterval: [ isDefined(history?.quickInterval) ? this.timewindow.history.quickInterval : null ],
|
quickInterval: [ isDefined(history?.quickInterval) ? this.timewindow.history.quickInterval : null ],
|
||||||
|
allowedLastIntervals: [ isDefinedAndNotNull(this.timewindow.history?.allowedLastIntervals)
|
||||||
|
? this.timewindow.history?.allowedLastIntervals : null ],
|
||||||
|
allowedQuickIntervals: [ isDefinedAndNotNull(this.timewindow.realtime?.allowedQuickIntervals)
|
||||||
|
? this.timewindow.realtime?.allowedQuickIntervals : null ],
|
||||||
disableCustomInterval: [ isDefinedAndNotNull(this.timewindow.history?.disableCustomInterval)
|
disableCustomInterval: [ isDefinedAndNotNull(this.timewindow.history?.disableCustomInterval)
|
||||||
? this.timewindow.history?.disableCustomInterval : false ],
|
? this.timewindow.history?.disableCustomInterval : false ],
|
||||||
disableCustomGroupInterval: [ isDefinedAndNotNull(this.timewindow.history?.disableCustomGroupInterval)
|
disableCustomGroupInterval: [ isDefinedAndNotNull(this.timewindow.history?.disableCustomGroupInterval)
|
||||||
@ -450,7 +460,7 @@ export class TimewindowConfigDialogComponent extends PageComponent implements On
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{maxHeight: '90vh', height: '100%'},
|
{maxHeight: '500px', height: '100%'},
|
||||||
{}, {}, true, () => {}, {padding: 0});
|
{}, {}, true, () => {}, {padding: 0});
|
||||||
aggregationConfigPopover.tbComponentRef.instance.popoverComponent = aggregationConfigPopover;
|
aggregationConfigPopover.tbComponentRef.instance.popoverComponent = aggregationConfigPopover;
|
||||||
}
|
}
|
||||||
@ -458,26 +468,38 @@ export class TimewindowConfigDialogComponent extends PageComponent implements On
|
|||||||
}
|
}
|
||||||
|
|
||||||
configureRealtimeLastIntervalOptions($event: Event) {
|
configureRealtimeLastIntervalOptions($event: Event) {
|
||||||
const resFn = (res) => {};
|
const resFn = (res) => {
|
||||||
this.openIntervalOptionsConfig($event, [], resFn, RealtimeWindowType.LAST_INTERVAL);
|
this.timewindowForm.get('realtime.allowedLastIntervals').patchValue(res);
|
||||||
|
};
|
||||||
|
this.openIntervalOptionsConfig($event, this.timewindowForm.get('realtime.allowedLastIntervals').value,
|
||||||
|
resFn, RealtimeWindowType.LAST_INTERVAL);
|
||||||
}
|
}
|
||||||
|
|
||||||
configureRealtimeQuickIntervalOptions($event: Event) {
|
configureRealtimeQuickIntervalOptions($event: Event) {
|
||||||
const resFn = (res) => {};
|
const resFn = (res) => {
|
||||||
this.openIntervalOptionsConfig($event, [], resFn, RealtimeWindowType.INTERVAL, TimewindowType.REALTIME);
|
this.timewindowForm.get('realtime.allowedQuickIntervals').patchValue(res);
|
||||||
|
};
|
||||||
|
this.openIntervalOptionsConfig($event, this.timewindowForm.get('realtime.allowedQuickIntervals').value,
|
||||||
|
resFn, RealtimeWindowType.INTERVAL, TimewindowType.REALTIME);
|
||||||
}
|
}
|
||||||
|
|
||||||
configureHistoryLastIntervalOptions($event: Event) {
|
configureHistoryLastIntervalOptions($event: Event) {
|
||||||
const resFn = (res) => {};
|
const resFn = (res) => {
|
||||||
this.openIntervalOptionsConfig($event, [], resFn, HistoryWindowType.LAST_INTERVAL);
|
this.timewindowForm.get('history.allowedLastIntervals').patchValue(res);
|
||||||
|
};
|
||||||
|
this.openIntervalOptionsConfig($event, this.timewindowForm.get('history.allowedLastIntervals').value,
|
||||||
|
resFn, HistoryWindowType.LAST_INTERVAL);
|
||||||
}
|
}
|
||||||
|
|
||||||
configureHistoryQuickIntervalOptions($event: Event) {
|
configureHistoryQuickIntervalOptions($event: Event) {
|
||||||
const resFn = (res) => {};
|
const resFn = (res) => {
|
||||||
this.openIntervalOptionsConfig($event, [], resFn, HistoryWindowType.INTERVAL, TimewindowType.HISTORY);
|
this.timewindowForm.get('history.allowedQuickIntervals').patchValue(res);
|
||||||
|
};
|
||||||
|
this.openIntervalOptionsConfig($event, this.timewindowForm.get('history.allowedQuickIntervals').value,
|
||||||
|
resFn, HistoryWindowType.INTERVAL, TimewindowType.HISTORY);
|
||||||
}
|
}
|
||||||
|
|
||||||
private openIntervalOptionsConfig($event: Event, allowedIntervals: Array<any>, resFn: (res) => void,
|
private openIntervalOptionsConfig($event: Event, allowedIntervals: Array<Interval | QuickTimeInterval>, resFn: (res) => void,
|
||||||
intervalType: RealtimeWindowType | HistoryWindowType, timewindowType?: TimewindowType) {
|
intervalType: RealtimeWindowType | HistoryWindowType, timewindowType?: TimewindowType) {
|
||||||
if ($event) {
|
if ($event) {
|
||||||
$event.stopPropagation();
|
$event.stopPropagation();
|
||||||
@ -489,6 +511,7 @@ export class TimewindowConfigDialogComponent extends PageComponent implements On
|
|||||||
const intervalsConfigPopover = this.popoverService.displayPopover(trigger, this.renderer,
|
const intervalsConfigPopover = this.popoverService.displayPopover(trigger, this.renderer,
|
||||||
this.viewContainerRef, IntervalOptionsConfigPanelComponent, ['left', 'leftTop', 'leftBottom'], true, null,
|
this.viewContainerRef, IntervalOptionsConfigPanelComponent, ['left', 'leftTop', 'leftBottom'], true, null,
|
||||||
{
|
{
|
||||||
|
aggregation: this.aggregation,
|
||||||
allowedIntervals: deepClone(allowedIntervals),
|
allowedIntervals: deepClone(allowedIntervals),
|
||||||
intervalType: intervalType,
|
intervalType: intervalType,
|
||||||
timewindowType: timewindowType,
|
timewindowType: timewindowType,
|
||||||
@ -497,7 +520,7 @@ export class TimewindowConfigDialogComponent extends PageComponent implements On
|
|||||||
resFn(result);
|
resFn(result);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{maxHeight: '90vh', height: '100%'},
|
{maxHeight: '500px', height: '100%'},
|
||||||
{}, {}, true, () => {}, {padding: 0});
|
{}, {}, true, () => {}, {padding: 0});
|
||||||
intervalsConfigPopover.tbComponentRef.instance.popoverComponent = intervalsConfigPopover;
|
intervalsConfigPopover.tbComponentRef.instance.popoverComponent = intervalsConfigPopover;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -88,6 +88,8 @@ export interface IntervalWindow {
|
|||||||
interval?: Interval;
|
interval?: Interval;
|
||||||
timewindowMs?: number;
|
timewindowMs?: number;
|
||||||
quickInterval?: QuickTimeInterval;
|
quickInterval?: QuickTimeInterval;
|
||||||
|
allowedLastIntervals? : Array<Interval>;
|
||||||
|
allowedQuickIntervals? : Array<QuickTimeInterval>;
|
||||||
disableCustomInterval?: boolean;
|
disableCustomInterval?: boolean;
|
||||||
disableCustomGroupInterval?: boolean;
|
disableCustomGroupInterval?: boolean;
|
||||||
hideInterval?: boolean;
|
hideInterval?: boolean;
|
||||||
@ -176,6 +178,12 @@ export interface WidgetTimewindow {
|
|||||||
stDiff?: number;
|
stDiff?: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface TimewindowIntervalOption {
|
||||||
|
name: string;
|
||||||
|
translateParams?: {[key: string]: any};
|
||||||
|
value: Interval | QuickTimeInterval;
|
||||||
|
}
|
||||||
|
|
||||||
export enum QuickTimeInterval {
|
export enum QuickTimeInterval {
|
||||||
YESTERDAY = 'YESTERDAY',
|
YESTERDAY = 'YESTERDAY',
|
||||||
DAY_BEFORE_YESTERDAY = 'DAY_BEFORE_YESTERDAY',
|
DAY_BEFORE_YESTERDAY = 'DAY_BEFORE_YESTERDAY',
|
||||||
|
|||||||
@ -4547,7 +4547,8 @@
|
|||||||
"edit-aggregation-functions-list-hint": "List of available options can be specified.",
|
"edit-aggregation-functions-list-hint": "List of available options can be specified.",
|
||||||
"allowed-aggregation-functions": "Allowed aggregation functions",
|
"allowed-aggregation-functions": "Allowed aggregation functions",
|
||||||
"edit-intervals-list": "Edit intervals list",
|
"edit-intervals-list": "Edit intervals list",
|
||||||
"edit-intervals-list-hint": "List of available interval options can be specified. It is possible to configure the grouping intervals list and default grouping interval."
|
"edit-intervals-list-hint": "List of available interval options can be specified.",
|
||||||
|
"edit-grouping-intervals-list-hint": "It is possible to configure the grouping intervals list and default grouping interval."
|
||||||
},
|
},
|
||||||
"tooltip": {
|
"tooltip": {
|
||||||
"trigger": "Trigger",
|
"trigger": "Trigger",
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user