Просмотр исходного кода

Changed name of emitAppEvent to just appEvent

Torkel Ödegaard 11 лет назад
Родитель
Сommit
6f1a6d5a56

+ 2 - 2
src/app/controllers/dashboardCtrl.js

@@ -58,7 +58,7 @@ function (angular, $, config, _) {
 
 
       $scope.setWindowTitleAndTheme();
       $scope.setWindowTitleAndTheme();
 
 
-      $scope.emitAppEvent("dashboard-loaded", $scope.dashboard);
+      $scope.appEvent("dashboard-loaded", $scope.dashboard);
     };
     };
 
 
     $scope.setWindowTitleAndTheme = function() {
     $scope.setWindowTitleAndTheme = function() {
@@ -113,7 +113,7 @@ function (angular, $, config, _) {
       var editScope = $rootScope.$new();
       var editScope = $rootScope.$new();
       editScope.object = options.object;
       editScope.object = options.object;
       editScope.updateHandler = options.updateHandler;
       editScope.updateHandler = options.updateHandler;
-      $scope.emitAppEvent('show-dash-editor', { src: 'app/partials/edit_json.html', scope: editScope });
+      $scope.appEvent('show-dash-editor', { src: 'app/partials/edit_json.html', scope: editScope });
     };
     };
 
 
     $scope.checkFeatureToggles = function() {
     $scope.checkFeatureToggles = function() {

+ 6 - 6
src/app/controllers/dashboardNavCtrl.js

@@ -69,7 +69,7 @@ function (angular, _, moment, config, store) {
     };
     };
 
 
     $scope.openSearch = function() {
     $scope.openSearch = function() {
-      $scope.emitAppEvent('show-dash-editor', { src: 'app/partials/search.html' });
+      $scope.appEvent('show-dash-editor', { src: 'app/partials/search.html' });
     };
     };
 
 
     $scope.saveDashboard = function() {
     $scope.saveDashboard = function() {
@@ -88,7 +88,7 @@ function (angular, _, moment, config, store) {
           $rootScope.$emit('dashboard-saved', $scope.dashboard);
           $rootScope.$emit('dashboard-saved', $scope.dashboard);
 
 
         }, function(err) {
         }, function(err) {
-          $scope.emitAppEvent('alert-error', ['Save failed', err]);
+          $scope.appEvent('alert-error', ['Save failed', err]);
         });
         });
     };
     };
 
 
@@ -101,9 +101,9 @@ function (angular, _, moment, config, store) {
 
 
       var id = options.id;
       var id = options.id;
       $scope.db.deleteDashboard(id).then(function(id) {
       $scope.db.deleteDashboard(id).then(function(id) {
-        alertSrv.set('Dashboard Deleted', id + ' has been deleted', 'success', 5000);
-      }, function() {
-        alertSrv.set('Dashboard Not Deleted', 'An error occurred deleting the dashboard', 'error', 5000);
+        $scope.appEvent('alert-success', ['Dashboard Deleted', id + ' has been deleted']);
+      }, function(err) {
+        $scope.appEvent('alert-error', ['Deleted failed', err]);
       });
       });
     };
     };
 
 
