diff --git a/CHANGELOG.md b/CHANGELOG.md
index a6ccfc84ac2..d56edad01a1 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -2,6 +2,7 @@
**New features**
- [Issue #1331](https://github.com/grafana/grafana/issues/1331). Graph & Singlestat: New axis/unit format selector and more units (kbytes, Joule, Watt, eV), and new design for graph axis & grid tab and single stat options tab views
+- [Issue #1241](https://github.com/grafana/grafana/issues/1242). Timepicker: New option in timepicker (under dashboard settings), to change ``now`` to be for example ``now-1m``, usefull when you want to ignore last minute because it contains incomplete data
**Enhancements**
- [Issue #1297](https://github.com/grafana/grafana/issues/1297). Graphite: Added cumulative and minimumBelow graphite functions
diff --git a/src/app/features/dashboard/timeSrv.js b/src/app/features/dashboard/timeSrv.js
index 564f30de7fd..e2f9f313d1e 100644
--- a/src/app/features/dashboard/timeSrv.js
+++ b/src/app/features/dashboard/timeSrv.js
@@ -112,6 +112,7 @@ define([
if(_.isUndefined(_t) || _.isUndefined(_t.from)) {
return false;
}
+
if(parse === false) {
return {
from: _t.from,
diff --git a/src/app/features/influxdb/datasource.js b/src/app/features/influxdb/datasource.js
index cef933d8d42..e1acd1632e7 100644
--- a/src/app/features/influxdb/datasource.js
+++ b/src/app/features/influxdb/datasource.js
@@ -374,7 +374,7 @@ function (angular, _, kbn, InfluxSeries, InfluxQueryBuilder) {
var fromIsAbsolute = from[from.length-1] === 's';
if (until === 'now()' && !fromIsAbsolute) {
- return 'time > now() - ' + from;
+ return 'time > ' + from;
}
return 'time > ' + from + ' and time < ' + until;
@@ -382,14 +382,7 @@ function (angular, _, kbn, InfluxSeries, InfluxQueryBuilder) {
function getInfluxTime(date) {
if (_.isString(date)) {
- if (date === 'now') {
- return 'now()';
- }
- else if (date.indexOf('now') >= 0) {
- return date.substring(4);
- }
-
- date = kbn.parseDate(date);
+ return date.replace('now', 'now()');
}
return to_utc_epoch_seconds(date);
diff --git a/src/app/panels/timepicker/editor.html b/src/app/panels/timepicker/editor.html
index fc51d35ad9f..b6073c64998 100644
--- a/src/app/panels/timepicker/editor.html
+++ b/src/app/panels/timepicker/editor.html
@@ -1,18 +1,44 @@
-
-
-
-
-
-
-
-
-
+
+
+
-
-
-
- For these changes to fully take effect save and reload the dashboard.
-
-
-
+
+
+
+ For these changes to fully take effect save and reload the dashboard.
+
+
+
diff --git a/src/app/panels/timepicker/module.js b/src/app/panels/timepicker/module.js
index eca4936ad00..2f0d9bd75b8 100644
--- a/src/app/panels/timepicker/module.js
+++ b/src/app/panels/timepicker/module.js
@@ -58,10 +58,14 @@ function (angular, app, _, moment, kbn) {
$scope.init = function() {
var time = timeSrv.timeRange(true);
- if(time) {
- $scope.panel.now = timeSrv.timeRange(false).to === "now" ? true : false;
- $scope.time = getScopeTimeObj(time.from,time.to);
+ $scope.panel.now = false;
+
+ var unparsed = timeSrv.timeRange(false);
+ if (_.isString(unparsed.to) && unparsed.to.indexOf('now') === 0) {
+ $scope.panel.now = true;
}
+
+ $scope.time = getScopeTimeObj(time.from, time.to);
};
$scope.customTime = function() {
@@ -142,6 +146,10 @@ function (angular, app, _, moment, kbn) {
to: "now"
};
+ if ($scope.panel.nowDelay) {
+ _filter.to = 'now-' + $scope.panel.nowDelay;
+ }
+
timeSrv.setTime(_filter);
$scope.time = getScopeTimeObj(kbn.parseDate(_filter.from),new Date());
diff --git a/src/test/specs/graph-tooltip-specs.js b/src/test/specs/graph-tooltip-specs.js
index 16b4211921f..155469f18a7 100644
--- a/src/test/specs/graph-tooltip-specs.js
+++ b/src/test/specs/graph-tooltip-specs.js
@@ -19,8 +19,7 @@ define([
tooltip: {
shared: true
},
- legend: {
- },
+ legend: { },
stack: false
};
diff --git a/src/test/specs/influxdb-datasource-specs.js b/src/test/specs/influxdb-datasource-specs.js
index f8b545e7db2..028423ac1f4 100644
--- a/src/test/specs/influxdb-datasource-specs.js
+++ b/src/test/specs/influxdb-datasource-specs.js
@@ -17,7 +17,7 @@ define([
describe('When querying influxdb with one target using query editor target spec', function() {
var results;
var urlExpected = "/series?p=mupp&q=select+mean(value)+from+%22test%22"+
- "+where+time+%3E+now()+-+1h+group+by+time(1s)+order+asc";
+ "+where+time+%3E+now()-1h+group+by+time(1s)+order+asc";
var query = {
range: { from: 'now-1h', to: 'now' },
targets: [{ series: 'test', column: 'value', function: 'mean' }],
@@ -50,7 +50,7 @@ define([
describe('When querying influxdb with one raw query', function() {
var results;
var urlExpected = "/series?p=mupp&q=select+value+from+series"+
- "+where+time+%3E+now()+-+1h";
+ "+where+time+%3E+now()-1h";
var query = {
range: { from: 'now-1h', to: 'now' },
targets: [{ query: "select value from series where $timeFilter", rawQuery: true }]
@@ -73,7 +73,7 @@ define([
describe('When issuing annotation query', function() {
var results;
var urlExpected = "/series?p=mupp&q=select+title+from+events.backend_01"+
- "+where+time+%3E+now()+-+1h";
+ "+where+time+%3E+now()-1h";
var range = { from: 'now-1h', to: 'now' };
var annotation = { query: 'select title from events.$server where $timeFilter' };