Browse Source

fixed small issue with share modal

Torkel Ödegaard 10 years ago
parent
commit
bb5eeee82e

+ 3 - 2
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 ? (' <tip>' + attrs.tip + '</tip>') : '';
           var label = '<label for="' + scope.$id + attrs.model + '" class="checkbox-label">' +
-                           attrs.text + tip + '</label>';
+                           text + tip + '</label>';
 
           var template = '<input class="cr1" id="' + scope.$id + attrs.model + '" type="checkbox" ' +
                           '       ng-model="' + attrs.model + '"' + ngchange +

+ 3 - 3
src/app/features/dashboard/partials/shareModal.html

@@ -20,17 +20,17 @@
 		<br>
 		<div class="gf-form">
 			<div class="gf-form-row">
-					<editor-checkbox text="Current time range" model="forCurrent" change="buildUrl()"></editor-checkbox>
+					<editor-checkbox text="Current time range" model="options.forCurrent" change="buildUrl()"></editor-checkbox>
 				</div>
 			</div>
 			<div class="gf-form" ng-if="panel">
 				<div class="gf-form-row">
-					<editor-checkbox text="This panel only" model="toPanel" change="buildUrl()"></editor-checkbox>
+					<editor-checkbox text="This panel only" model="options.toPanel" change="buildUrl()"></editor-checkbox>
 				</div>
 			</div>
 			<div class="gf-form">
 				<div class="gf-form-row">
-					<editor-checkbox text="Include template variables" model="includeTemplateVars" change="buildUrl()"></editor-checkbox>
+					<editor-checkbox text="Include template variables" model="options.includeTemplateVars" change="buildUrl()"></editor-checkbox>
 				</div>
 			</div>
 

+ 8 - 10
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 {

+ 3 - 3
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' });