From 3be11b9861cf4aa43778062897bdcf0d9f110481 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torkel=20=C3=96degaard?= Date: Sat, 17 Jan 2015 08:27:55 +0100 Subject: [PATCH 01/10] Small cosmetic change --- src/app/features/annotations/partials/editor.html | 4 ++-- src/app/partials/dashboard.html | 2 +- src/app/partials/dasheditor.html | 2 +- src/app/partials/roweditor.html | 2 +- src/app/partials/templating_editor.html | 4 ++-- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/app/features/annotations/partials/editor.html b/src/app/features/annotations/partials/editor.html index 14208dc2ab2..ae2d624edd9 100644 --- a/src/app/features/annotations/partials/editor.html +++ b/src/app/features/annotations/partials/editor.html @@ -26,7 +26,7 @@ {{annotation.name}} - + Edit @@ -34,7 +34,7 @@ - + diff --git a/src/app/partials/dashboard.html b/src/app/partials/dashboard.html index 5795c6e2c8f..d5118a3ee96 100644 --- a/src/app/partials/dashboard.html +++ b/src/app/partials/dashboard.html @@ -104,7 +104,7 @@
- + ADD ROW
diff --git a/src/app/partials/dasheditor.html b/src/app/partials/dasheditor.html index f19c5701c38..fdeb3a4db24 100644 --- a/src/app/partials/dasheditor.html +++ b/src/app/partials/dasheditor.html @@ -54,7 +54,7 @@ - + diff --git a/src/app/partials/roweditor.html b/src/app/partials/roweditor.html index e15f765d2af..450d8a01a3e 100644 --- a/src/app/partials/roweditor.html +++ b/src/app/partials/roweditor.html @@ -41,7 +41,7 @@ - + diff --git a/src/app/partials/templating_editor.html b/src/app/partials/templating_editor.html index c17d0259b2b..1fd600a5701 100644 --- a/src/app/partials/templating_editor.html +++ b/src/app/partials/templating_editor.html @@ -31,7 +31,7 @@ {{variable.query}} - + Edit @@ -39,7 +39,7 @@ - + From e411b8e423f42aa9c151e46a280d9601dd2b7617 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torkel=20=C3=96degaard?= Date: Mon, 19 Jan 2015 13:07:55 +0100 Subject: [PATCH 02/10] Fixed icons in graph tooltip, not updated after recent font awesome upgrade, Closes #1355 --- src/app/panels/graph/graph.tooltip.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/app/panels/graph/graph.tooltip.js b/src/app/panels/graph/graph.tooltip.js index 9e750cb6a9c..67d6c601104 100644 --- a/src/app/panels/graph/graph.tooltip.js +++ b/src/app/panels/graph/graph.tooltip.js @@ -163,7 +163,7 @@ function ($) { value = series.formatValue(hoverInfo.value); seriesHtml += '
'; - seriesHtml += ' ' + series.label + ':
'; + seriesHtml += ' ' + series.label + ':
'; seriesHtml += '
' + value + '
'; plot.highlight(i, hoverInfo.hoverIndex); } @@ -174,7 +174,7 @@ function ($) { else if (item) { series = seriesList[item.seriesIndex]; group = '
'; - group += ' ' + series.label + ':
'; + group += ' ' + series.label + ':
'; if (scope.panel.stack && scope.panel.tooltip.value_type === 'individual') { value = item.datapoint[1] - item.datapoint[2]; From 5cef73331c4de86b6036b5e19b7b2f7c5e5f49d3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torkel=20=C3=96degaard?= Date: Wed, 21 Jan 2015 07:27:27 +0100 Subject: [PATCH 03/10] Fixed asteric icon in graphite metric path selector, broken after resent font awesome upgrade, #1361 --- src/app/features/graphite/queryCtrl.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/app/features/graphite/queryCtrl.js b/src/app/features/graphite/queryCtrl.js index 0654c474af5..d878386d461 100644 --- a/src/app/features/graphite/queryCtrl.js +++ b/src/app/features/graphite/queryCtrl.js @@ -293,7 +293,7 @@ function (angular, _, config, gfunc, Parser) { function MetricSegment(options) { if (options === '*' || options.value === '*') { this.value = '*'; - this.html = $sce.trustAsHtml(''); + this.html = $sce.trustAsHtml(''); this.expandable = true; return; } From d3c37bda718bc577ad093cfd72faf356b9422653 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torkel=20=C3=96degaard?= Date: Fri, 23 Jan 2015 10:29:54 +0100 Subject: [PATCH 04/10] Graphite: Fix for nested complex queries, where a query references a query that references another query (ie the #[A-Z] syntax), Fixes #1372 --- CHANGELOG.md | 1 + src/app/features/graphite/datasource.js | 1 + src/test/specs/graphiteDatasource-specs.js | 7 +++++++ 3 files changed, 9 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index aa3114b39af..1a8450a80e8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,7 @@ - [Issue #1298](https://github.com/grafana/grafana/issues/1298). InfluxDB: Fix handling of empty array in templating variable query - [Issue #1309](https://github.com/grafana/grafana/issues/1309). Graph: Fixed issue when using zero as a grid threshold - [Issue #1345](https://github.com/grafana/grafana/issues/1345). UI: Fixed position of confirm modal when scrolled down +- [Issue #1372](https://github.com/grafana/grafana/issues/1372). Graphite: Fix for nested complex queries, where a query references a query that references another query (ie the #[A-Z] syntax) **Tech** - [Issue #1311](https://github.com/grafana/grafana/issues/1311). Tech: Updated Font-Awesome from 3.2 to 4.2 diff --git a/src/app/features/graphite/datasource.js b/src/app/features/graphite/datasource.js index 639e150a320..a486250ac74 100644 --- a/src/app/features/graphite/datasource.js +++ b/src/app/features/graphite/datasource.js @@ -276,6 +276,7 @@ function (angular, _, $, config, kbn, moment) { targetValue = targets[this._seriesRefLetters[i]]; targetValue = targetValue.replace(regex, nestedSeriesRegexReplacer); + targets[this._seriesRefLetters[i]] = targetValue; clean_options.push("target=" + encodeURIComponent(targetValue)); } diff --git a/src/test/specs/graphiteDatasource-specs.js b/src/test/specs/graphiteDatasource-specs.js index e23f0e89d4c..58bc62be7ce 100644 --- a/src/test/specs/graphiteDatasource-specs.js +++ b/src/test/specs/graphiteDatasource-specs.js @@ -74,6 +74,13 @@ define([ expect(results[2]).to.be('target=asPercent(series1%2Cseries2)'); }); + it('should replace target placeholder when nesting query references', function() { + var results = ctx.ds.buildGraphiteParams({ + targets: [{target: 'series1'}, {target: 'sumSeries(#A)'}, {target: 'asPercent(#A,#B)'}] + }); + expect(results[2]).to.be('target=' + encodeURIComponent("asPercent(series1,sumSeries(series1))")); + }); + it('should fix wrong minute interval parameters', function() { var results = ctx.ds.buildGraphiteParams({ targets: [{target: "summarize(prod.25m.count, '25m', 'sum')" }] From 1508d0ac236242bf7ee81466fcc992d594f82a7f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torkel=20=C3=96degaard?= Date: Fri, 23 Jan 2015 10:41:23 +0100 Subject: [PATCH 05/10] TemplatOCing: Fix to allow custom template variables to contain white space, now only splits on ',', Fixes #1363 --- CHANGELOG.md | 1 + src/app/features/templating/templateValuesSrv.js | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1a8450a80e8..230ff061e8d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,7 @@ - [Issue #1309](https://github.com/grafana/grafana/issues/1309). Graph: Fixed issue when using zero as a grid threshold - [Issue #1345](https://github.com/grafana/grafana/issues/1345). UI: Fixed position of confirm modal when scrolled down - [Issue #1372](https://github.com/grafana/grafana/issues/1372). Graphite: Fix for nested complex queries, where a query references a query that references another query (ie the #[A-Z] syntax) +- [Issue #1363](https://github.com/grafana/grafana/issues/1363). Templating: Fix to allow custom template variables to contain white space, now only splits on ',' **Tech** - [Issue #1311](https://github.com/grafana/grafana/issues/1311). Tech: Updated Font-Awesome from 3.2 to 4.2 diff --git a/src/app/features/templating/templateValuesSrv.js b/src/app/features/templating/templateValuesSrv.js index 51b11dfb3fa..0add3fc5df9 100644 --- a/src/app/features/templating/templateValuesSrv.js +++ b/src/app/features/templating/templateValuesSrv.js @@ -81,7 +81,7 @@ function (angular, _, kbn) { this._updateNonQueryVariable = function(variable) { // extract options in comma seperated string - variable.options = _.map(variable.query.split(/[\s,]+/), function(text) { + variable.options = _.map(variable.query.split(/[,]+/), function(text) { return { text: text, value: text }; }); From c2c81e7e6aafcfec6814e0acde11927a7c88a321 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torkel=20=C3=96degaard?= Date: Fri, 23 Jan 2015 11:36:18 +0100 Subject: [PATCH 06/10] Graph: Fix for all series tooltip showing series with all null values when Hide Empty option is enabled, Fixes #1359 --- CHANGELOG.md | 1 + src/app/features/templating/templateValuesSrv.js | 2 +- src/app/panels/graph/graph.tooltip.js | 2 +- src/test/specs/graph-tooltip-specs.js | 2 ++ 4 files changed, 5 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 230ff061e8d..a6ccfc84ac2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,6 +15,7 @@ - [Issue #1345](https://github.com/grafana/grafana/issues/1345). UI: Fixed position of confirm modal when scrolled down - [Issue #1372](https://github.com/grafana/grafana/issues/1372). Graphite: Fix for nested complex queries, where a query references a query that references another query (ie the #[A-Z] syntax) - [Issue #1363](https://github.com/grafana/grafana/issues/1363). Templating: Fix to allow custom template variables to contain white space, now only splits on ',' +- [Issue #1359](https://github.com/grafana/grafana/issues/1359). Graph: Fix for all series tooltip showing series with all null values when ``Hide Empty`` option is enabled **Tech** - [Issue #1311](https://github.com/grafana/grafana/issues/1311). Tech: Updated Font-Awesome from 3.2 to 4.2 diff --git a/src/app/features/templating/templateValuesSrv.js b/src/app/features/templating/templateValuesSrv.js index 0add3fc5df9..baff0a840b8 100644 --- a/src/app/features/templating/templateValuesSrv.js +++ b/src/app/features/templating/templateValuesSrv.js @@ -82,7 +82,7 @@ function (angular, _, kbn) { this._updateNonQueryVariable = function(variable) { // extract options in comma seperated string variable.options = _.map(variable.query.split(/[,]+/), function(text) { - return { text: text, value: text }; + return { text: text.trim(), value: text.trim() }; }); if (variable.type === 'interval') { diff --git a/src/app/panels/graph/graph.tooltip.js b/src/app/panels/graph/graph.tooltip.js index 67d6c601104..9e0ff0b8c7b 100644 --- a/src/app/panels/graph/graph.tooltip.js +++ b/src/app/panels/graph/graph.tooltip.js @@ -71,7 +71,7 @@ function ($) { for (i = 0; i < seriesList.length; i++) { series = seriesList[i]; - if (!series.data.length) { + if (!series.data.length || (scope.panel.legend.hideEmpty && series.allIsNull)) { results.push({ hidden: true }); continue; } diff --git a/src/test/specs/graph-tooltip-specs.js b/src/test/specs/graph-tooltip-specs.js index b7def74ac89..16b4211921f 100644 --- a/src/test/specs/graph-tooltip-specs.js +++ b/src/test/specs/graph-tooltip-specs.js @@ -19,6 +19,8 @@ define([ tooltip: { shared: true }, + legend: { + }, stack: false }; From b940f4a97d7a849371bfb5345c1e8617140f26c7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torkel=20=C3=96degaard?= Date: Sun, 25 Jan 2015 13:45:08 +0100 Subject: [PATCH 07/10] 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, Closes #1242, Closes #374 --- CHANGELOG.md | 1 + src/app/features/dashboard/timeSrv.js | 1 + src/app/features/influxdb/datasource.js | 11 +--- src/app/panels/timepicker/editor.html | 58 +++++++++++++++------ src/app/panels/timepicker/module.js | 14 +++-- src/test/specs/graph-tooltip-specs.js | 3 +- src/test/specs/influxdb-datasource-specs.js | 6 +-- 7 files changed, 61 insertions(+), 33 deletions(-) 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 @@
-
-
- - -
-
- - -
+
+
+
    +
  • + Relative time options +
  • +
  • + +
  • +
  • + Until +
  • +
  • + now- +
  • +
  • + +
  • +
+
+
+
+
    +
  • + Auto-refresh options +
  • +
  • + +
  • +
+
+
-

-
- - 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' }; From 6fc451da9e0b55547f4f04b5d5de2b2202ad3856 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torkel=20=C3=96degaard?= Date: Sun, 25 Jan 2015 14:51:51 +0100 Subject: [PATCH 08/10] Small fix --- src/app/panels/timepicker/editor.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/app/panels/timepicker/editor.html b/src/app/panels/timepicker/editor.html index b6073c64998..8771bcadb20 100644 --- a/src/app/panels/timepicker/editor.html +++ b/src/app/panels/timepicker/editor.html @@ -16,7 +16,7 @@ now-
  • -
  • From 1c8ef716a2df95d1166e9cd6402abf8632e1d054 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torkel=20=C3=96degaard?= Date: Mon, 26 Jan 2015 10:57:08 +0100 Subject: [PATCH 09/10] Began work on time overrides for panels, to enable different time periods on the same dashboard, #171 --- .../dashboard/partials/panelTime.html | 43 +++++++++++++++++++ src/app/features/dashboard/timeSrv.js | 14 ++++-- src/app/panels/graph/module.html | 4 ++ src/app/panels/graph/module.js | 23 ++++++++++ src/css/less/graph.less | 13 +++++- src/css/less/panel.less | 4 +- 6 files changed, 94 insertions(+), 7 deletions(-) create mode 100644 src/app/features/dashboard/partials/panelTime.html diff --git a/src/app/features/dashboard/partials/panelTime.html b/src/app/features/dashboard/partials/panelTime.html new file mode 100644 index 00000000000..7b8b507a2ae --- /dev/null +++ b/src/app/features/dashboard/partials/panelTime.html @@ -0,0 +1,43 @@ +
    +
    +
    +
      +
    • + +
    • +
    • + Override relative time +
    • +
    • + Last +
    • +
    • + +
    • +
    +
    +
    +
    +
      +
    • + +
    • +
    • + Add time shift +
    • +
    • + Amount +
    • +
    • + +
    • +
    +
    +
    +
    +
    + diff --git a/src/app/features/dashboard/timeSrv.js b/src/app/features/dashboard/timeSrv.js index e2f9f313d1e..0d8dc31567b 100644 --- a/src/app/features/dashboard/timeSrv.js +++ b/src/app/features/dashboard/timeSrv.js @@ -19,12 +19,23 @@ define([ this.time = dashboard.time; this._initTimeFromUrl(); + this._parseTime(); if(this.dashboard.refresh) { this.set_interval(this.dashboard.refresh); } }; + this._parseTime = function() { + // when absolute time is saved in json it is turned to a string + if (_.isString(this.time.from) && this.time.from.indexOf('Z') >= 0) { + this.time.from = new Date(this.time.from); + } + if (_.isString(this.time.to) && this.time.to.indexOf('Z') >= 0) { + this.time.to = new Date(this.time.to); + } + }; + this._parseUrlParam = function(value) { if (value.indexOf('now') !== -1) { return value; @@ -109,9 +120,6 @@ define([ this.timeRange = function(parse) { var _t = this.time; - if(_.isUndefined(_t) || _.isUndefined(_t.from)) { - return false; - } if(parse === false) { return { diff --git a/src/app/panels/graph/module.html b/src/app/panels/graph/module.html index fa205e488a6..20896fc5c83 100644 --- a/src/app/panels/graph/module.html +++ b/src/app/panels/graph/module.html @@ -3,6 +3,10 @@
    + + {{panelMeta.timeInfo}} + +
    No datapoints No datapoints returned from metric query diff --git a/src/app/panels/graph/module.js b/src/app/panels/graph/module.js index 7fde36b475f..eac410360ad 100644 --- a/src/app/panels/graph/module.js +++ b/src/app/panels/graph/module.js @@ -26,6 +26,7 @@ function (angular, app, $, _, kbn, moment, TimeSeries, PanelMeta) { $scope.panelMeta.addEditorTab('Axes & Grid', 'app/panels/graph/axisEditor.html'); $scope.panelMeta.addEditorTab('Display Styles', 'app/panels/graph/styleEditor.html'); + $scope.panelMeta.addEditorTab('Time range', 'app/features/dashboard/partials/panelTime.html'); $scope.panelMeta.addExtendedMenuItem('Export CSV', '', 'exportCsv()'); $scope.panelMeta.addExtendedMenuItem('Toggle legend', '', 'toggleLegend()'); @@ -88,6 +89,9 @@ function (angular, app, $, _, kbn, moment, TimeSeries, PanelMeta) { value_type: 'cumulative', shared: false, }, + // time overrides + timeFrom: null, + timeShift: null, // metric queries targets: [{}], // series color overrides @@ -114,6 +118,25 @@ function (angular, app, $, _, kbn, moment, TimeSeries, PanelMeta) { $scope.updateTimeRange = function () { $scope.range = timeSrv.timeRange(); $scope.rangeUnparsed = timeSrv.timeRange(false); + + $scope.panelMeta.timeInfo = ""; + + // check panel time overrrides + if ($scope.panel.timeFrom) { + if (_.isString($scope.rangeUnparsed.from)) { + $scope.panelMeta.timeInfo = "Last " + $scope.panel.timeFrom; + $scope.rangeUnparsed.from = 'now-' + $scope.panel.timeFrom; + $scope.range.from = kbn.parseDate($scope.rangeUnparsed.from); + } + } + // if ($scope.panel.timeShift) { + // // from: now-1h + // // to: now + // // timeshift: 1d + // // from: now-1d-1h + // // to: now-1d + // } + if ($scope.panel.maxDataPoints) { $scope.resolution = $scope.panel.maxDataPoints; } diff --git a/src/css/less/graph.less b/src/css/less/graph.less index 5ad38283689..46263a43988 100644 --- a/src/css/less/graph.less +++ b/src/css/less/graph.less @@ -141,7 +141,7 @@ vertical-align: top; position: relative; left: 4px; - top: -20px; + top: -25px; } .graph-legend { @@ -260,7 +260,6 @@ transform-origin: right top; } - .axisLabel { color: @textColor; font-size: @fontSizeSmall; @@ -269,3 +268,13 @@ font-size: 12px; } +.graph-time-info { + font-weight: bold; + float: right; + margin-right: 15px; + color: @blue; + font-size: 85%; + position: relative; + top: -20px; +} + diff --git a/src/css/less/panel.less b/src/css/less/panel.less index 7a9a8aba4ff..451431b9d76 100644 --- a/src/css/less/panel.less +++ b/src/css/less/panel.less @@ -49,8 +49,8 @@ .panel-loading { position:absolute; - top: 0px; - right: 4px; + top: -3px; + right: 0px; z-index: 800; } From ea5da627af111cc74c3c21a27233bdbe35cdf2fb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torkel=20=C3=96degaard?= Date: Mon, 26 Jan 2015 11:49:18 +0100 Subject: [PATCH 10/10] Panel: Different time periods, panels can override dashboard relative time and/or add a time shift, #171, only works for graph panel for now, need feedback for how to do it for singlestat panel --- CHANGELOG.md | 1 + src/app/panels/graph/module.js | 17 +++++++++-------- src/test/specs/kbn-format-specs.js | 11 +++++++++++ 3 files changed, 21 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d56edad01a1..5d5721604c4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,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 +- [Issue #171](https://github.com/grafana/grafana/issues/171). Panel: Different time periods, panels can override dashboard relative time and/or add a time shift **Enhancements** - [Issue #1297](https://github.com/grafana/grafana/issues/1297). Graphite: Added cumulative and minimumBelow graphite functions diff --git a/src/app/panels/graph/module.js b/src/app/panels/graph/module.js index eac410360ad..56a15a7b72e 100644 --- a/src/app/panels/graph/module.js +++ b/src/app/panels/graph/module.js @@ -124,18 +124,19 @@ function (angular, app, $, _, kbn, moment, TimeSeries, PanelMeta) { // check panel time overrrides if ($scope.panel.timeFrom) { if (_.isString($scope.rangeUnparsed.from)) { - $scope.panelMeta.timeInfo = "Last " + $scope.panel.timeFrom; + $scope.panelMeta.timeInfo = "last " + $scope.panel.timeFrom; $scope.rangeUnparsed.from = 'now-' + $scope.panel.timeFrom; $scope.range.from = kbn.parseDate($scope.rangeUnparsed.from); } } - // if ($scope.panel.timeShift) { - // // from: now-1h - // // to: now - // // timeshift: 1d - // // from: now-1d-1h - // // to: now-1d - // } + + if ($scope.panel.timeShift) { + var timeShift = '-' + $scope.panel.timeShift; + $scope.panelMeta.timeInfo += ' timeshift ' + timeShift; + $scope.range.from = kbn.parseDateMath(timeShift, $scope.range.from); + $scope.range.to = kbn.parseDateMath(timeShift, $scope.range.to); + $scope.rangeUnparsed = $scope.range; + } if ($scope.panel.maxDataPoints) { $scope.resolution = $scope.panel.maxDataPoints; diff --git a/src/test/specs/kbn-format-specs.js b/src/test/specs/kbn-format-specs.js index 785d9376411..7c75e7eca93 100644 --- a/src/test/specs/kbn-format-specs.js +++ b/src/test/specs/kbn-format-specs.js @@ -69,4 +69,15 @@ define([ }); + describe('relative time to date parsing', function() { + it('should handle negative time', function() { + var date = kbn.parseDateMath('-2d', new Date(2014,1,5)); + expect(date.getTime()).to.equal(new Date(2014, 1, 3).getTime()); + }); + it('should handle multiple math expressions', function() { + var date = kbn.parseDateMath('-2d-6h', new Date(2014, 1, 5)); + expect(date.toString()).to.equal(new Date(2014, 1, 2, 18).toString()); + }); + }); + });