UI: Fixed some time new time windows intervals not apply

This commit is contained in:
Vladyslav_Prykhodko 2024-03-20 12:50:50 +02:00 committed by Chantsova Ekaterina
parent eceed0c4b1
commit 03c3079100
3 changed files with 20 additions and 16 deletions

View File

@ -51,7 +51,8 @@
"import/order": "off", "import/order": "off",
"@typescript-eslint/member-ordering": "off", "@typescript-eslint/member-ordering": "off",
"no-underscore-dangle": "off", "no-underscore-dangle": "off",
"@typescript-eslint/naming-convention": "off" "@typescript-eslint/naming-convention": "off",
"jsdoc/newline-after-description": 0
} }
}, },
{ {

View File

@ -21,6 +21,7 @@ import { coerceNumberProperty } from '@angular/cdk/coercion';
import { SubscriptSizing } from '@angular/material/form-field'; import { SubscriptSizing } from '@angular/material/form-field';
import { coerceBoolean } from '@shared/decorators/coercion'; import { coerceBoolean } from '@shared/decorators/coercion';
import { Interval, IntervalMath, TimeInterval } from '@shared/models/time/time.models'; import { Interval, IntervalMath, TimeInterval } from '@shared/models/time/time.models';
import { isDefined } from '@core/utils';
@Component({ @Component({
selector: 'tb-timeinterval', selector: 'tb-timeinterval',
@ -90,14 +91,14 @@ export class TimeintervalComponent implements OnInit, ControlValueAccessor {
secs = 0; secs = 0;
interval: Interval = 0; interval: Interval = 0;
modelValue: Interval;
advanced = false;
rendered = false;
intervals: Array<TimeInterval>; intervals: Array<TimeInterval>;
private propagateChange = (_: any) => {}; advanced = false;
private modelValue: Interval;
private rendered = false;
private propagateChange: (value: any) => void = () => {};
constructor(private timeService: TimeService) { constructor(private timeService: TimeService) {
} }
@ -108,6 +109,9 @@ export class TimeintervalComponent implements OnInit, ControlValueAccessor {
registerOnChange(fn: any): void { registerOnChange(fn: any): void {
this.propagateChange = fn; this.propagateChange = fn;
if (isDefined(this.modelValue) && this.rendered) {
this.propagateChange(this.modelValue);
}
} }
registerOnTouched(fn: any): void { registerOnTouched(fn: any): void {
@ -132,7 +136,7 @@ export class TimeintervalComponent implements OnInit, ControlValueAccessor {
} }
} }
setInterval(interval: Interval) { private setInterval(interval: Interval) {
if (!this.advanced) { if (!this.advanced) {
this.interval = interval; this.interval = interval;
} }
@ -143,7 +147,7 @@ export class TimeintervalComponent implements OnInit, ControlValueAccessor {
this.secs = intervalSeconds % 60; this.secs = intervalSeconds % 60;
} }
boundInterval(updateToPreferred = false) { private boundInterval(updateToPreferred = false) {
const min = this.timeService.boundMinInterval(this.minValue); const min = this.timeService.boundMinInterval(this.minValue);
const max = this.timeService.boundMaxInterval(this.maxValue); const max = this.timeService.boundMaxInterval(this.maxValue);
this.intervals = this.timeService.getIntervals(this.minValue, this.maxValue, this.useCalendarIntervals); this.intervals = this.timeService.getIntervals(this.minValue, this.maxValue, this.useCalendarIntervals);
@ -165,7 +169,7 @@ export class TimeintervalComponent implements OnInit, ControlValueAccessor {
} }
} }
updateView(updateToPreferred = false) { private updateView(updateToPreferred = false) {
if (!this.rendered) { if (!this.rendered) {
return; return;
} }
@ -187,7 +191,7 @@ export class TimeintervalComponent implements OnInit, ControlValueAccessor {
this.boundInterval(updateToPreferred); this.boundInterval(updateToPreferred);
} }
calculateIntervalMs(): number { private calculateIntervalMs(): number {
return (this.days * 86400 + return (this.days * 86400 +
this.hours * 3600 + this.hours * 3600 +
this.mins * 60 + this.mins * 60 +
@ -232,7 +236,7 @@ export class TimeintervalComponent implements OnInit, ControlValueAccessor {
} }
} }
onSecsChange() { private onSecsChange() {
if (typeof this.secs === 'undefined') { if (typeof this.secs === 'undefined') {
return; return;
} }
@ -252,7 +256,7 @@ export class TimeintervalComponent implements OnInit, ControlValueAccessor {
this.updateView(); this.updateView();
} }
onMinsChange() { private onMinsChange() {
if (typeof this.mins === 'undefined') { if (typeof this.mins === 'undefined') {
return; return;
} }
@ -272,7 +276,7 @@ export class TimeintervalComponent implements OnInit, ControlValueAccessor {
this.updateView(); this.updateView();
} }
onHoursChange() { private onHoursChange() {
if (typeof this.hours === 'undefined') { if (typeof this.hours === 'undefined') {
return; return;
} }
@ -292,7 +296,7 @@ export class TimeintervalComponent implements OnInit, ControlValueAccessor {
this.updateView(); this.updateView();
} }
onDaysChange() { private onDaysChange() {
if (typeof this.days === 'undefined') { if (typeof this.days === 'undefined') {
return; return;
} }

View File

@ -20,7 +20,6 @@ import {
AggregationType, AggregationType,
DAY, DAY,
HistoryWindowType, HistoryWindowType,
QuickTimeInterval,
quickTimeIntervalPeriod, quickTimeIntervalPeriod,
RealtimeWindowType, RealtimeWindowType,
Timewindow, Timewindow,