diff --git a/package.json b/package.json index eecf826776e..8de8f05cf8a 100644 --- a/package.json +++ b/package.json @@ -4,7 +4,7 @@ "company": "Coding Instinct AB" }, "name": "grafana", - "version": "1.7.0", + "version": "1.8.0", "repository": { "type": "git", "url": "http://github.com/torkelo/grafana.git" diff --git a/src/app/controllers/all.js b/src/app/controllers/all.js index 8d7035bbb65..cf63f0940e0 100644 --- a/src/app/controllers/all.js +++ b/src/app/controllers/all.js @@ -14,4 +14,5 @@ define([ './inspectCtrl', './opentsdbTargetCtrl', './annotationsEditorCtrl', + './templateEditorCtrl', ], function () {}); diff --git a/src/app/controllers/annotationsEditorCtrl.js b/src/app/controllers/annotationsEditorCtrl.js index 60f40eee7cd..371bbad5838 100644 --- a/src/app/controllers/annotationsEditorCtrl.js +++ b/src/app/controllers/annotationsEditorCtrl.js @@ -1,10 +1,9 @@ define([ 'angular', - 'app', 'lodash', 'jquery' ], -function (angular, app, _, $) { +function (angular, _, $) { 'use strict'; var module = angular.module('grafana.controllers'); @@ -63,7 +62,8 @@ function (angular, app, _, $) { $scope.add = function() { $scope.currentAnnotation.datasource = $scope.currentDatasource.name; $scope.annotations.push($scope.currentAnnotation); - $scope.currentAnnotation = angular.copy(annotationDefaults); + $scope.reset(); + $scope.editor.index = 0; }; $scope.removeAnnotation = function(annotation) { diff --git a/src/app/controllers/templateEditorCtrl.js b/src/app/controllers/templateEditorCtrl.js new file mode 100644 index 00000000000..8b9db552625 --- /dev/null +++ b/src/app/controllers/templateEditorCtrl.js @@ -0,0 +1,50 @@ +define([ + 'angular', + 'lodash', +], +function (angular, _) { + 'use strict'; + + var module = angular.module('grafana.controllers'); + + module.controller('TemplateEditorCtrl', function($scope, datasourceSrv) { + + var replacementDefaults = { + type: 'metric query', + datasource: null, + refresh_on_load: false, + name: '', + options: [], + }; + + $scope.init = function() { + $scope.editor = { index: 0 }; + $scope.datasources = datasourceSrv.getMetricSources(); + $scope.currentDatasource = _.findWhere($scope.datasources, { default: true }); + $scope.templateParameters = $scope.filter.templateParameters; + $scope.reset(); + }; + + $scope.add = function() { + $scope.current.datasource = $scope.currentDatasource.name; + $scope.templateParameters.push($scope.current); + $scope.reset(); + }; + + $scope.reset = function() { + $scope.currentIsNew = true; + $scope.current = angular.copy(replacementDefaults); + $scope.editor.index = 0; + }; + + $scope.removeTemplateParam = function(templateParam) { + var index = _.indexOf($scope.templateParameters, templateParam); + $scope.templateParameters.splice(index, 1); + }; + + $scope.setDatasource = function() { + }; + + }); + +}); diff --git a/src/app/panels/graph/styleEditor.html b/src/app/panels/graph/styleEditor.html index de7318d4500..a699ae4e1a4 100644 --- a/src/app/panels/graph/styleEditor.html +++ b/src/app/panels/graph/styleEditor.html @@ -67,8 +67,7 @@
| {{templateParam.name}} | +{{templateParam.query}} | ++ + Edit + + | ++ + Remove + + | +