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; }