From bb5eeee82e9d2e940bde7f1d991df573624b12aa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torkel=20=C3=96degaard?= Date: Tue, 17 Mar 2015 17:33:31 -0400 Subject: [PATCH] fixed small issue with share modal --- src/app/directives/tip.js | 5 +++-- .../dashboard/partials/shareModal.html | 6 +++--- src/app/features/dashboard/sharePanelCtrl.js | 18 ++++++++---------- src/test/specs/sharePanelCtrl-specs.js | 6 +++--- 4 files changed, 17 insertions(+), 18 deletions(-) diff --git a/src/app/directives/tip.js b/src/app/directives/tip.js index f86668461a4..edf57d47828 100644 --- a/src/app/directives/tip.js +++ b/src/app/directives/tip.js @@ -57,14 +57,15 @@ function (angular, kbn) { angular .module('grafana.directives') - .directive('editorCheckbox', function($compile) { + .directive('editorCheckbox', function($compile, $interpolate) { return { restrict: 'E', link: function(scope, elem, attrs) { + var text = $interpolate(attrs.text)(scope); var ngchange = attrs.change ? (' ng-change="' + attrs.change + '"') : ''; var tip = attrs.tip ? (' ' + attrs.tip + '') : ''; var label = ''; + text + tip + ''; var template = '
- +
- +
- +
diff --git a/src/app/features/dashboard/sharePanelCtrl.js b/src/app/features/dashboard/sharePanelCtrl.js index 42a0e26fbee..eca10678806 100644 --- a/src/app/features/dashboard/sharePanelCtrl.js +++ b/src/app/features/dashboard/sharePanelCtrl.js @@ -13,15 +13,13 @@ function (angular, _, require, config) { $scope.init = function() { $scope.editor = { index: 0 }; - $scope.forCurrent = true; + $scope.options = { + forCurrent: true, + toPanel: $scope.panel ? true : false, + includeTemplateVars: true + }; - if ($scope.panel) { - $scope.toPanel = true; - } - - $scope.includeTemplateVars = true; $scope.buildUrl(); - }; $scope.buildUrl = function() { @@ -38,7 +36,7 @@ function (angular, _, require, config) { params.from = range.from; params.to = range.to; - if ($scope.includeTemplateVars) { + if ($scope.options.includeTemplateVars) { _.each(templateSrv.variables, function(variable) { params['var-' + variable.name] = variable.current.text; }); @@ -49,12 +47,12 @@ function (angular, _, require, config) { }); } - if (!$scope.forCurrent) { + if (!$scope.options.forCurrent) { delete params.from; delete params.to; } - if ($scope.toPanel) { + if ($scope.options.toPanel) { params.panelId = $scope.panel.id; params.fullscreen = true; } else { diff --git a/src/test/specs/sharePanelCtrl-specs.js b/src/test/specs/sharePanelCtrl-specs.js index acfc849db25..bdbc3cfe5c3 100644 --- a/src/test/specs/sharePanelCtrl-specs.js +++ b/src/test/specs/sharePanelCtrl-specs.js @@ -42,7 +42,7 @@ define([ it('should remove panel id when toPanel is false', function() { ctx.$location.path('/test'); ctx.scope.panel = { id: 22 }; - ctx.scope.toPanel = false; + ctx.scope.options = { toPanel: false, forCurrent: true }; setTime({ from: 'now-1h', to: 'now' }); ctx.scope.buildUrl(); @@ -52,8 +52,8 @@ define([ it('should include template variables in url', function() { ctx.$location.path('/test'); ctx.scope.panel = { id: 22 }; - ctx.scope.includeTemplateVars = true; - ctx.scope.toPanel = false; + ctx.scope.options = { includeTemplateVars: true, toPanel: false, forCurrent: true }; + ctx.templateSrv.variables = [{ name: 'app', current: {text: 'mupp' }}, {name: 'server', current: {text: 'srv-01'}}]; setTime({ from: 'now-1h', to: 'now' });