diff --git a/src/app/controllers/dash.js b/src/app/controllers/dash.js index eb26c5fe17b..bd7256674e8 100644 --- a/src/app/controllers/dash.js +++ b/src/app/controllers/dash.js @@ -32,7 +32,7 @@ function (angular, $, config, _) { module.controller('DashCtrl', function( $scope, $rootScope, $timeout, ejsResource, filterSrv, dashboardKeybindings, - alertSrv, panelMove, keyboardManager, grafanaVersion) { + alertSrv, keyboardManager, grafanaVersion) { $scope.editor = { index: 0 @@ -40,13 +40,6 @@ function (angular, $, config, _) { $scope.grafanaVersion = grafanaVersion[0] === '@' ? 'master' : grafanaVersion; - // For moving stuff around the dashboard. - $scope.panelMoveDrop = panelMove.onDrop; - $scope.panelMoveStart = panelMove.onStart; - $scope.panelMoveStop = panelMove.onStop; - $scope.panelMoveOver = panelMove.onOver; - $scope.panelMoveOut = panelMove.onOut; - $scope.init = function() { $scope.config = config; @@ -81,7 +74,7 @@ function (angular, $, config, _) { $scope.add_row_default = function() { $scope.reset_row(); $scope.row.title = 'New row'; - $scope.add_row(dashboard.current, $scope.row); + $scope.add_row($scope.dashboard, $scope.row); }; $scope.reset_row = function() { diff --git a/src/app/controllers/dashLoader.js b/src/app/controllers/dashLoader.js index b4c5045a682..c4f96f8c4ff 100644 --- a/src/app/controllers/dashLoader.js +++ b/src/app/controllers/dashLoader.js @@ -23,9 +23,6 @@ function (angular, _, moment) { $scope.zoom(2); }); - $rootScope.$on('dashboard-loaded', function(event, dashboard) { - $scope.loader = dashboard.loader; - }); }; $scope.exitFullscreen = function() { @@ -33,11 +30,11 @@ function (angular, _, moment) { }; $scope.showDropdown = function(type) { - if(_.isUndefined($scope.loader)) { + if(_.isUndefined($scope.dashboard)) { return true; } - var _l = $scope.loader; + var _l = $scope.dashboard.loader; if(type === 'load') { return (_l.load_elasticsearch || _l.load_gist || _l.load_local); } @@ -51,7 +48,7 @@ function (angular, _, moment) { }; $scope.set_default = function() { - if(dashboard.set_default($location.path())) { + if($scope.dashboard.set_default($location.path())) { alertSrv.set('Home Set','This page has been set as your default dashboard','success',5000); } else { alertSrv.set('Incompatible Browser','Sorry, your browser is too old for this feature','error',5000); @@ -59,7 +56,7 @@ function (angular, _, moment) { }; $scope.purge_default = function() { - if(dashboard.purge_default()) { + if($scope.dashboard.purge_default()) { alertSrv.set('Local Default Clear','Your default dashboard has been reset to the default', 'success',5000); } else { @@ -68,7 +65,7 @@ function (angular, _, moment) { }; $scope.elasticsearch_save = function(type,ttl) { - dashboard.elasticsearch_save(type, dashboard.current.title, ttl) + $scope.dashboard.elasticsearch_save(type, $scope.dashboard.title, ttl) .then(function(result) { if(_.isUndefined(result._id)) { alertSrv.set('Save failed','Dashboard could not be saved to Elasticsearch','error',5000); @@ -77,10 +74,10 @@ function (angular, _, moment) { alertSrv.set('Dashboard Saved', 'Dashboard has been saved to Elasticsearch as "' + result._id + '"','success', 5000); if(type === 'temp') { - $scope.share = dashboard.share_link(dashboard.current.title,'temp',result._id); + $scope.share = $scope.dashboard.share_link($scope.dashboard.title,'temp',result._id); } - $rootScope.$emit('dashboard-saved', dashboard.current); + $rootScope.$emit('dashboard-saved', $scope.dashboard); }); }; @@ -89,7 +86,7 @@ function (angular, _, moment) { return; } - dashboard.elasticsearch_delete(id).then( + $scope.dashboard.elasticsearch_delete(id).then( function(result) { if(!_.isUndefined(result)) { if(result.found) { @@ -108,7 +105,7 @@ function (angular, _, moment) { }; $scope.save_gist = function() { - dashboard.save_gist($scope.gist.title).then(function(link) { + $scope.dashboard.save_gist($scope.gist.title).then(function(link) { if (!_.isUndefined(link)) { $scope.gist.last = link; alertSrv.set('Gist saved','You will be able to access your exported dashboard file at '+ @@ -120,7 +117,7 @@ function (angular, _, moment) { }; $scope.gist_dblist = function(id) { - dashboard.gist_list(id).then(function(files) { + $scope.dashboard.gist_list(id).then(function(files) { if (files && files.length > 0) { $scope.gist.files = files; } else { @@ -162,7 +159,7 @@ function (angular, _, moment) { }; $scope.removeAsFavorite = function() { - playlistSrv.removeAsFavorite(dashboard.current); + playlistSrv.removeAsFavorite($scope.dashboard); $scope.isFavorite = false; }; diff --git a/src/app/controllers/graphiteImport.js b/src/app/controllers/graphiteImport.js index e0a0f36389c..35153e092a3 100644 --- a/src/app/controllers/graphiteImport.js +++ b/src/app/controllers/graphiteImport.js @@ -8,7 +8,7 @@ function (angular, app, _) { var module = angular.module('kibana.controllers'); - module.controller('GraphiteImportCtrl', function($scope, $rootScope, $timeout, datasourceSrv, dashboard) { + module.controller('GraphiteImportCtrl', function($scope, $rootScope, $timeout, datasourceSrv) { $scope.init = function() { console.log('hej!'); @@ -68,7 +68,7 @@ function (angular, app, _) { currentRow = angular.copy(rowTemplate); - var newDashboard = angular.copy(dashboard.current); + var newDashboard = angular.copy($scope.dashboard); newDashboard.rows = []; newDashboard.title = state.name; newDashboard.rows.push(currentRow); diff --git a/src/app/controllers/panelBaseCtrl.js b/src/app/controllers/panelBaseCtrl.js index 24ce1ddd25f..7cb3ed08d16 100644 --- a/src/app/controllers/panelBaseCtrl.js +++ b/src/app/controllers/panelBaseCtrl.js @@ -86,7 +86,7 @@ function (angular, _, $) { $timeout(function() { if (oldTimeRange !== $scope.range) { - $scope.dashboard.refresh(); + $scope.dashboard.emit_refresh(); } else { $scope.$emit('render'); diff --git a/src/app/controllers/row.js b/src/app/controllers/row.js index a4f15c32e53..3b66aa9741c 100644 --- a/src/app/controllers/row.js +++ b/src/app/controllers/row.js @@ -76,12 +76,12 @@ function (angular, app, _) { $scope.delete_row = function() { if (confirm("Are you sure you want to delete this row?")) { - $scope.dashboard.current.rows = _.without($scope.dashboard.current.rows, $scope.row); + $scope.dashboard.rows = _.without($scope.dashboard.rows, $scope.row); } }; $scope.move_row = function(direction) { - var rowsList = $scope.dashboard.current.rows; + var rowsList = $scope.dashboard.rows; var rowIndex = _.indexOf(rowsList, $scope.row); var newIndex = rowIndex + direction; if (newIndex >= 0 && newIndex <= (rowsList.length - 1)) { @@ -116,12 +116,12 @@ function (angular, app, _) { row.panels.push(angular.copy(panel)); } else { - var rowsList = $scope.dashboard.current.rows; + var rowsList = $scope.dashboard.rows; var rowIndex = _.indexOf(rowsList, row); if (rowIndex === rowsList.length - 1) { var newRow = angular.copy($scope.row); newRow.panels = []; - $scope.dashboard.current.rows.push(newRow); + $scope.dashboard.rows.push(newRow); $scope.duplicatePanel(panel, newRow); } else { diff --git a/src/app/controllers/search.js b/src/app/controllers/search.js index 736c500a1e0..6b9428c5342 100644 --- a/src/app/controllers/search.js +++ b/src/app/controllers/search.js @@ -153,7 +153,7 @@ function (angular, _, config, $) { }; $scope.addMetricToCurrentDashboard = function (metricId) { - dashboard.current.rows.push({ + dashboard.rows.push({ title: '', height: '250px', editable: true, diff --git a/src/app/panels/filtering/module.js b/src/app/panels/filtering/module.js index 46a88fa0565..16ee9cfafc3 100644 --- a/src/app/panels/filtering/module.js +++ b/src/app/panels/filtering/module.js @@ -43,7 +43,7 @@ function (angular, app, _) { .then(function() { // only refresh in the outermost call if (!recursive) { - $scope.dashboard.refresh(); + $scope.dashboard.emit_refresh(); } }); }; diff --git a/src/app/panels/timepicker/module.html b/src/app/panels/timepicker/module.html index ea1759d2141..5c6513bf666 100644 --- a/src/app/panels/timepicker/module.html +++ b/src/app/panels/timepicker/module.html @@ -25,7 +25,7 @@ {{time.to.date | moment:'ago'}} Time filter - refreshed every {{dashboard.current.refresh}} + refreshed every {{dashboard.refresh}} @@ -47,8 +47,8 @@ -