@@ -138,7 +138,7 @@ function (angular, _, moment, config, store) {
     };
     };
 
 
     $scope.editJson = function() {
     $scope.editJson = function() {
-      $scope.emitAppEvent('show-json-editor', { object: $scope.dashboard });
+      $scope.appEvent('show-json-editor', { object: $scope.dashboard });
     };
     };
 
 
     $scope.openSaveDropdown = function() {
     $scope.openSaveDropdown = function() {

+ 1 - 1
src/app/controllers/grafanaCtrl.js

@@ -41,7 +41,7 @@ function (angular, config, _, $, store) {
       this.$on('$destroy', unbind);
       this.$on('$destroy', unbind);
     };
     };
 
 
-    $rootScope.emitAppEvent = function(name, payload) {
+    $rootScope.appEvent = function(name, payload) {
       $rootScope.$emit(name, payload);
       $rootScope.$emit(name, payload);
     };
     };
 
 

+ 2 - 2
src/app/controllers/search.js

@@ -29,7 +29,7 @@ function (angular, _, config, $) {
 
 
     $scope.keyDown = function (evt) {
     $scope.keyDown = function (evt) {
       if (evt.keyCode === 27) {
       if (evt.keyCode === 27) {
-        $scope.emitAppEvent('hide-dash-editor');
+        $scope.appEvent('hide-dash-editor');
       }
       }
       if (evt.keyCode === 40) {
       if (evt.keyCode === 40) {
         $scope.moveSelection(1);
         $scope.moveSelection(1);
@@ -121,7 +121,7 @@ function (angular, _, config, $) {
 
 
     $scope.deleteDashboard = function(dash, evt) {
     $scope.deleteDashboard = function(dash, evt) {
       evt.stopPropagation();
       evt.stopPropagation();
-      $scope.emitAppEvent('delete-dashboard', { id: dash.id, title: dash.title });
+      $scope.appEvent('delete-dashboard', { id: dash.id, title: dash.title });
       $scope.results.dashboards = _.without($scope.results.dashboards, dash);
       $scope.results.dashboards = _.without($scope.results.dashboards, dash);
     };
     };
 
 

+ 1 - 1
src/app/directives/dashEditLink.js

@@ -16,7 +16,7 @@ function (angular, $) {
           elem.bind('click',function() {
           elem.bind('click',function() {
             $timeout(function() {
             $timeout(function() {
               var editorScope = attrs.editorScope === 'isolated' ? null : scope;
               var editorScope = attrs.editorScope === 'isolated' ? null : scope;
-              scope.emitAppEvent('show-dash-editor', { src: partial, scope: editorScope });
+              scope.appEvent('show-dash-editor', { src: partial, scope: editorScope });
             });
             });
           });
           });
         }
         }

+ 1 - 1
src/app/panels/timepicker/module.js

@@ -79,7 +79,7 @@ function (angular, app, _, moment, kbn) {
         $scope.temptime.to.date = moment($scope.temptime.to.date).add('days',1).toDate();
         $scope.temptime.to.date = moment($scope.temptime.to.date).add('days',1).toDate();
       }
       }
 
 
-      $scope.emitAppEvent('show-dash-editor', {src: 'app/panels/timepicker/custom.html', scope: $scope });
+      $scope.appEvent('show-dash-editor', {src: 'app/panels/timepicker/custom.html', scope: $scope });
     };
     };
 
 
     // Constantly validate the input of the fields. This function does not change any date variables
     // Constantly validate the input of the fields. This function does not change any date variables

+ 1 - 1
src/app/services/alertSrv.js

@@ -18,7 +18,7 @@ function (angular, _) {
         self.set(alert[0], alert[1], 'warning', 5000);
         self.set(alert[0], alert[1], 'warning', 5000);
       });
       });
       $rootScope.onAppEvent('alert-success', function(e, alert) {
       $rootScope.onAppEvent('alert-success', function(e, alert) {
-        self.set(alert[0], alert[0], 'success', 3000);
+        self.set(alert[0], alert[1], 'success', 3000);
       });
       });
     };
     };
 
 

+ 4 - 4
src/app/services/dashboard/dashboardKeyBindings.js

