From 9fc6c4888fc5644ea16998938d7af015adc08a51 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torkel=20=C3=96degaard?= Date: Tue, 26 Aug 2014 09:32:30 +0200 Subject: [PATCH] converting more modals to edit panels --- src/app/controllers/annotationsEditorCtrl.js | 37 +++--- src/app/directives/bootstrap-tagsinput.js | 4 +- src/app/directives/dashEditLink.js | 5 +- src/app/partials/annotations_editor.html | 123 ++++++++++--------- src/app/partials/dasheditor.html | 33 ++--- src/app/partials/paneleditor.html | 45 ++++--- src/app/partials/roweditor.html | 24 ++-- src/app/partials/submenu.html | 4 +- src/css/less/bootswatch.dark.less | 6 +- src/css/less/grafana.less | 6 +- 10 files changed, 152 insertions(+), 135 deletions(-) diff --git a/src/app/controllers/annotationsEditorCtrl.js b/src/app/controllers/annotationsEditorCtrl.js index 99acea2c18c..6baf6279b02 100644 --- a/src/app/controllers/annotationsEditorCtrl.js +++ b/src/app/controllers/annotationsEditorCtrl.js @@ -1,14 +1,15 @@ define([ 'angular', 'app', - 'lodash' + 'lodash', + 'jquery' ], -function (angular, app, _) { +function (angular, app, _, $) { 'use strict'; var module = angular.module('grafana.controllers'); - module.controller('AnnotationsEditorCtrl', function($scope, datasourceSrv) { + module.controller('AnnotationsEditorCtrl', function($scope, datasourceSrv, $timeout) { var annotationDefaults = { name: '', datasource: null, @@ -22,12 +23,20 @@ function (angular, app, _) { $scope.init = function() { $scope.currentAnnotation = angular.copy(annotationDefaults); $scope.currentIsNew = true; + $scope.editor = { index: 0 }; $scope.datasources = datasourceSrv.getAnnotationSources(); $scope.annotations = $scope.dashboard.annotations.list; if ($scope.datasources.length > 0) { $scope.currentDatasource = $scope.datasources[0]; } + + $scope.$watch('editor.index', function(newVal) { + console.log("value", newVal); + if (newVal !== 2) { + $scope.reset(); + } + }); }; $scope.setDatasource = function() { @@ -42,9 +51,12 @@ function (angular, app, _) { if (!$scope.currentDatasource) { $scope.currentDatasource = $scope.datasources[0]; } + + $scope.editor.index = 2; + $(".tooltip.in").remove(); }; - $scope.update = function() { + $scope.reset = function() { $scope.currentAnnotation = angular.copy(annotationDefaults); $scope.currentIsNew = true; }; @@ -62,21 +74,4 @@ function (angular, app, _) { }); - module.controller('EditViewCtrl', function($scope) { - $scope.editPanelSrc = null; - - $scope.onAppEvent('show-edit-panel', function(evt, payload) { - if (payload.src === $scope.editPanelSrc) { - $scope.dismiss(); - return; - } - $scope.editPanelSrc = payload.src; - }); - - $scope.dismiss = function() { - $scope.editPanelSrc = null; - }; - - }); - }); diff --git a/src/app/directives/bootstrap-tagsinput.js b/src/app/directives/bootstrap-tagsinput.js index 613cc872d78..a8b7eb6a7ad 100644 --- a/src/app/directives/bootstrap-tagsinput.js +++ b/src/app/directives/bootstrap-tagsinput.js @@ -102,7 +102,7 @@ function (angular, $) { var li = '' + '' + (item.text || '') + ''; if (item.submenu && item.submenu.length) { @@ -131,4 +131,4 @@ function (angular, $) { } }; }); -}); \ No newline at end of file +}); diff --git a/src/app/directives/dashEditLink.js b/src/app/directives/dashEditLink.js index c2e781ba3ae..6baf3f05de7 100644 --- a/src/app/directives/dashEditLink.js +++ b/src/app/directives/dashEditLink.js @@ -32,13 +32,16 @@ function (angular, $) { var editorScope; var lastEditor; - scope.onAppEvent('show-dash-editor', function(evt, payload) { if (lastEditor === payload.src) { editorScope.dismiss(); return; } + if (lastEditor) { + editorScope.dismiss(); + } + lastEditor = payload.src; editorScope = payload.scope.$new(); editorScope.dismiss = function() { diff --git a/src/app/partials/annotations_editor.html b/src/app/partials/annotations_editor.html index 38508216f5f..e921354bc72 100644 --- a/src/app/partials/annotations_editor.html +++ b/src/app/partials/annotations_editor.html @@ -1,67 +1,72 @@
- + +
diff --git a/src/app/partials/dasheditor.html b/src/app/partials/dasheditor.html index 3169859da01..3fd45081e8a 100644 --- a/src/app/partials/dasheditor.html +++ b/src/app/partials/dasheditor.html @@ -49,30 +49,31 @@
-

Rows

+
Rows
- - - - - - - +
Title
{{row.title}}{{row.title}}
-

Add Row

- - - - -
- +
+
+
Add Row
+
+ + +
+
+ + +
+
+ +
@@ -115,5 +116,5 @@ - + diff --git a/src/app/partials/paneleditor.html b/src/app/partials/paneleditor.html index 62692c5f88e..ebc8a40ac63 100644 --- a/src/app/partials/paneleditor.html +++ b/src/app/partials/paneleditor.html @@ -1,23 +1,30 @@ -