From fe34c8f2e07478fca3d0480ca0b4fceccbfb4afd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torkel=20=C3=96degaard?= Date: Fri, 20 Feb 2015 12:20:10 +0100 Subject: [PATCH] Worked on submenu row (templating, annotations), removed templating and annotation feature toggles, the submenu row will be visible as soon as there are any template vars or annotations, #1503 --- src/app/features/annotations/editorCtrl.js | 2 ++ src/app/features/dashboard/dashboardCtrl.js | 10 +++++----- src/app/features/dashboard/dashboardSrv.js | 12 ++++++------ src/app/features/dashboard/submenuCtrl.js | 1 + src/app/features/templating/editorCtrl.js | 2 ++ src/app/partials/dasheditor.html | 20 +++----------------- src/app/partials/submenu.html | 13 ++++++++++--- src/css/less/grafana.less | 3 --- src/css/less/submenu.less | 4 ++-- src/test/specs/dashboardSrv-specs.js | 2 -- 10 files changed, 31 insertions(+), 38 deletions(-) diff --git a/src/app/features/annotations/editorCtrl.js b/src/app/features/annotations/editorCtrl.js index 9b6da497dce..b61dd6b05e4 100644 --- a/src/app/features/annotations/editorCtrl.js +++ b/src/app/features/annotations/editorCtrl.js @@ -64,11 +64,13 @@ function (angular, _, $) { $scope.annotations.push($scope.currentAnnotation); $scope.reset(); $scope.editor.index = 0; + $scope.updateSubmenuVisibility(); }; $scope.removeAnnotation = function(annotation) { var index = _.indexOf($scope.annotations, annotation); $scope.annotations.splice(index, 1); + $scope.updateSubmenuVisibility(); }; }); diff --git a/src/app/features/dashboard/dashboardCtrl.js b/src/app/features/dashboard/dashboardCtrl.js index 712998c6a45..facd5fada43 100644 --- a/src/app/features/dashboard/dashboardCtrl.js +++ b/src/app/features/dashboard/dashboardCtrl.js @@ -51,14 +51,18 @@ function (angular, $, config) { timeSrv.init($scope.dashboard); templateValuesSrv.init($scope.dashboard, $scope.dashboardViewState); - $scope.checkFeatureToggles(); dashboardKeybindings.shortcuts($scope); + $scope.updateSubmenuVisibility(); $scope.setWindowTitleAndTheme(); $scope.appEvent("dashboard-loaded", $scope.dashboard); }; + $scope.updateSubmenuVisibility = function() { + $scope.submenuEnabled = $scope.dashboard.hasTemplateVarsOrAnnotations(); + }; + $scope.setWindowTitleAndTheme = function() { window.document.title = config.window_title_prefix + $scope.dashboard.title; $scope.contextSrv.lightTheme = $scope.dashboard.style === 'light'; @@ -101,10 +105,6 @@ function (angular, $, config) { $scope.appEvent('show-dash-editor', { src: 'app/partials/edit_json.html', scope: editScope }); }; - $scope.checkFeatureToggles = function() { - $scope.submenuEnabled = $scope.dashboard.templating.enable || $scope.dashboard.annotations.enable || false; - }; - $scope.onDrop = function(panelId, row, dropTarget) { var info = $scope.dashboard.getPanelInfoById(panelId); if (dropTarget) { diff --git a/src/app/features/dashboard/dashboardSrv.js b/src/app/features/dashboard/dashboardSrv.js index 94448265cca..8a41ddee5d8 100644 --- a/src/app/features/dashboard/dashboardSrv.js +++ b/src/app/features/dashboard/dashboardSrv.js @@ -91,6 +91,10 @@ function (angular, $, kbn, _, moment) { row.panels.push(panel); }; + p.hasTemplateVarsOrAnnotations = function() { + return this.templating.list.length > 0 || this.annotations.list.length > 0; + }; + p.getPanelInfoById = function(panelId) { var result = {}; _.each(this.rows, function(row) { @@ -215,15 +219,11 @@ function (angular, $, kbn, _, moment) { if (oldVersion < 6) { // move pulldowns to new schema - var filtering = _.findWhere(old.pulldowns, { type: 'filtering' }); var annotations = _.findWhere(old.pulldowns, { type: 'annotations' }); - if (filtering) { - this.templating.enable = filtering.enable; - } + if (annotations) { this.annotations = { - list: annotations.annotations, - enable: annotations.enable + list: annotations.annotations || [], }; } diff --git a/src/app/features/dashboard/submenuCtrl.js b/src/app/features/dashboard/submenuCtrl.js index bf71377dd14..456cc1b76c1 100644 --- a/src/app/features/dashboard/submenuCtrl.js +++ b/src/app/features/dashboard/submenuCtrl.js @@ -18,6 +18,7 @@ function (angular, _) { $scope.panel = $scope.pulldown; $scope.row = $scope.pulldown; $scope.variables = $scope.dashboard.templating.list; + $scope.annotations = $scope.dashboard.templating.list; }; $scope.disableAnnotation = function (annotation) { diff --git a/src/app/features/templating/editorCtrl.js b/src/app/features/templating/editorCtrl.js index 51b5d7c9e38..f17c383155d 100644 --- a/src/app/features/templating/editorCtrl.js +++ b/src/app/features/templating/editorCtrl.js @@ -36,6 +36,7 @@ function (angular, _) { if ($scope.isValid()) { $scope.variables.push($scope.current); $scope.update(); + $scope.updateSubmenuVisibility(); } }; @@ -104,6 +105,7 @@ function (angular, _) { $scope.removeVariable = function(variable) { var index = _.indexOf($scope.variables, variable); $scope.variables.splice(index, 1); + $scope.updateSubmenuVisibility(); }; }); diff --git a/src/app/partials/dasheditor.html b/src/app/partials/dasheditor.html index 4d7d372d22b..843f73b24db 100644 --- a/src/app/partials/dasheditor.html +++ b/src/app/partials/dasheditor.html @@ -5,7 +5,7 @@
-
+
@@ -33,6 +33,7 @@
+
@@ -70,25 +71,10 @@
-
-
- - -
- - - -
- -
-
-
- -
-
+
diff --git a/src/app/partials/submenu.html b/src/app/partials/submenu.html index b822d576523..1012a42919c 100644 --- a/src/app/partials/submenu.html +++ b/src/app/partials/submenu.html @@ -1,7 +1,8 @@ diff --git a/src/css/less/grafana.less b/src/css/less/grafana.less index 55e8def8f33..f981201fa20 100644 --- a/src/css/less/grafana.less +++ b/src/css/less/grafana.less @@ -26,9 +26,6 @@ .row-tab { display: none; } - .submenu-controls { - display: none; - } .add-row-panel-hint { display: none; } diff --git a/src/css/less/submenu.less b/src/css/less/submenu.less index 3e919890442..f560acf175c 100644 --- a/src/css/less/submenu.less +++ b/src/css/less/submenu.less @@ -1,11 +1,11 @@ -.submenu-controls-visible:not(.hide-controls) { +.submenu-controls-visible { .panel-fullscreen { top: 88px; } } .submenu-controls { - margin: 5px 5px 0 10px; + margin: 5px 10px 0 10px; } .annotation-disabled, .annotation-disabled a { diff --git a/src/test/specs/dashboardSrv-specs.js b/src/test/specs/dashboardSrv-specs.js index 739d66871bc..2254739ac54 100644 --- a/src/test/specs/dashboardSrv-specs.js +++ b/src/test/specs/dashboardSrv-specs.js @@ -157,8 +157,6 @@ define([ }); it('should move pulldowns to new schema', function() { - expect(model.templating.enable).to.be(true); - expect(model.annotations.enable).to.be(true); expect(model.annotations.list[0].name).to.be('old'); });