@@ -22,7 +22,7 @@ function(angular, $) {
       });
       });
 
 
       keyboardManager.bind('ctrl+f', function() {
       keyboardManager.bind('ctrl+f', function() {
-        scope.emitAppEvent('show-dash-editor', { src: 'app/partials/search.html' });
+        scope.appEvent('show-dash-editor', { src: 'app/partials/search.html' });
       }, { inputDisabled: true });
       }, { inputDisabled: true });
 
 
       keyboardManager.bind('ctrl+h', function() {
       keyboardManager.bind('ctrl+h', function() {
@@ -31,7 +31,7 @@ function(angular, $) {
       }, { inputDisabled: true });
       }, { inputDisabled: true });
 
 
       keyboardManager.bind('ctrl+s', function(evt) {
       keyboardManager.bind('ctrl+s', function(evt) {
-        scope.emitAppEvent('save-dashboard', evt);
+        scope.appEvent('save-dashboard', evt);
       }, { inputDisabled: true });
       }, { inputDisabled: true });
 
 
       keyboardManager.bind('ctrl+r', function() {
       keyboardManager.bind('ctrl+r', function() {
@@ -39,7 +39,7 @@ function(angular, $) {
       }, { inputDisabled: true });
       }, { inputDisabled: true });
 
 
       keyboardManager.bind('ctrl+z', function(evt) {
       keyboardManager.bind('ctrl+z', function(evt) {
-        scope.emitAppEvent('zoom-out', evt);
+        scope.appEvent('zoom-out', evt);
       }, { inputDisabled: true });
       }, { inputDisabled: true });
 
 
       keyboardManager.bind('esc', function() {
       keyboardManager.bind('esc', function() {
@@ -53,7 +53,7 @@ function(angular, $) {
           modalData.$scope.dismiss();
           modalData.$scope.dismiss();
         }
         }
 
 
-        scope.emitAppEvent('hide-dash-editor');
+        scope.appEvent('hide-dash-editor');
 
 
         scope.exitFullscreen();
         scope.exitFullscreen();
       }, { inputDisabled: true });
       }, { inputDisabled: true });

+ 3 - 3
src/app/services/panelSrv.js

@@ -52,19 +52,19 @@ function (angular, _) {
           $scope.toggleFullscreen(true);
           $scope.toggleFullscreen(true);
         }
         }
         else {
         else {
-          $scope.emitAppEvent('show-dash-editor', { src: 'app/partials/paneleditor.html', scope: $scope });
+          $scope.appEvent('show-dash-editor', { src: 'app/partials/paneleditor.html', scope: $scope });
         }
         }
       };
       };
 
 
       $scope.sharePanel = function() {
       $scope.sharePanel = function() {
-        $scope.emitAppEvent('show-modal', {
+        $scope.appEvent('show-modal', {
           src: './app/partials/share-panel.html',
           src: './app/partials/share-panel.html',
           scope: $scope.$new()
           scope: $scope.$new()
         });
         });
       };
       };
 
 
       $scope.editPanelJson = function() {
       $scope.editPanelJson = function() {
-        $scope.emitAppEvent('show-json-editor', { object: $scope.panel, updateHandler: $scope.replacePanel });
+        $scope.appEvent('show-json-editor', { object: $scope.panel, updateHandler: $scope.replacePanel });
       };
       };
 
 
       $scope.updateColumnSpan = function(span) {
       $scope.updateColumnSpan = function(span) {

+ 1 - 1
src/app/services/timeSrv.js

@@ -91,7 +91,7 @@ define([
         this.old_refresh = null;
         this.old_refresh = null;
       }
       }
 
 
-      $rootScope.emitAppEvent('time-range-changed', this.time);
+      $rootScope.appEvent('time-range-changed', this.time);
       $timeout(this.refreshDashboard, 0);
       $timeout(this.refreshDashboard, 0);
     };
     };
 
 

+ 1 - 1
src/test/specs/helpers.js

@@ -68,7 +68,7 @@ define([
         self.$httpBackend =  $httpBackend;
         self.$httpBackend =  $httpBackend;
 
 
         self.$rootScope.onAppEvent = function() {};
         self.$rootScope.onAppEvent = function() {};
-        self.$rootScope.emitAppEvent = function() {};
+        self.$rootScope.appEvent = function() {};
 
 
         self.service = $injector.get(name);
         self.service = $injector.get(name);
       });
       });