|
|
|
|
@ -70,7 +70,7 @@ export class TimeSrv { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (!isNaN(value)) { |
|
|
|
|
var epoch = parseInt(value); |
|
|
|
|
const epoch = parseInt(value); |
|
|
|
|
return moment.utc(epoch); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@ -78,7 +78,7 @@ export class TimeSrv { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private initTimeFromUrl() { |
|
|
|
|
var params = this.$location.search(); |
|
|
|
|
const params = this.$location.search(); |
|
|
|
|
if (params.from) { |
|
|
|
|
this.time.from = this.parseUrlParam(params.from) || this.time.from; |
|
|
|
|
} |
|
|
|
|
@ -91,8 +91,8 @@ export class TimeSrv { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private routeUpdated() { |
|
|
|
|
var params = this.$location.search(); |
|
|
|
|
var urlRange = this.timeRangeForUrl(); |
|
|
|
|
const params = this.$location.search(); |
|
|
|
|
const urlRange = this.timeRangeForUrl(); |
|
|
|
|
// check if url has time range
|
|
|
|
|
if (params.from && params.to) { |
|
|
|
|
// is it different from what our current time range?
|
|
|
|
|
@ -114,7 +114,7 @@ export class TimeSrv { |
|
|
|
|
this.dashboard.refresh = interval; |
|
|
|
|
this.cancelNextRefresh(); |
|
|
|
|
if (interval) { |
|
|
|
|
var intervalMs = kbn.interval_to_ms(interval); |
|
|
|
|
const intervalMs = kbn.interval_to_ms(interval); |
|
|
|
|
|
|
|
|
|
this.refreshTimer = this.timer.register( |
|
|
|
|
this.$timeout(() => { |
|
|
|
|
@ -125,7 +125,7 @@ export class TimeSrv { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// update url
|
|
|
|
|
var params = this.$location.search(); |
|
|
|
|
const params = this.$location.search(); |
|
|
|
|
if (interval) { |
|
|
|
|
params.refresh = interval; |
|
|
|
|
this.$location.search(params); |
|
|
|
|
@ -171,8 +171,8 @@ export class TimeSrv { |
|
|
|
|
|
|
|
|
|
// update url
|
|
|
|
|
if (fromRouteUpdate !== true) { |
|
|
|
|
var urlRange = this.timeRangeForUrl(); |
|
|
|
|
var urlParams = this.$location.search(); |
|
|
|
|
const urlRange = this.timeRangeForUrl(); |
|
|
|
|
const urlParams = this.$location.search(); |
|
|
|
|
urlParams.from = urlRange.from; |
|
|
|
|
urlParams.to = urlRange.to; |
|
|
|
|
this.$location.search(urlParams); |
|
|
|
|
@ -183,7 +183,7 @@ export class TimeSrv { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
timeRangeForUrl() { |
|
|
|
|
var range = this.timeRange().raw; |
|
|
|
|
const range = this.timeRange().raw; |
|
|
|
|
|
|
|
|
|
if (moment.isMoment(range.from)) { |
|
|
|
|
range.from = range.from.valueOf().toString(); |
|
|
|
|
@ -197,12 +197,12 @@ export class TimeSrv { |
|
|
|
|
|
|
|
|
|
timeRange() { |
|
|
|
|
// make copies if they are moment (do not want to return out internal moment, because they are mutable!)
|
|
|
|
|
var raw = { |
|
|
|
|
const raw = { |
|
|
|
|
from: moment.isMoment(this.time.from) ? moment(this.time.from) : this.time.from, |
|
|
|
|
to: moment.isMoment(this.time.to) ? moment(this.time.to) : this.time.to, |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
var timezone = this.dashboard && this.dashboard.getTimezone(); |
|
|
|
|
const timezone = this.dashboard && this.dashboard.getTimezone(); |
|
|
|
|
|
|
|
|
|
return { |
|
|
|
|
from: dateMath.parse(raw.from, false, timezone), |
|
|
|
|
@ -212,16 +212,16 @@ export class TimeSrv { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
zoomOut(e, factor) { |
|
|
|
|
var range = this.timeRange(); |
|
|
|
|
const range = this.timeRange(); |
|
|
|
|
|
|
|
|
|
var timespan = range.to.valueOf() - range.from.valueOf(); |
|
|
|
|
var center = range.to.valueOf() - timespan / 2; |
|
|
|
|
const timespan = range.to.valueOf() - range.from.valueOf(); |
|
|
|
|
const center = range.to.valueOf() - timespan / 2; |
|
|
|
|
|
|
|
|
|
var to = center + timespan * factor / 2; |
|
|
|
|
var from = center - timespan * factor / 2; |
|
|
|
|
let to = center + timespan * factor / 2; |
|
|
|
|
let from = center - timespan * factor / 2; |
|
|
|
|
|
|
|
|
|
if (to > Date.now() && range.to <= Date.now()) { |
|
|
|
|
var offset = to - Date.now(); |
|
|
|
|
const offset = to - Date.now(); |
|
|
|
|
from = from - offset; |
|
|
|
|
to = Date.now(); |
|
|
|
|
} |
|
|
|
|
|