diff --git a/ui-ngx/src/app/core/api/data-aggregator.ts b/ui-ngx/src/app/core/api/data-aggregator.ts index 2c27e6fcf0..02c1c8649a 100644 --- a/ui-ngx/src/app/core/api/data-aggregator.ts +++ b/ui-ngx/src/app/core/api/data-aggregator.ts @@ -17,10 +17,9 @@ import { SubscriptionData, SubscriptionDataHolder } from '@app/shared/models/telemetry/telemetry.models'; import { AggregationType, calculateIntervalComparisonEndTime, - calculateIntervalEndTime, - calculateIntervalStartTime, + calculateIntervalEndTime, calculateIntervalStartEndTime, getCurrentTime, - getCurrentTimeForComparison, + getCurrentTimeForComparison, getTime, SubscriptionTimewindow } from '@shared/models/time/time.models'; import { UtilsService } from '@core/services/utils.service'; @@ -245,11 +244,12 @@ export class DataAggregator { this.startTs = this.subsTw.startTs + this.subsTw.tsOffset; if (this.subsTw.quickInterval) { if (this.subsTw.timeForComparison === 'previousInterval') { + const startDate = getTime(this.subsTw.startTs, this.subsTw.timezone); const currentDate = getCurrentTime(this.subsTw.timezone); - this.endTs = calculateIntervalComparisonEndTime(this.subsTw.quickInterval, currentDate) + this.subsTw.tsOffset; + this.endTs = calculateIntervalComparisonEndTime(this.subsTw.quickInterval, startDate, currentDate) + this.subsTw.tsOffset; } else { - const currentDate = this.getCurrentTime(); - this.endTs = calculateIntervalEndTime(this.subsTw.quickInterval, currentDate) + this.subsTw.tsOffset; + const startDate = getTime(this.subsTw.startTs, this.subsTw.timezone); + this.endTs = calculateIntervalEndTime(this.subsTw.quickInterval, startDate, this.subsTw.timezone) + this.subsTw.tsOffset; } } else { this.endTs = this.startTs + this.subsTw.aggregation.timeWindow; @@ -270,9 +270,9 @@ export class DataAggregator { if (delta || !this.data || rangeChanged) { const tickTs = delta * this.subsTw.aggregation.interval; if (this.subsTw.quickInterval) { - const currentDate = this.getCurrentTime(); - this.startTs = calculateIntervalStartTime(this.subsTw.quickInterval, currentDate) + this.subsTw.tsOffset; - this.endTs = calculateIntervalEndTime(this.subsTw.quickInterval, currentDate) + this.subsTw.tsOffset; + const startEndTime = calculateIntervalStartEndTime(this.subsTw.quickInterval, this.subsTw.timezone); + this.startTs = startEndTime[0] + this.subsTw.tsOffset; + this.endTs = startEndTime[1] + this.subsTw.tsOffset; } else { this.startTs += tickTs; this.endTs += tickTs; diff --git a/ui-ngx/src/app/core/api/widget-subscription.ts b/ui-ngx/src/app/core/api/widget-subscription.ts index 6663735bd5..b74a807729 100644 --- a/ui-ngx/src/app/core/api/widget-subscription.ts +++ b/ui-ngx/src/app/core/api/widget-subscription.ts @@ -37,12 +37,11 @@ import { } from '@app/shared/models/widget.models'; import { HttpErrorResponse } from '@angular/common/http'; import { - calculateIntervalEndTime, - calculateIntervalStartTime, + calculateIntervalStartEndTime, calculateTsOffset, ComparisonDuration, createSubscriptionTimewindow, createTimewindowForComparison, - getCurrentTime, isHistoryTypeTimewindow, + isHistoryTypeTimewindow, SubscriptionTimewindow, Timewindow, timewindowTypeChanged, toHistoryTimewindow, @@ -1106,11 +1105,9 @@ export class WidgetSubscription implements IWidgetSubscription { this.timeWindow.timezone = this.subscriptionTimewindow.timezone; if (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; + const startEndTime = calculateIntervalStartEndTime(this.subscriptionTimewindow.quickInterval, this.subscriptionTimewindow.timezone); + this.timeWindow.maxTime = startEndTime[1] + this.subscriptionTimewindow.tsOffset; + this.timeWindow.minTime = startEndTime[0] + this.subscriptionTimewindow.tsOffset; } else { this.timeWindow.maxTime = moment().valueOf() + this.subscriptionTimewindow.tsOffset + this.timeWindow.stDiff; this.timeWindow.minTime = this.timeWindow.maxTime - this.subscriptionTimewindow.realtimeWindowMs; 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 c1dd69ecf5..40a6b0cece 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 @@ -56,9 +56,7 @@ 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 { - calculateIntervalEndTime, - calculateIntervalStartTime, - getCurrentTime, + calculateIntervalStartEndTime, HistoryWindowType, Timewindow } from '@shared/models/time/time.models'; @@ -303,9 +301,9 @@ export class EntitiesTableComponent extends PageComponent implements AfterViewIn 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); + const startEndTime = calculateIntervalStartEndTime(this.timewindow.history.quickInterval); + timePageLink.startTime = startEndTime[0]; + timePageLink.endTime = startEndTime[1]; } else { timePageLink.startTime = this.timewindow.history.fixedTimewindow.startTimeMs; timePageLink.endTime = this.timewindow.history.fixedTimewindow.endTimeMs; diff --git a/ui-ngx/src/app/shared/models/time/time.models.ts b/ui-ngx/src/app/shared/models/time/time.models.ts index a686857ed1..c9520f09df 100644 --- a/ui-ngx/src/app/shared/models/time/time.models.ts +++ b/ui-ngx/src/app/shared/models/time/time.models.ts @@ -174,19 +174,18 @@ export const QuickTimeIntervalTranslationMap = new Map