mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
fix(timerange): fix handling of invalid dates in from/to url parameters, fixes #3345
This commit is contained in:
parent
2345b41a74
commit
0b4552a8e7
@ -21,6 +21,7 @@ define([
|
|||||||
|
|
||||||
this._initTimeFromUrl();
|
this._initTimeFromUrl();
|
||||||
this._parseTime();
|
this._parseTime();
|
||||||
|
console.log(dashboard.time);
|
||||||
|
|
||||||
if(this.dashboard.refresh) {
|
if(this.dashboard.refresh) {
|
||||||
this.setAutoRefresh(this.dashboard.refresh);
|
this.setAutoRefresh(this.dashboard.refresh);
|
||||||
@ -47,8 +48,9 @@ define([
|
|||||||
if (value.length === 15) {
|
if (value.length === 15) {
|
||||||
return moment.utc(value, 'YYYYMMDDTHHmmss');
|
return moment.utc(value, 'YYYYMMDDTHHmmss');
|
||||||
}
|
}
|
||||||
var epoch = parseInt(value);
|
|
||||||
if (!_.isNaN(epoch)) {
|
if (!isNaN(value)) {
|
||||||
|
var epoch = parseInt(value);
|
||||||
return moment(epoch);
|
return moment(epoch);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -15,7 +15,7 @@ define([],
|
|||||||
rows: [],
|
rows: [],
|
||||||
pulldowns: [ { type: 'templating' }, { type: 'annotations' } ],
|
pulldowns: [ { type: 'templating' }, { type: 'annotations' } ],
|
||||||
nav: [ { type: 'timepicker' } ],
|
nav: [ { type: 'timepicker' } ],
|
||||||
time: {from: '1h', to: 'now'},
|
time: {from: 'now-6h', to: 'now'},
|
||||||
templating: {
|
templating: {
|
||||||
list: []
|
list: []
|
||||||
},
|
},
|
||||||
|
@ -75,6 +75,14 @@ define([
|
|||||||
expect(time.to.valueOf()).to.equal(1410337665699);
|
expect(time.to.valueOf()).to.equal(1410337665699);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should handle bad dates', function() {
|
||||||
|
ctx.$routeParams.from = '20151126T00010%3C%2Fp%3E%3Cspan%20class';
|
||||||
|
ctx.$routeParams.to = 'now';
|
||||||
|
_dashboard.time.from = 'now-6h';
|
||||||
|
ctx.service.init(_dashboard);
|
||||||
|
expect(ctx.service.time.from).to.equal('now-6h');
|
||||||
|
expect(ctx.service.time.to).to.equal('now');
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('setTime', function() {
|
describe('setTime', function() {
|
||||||
|
Loading…
Reference in New Issue
Block a user