diff --git a/src/app/controllers/annotationsEditorCtrl.js b/src/app/controllers/annotationsEditorCtrl.js index 5234e429206..9b6da497dce 100644 --- a/src/app/controllers/annotationsEditorCtrl.js +++ b/src/app/controllers/annotationsEditorCtrl.js @@ -20,15 +20,10 @@ function (angular, _, $) { }; $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.reset(); $scope.$watch('editor.index', function(newVal) { if (newVal !== 2) { @@ -37,18 +32,17 @@ function (angular, _, $) { }); }; - $scope.setDatasource = function() { - $scope.currentAnnotation.datasource = $scope.currentDatasource.name; + $scope.datasourceChanged = function() { + $scope.currentDatasource = _.findWhere($scope.datasources, { name: $scope.currentAnnotation.datasource }); + if (!$scope.currentDatasource) { + $scope.currentDatasource = $scope.datasources[0]; + } }; $scope.edit = function(annotation) { $scope.currentAnnotation = annotation; $scope.currentIsNew = false; - $scope.currentDatasource = _.findWhere($scope.datasources, { name: annotation.datasource }); - - if (!$scope.currentDatasource) { - $scope.currentDatasource = $scope.datasources[0]; - } + $scope.datasourceChanged(); $scope.editor.index = 2; $(".tooltip.in").remove(); @@ -57,6 +51,13 @@ function (angular, _, $) { $scope.reset = function() { $scope.currentAnnotation = angular.copy(annotationDefaults); $scope.currentIsNew = true; + $scope.datasourceChanged(); + $scope.currentAnnotation.datasource = $scope.currentDatasource.name; + }; + + $scope.update = function() { + $scope.reset(); + $scope.editor.index = 0; }; $scope.add = function() { diff --git a/src/app/partials/annotations_editor.html b/src/app/partials/annotations_editor.html index f23a425e9c6..cb9db2244d6 100644 --- a/src/app/partials/annotations_editor.html +++ b/src/app/partials/annotations_editor.html @@ -19,7 +19,7 @@ @@ -48,7 +48,7 @@
- +
@@ -71,11 +71,12 @@
-
diff --git a/src/app/partials/roweditor.html b/src/app/partials/roweditor.html index af8c5405999..032163ea64b 100644 --- a/src/app/partials/roweditor.html +++ b/src/app/partials/roweditor.html @@ -29,29 +29,32 @@
-

Panels

-
- +   {{annotation.name}} @@ -31,7 +31,7 @@ - +
+
- - - + + + - + - - - - - -
Title TypeSpan ({{dashboard.rowSpan(row)}}/12)DeleteMoveSpan
{{panel.title}}{{panel.title}} {{panel.type}}
- - + + + + + + + + + + + +