diff --git a/public/app/features/templating/editorCtrl.js b/public/app/features/templating/editorCtrl.js index 65b06f3ceb3..524cc9f86fd 100644 --- a/public/app/features/templating/editorCtrl.js +++ b/public/app/features/templating/editorCtrl.js @@ -22,7 +22,8 @@ function (angular, _) { }; $scope.init = function() { - $scope.editor = { index: 0 }; + $scope.mode = 'list'; + $scope.datasources = _.filter(datasourceSrv.getMetricSources(), function(ds) { return !ds.meta.builtIn; }); @@ -30,8 +31,8 @@ function (angular, _) { $scope.variables = templateSrv.variables; $scope.reset(); - $scope.$watch('editor.index', function(index) { - if ($scope.currentIsNew === false && index === 1) { + $scope.$watch('mode', function(val) { + if (val === 'new') { $scope.reset(); } }); @@ -75,7 +76,7 @@ function (angular, _) { $scope.edit = function(variable) { $scope.current = variable; $scope.currentIsNew = false; - $scope.editor.index = 2; + $scope.mode = 'edit'; if ($scope.current.datasource === void 0) { $scope.current.datasource = null; @@ -88,7 +89,7 @@ function (angular, _) { if ($scope.isValid()) { $scope.runQuery().then(function() { $scope.reset(); - $scope.editor.index = 0; + $scope.mode = 'list'; }); } }; diff --git a/public/app/features/templating/partials/editor.html b/public/app/features/templating/partials/editor.html index a76c83580d5..ad8dca84f49 100644 --- a/public/app/features/templating/partials/editor.html +++ b/public/app/features/templating/partials/editor.html @@ -5,10 +5,27 @@ Templating +
+
- + +