UI: Set default interval to 1 sec for no aggregation.

This commit is contained in:
Igor Kulikov 2017-03-16 13:56:37 +02:00
parent e80d355b22
commit 3b05eba89d

View File

@ -238,23 +238,25 @@ function TimeService($translate, types) {
interval = timewindow.realtime.interval; interval = timewindow.realtime.interval;
} }
var aggType;
if (timewindow.aggregation) {
aggType = timewindow.aggregation.type || types.aggregation.avg.value;
} else {
aggType = types.aggregation.avg.value;
}
var historyTimewindow = { var historyTimewindow = {
history: { history: {
fixedTimewindow: { fixedTimewindow: {
startTimeMs: startTimeMs, startTimeMs: startTimeMs,
endTimeMs: endTimeMs endTimeMs: endTimeMs
}, },
interval: boundIntervalToTimewindow(endTimeMs - startTimeMs, interval) interval: boundIntervalToTimewindow(endTimeMs - startTimeMs, interval, aggType)
}, },
aggregation: { aggregation: {
type: aggType
} }
} }
if (timewindow.aggregation) {
historyTimewindow.aggregation.type = timewindow.aggregation.type || types.aggregation.avg.value;
} else {
historyTimewindow.aggregation.type = types.aggregation.avg.value;
}
return historyTimewindow; return historyTimewindow;
} }
@ -281,7 +283,8 @@ function TimeService($translate, types) {
if (angular.isDefined(timewindow.realtime)) { if (angular.isDefined(timewindow.realtime)) {
subscriptionTimewindow.realtimeWindowMs = timewindow.realtime.timewindowMs; subscriptionTimewindow.realtimeWindowMs = timewindow.realtime.timewindowMs;
subscriptionTimewindow.aggregation.interval = subscriptionTimewindow.aggregation.interval =
boundIntervalToTimewindow(subscriptionTimewindow.realtimeWindowMs, timewindow.realtime.interval); boundIntervalToTimewindow(subscriptionTimewindow.realtimeWindowMs, timewindow.realtime.interval,
subscriptionTimewindow.aggregation.type);
subscriptionTimewindow.startTs = (new Date).getTime() + stDiff - subscriptionTimewindow.realtimeWindowMs; subscriptionTimewindow.startTs = (new Date).getTime() + stDiff - subscriptionTimewindow.realtimeWindowMs;
var startDiff = subscriptionTimewindow.startTs % subscriptionTimewindow.aggregation.interval; var startDiff = subscriptionTimewindow.startTs % subscriptionTimewindow.aggregation.interval;
aggTimewindow = subscriptionTimewindow.realtimeWindowMs; aggTimewindow = subscriptionTimewindow.realtimeWindowMs;
@ -306,7 +309,8 @@ function TimeService($translate, types) {
aggTimewindow = subscriptionTimewindow.fixedWindow.endTimeMs - subscriptionTimewindow.fixedWindow.startTimeMs; aggTimewindow = subscriptionTimewindow.fixedWindow.endTimeMs - subscriptionTimewindow.fixedWindow.startTimeMs;
} }
subscriptionTimewindow.startTs = subscriptionTimewindow.fixedWindow.startTimeMs; subscriptionTimewindow.startTs = subscriptionTimewindow.fixedWindow.startTimeMs;
subscriptionTimewindow.aggregation.interval = boundIntervalToTimewindow(aggTimewindow, timewindow.history.interval); subscriptionTimewindow.aggregation.interval =
boundIntervalToTimewindow(aggTimewindow, timewindow.history.interval, subscriptionTimewindow.aggregation.type);
} }
var aggregation = subscriptionTimewindow.aggregation; var aggregation = subscriptionTimewindow.aggregation;
aggregation.timeWindow = aggTimewindow; aggregation.timeWindow = aggTimewindow;
@ -316,13 +320,17 @@ function TimeService($translate, types) {
return subscriptionTimewindow; return subscriptionTimewindow;
} }
function boundIntervalToTimewindow(timewindow, intervalMs) { function boundIntervalToTimewindow(timewindow, intervalMs, aggType) {
var min = minIntervalLimit(timewindow); if (aggType === types.aggregation.none.value) {
var max = maxIntervalLimit(timewindow); return SECOND;
if (intervalMs) {
return toBound(intervalMs, min, max, intervalMs);
} else { } else {
return boundToPredefinedInterval(min, max, avgInterval(timewindow)); var min = minIntervalLimit(timewindow);
var max = maxIntervalLimit(timewindow);
if (intervalMs) {
return toBound(intervalMs, min, max, intervalMs);
} else {
return boundToPredefinedInterval(min, max, avgInterval(timewindow));
}
} }
} }