From 57b5b4c3761cbeba434ff16f7edf1983198bd0ad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torkel=20=C3=96degaard?= Date: Sun, 1 Mar 2015 11:48:09 +0100 Subject: [PATCH] Worked on relative time and timeshift overrides for singlestat, still an issue for how to visualize the time override --- src/app/features/panel/panelSrv.js | 18 ++++++++++++------ src/app/panels/singlestat/editor.html | 4 ++-- src/app/panels/singlestat/module.html | 2 +- src/app/panels/singlestat/module.js | 1 - 4 files changed, 15 insertions(+), 10 deletions(-) diff --git a/src/app/features/panel/panelSrv.js b/src/app/features/panel/panelSrv.js index f157de2b28c..45c9d745494 100644 --- a/src/app/features/panel/panelSrv.js +++ b/src/app/features/panel/panelSrv.js @@ -8,7 +8,7 @@ function (angular, _, config) { var module = angular.module('grafana.services'); - module.service('panelSrv', function($rootScope, $timeout, datasourceSrv) { + module.service('panelSrv', function($rootScope, $timeout, datasourceSrv, $q) { this.init = function($scope) { if (!$scope.panel.span) { $scope.panel.span = 12; } @@ -88,21 +88,27 @@ function (angular, _, config) { return $scope.dashboardViewState.fullscreen && !$scope.fullscreen; }; + $scope.getCurrentDatasource = function() { + if ($scope.datasource) { + return $q.when($scope.datasource); + } + + return datasourceSrv.get($scope.panel.datasource); + }; + $scope.get_data = function() { if ($scope.otherPanelInFullscreenMode()) { return; } delete $scope.panelMeta.error; $scope.panelMeta.loading = true; - if ($scope.datasource) { - return $scope.refreshData($scope.datasource); - } - - datasourceSrv.get($scope.panel.datasource).then(function(datasource) { + $scope.getCurrentDatasource().then(function(datasource) { $scope.datasource = datasource; + return $scope.refreshData($scope.datasource).then(function() { $scope.panelMeta.loading = false; }); + }, function(err) { console.log('Panel data error:', err); $scope.panelMeta.loading = false; diff --git a/src/app/panels/singlestat/editor.html b/src/app/panels/singlestat/editor.html index 41ca71a32b3..da3892a59f0 100644 --- a/src/app/panels/singlestat/editor.html +++ b/src/app/panels/singlestat/editor.html @@ -37,7 +37,7 @@ Prefix
  • - +
  • Value @@ -49,7 +49,7 @@ Postfix
  • - +
  • diff --git a/src/app/panels/singlestat/module.html b/src/app/panels/singlestat/module.html index 7b5d6a267bb..5aeb468db27 100644 --- a/src/app/panels/singlestat/module.html +++ b/src/app/panels/singlestat/module.html @@ -1,4 +1,4 @@
    -
    +
    diff --git a/src/app/panels/singlestat/module.js b/src/app/panels/singlestat/module.js index e37f5973017..1b802740017 100644 --- a/src/app/panels/singlestat/module.js +++ b/src/app/panels/singlestat/module.js @@ -88,7 +88,6 @@ function (angular, app, _, TimeSeries, kbn, PanelMeta) { }; $scope.dataHandler = function(results) { - $scope.panelMeta.loading = false; $scope.series = _.map(results.data, $scope.seriesHandler); $scope.render(); };