diff --git a/src/app/controllers/dashboardCtrl.js b/src/app/controllers/dashboardCtrl.js index d881f114765..b37672a1ffc 100644 --- a/src/app/controllers/dashboardCtrl.js +++ b/src/app/controllers/dashboardCtrl.js @@ -11,9 +11,16 @@ function (angular, $, config, _) { var module = angular.module('grafana.controllers'); module.controller('DashboardCtrl', function( - $scope, $rootScope, dashboardKeybindings, - filterSrv, dashboardSrv, dashboardViewStateSrv, - panelMoveSrv, timer, $timeout) { + $scope, + $rootScope, + dashboardKeybindings, + filterSrv, + templateSrv, + dashboardSrv, + dashboardViewStateSrv, + panelMoveSrv, + timer, + $timeout) { $scope.editor = { index: 0 }; $scope.panelNames = config.panels; @@ -47,6 +54,7 @@ function (angular, $, config, _) { $scope.filter = filterSrv; $scope.filter.init($scope.dashboard); + templateSrv.init($scope.dashboard); $scope.submenuEnabled = $scope.dashboard.templating.enable || $scope.dashboard.annotations.enable; diff --git a/src/app/controllers/submenuCtrl.js b/src/app/controllers/submenuCtrl.js index 13e10cbe852..edaab142eb3 100644 --- a/src/app/controllers/submenuCtrl.js +++ b/src/app/controllers/submenuCtrl.js @@ -50,7 +50,6 @@ function (angular, app, _) { $scope.applyFilter = function(templateParam) { return datasourceSrv.default.metricFindQuery($scope.filter, templateParam.query) .then(function (results) { - templateParam.editing = undefined; templateParam.options = _.map(results, function(node) { return { text: node.text, value: node.text }; }); diff --git a/src/app/controllers/templateEditorCtrl.js b/src/app/controllers/templateEditorCtrl.js index b81d553eb09..85c7d81f669 100644 --- a/src/app/controllers/templateEditorCtrl.js +++ b/src/app/controllers/templateEditorCtrl.js @@ -10,7 +10,7 @@ function (angular, _) { module.controller('TemplateEditorCtrl', function($scope, datasourceSrv) { var replacementDefaults = { - type: 'metric query', + type: 'query', datasource: null, refresh_on_load: false, name: '', @@ -24,8 +24,17 @@ function (angular, _) { $scope.templateParameters = $scope.filter.templateParameters; $scope.reset(); - $scope.$watch('editor.index', function(newVal) { - if (newVal !== 2) { $scope.reset(); } + _.each($scope.templateParameters, function(param) { + if (param.datasource === void 0) { + param.datasource = null; + param.type = 'query'; + } + }); + + $scope.$watch('editor.index', function(index) { + if ($scope.currentIsNew === false && index === 1) { + $scope.reset(); + } }); }; @@ -33,6 +42,11 @@ function (angular, _) { $scope.current.datasource = $scope.currentDatasource.name; $scope.templateParameters.push($scope.current); $scope.reset(); + $scope.editor.index = 0; + }; + + $scope.runQuery = function() { + $scope.filter.refreshTemplateParameter($scope.current); }; $scope.edit = function(param) { @@ -47,10 +61,14 @@ function (angular, _) { $scope.editor.index = 2; }; + $scope.update = function() { + $scope.reset(); + $scope.editor.index = 0; + }; + $scope.reset = function() { $scope.currentIsNew = true; $scope.current = angular.copy(replacementDefaults); - $scope.editor.index = 0; }; $scope.removeTemplateParam = function(templateParam) { diff --git a/src/app/partials/influxdb/editor.html b/src/app/partials/influxdb/editor.html index 8bc3baf8ff7..ecbb9af28a0 100644 --- a/src/app/partials/influxdb/editor.html +++ b/src/app/partials/influxdb/editor.html @@ -14,7 +14,7 @@ - + @@ -171,7 +171,9 @@ + +
diff --git a/src/app/partials/inspector.html b/src/app/partials/inspector.html index 7f2ec526f70..79ca806d9f0 100644 --- a/src/app/partials/inspector.html +++ b/src/app/partials/inspector.html @@ -1,69 +1,80 @@ + diff --git a/src/app/partials/opentsdb/editor.html b/src/app/partials/opentsdb/editor.html index bce27f230f2..32d34dab7a8 100644 --- a/src/app/partials/opentsdb/editor.html +++ b/src/app/partials/opentsdb/editor.html @@ -12,7 +12,7 @@ - + diff --git a/src/app/partials/templating_editor.html b/src/app/partials/templating_editor.html index ef91bcf285d..57a1f6ad7a5 100644 --- a/src/app/partials/templating_editor.html +++ b/src/app/partials/templating_editor.html @@ -22,8 +22,8 @@
-
- {{templateParam.name}} + + [[{{templateParam.name}}]] {{templateParam.query}} @@ -54,7 +54,7 @@
- +
@@ -63,9 +63,29 @@
-
- - +
+ + + +
+
+ +
+
+ + + +
+
+ +
+
+ +
    +
  • + {{option.text}} +
  • +
@@ -74,8 +94,8 @@
diff --git a/src/app/services/all.js b/src/app/services/all.js index 62deab62e5e..6eb8fb534c0 100644 --- a/src/app/services/all.js +++ b/src/app/services/all.js @@ -2,6 +2,7 @@ define([ './alertSrv', './datasourceSrv', './filterSrv', + './templateSrv', './panelSrv', './timer', './panelMove', diff --git a/src/app/services/datasourceSrv.js b/src/app/services/datasourceSrv.js index a0a123d4509..5d26ebdc28c 100644 --- a/src/app/services/datasourceSrv.js +++ b/src/app/services/datasourceSrv.js @@ -12,7 +12,7 @@ function (angular, _, config) { var module = angular.module('grafana.services'); - module.service('datasourceSrv', function($q, filterSrv, $http, $injector) { + module.service('datasourceSrv', function($q, $http, $injector) { var datasources = {}; var metricSources = []; var annotationSources = []; diff --git a/src/app/services/filterSrv.js b/src/app/services/filterSrv.js index 6b7787c7940..4dede583803 100644 --- a/src/app/services/filterSrv.js +++ b/src/app/services/filterSrv.js @@ -78,11 +78,6 @@ define([ } }, - removeTemplateParameter: function(templateParameter) { - this.templateParameters = _.without(this.templateParameters, templateParameter); - this.dashboard.templating.list = this.templateParameters; - }, - init: function(dashboard) { this.dashboard = dashboard; this.templateSettings = { interpolate : /\[\[([\s\S]+?)\]\]/g }; diff --git a/src/app/services/templateSrv.js b/src/app/services/templateSrv.js new file mode 100644 index 00000000000..7165f4442ba --- /dev/null +++ b/src/app/services/templateSrv.js @@ -0,0 +1,21 @@ +define([ + 'angular', + 'lodash', + 'kbn', + 'store' +], +function (angular) { + 'use strict'; + + var module = angular.module('grafana.services'); + + module.service('templateSrv', function() { + + this.init = function(dashboard) { + this.dashboard = dashboard; + + }; + + }); + +}); diff --git a/src/css/less/overrides.less b/src/css/less/overrides.less index 14c1fabf9b8..59e30d264c7 100644 --- a/src/css/less/overrides.less +++ b/src/css/less/overrides.less @@ -467,7 +467,6 @@ div.flot-text { /************************* * Right Positions *************************/ - .popover { &.rightTop .arrow { top: 10%; @@ -639,3 +638,4 @@ code, pre { background-color: @grafanaPanelBackground; color: @textColor; } + diff --git a/src/css/less/tables_lists.less b/src/css/less/tables_lists.less index 29896b02e47..4f95c1a1082 100644 --- a/src/css/less/tables_lists.less +++ b/src/css/less/tables_lists.less @@ -9,7 +9,12 @@ padding: 5px 10px; white-space: nowrap; border-bottom: 1px solid @grafanaListBorderBottom; - border-top: 1px solid @grafanaListBorderTop; + } + + tr:first-child { + td { + border-top: 1px solid @grafanaListBorderBottom; + } } td:first-child { diff --git a/src/css/less/variables.dark.less b/src/css/less/variables.dark.less index 7214adba17f..048ffd1a689 100644 --- a/src/css/less/variables.dark.less +++ b/src/css/less/variables.dark.less @@ -6,7 +6,7 @@ // ------------------------- @black: #000; @gray: #bbb; -@grayDark: #303030; +@grayDark: #242424; @grayDarker: #1f1f1f; @grayLight: #ADAFAE; @@ -29,10 +29,6 @@ // ------------------------- @grafanaPanelBackground: @grayDarker; -// Submenu -@submenuBackground: #292929; -@submenuBorder: #202020; - // Tabs @fullEditBorder: #555; @@ -43,8 +39,8 @@ @grafanaTargetColorHide: darken(#c8c8c8, 25%); @grafanaTargetSegmentBorder: #050505; -@grafanaTargetFuncBackground: #444; -@grafanaTargetFuncHightlight: #555; +@grafanaTargetFuncBackground: #333; +@grafanaTargetFuncHightlight: #444; // Scaffolding // ------------------------- @@ -133,7 +129,7 @@ // Forms // ------------------------- -@inputBackground: lighten(@grayDark,0%); +@inputBackground: lighten(@grayDark,5%); @inputBorder: lighten(@grayDark,5%); @inputBorderRadius: @baseBorderRadius; @inputDisabledBackground: #555;