From 1ea54049d07c4cc7959e20a6f9b6ffde24e670b4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torkel=20=C3=96degaard?= Date: Sat, 28 May 2016 16:59:29 +0200 Subject: [PATCH] feat(templating): added new template variable type constant --- public/app/features/templating/editorCtrl.js | 20 +++++++++++++++++++ .../features/templating/partials/editor.html | 10 +++++++++- .../features/templating/templateValuesSrv.js | 8 +++++++- 3 files changed, 36 insertions(+), 2 deletions(-) diff --git a/public/app/features/templating/editorCtrl.js b/public/app/features/templating/editorCtrl.js index 43bda1db05f..5efebc21e30 100644 --- a/public/app/features/templating/editorCtrl.js +++ b/public/app/features/templating/editorCtrl.js @@ -25,6 +25,7 @@ function (angular, _) { {value: "interval", text: "Interval"}, {value: "datasource", text: "Data source"}, {value: "custom", text: "Custom"}, + {value: "constant", text: "Constant"}, ]; $scope.refreshOptions = [ @@ -141,15 +142,34 @@ function (angular, _) { $scope.current = angular.copy(replacementDefaults); }; + $scope.showSelectionOptions = function() { + if ($scope.current) { + if ($scope.current.type === 'query') { + return true; + } + if ($scope.current.type === 'custom') { + return true; + } + } + return false; + }; + $scope.typeChanged = function () { if ($scope.current.type === 'interval') { $scope.current.query = '1m,10m,30m,1h,6h,12h,1d,7d,14d,30d'; + $scope.current.refresh = 0; } if ($scope.current.type === 'query') { $scope.current.query = ''; } + if ($scope.current.type === 'constant') { + $scope.current.query = ''; + $scope.current.refresh = 0; + $scope.current.hide = 2; + } + if ($scope.current.type === 'datasource') { $scope.current.query = $scope.datasourceTypes[0].value; $scope.current.regex = ''; diff --git a/public/app/features/templating/partials/editor.html b/public/app/features/templating/partials/editor.html index fc387ff44cf..19f9c25715b 100644 --- a/public/app/features/templating/partials/editor.html +++ b/public/app/features/templating/partials/editor.html @@ -152,6 +152,14 @@ +
+
Constant options
+
+ Value + +
+
+
Query Options
@@ -214,7 +222,7 @@
-
+
Selection Options