diff --git a/ui-ngx/src/app/core/api/data-aggregator.ts b/ui-ngx/src/app/core/api/data-aggregator.ts index a57ad25d93..e31d821efd 100644 --- a/ui-ngx/src/app/core/api/data-aggregator.ts +++ b/ui-ngx/src/app/core/api/data-aggregator.ts @@ -15,7 +15,12 @@ /// import { SubscriptionData, SubscriptionDataHolder } from '@app/shared/models/telemetry/telemetry.models'; -import { AggregationType } from '@shared/models/time/time.models'; +import { + AggregationType, + calculateIntervalEndTime, + calculateIntervalStartTime, getCurrentTime, + QuickTimeInterval, SubscriptionTimewindow +} from '@shared/models/time/time.models'; import { UtilsService } from '@core/services/utils.service'; import { deepClone } from '@core/utils'; import Timeout = NodeJS.Timeout; @@ -73,33 +78,29 @@ export class DataAggregator { private resetPending = false; private updatedData = false; - private noAggregation = this.aggregationType === AggregationType.NONE; - private aggregationTimeout = Math.max(this.interval, 1000); + private noAggregation = this.subsTw.aggregation.type === AggregationType.NONE; + private aggregationTimeout = Math.max(this.subsTw.aggregation.interval, 1000); private readonly aggFunction: AggFunction; private intervalTimeoutHandle: Timeout; private intervalScheduledTime: number; + private startTs = this.subsTw.startTs + this.subsTw.tsOffset; private endTs: number; private elapsed: number; constructor(private onDataCb: onAggregatedData, private tsKeyNames: string[], - private startTs: number, - private limit: number, - private aggregationType: AggregationType, - private timeWindow: number, - private interval: number, - private stateData: boolean, + private subsTw: SubscriptionTimewindow, private utils: UtilsService, private ignoreDataUpdateOnIntervalTick: boolean) { this.tsKeyNames.forEach((key) => { this.dataBuffer[key] = []; }); - if (this.stateData) { + if (this.subsTw.aggregation.stateData) { this.lastPrevKvPairData = {}; } - switch (this.aggregationType) { + switch (this.subsTw.aggregation.type) { case AggregationType.MIN: this.aggFunction = min; break; @@ -129,18 +130,21 @@ export class DataAggregator { return prevOnDataCb; } - public reset(startTs: number, timeWindow: number, interval: number) { + public reset(subsTw: SubscriptionTimewindow) { if (this.intervalTimeoutHandle) { clearTimeout(this.intervalTimeoutHandle); this.intervalTimeoutHandle = null; } + this.subsTw = subsTw; this.intervalScheduledTime = this.utils.currentPerfTime(); - this.startTs = startTs; - this.timeWindow = timeWindow; - this.interval = interval; - this.endTs = this.startTs + this.timeWindow; + this.startTs = this.subsTw.startTs + this.subsTw.tsOffset; + if (this.subsTw.quickInterval) { + this.endTs = calculateIntervalEndTime(this.subsTw.quickInterval, null, this.subsTw.timezone) + this.subsTw.tsOffset; + } else { + this.endTs = this.startTs + this.subsTw.aggregation.timeWindow; + } this.elapsed = 0; - this.aggregationTimeout = Math.max(this.interval, 1000); + this.aggregationTimeout = Math.max(this.subsTw.aggregation.interval, 1000); this.resetPending = true; this.updatedData = false; this.intervalTimeoutHandle = setTimeout(this.onInterval.bind(this), this.aggregationTimeout); @@ -161,7 +165,11 @@ export class DataAggregator { if (!this.dataReceived) { this.elapsed = 0; this.dataReceived = true; - this.endTs = this.startTs + this.timeWindow; + if (this.subsTw.quickInterval) { + this.endTs = calculateIntervalEndTime(this.subsTw.quickInterval, null, this.subsTw.timezone) + this.subsTw.tsOffset; + } else { + this.endTs = this.startTs + this.subsTw.aggregation.timeWindow; + } } if (this.resetPending) { this.resetPending = false; @@ -195,12 +203,19 @@ export class DataAggregator { this.intervalTimeoutHandle = null; } if (!history) { - const delta = Math.floor(this.elapsed / this.interval); + const delta = Math.floor(this.elapsed / this.subsTw.aggregation.interval); if (delta || !this.data) { - this.startTs += delta * this.interval; - this.endTs += delta * this.interval; + const tickTs = delta * this.subsTw.aggregation.interval; + if (this.subsTw.quickInterval) { + const currentDate = getCurrentTime(this.subsTw.timezone); + this.startTs = calculateIntervalStartTime(this.subsTw.quickInterval, currentDate) + this.subsTw.tsOffset; + this.endTs = calculateIntervalEndTime(this.subsTw.quickInterval, currentDate) + this.subsTw.tsOffset; + } else { + this.startTs += tickTs; + this.endTs += tickTs; + } this.data = this.updateData(); - this.elapsed = this.elapsed - delta * this.interval; + this.elapsed = this.elapsed - delta * this.subsTw.aggregation.interval; } } else { this.data = this.updateData(); @@ -223,7 +238,7 @@ export class DataAggregator { let keyData = this.dataBuffer[key]; aggKeyData.forEach((aggData, aggTimestamp) => { if (aggTimestamp <= this.startTs) { - if (this.stateData && + if (this.subsTw.aggregation.stateData && (!this.lastPrevKvPairData[key] || this.lastPrevKvPairData[key][0] < aggTimestamp)) { this.lastPrevKvPairData[key] = [aggTimestamp, aggData.aggValue]; } @@ -235,11 +250,11 @@ export class DataAggregator { } }); keyData.sort((set1, set2) => set1[0] - set2[0]); - if (this.stateData) { + if (this.subsTw.aggregation.stateData) { this.updateStateBounds(keyData, deepClone(this.lastPrevKvPairData[key])); } - if (keyData.length > this.limit) { - keyData = keyData.slice(keyData.length - this.limit); + if (keyData.length > this.subsTw.aggregation.limit) { + keyData = keyData.slice(keyData.length - this.subsTw.aggregation.limit); } this.dataBuffer[key] = keyData; } @@ -275,7 +290,7 @@ export class DataAggregator { } private processAggregatedData(data: SubscriptionData): AggregationMap { - const isCount = this.aggregationType === AggregationType.COUNT; + const isCount = this.subsTw.aggregation.type === AggregationType.COUNT; const aggregationMap: AggregationMap = {}; for (const key of Object.keys(data)) { let aggKeyData = aggregationMap[key]; @@ -300,7 +315,7 @@ export class DataAggregator { } private updateAggregatedData(data: SubscriptionData) { - const isCount = this.aggregationType === AggregationType.COUNT; + const isCount = this.subsTw.aggregation.type === AggregationType.COUNT; for (const key of Object.keys(data)) { let aggKeyData = this.aggregationMap[key]; if (!aggKeyData) { @@ -312,7 +327,8 @@ export class DataAggregator { const timestamp = kvPair[0]; const value = this.convertValue(kvPair[1]); const aggTimestamp = this.noAggregation ? timestamp : (this.startTs + - Math.floor((timestamp - this.startTs) / this.interval) * this.interval + this.interval / 2); + Math.floor((timestamp - this.startTs) / this.subsTw.aggregation.interval) * + this.subsTw.aggregation.interval + this.subsTw.aggregation.interval / 2); let aggData = aggKeyData.get(aggTimestamp); if (!aggData) { aggData = { diff --git a/ui-ngx/src/app/core/api/entity-data-subscription.ts b/ui-ngx/src/app/core/api/entity-data-subscription.ts index dbc9bd2adb..1b8c99a285 100644 --- a/ui-ngx/src/app/core/api/entity-data-subscription.ts +++ b/ui-ngx/src/app/core/api/entity-data-subscription.ts @@ -237,7 +237,7 @@ export class EntityDataSubscription { }; if (this.entityDataSubscriptionOptions.isPaginatedDataSubscription) { - this.prepareSubscriptionCommands(this.dataCommand); + this.prepareSubscriptionCommands(); } this.subscriber.subscriptionCommands.push(this.dataCommand); @@ -256,8 +256,8 @@ export class EntityDataSubscription { if (this.started) { const targetCommand = this.entityDataSubscriptionOptions.isPaginatedDataSubscription ? this.dataCommand : this.subsCommand; if (this.entityDataSubscriptionOptions.type === widgetType.timeseries && - !this.history && this.tsFields.length) { - const newSubsTw: SubscriptionTimewindow = this.listener.updateRealtimeSubscription(); + !this.history && this.tsFields.length) { + const newSubsTw = this.listener.updateRealtimeSubscription(); this.subsTw = newSubsTw; targetCommand.tsCmd.startTs = this.subsTw.startTs; targetCommand.tsCmd.timeWindow = this.subsTw.aggregation.timeWindow; @@ -266,9 +266,10 @@ export class EntityDataSubscription { targetCommand.tsCmd.agg = this.subsTw.aggregation.type; targetCommand.tsCmd.fetchLatestPreviousPoint = this.subsTw.aggregation.stateData; this.dataAggregators.forEach((dataAggregator) => { - dataAggregator.reset(newSubsTw.startTs, newSubsTw.aggregation.timeWindow, newSubsTw.aggregation.interval); + dataAggregator.reset(newSubsTw); }); } + this.subscriber.setTsOffset(this.subsTw.tsOffset); targetCommand.query = this.dataCommand.query; this.subscriber.subscriptionCommands = [targetCommand]; } else { @@ -393,7 +394,7 @@ export class EntityDataSubscription { if (this.datasourceType === DatasourceType.entity) { this.subsCommand = new EntityDataCmd(); this.subsCommand.cmdId = this.dataCommand.cmdId; - this.prepareSubscriptionCommands(this.subsCommand); + this.prepareSubscriptionCommands(); if (!this.subsCommand.isEmpty()) { this.subscriber.subscriptionCommands = [this.subsCommand]; this.subscriber.update(); @@ -404,11 +405,11 @@ export class EntityDataSubscription { this.started = true; } - private prepareSubscriptionCommands(cmd: EntityDataCmd) { + private prepareSubscriptionCommands() { if (this.entityDataSubscriptionOptions.type === widgetType.timeseries) { if (this.tsFields.length > 0) { if (this.history) { - cmd.historyCmd = { + this.subsCommand.historyCmd = { keys: this.tsFields.map(key => key.key), startTs: this.subsTw.fixedWindow.startTimeMs, endTs: this.subsTw.fixedWindow.endTimeMs, @@ -418,7 +419,7 @@ export class EntityDataSubscription { fetchLatestPreviousPoint: this.subsTw.aggregation.stateData }; } else { - cmd.tsCmd = { + this.subsCommand.tsCmd = { keys: this.tsFields.map(key => key.key), startTs: this.subsTw.startTs, timeWindow: this.subsTw.aggregation.timeWindow, @@ -429,9 +430,10 @@ export class EntityDataSubscription { }; } } + this.subscriber.setTsOffset(this.subsTw.tsOffset); } else if (this.entityDataSubscriptionOptions.type === widgetType.latest) { if (this.latestValues.length > 0) { - cmd.latestCmd = { + this.subsCommand.latestCmd = { keys: this.latestValues }; } @@ -745,12 +747,7 @@ export class EntityDataSubscription { this.onData(data, dataKeyType, dataIndex, detectChanges, dataUpdatedCb); }, tsKeyNames, - subsTw.startTs, - subsTw.aggregation.limit, - subsTw.aggregation.type, - subsTw.aggregation.timeWindow, - subsTw.aggregation.interval, - subsTw.aggregation.stateData, + subsTw, this.utils, this.entityDataSubscriptionOptions.ignoreDataUpdateOnIntervalTick ); @@ -827,7 +824,8 @@ export class EntityDataSubscription { startTime = dataKey.lastUpdateTime + this.frequency; endTime = dataKey.lastUpdateTime + deltaElapsed; } else { - startTime = this.entityDataSubscriptionOptions.subscriptionTimewindow.startTs; + startTime = this.entityDataSubscriptionOptions.subscriptionTimewindow.startTs + + this.entityDataSubscriptionOptions.subscriptionTimewindow.tsOffset; endTime = startTime + this.entityDataSubscriptionOptions.subscriptionTimewindow.realtimeWindowMs + this.frequency; if (this.entityDataSubscriptionOptions.subscriptionTimewindow.aggregation.type === AggregationType.NONE) { const time = endTime - this.frequency * this.entityDataSubscriptionOptions.subscriptionTimewindow.aggregation.limit; @@ -835,8 +833,10 @@ export class EntityDataSubscription { } } } else { - startTime = this.entityDataSubscriptionOptions.subscriptionTimewindow.fixedWindow.startTimeMs; - endTime = this.entityDataSubscriptionOptions.subscriptionTimewindow.fixedWindow.endTimeMs; + startTime = this.entityDataSubscriptionOptions.subscriptionTimewindow.fixedWindow.startTimeMs + + this.entityDataSubscriptionOptions.subscriptionTimewindow.tsOffset; + endTime = this.entityDataSubscriptionOptions.subscriptionTimewindow.fixedWindow.endTimeMs + + this.entityDataSubscriptionOptions.subscriptionTimewindow.tsOffset; } } generatedData.data[`${dataKey.name}_${dataKey.index}`] = this.generateSeries(dataKey, index, startTime, endTime); diff --git a/ui-ngx/src/app/core/api/widget-subscription.ts b/ui-ngx/src/app/core/api/widget-subscription.ts index ce36f57e10..e658618dea 100644 --- a/ui-ngx/src/app/core/api/widget-subscription.ts +++ b/ui-ngx/src/app/core/api/widget-subscription.ts @@ -37,8 +37,10 @@ import { } from '@app/shared/models/widget.models'; import { HttpErrorResponse } from '@angular/common/http'; import { + calculateIntervalEndTime, + calculateIntervalStartTime, createSubscriptionTimewindow, - createTimewindowForComparison, + createTimewindowForComparison, getCurrentTime, SubscriptionTimewindow, Timewindow, toHistoryTimewindow, @@ -837,9 +839,11 @@ export class WidgetSubscription implements IWidgetSubscription { if (this.alarmDataListener) { this.ctx.alarmDataService.stopSubscription(this.alarmDataListener); } + if (this.timeWindowConfig) { this.updateRealtimeSubscription(); } + this.alarmDataListener = { subscriptionTimewindow: this.subscriptionTimewindow, alarmSource: this.alarmSource, @@ -1080,12 +1084,21 @@ export class WidgetSubscription implements IWidgetSubscription { private updateTimewindow() { this.timeWindow.interval = this.subscriptionTimewindow.aggregation.interval || 1000; + this.timeWindow.timezone = this.subscriptionTimewindow.timezone; if (this.subscriptionTimewindow.realtimeWindowMs) { - this.timeWindow.maxTime = moment().valueOf() + this.timeWindow.stDiff; - this.timeWindow.minTime = this.timeWindow.maxTime - this.subscriptionTimewindow.realtimeWindowMs; + if (this.subscriptionTimewindow.quickInterval) { + const currentDate = getCurrentTime(this.subscriptionTimewindow.timezone); + this.timeWindow.maxTime = calculateIntervalEndTime( + this.subscriptionTimewindow.quickInterval, currentDate) + this.subscriptionTimewindow.tsOffset; + this.timeWindow.minTime = calculateIntervalStartTime( + this.subscriptionTimewindow.quickInterval, currentDate) + this.subscriptionTimewindow.tsOffset; + } else { + this.timeWindow.maxTime = moment().valueOf() + this.subscriptionTimewindow.tsOffset + this.timeWindow.stDiff; + this.timeWindow.minTime = this.timeWindow.maxTime - this.subscriptionTimewindow.realtimeWindowMs; + } } else if (this.subscriptionTimewindow.fixedWindow) { - this.timeWindow.maxTime = this.subscriptionTimewindow.fixedWindow.endTimeMs; - this.timeWindow.minTime = this.subscriptionTimewindow.fixedWindow.startTimeMs; + this.timeWindow.maxTime = this.subscriptionTimewindow.fixedWindow.endTimeMs + this.subscriptionTimewindow.tsOffset; + this.timeWindow.minTime = this.subscriptionTimewindow.fixedWindow.startTimeMs + this.subscriptionTimewindow.tsOffset; } } @@ -1103,12 +1116,13 @@ export class WidgetSubscription implements IWidgetSubscription { private updateComparisonTimewindow() { this.comparisonTimeWindow.interval = this.timewindowForComparison.aggregation.interval || 1000; + this.comparisonTimeWindow.timezone = this.timewindowForComparison.timezone; if (this.timewindowForComparison.realtimeWindowMs) { this.comparisonTimeWindow.maxTime = moment(this.timeWindow.maxTime).subtract(1, this.timeForComparison).valueOf(); - this.comparisonTimeWindow.minTime = this.comparisonTimeWindow.maxTime - this.timewindowForComparison.realtimeWindowMs; + this.comparisonTimeWindow.minTime = moment(this.timeWindow.minTime).subtract(1, this.timeForComparison).valueOf(); } else if (this.timewindowForComparison.fixedWindow) { - this.comparisonTimeWindow.maxTime = this.timewindowForComparison.fixedWindow.endTimeMs; - this.comparisonTimeWindow.minTime = this.timewindowForComparison.fixedWindow.startTimeMs; + this.comparisonTimeWindow.maxTime = this.timewindowForComparison.fixedWindow.endTimeMs + this.timewindowForComparison.tsOffset; + this.comparisonTimeWindow.minTime = this.timewindowForComparison.fixedWindow.startTimeMs + this.timewindowForComparison.tsOffset; } } @@ -1335,7 +1349,7 @@ export class WidgetSubscription implements IWidgetSubscription { this.onDataUpdated(); } - private alarmsUpdated(_updated: Array, alarms: PageData) { + private alarmsUpdated(updated: Array, alarms: PageData) { this.alarmsLoaded(alarms, 0, 0); } diff --git a/ui-ngx/src/app/modules/home/components/dashboard-page/dashboard-page.component.html b/ui-ngx/src/app/modules/home/components/dashboard-page/dashboard-page.component.html index 1cc501a0d1..762b7149a2 100644 --- a/ui-ngx/src/app/modules/home/components/dashboard-page/dashboard-page.component.html +++ b/ui-ngx/src/app/modules/home/components/dashboard-page/dashboard-page.component.html @@ -91,6 +91,7 @@ direction="left" tooltipPosition="below" aggregation="true" + timezone="true" [(ngModel)]="dashboardCtx.dashboardTimewindow"> diff --git a/ui-ngx/src/app/modules/home/components/entity/entities-table.component.ts b/ui-ngx/src/app/modules/home/components/entity/entities-table.component.ts index da735c1567..c1dd69ecf5 100644 --- a/ui-ngx/src/app/modules/home/components/entity/entities-table.component.ts +++ b/ui-ngx/src/app/modules/home/components/entity/entities-table.component.ts @@ -55,7 +55,13 @@ import { EntityTypeTranslation } from '@shared/models/entity-type.models'; import { DialogService } from '@core/services/dialog.service'; import { AddEntityDialogComponent } from './add-entity-dialog.component'; import { AddEntityDialogData, EntityAction } from '@home/models/entity/entity-component.models'; -import { HistoryWindowType, Timewindow } from '@shared/models/time/time.models'; +import { + calculateIntervalEndTime, + calculateIntervalStartTime, + getCurrentTime, + HistoryWindowType, + Timewindow +} from '@shared/models/time/time.models'; import { DomSanitizer, SafeHtml } from '@angular/platform-browser'; import { TbAnchorComponent } from '@shared/components/tb-anchor.component'; import { isDefined, isUndefined } from '@core/utils'; @@ -296,6 +302,10 @@ export class EntitiesTableComponent extends PageComponent implements AfterViewIn const currentTime = Date.now(); timePageLink.startTime = currentTime - this.timewindow.history.timewindowMs; timePageLink.endTime = currentTime; + } else if (this.timewindow.history.historyType === HistoryWindowType.INTERVAL) { + const currentDate = getCurrentTime(); + timePageLink.startTime = calculateIntervalStartTime(this.timewindow.history.quickInterval, currentDate); + timePageLink.endTime = calculateIntervalEndTime(this.timewindow.history.quickInterval, currentDate); } else { timePageLink.startTime = this.timewindow.history.fixedTimewindow.startTimeMs; timePageLink.endTime = this.timewindow.history.fixedTimewindow.endTimeMs; diff --git a/ui-ngx/src/app/modules/home/components/profile/alarm/alarm-schedule.component.ts b/ui-ngx/src/app/modules/home/components/profile/alarm/alarm-schedule.component.ts index 5c9a1cd0aa..d5c9f02876 100644 --- a/ui-ngx/src/app/modules/home/components/profile/alarm/alarm-schedule.component.ts +++ b/ui-ngx/src/app/modules/home/components/profile/alarm/alarm-schedule.component.ts @@ -94,11 +94,10 @@ export class AlarmScheduleComponent implements ControlValueAccessor, Validator, items: this.fb.array(Array.from({length: 7}, (value, i) => this.defaultItemsScheduler(i)), this.validateItems) }); this.alarmScheduleForm.get('type').valueChanges.subscribe((type) => { - getDefaultTimezone().subscribe((defaultTimezone) => { - this.alarmScheduleForm.reset({type, items: this.defaultItems, timezone: defaultTimezone}, {emitEvent: false}); - this.updateValidators(type, true); - this.alarmScheduleForm.updateValueAndValidity(); - }); + const defaultTimezone = getDefaultTimezone(); + this.alarmScheduleForm.reset({type, items: this.defaultItems, timezone: defaultTimezone}, {emitEvent: false}); + this.updateValidators(type, true); + this.alarmScheduleForm.updateValueAndValidity(); }); this.alarmScheduleForm.valueChanges.subscribe(() => { this.updateModel(); diff --git a/ui-ngx/src/app/shared/components/time/quick-time-interval.component.html b/ui-ngx/src/app/shared/components/time/quick-time-interval.component.html new file mode 100644 index 0000000000..c9f367c574 --- /dev/null +++ b/ui-ngx/src/app/shared/components/time/quick-time-interval.component.html @@ -0,0 +1,27 @@ + +
+ + timewindow.interval + + + {{ timeIntervalTranslationMap.get(interval) | translate}} + + + +
diff --git a/ui-ngx/src/app/shared/components/time/quick-time-interval.component.scss b/ui-ngx/src/app/shared/components/time/quick-time-interval.component.scss new file mode 100644 index 0000000000..97c400525e --- /dev/null +++ b/ui-ngx/src/app/shared/components/time/quick-time-interval.component.scss @@ -0,0 +1,19 @@ +/** + * Copyright © 2016-2021 The Thingsboard Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +:host { + min-width: 364px; +} diff --git a/ui-ngx/src/app/shared/components/time/quick-time-interval.component.ts b/ui-ngx/src/app/shared/components/time/quick-time-interval.component.ts new file mode 100644 index 0000000000..3eab8c428d --- /dev/null +++ b/ui-ngx/src/app/shared/components/time/quick-time-interval.component.ts @@ -0,0 +1,79 @@ +/// +/// Copyright © 2016-2021 The Thingsboard Authors +/// +/// Licensed under the Apache License, Version 2.0 (the "License"); +/// you may not use this file except in compliance with the License. +/// You may obtain a copy of the License at +/// +/// http://www.apache.org/licenses/LICENSE-2.0 +/// +/// Unless required by applicable law or agreed to in writing, software +/// distributed under the License is distributed on an "AS IS" BASIS, +/// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +/// See the License for the specific language governing permissions and +/// limitations under the License. +/// + +import { Component, forwardRef, Input, OnInit } from '@angular/core'; +import { ControlValueAccessor, NG_VALUE_ACCESSOR } from '@angular/forms'; +import { QuickTimeInterval, QuickTimeIntervalTranslationMap } from '@shared/models/time/time.models'; + +@Component({ + selector: 'tb-quick-time-interval', + templateUrl: './quick-time-interval.component.html', + styleUrls: ['./quick-time-interval.component.scss'], + providers: [ + { + provide: NG_VALUE_ACCESSOR, + useExisting: forwardRef(() => QuickTimeIntervalComponent), + multi: true + } + ] +}) +export class QuickTimeIntervalComponent implements OnInit, ControlValueAccessor { + + private allIntervals = Object.values(QuickTimeInterval); + + modelValue: QuickTimeInterval; + timeIntervalTranslationMap = QuickTimeIntervalTranslationMap; + + rendered = false; + + @Input() disabled: boolean; + + @Input() onlyCurrentInterval = false; + + private propagateChange = (_: any) => {}; + + constructor() { + } + + get intervals() { + if (this.onlyCurrentInterval) { + return this.allIntervals.filter(interval => interval.startsWith('CURRENT_')); + } + return this.allIntervals; + } + + ngOnInit(): void { + } + + registerOnChange(fn: any): void { + this.propagateChange = fn; + } + + registerOnTouched(fn: any): void { + } + + setDisabledState(isDisabled: boolean): void { + this.disabled = isDisabled; + } + + writeValue(interval: QuickTimeInterval): void { + this.modelValue = interval; + } + + onIntervalChange() { + this.propagateChange(this.modelValue); + } +} diff --git a/ui-ngx/src/app/shared/components/time/timewindow-panel.component.html b/ui-ngx/src/app/shared/components/time/timewindow-panel.component.html index e4ddaa0f56..42c3266e62 100644 --- a/ui-ngx/src/app/shared/components/time/timewindow-panel.component.html +++ b/ui-ngx/src/app/shared/components/time/timewindow-panel.component.html @@ -21,16 +21,43 @@ -
- -
+
+
+ + +
+
+
+ + +
+ timewindow.last + +
+
+ +
+ timewindow.interval + +
+
+
+
+
+
@@ -65,6 +92,17 @@ style="padding-top: 8px;">
+ +
+ timewindow.interval + +
+
@@ -139,6 +177,16 @@ predefinedName="aggregation.group-interval"> +
+
+ + +
+ + +