diff --git a/src/app/app.js b/src/app/app.js index 493b8a2a04c..951e41b56ca 100644 --- a/src/app/app.js +++ b/src/app/app.js @@ -49,23 +49,6 @@ function (angular, $, _, appLevelRequire, config) { return module; }; - app.safeApply = function ($scope, fn) { - switch($scope.$$phase) { - case '$apply': - // $digest hasn't started, we should be good - $scope.$eval(fn); - break; - case '$digest': - // waiting to $apply the changes - setTimeout(function () { app.safeApply($scope, fn); }, 10); - break; - default: - // clear to begin an $apply $$phase - $scope.$apply(fn); - break; - } - }; - app.config(function ($routeProvider, $controllerProvider, $compileProvider, $filterProvider, $provide) { $routeProvider.otherwise({ redirectTo: config.default_route }); @@ -97,12 +80,6 @@ function (angular, $, _, appLevelRequire, config) { apps_deps.push(module_name); }); - app.panel_helpers = { - partial: function (name) { - return 'app/partials/'+name+'.html'; - } - }; - // load the core components require([ 'controllers/all', @@ -116,7 +93,6 @@ function (angular, $, _, appLevelRequire, config) { angular .element(document) .ready(function() { - $('body').attr('ng-controller', 'DashCtrl'); angular.bootstrap(document, apps_deps) .invoke(['$rootScope', function ($rootScope) { _.each(pre_boot_modules, function (module) { diff --git a/src/app/controllers/all.js b/src/app/controllers/all.js index e95b99685be..3964cfc3475 100644 --- a/src/app/controllers/all.js +++ b/src/app/controllers/all.js @@ -1,4 +1,5 @@ define([ + './grafanaCtrl', './dash', './dashLoader', './row', diff --git a/src/app/controllers/dash.js b/src/app/controllers/dash.js index bd7256674e8..01c03b77b75 100644 --- a/src/app/controllers/dash.js +++ b/src/app/controllers/dash.js @@ -30,35 +30,15 @@ function (angular, $, config, _) { var module = angular.module('kibana.controllers'); - module.controller('DashCtrl', function( - $scope, $rootScope, $timeout, ejsResource, filterSrv, dashboardKeybindings, - alertSrv, keyboardManager, grafanaVersion) { + module.controller('DashCtrl', function($scope, $rootScope, dashboardKeybindings) { - $scope.editor = { - index: 0 - }; - - $scope.grafanaVersion = grafanaVersion[0] === '@' ? 'master' : grafanaVersion; + $scope.editor = { index: 0 }; $scope.init = function() { - $scope.config = config; - - // Make stuff, including underscore.js available to views - $scope._ = _; - $scope.dashAlerts = alertSrv; - - // Clear existing alerts - alertSrv.clearAll(); - $scope.reset_row(); - - $scope.ejs = ejsResource(config.elasticsearch, config.elasticsearchBasicAuth); - - $scope.bindKeyboardShortcuts(); + dashboardKeybindings.shortcuts(); }; - $scope.bindKeyboardShortcuts = dashboardKeybindings.shortcuts; - $scope.isPanel = function(obj) { if(!_.isNull(obj) && !_.isUndefined(obj) && !_.isUndefined(obj.type)) { return true; diff --git a/src/app/controllers/graphiteImport.js b/src/app/controllers/graphiteImport.js index 35153e092a3..5cdd0e086c5 100644 --- a/src/app/controllers/graphiteImport.js +++ b/src/app/controllers/graphiteImport.js @@ -96,7 +96,7 @@ function (angular, app, _) { currentRow.panels.push(panel); }); - dashboard.dash_load(newDashboard); + $scope.dashboard.dash_load(newDashboard); } }); diff --git a/src/app/controllers/search.js b/src/app/controllers/search.js index 6b9428c5342..18bf04f72b2 100644 --- a/src/app/controllers/search.js +++ b/src/app/controllers/search.js @@ -9,14 +9,15 @@ function (angular, _, config, $) { var module = angular.module('kibana.controllers'); - module.controller('SearchCtrl', function($scope, $rootScope, dashboard, $element, $location) { + module.controller('SearchCtrl', function($scope, $rootScope, $element, $location, ejsResource) { $scope.init = function() { + $scope.ejs = ejsResource(config.elasticsearch, config.elasticsearchBasicAuth); $scope.giveSearchFocus = 0; $scope.selectedIndex = -1; $scope.results = {dashboards: [], tags: [], metrics: []}; $scope.query = { query: 'title:' }; - $rootScope.$on('open-search', $scope.openSearch); + $scope.$onRootScope('open-search', $scope.openSearch, $scope); }; $scope.keyDown = function (evt) { @@ -153,7 +154,7 @@ function (angular, _, config, $) { }; $scope.addMetricToCurrentDashboard = function (metricId) { - dashboard.rows.push({ + $scope.dashboard.rows.push({ title: '', height: '250px', editable: true, diff --git a/src/app/partials/dashboard.html b/src/app/partials/dashboard.html index 3a78dd59adf..bec767e6a89 100644 --- a/src/app/partials/dashboard.html +++ b/src/app/partials/dashboard.html @@ -1,111 +1,114 @@ - +
-