Commit b995dc54 by Torkel Ödegaard

further refactoring

parent 79404e75
...@@ -32,7 +32,7 @@ function (angular, $, config, _) { ...@@ -32,7 +32,7 @@ function (angular, $, config, _) {
module.controller('DashCtrl', function( module.controller('DashCtrl', function(
$scope, $rootScope, $timeout, ejsResource, filterSrv, dashboardKeybindings, $scope, $rootScope, $timeout, ejsResource, filterSrv, dashboardKeybindings,
alertSrv, panelMove, keyboardManager, grafanaVersion) { alertSrv, keyboardManager, grafanaVersion) {
$scope.editor = { $scope.editor = {
index: 0 index: 0
...@@ -40,13 +40,6 @@ function (angular, $, config, _) { ...@@ -40,13 +40,6 @@ function (angular, $, config, _) {
$scope.grafanaVersion = grafanaVersion[0] === '@' ? 'master' : grafanaVersion; $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.init = function() {
$scope.config = config; $scope.config = config;
...@@ -81,7 +74,7 @@ function (angular, $, config, _) { ...@@ -81,7 +74,7 @@ function (angular, $, config, _) {
$scope.add_row_default = function() { $scope.add_row_default = function() {
$scope.reset_row(); $scope.reset_row();
$scope.row.title = 'New row'; $scope.row.title = 'New row';
$scope.add_row(dashboard.current, $scope.row); $scope.add_row($scope.dashboard, $scope.row);
}; };
$scope.reset_row = function() { $scope.reset_row = function() {
......
...@@ -23,9 +23,6 @@ function (angular, _, moment) { ...@@ -23,9 +23,6 @@ function (angular, _, moment) {
$scope.zoom(2); $scope.zoom(2);
}); });
$rootScope.$on('dashboard-loaded', function(event, dashboard) {
$scope.loader = dashboard.loader;
});
}; };
$scope.exitFullscreen = function() { $scope.exitFullscreen = function() {
...@@ -33,11 +30,11 @@ function (angular, _, moment) { ...@@ -33,11 +30,11 @@ function (angular, _, moment) {
}; };
$scope.showDropdown = function(type) { $scope.showDropdown = function(type) {
if(_.isUndefined($scope.loader)) { if(_.isUndefined($scope.dashboard)) {
return true; return true;
} }
var _l = $scope.loader; var _l = $scope.dashboard.loader;
if(type === 'load') { if(type === 'load') {
return (_l.load_elasticsearch || _l.load_gist || _l.load_local); return (_l.load_elasticsearch || _l.load_gist || _l.load_local);
} }
...@@ -51,7 +48,7 @@ function (angular, _, moment) { ...@@ -51,7 +48,7 @@ function (angular, _, moment) {
}; };
$scope.set_default = function() { $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); alertSrv.set('Home Set','This page has been set as your default dashboard','success',5000);
} else { } else {
alertSrv.set('Incompatible Browser','Sorry, your browser is too old for this feature','error',5000); alertSrv.set('Incompatible Browser','Sorry, your browser is too old for this feature','error',5000);
...@@ -59,7 +56,7 @@ function (angular, _, moment) { ...@@ -59,7 +56,7 @@ function (angular, _, moment) {
}; };
$scope.purge_default = function() { $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', alertSrv.set('Local Default Clear','Your default dashboard has been reset to the default',
'success',5000); 'success',5000);
} else { } else {
...@@ -68,7 +65,7 @@ function (angular, _, moment) { ...@@ -68,7 +65,7 @@ function (angular, _, moment) {
}; };
$scope.elasticsearch_save = function(type,ttl) { $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) { .then(function(result) {
if(_.isUndefined(result._id)) { if(_.isUndefined(result._id)) {
alertSrv.set('Save failed','Dashboard could not be saved to Elasticsearch','error',5000); alertSrv.set('Save failed','Dashboard could not be saved to Elasticsearch','error',5000);
...@@ -77,10 +74,10 @@ function (angular, _, moment) { ...@@ -77,10 +74,10 @@ function (angular, _, moment) {
alertSrv.set('Dashboard Saved', 'Dashboard has been saved to Elasticsearch as "' + result._id + '"','success', 5000); alertSrv.set('Dashboard Saved', 'Dashboard has been saved to Elasticsearch as "' + result._id + '"','success', 5000);
if(type === 'temp') { 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) { ...@@ -89,7 +86,7 @@ function (angular, _, moment) {
return; return;
} }
dashboard.elasticsearch_delete(id).then( $scope.dashboard.elasticsearch_delete(id).then(
function(result) { function(result) {
if(!_.isUndefined(result)) { if(!_.isUndefined(result)) {
if(result.found) { if(result.found) {
...@@ -108,7 +105,7 @@ function (angular, _, moment) { ...@@ -108,7 +105,7 @@ function (angular, _, moment) {
}; };
$scope.save_gist = function() { $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)) { if (!_.isUndefined(link)) {
$scope.gist.last = link; $scope.gist.last = link;
alertSrv.set('Gist saved','You will be able to access your exported dashboard file at '+ alertSrv.set('Gist saved','You will be able to access your exported dashboard file at '+
...@@ -120,7 +117,7 @@ function (angular, _, moment) { ...@@ -120,7 +117,7 @@ function (angular, _, moment) {
}; };
$scope.gist_dblist = function(id) { $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) { if (files && files.length > 0) {
$scope.gist.files = files; $scope.gist.files = files;
} else { } else {
...@@ -162,7 +159,7 @@ function (angular, _, moment) { ...@@ -162,7 +159,7 @@ function (angular, _, moment) {
}; };
$scope.removeAsFavorite = function() { $scope.removeAsFavorite = function() {
playlistSrv.removeAsFavorite(dashboard.current); playlistSrv.removeAsFavorite($scope.dashboard);
$scope.isFavorite = false; $scope.isFavorite = false;
}; };
......
...@@ -8,7 +8,7 @@ function (angular, app, _) { ...@@ -8,7 +8,7 @@ function (angular, app, _) {
var module = angular.module('kibana.controllers'); 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() { $scope.init = function() {
console.log('hej!'); console.log('hej!');
...@@ -68,7 +68,7 @@ function (angular, app, _) { ...@@ -68,7 +68,7 @@ function (angular, app, _) {
currentRow = angular.copy(rowTemplate); currentRow = angular.copy(rowTemplate);
var newDashboard = angular.copy(dashboard.current); var newDashboard = angular.copy($scope.dashboard);
newDashboard.rows = []; newDashboard.rows = [];
newDashboard.title = state.name; newDashboard.title = state.name;
newDashboard.rows.push(currentRow); newDashboard.rows.push(currentRow);
......
...@@ -86,7 +86,7 @@ function (angular, _, $) { ...@@ -86,7 +86,7 @@ function (angular, _, $) {
$timeout(function() { $timeout(function() {
if (oldTimeRange !== $scope.range) { if (oldTimeRange !== $scope.range) {
$scope.dashboard.refresh(); $scope.dashboard.emit_refresh();
} }
else { else {
$scope.$emit('render'); $scope.$emit('render');
......
...@@ -76,12 +76,12 @@ function (angular, app, _) { ...@@ -76,12 +76,12 @@ function (angular, app, _) {
$scope.delete_row = function() { $scope.delete_row = function() {
if (confirm("Are you sure you want to delete this row?")) { 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) { $scope.move_row = function(direction) {
var rowsList = $scope.dashboard.current.rows; var rowsList = $scope.dashboard.rows;
var rowIndex = _.indexOf(rowsList, $scope.row); var rowIndex = _.indexOf(rowsList, $scope.row);
var newIndex = rowIndex + direction; var newIndex = rowIndex + direction;
if (newIndex >= 0 && newIndex <= (rowsList.length - 1)) { if (newIndex >= 0 && newIndex <= (rowsList.length - 1)) {
...@@ -116,12 +116,12 @@ function (angular, app, _) { ...@@ -116,12 +116,12 @@ function (angular, app, _) {
row.panels.push(angular.copy(panel)); row.panels.push(angular.copy(panel));
} }
else { else {
var rowsList = $scope.dashboard.current.rows; var rowsList = $scope.dashboard.rows;
var rowIndex = _.indexOf(rowsList, row); var rowIndex = _.indexOf(rowsList, row);
if (rowIndex === rowsList.length - 1) { if (rowIndex === rowsList.length - 1) {
var newRow = angular.copy($scope.row); var newRow = angular.copy($scope.row);
newRow.panels = []; newRow.panels = [];
$scope.dashboard.current.rows.push(newRow); $scope.dashboard.rows.push(newRow);
$scope.duplicatePanel(panel, newRow); $scope.duplicatePanel(panel, newRow);
} }
else { else {
......
...@@ -153,7 +153,7 @@ function (angular, _, config, $) { ...@@ -153,7 +153,7 @@ function (angular, _, config, $) {
}; };
$scope.addMetricToCurrentDashboard = function (metricId) { $scope.addMetricToCurrentDashboard = function (metricId) {
dashboard.current.rows.push({ dashboard.rows.push({
title: '', title: '',
height: '250px', height: '250px',
editable: true, editable: true,
......
...@@ -43,7 +43,7 @@ function (angular, app, _) { ...@@ -43,7 +43,7 @@ function (angular, app, _) {
.then(function() { .then(function() {
// only refresh in the outermost call // only refresh in the outermost call
if (!recursive) { if (!recursive) {
$scope.dashboard.refresh(); $scope.dashboard.emit_refresh();
} }
}); });
}; };
......
...@@ -25,7 +25,7 @@ ...@@ -25,7 +25,7 @@
<span class="pointer" ng-show="panel.now">{{time.to.date | moment:'ago'}}</span> <span class="pointer" ng-show="panel.now">{{time.to.date | moment:'ago'}}</span>
</span> </span>
<span ng-hide="filter.time">Time filter</span> <span ng-hide="filter.time">Time filter</span>
<span ng-show="dashboard.current.refresh" class="text-warning">refreshed every {{dashboard.current.refresh}} </span> <span ng-show="dashboard.refresh" class="text-warning">refreshed every {{dashboard.refresh}} </span>
<i class="icon-caret-down"></i> <i class="icon-caret-down"></i>
</a> </a>
...@@ -47,8 +47,8 @@ ...@@ -47,8 +47,8 @@
</ul> </ul>
</li> </li>
<li ng-show="!dashboard.current.refresh" class="grafana-menu-refresh"> <li ng-show="!dashboard.refresh" class="grafana-menu-refresh">
<a class="icon-refresh" ng-click="dashboard.refresh()"></a> <a class="icon-refresh" ng-click="dashboard.emit_refresh()"></a>
</li> </li>
</ul> </ul>
......
...@@ -16,7 +16,7 @@ ...@@ -16,7 +16,7 @@
</a> </a>
</li> </li>
<li ng-repeat="pulldown in dashboard.current.nav" ng-controller="PulldownCtrl" ng-show="pulldown.enable"><kibana-simple-panel type="pulldown.type" ng-cloak></kibana-simple-panel></li> <li ng-repeat="pulldown in dashboard.nav" ng-controller="PulldownCtrl" ng-show="pulldown.enable"><kibana-simple-panel type="pulldown.type" ng-cloak></kibana-simple-panel></li>
<li class="dropdown grafana-menu-save" ng-show="showDropdown('save')"> <li class="dropdown grafana-menu-save" ng-show="showDropdown('save')">
<a href="#" bs-tooltip="'Save'" data-placement="bottom" class="dropdown-toggle" data-toggle="dropdown" ng-click="openSaveDropdown()"> <a href="#" bs-tooltip="'Save'" data-placement="bottom" class="dropdown-toggle" data-toggle="dropdown" ng-click="openSaveDropdown()">
...@@ -25,17 +25,17 @@ ...@@ -25,17 +25,17 @@
<ul class="save-dashboard-dropdown dropdown-menu"> <ul class="save-dashboard-dropdown dropdown-menu">
<li ng-show="dashboard.current.loader.save_elasticsearch"> <li ng-show="dashboard.loader.save_elasticsearch">
<form class="input-prepend nomargin save-dashboard-dropdown-save-form"> <form class="input-prepend nomargin save-dashboard-dropdown-save-form">
<input class='input-medium' ng-model="dashboard.current.title" type="text" ng-model="elasticsearch.title"/> <input class='input-medium' ng-model="dashboard.title" type="text" ng-model="elasticsearch.title"/>
<button class="btn" ng-click="elasticsearch_save('dashboard')"><i class="icon-save"></i></button> <button class="btn" ng-click="elasticsearch_save('dashboard')"><i class="icon-save"></i></button>
</form> </form>
</li> </li>
<li ng-show="dashboard.current.loader.save_default"> <li ng-show="dashboard.loader.save_default">
<a class="link" ng-click="set_default()">Save as Home</a> <a class="link" ng-click="set_default()">Save as Home</a>
</li> </li>
<li ng-show="dashboard.current.loader.save_default"> <li ng-show="dashboard.loader.save_default">
<a class="link" ng-click="purge_default()">Reset Home</a> <a class="link" ng-click="purge_default()">Reset Home</a>
</li> </li>
<li ng-show="!isFavorite"> <li ng-show="!isFavorite">
...@@ -44,12 +44,12 @@ ...@@ -44,12 +44,12 @@
<li ng-show="isFavorite"> <li ng-show="isFavorite">
<a class="link" ng-click="removeAsFavorite()">Remove as favorite</a> <a class="link" ng-click="removeAsFavorite()">Remove as favorite</a>
</li> </li>
<li ng-show="dashboard.current.loader.save_local"> <li ng-show="dashboard.loader.save_local">
<a class="link" ng-click="dashboard.to_file()">Export dashboard</a> <a class="link" ng-click="dashboard.to_file()">Export dashboard</a>
</li> </li>
<li ng-show="showDropdown('share')"><a bs-tooltip="'Share'" data-placement="bottom" ng-click="elasticsearch_save('temp',dashboard.current.loader.save_temp_ttl)" config-modal="app/partials/dashLoaderShare.html">Share temp copy</i></a></li> <li ng-show="showDropdown('share')"><a bs-tooltip="'Share'" data-placement="bottom" ng-click="elasticsearch_save('temp',dashboard.loader.save_temp_ttl)" config-modal="app/partials/dashLoaderShare.html">Share temp copy</i></a></li>
<li ng-show="dashboard.current.loader.save_gist" style="margin:10px"> <li ng-show="dashboard.loader.save_gist" style="margin:10px">
<h6>Gist</h6> <h6>Gist</h6>
<form class="input-append"> <form class="input-append">
<input class='input-medium' placeholder='Title' type="text" ng-model="gist.title"/> <input class='input-medium' placeholder='Title' type="text" ng-model="gist.title"/>
...@@ -68,7 +68,7 @@ ...@@ -68,7 +68,7 @@
<li class="grafana-menu-home"><a bs-tooltip="'Goto saved default'" data-placement="bottom" href='#/dashboard'><i class='icon-home'></i></a></li> <li class="grafana-menu-home"><a bs-tooltip="'Goto saved default'" data-placement="bottom" href='#/dashboard'><i class='icon-home'></i></a></li>
<li class="grafana-menu-edit" ng-show="dashboard.current.editable" bs-tooltip="'Configure dashboard'" data-placement="bottom"><a class="link" config-modal="app/partials/dasheditor.html"><i class='icon-cog pointer'></i></a></li> <li class="grafana-menu-edit" ng-show="dashboard.editable" bs-tooltip="'Configure dashboard'" data-placement="bottom"><a class="link" config-modal="app/partials/dasheditor.html"><i class='icon-cog pointer'></i></a></li>
<li class="grafana-menu-stop-playlist hide"> <li class="grafana-menu-stop-playlist hide">
<a class='small' ng-click='stopPlaylist(2)'> <a class='small' ng-click='stopPlaylist(2)'>
......
...@@ -107,7 +107,7 @@ ...@@ -107,7 +107,7 @@
</div> </div>
</div> </div>
<div ng-show='dashboard.editable && dashboard.current.panel_hints' class="row-fluid add-row-panel-hint"> <div ng-show='dashboard.editable && dashboard.panel_hints' class="row-fluid add-row-panel-hint">
<div class="span12" style="text-align:right;"> <div class="span12" style="text-align:right;">
<span style="margin-right: 10px;" ng-click="add_row_default()" class="pointer btn btn-info btn-mini"> <span style="margin-right: 10px;" ng-click="add_row_default()" class="pointer btn btn-info btn-mini">
<span><i class="icon-plus-sign"></i> ADD A ROW</span> <span><i class="icon-plus-sign"></i> ADD A ROW</span>
......
...@@ -92,7 +92,7 @@ ...@@ -92,7 +92,7 @@
</div> </div>
</li> </li>
<!-- ng-show="dashboard.current.loader.load_gist || dashboard.current.loader.load_local" --> <!-- ng-show="dashboard.loader.load_gist || dashboard.loader.load_local" -->
<li ng-if="showImport" style="margin: 20px;"> <li ng-if="showImport" style="margin: 20px;">
<div class="editor-row"> <div class="editor-row">
<div class="section"> <div class="section">
...@@ -105,7 +105,7 @@ ...@@ -105,7 +105,7 @@
</div> </div>
</div> </div>
<div class="editor-row" ng-show='dashboard.current.loader.load_gist'> <div class="editor-row" ng-show='dashboard.loader.load_gist'>
<h5>Gist <tip>Enter a gist number or url</tip></h5> <h5>Gist <tip>Enter a gist number or url</tip></h5>
<form> <form>
<input type="text" ng-model="gist.url" placeholder="Gist number or URL"><br> <input type="text" ng-model="gist.url" placeholder="Gist number or URL"><br>
......
...@@ -17,7 +17,8 @@ function (angular, $, config, _) { ...@@ -17,7 +17,8 @@ function (angular, $, config, _) {
}); });
}); });
module.controller('DashFromFileProvider', function($scope, $rootScope, $http, $routeParams, alertSrv, dashboard, filterSrv) { module.controller('DashFromFileProvider', function(
$scope, $rootScope, $http, $routeParams, alertSrv, dashboard, filterSrv, panelMoveSrv) {
$scope.init = function() { $scope.init = function() {
console.log('DashFromFileProvider->init()') console.log('DashFromFileProvider->init()')
...@@ -28,6 +29,14 @@ function (angular, $, config, _) { ...@@ -28,6 +29,14 @@ function (angular, $, config, _) {
$scope.filter = filterSrv; $scope.filter = filterSrv;
$scope.filter.init($scope.dashboard); $scope.filter.init($scope.dashboard);
var panelMove = panelMoveSrv.create($scope.dashboard);
// 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;
$rootScope.$emit("dashboard-loaded", $scope.dashboard); $rootScope.$emit("dashboard-loaded", $scope.dashboard);
}); });
}; };
......
...@@ -9,6 +9,7 @@ define([ ...@@ -9,6 +9,7 @@ define([
module.service('annotationsSrv', function(datasourceSrv, $q, alertSrv, $rootScope) { module.service('annotationsSrv', function(datasourceSrv, $q, alertSrv, $rootScope) {
var promiseCached; var promiseCached;
var annotationPanel;
var list = []; var list = [];
this.init = function() { this.init = function() {
...@@ -21,7 +22,7 @@ define([ ...@@ -21,7 +22,7 @@ define([
}; };
this.getAnnotations = function(filterSrv, rangeUnparsed, dashboard) { this.getAnnotations = function(filterSrv, rangeUnparsed, dashboard) {
var annotationPanel = _.findWhere(dashboard.pulldowns, { type: 'annotations' }); annotationPanel = _.findWhere(dashboard.pulldowns, { type: 'annotations' });
if (!annotationPanel.enable) { if (!annotationPanel.enable) {
return $q.when(null); return $q.when(null);
} }
......
...@@ -63,7 +63,7 @@ function (angular, $, kbn, _) { ...@@ -63,7 +63,7 @@ function (angular, $, kbn, _) {
var p = DashboardModel.prototype; var p = DashboardModel.prototype;
p.refresh = function() { p.emit_refresh = function() {
$rootScope.$broadcast('refresh'); $rootScope.$broadcast('refresh');
}; };
......
...@@ -39,7 +39,7 @@ function(angular, $) { ...@@ -39,7 +39,7 @@ function(angular, $) {
}, { inputDisabled: true }); }, { inputDisabled: true });
keyboardManager.bind('ctrl+r', function() { keyboardManager.bind('ctrl+r', function() {
dashboard.refresh(); dashboard.emit_refresh();
}, { inputDisabled: true }); }, { inputDisabled: true });
keyboardManager.bind('ctrl+z', function(evt) { keyboardManager.bind('ctrl+z', function(evt) {
......
...@@ -60,7 +60,7 @@ define([ ...@@ -60,7 +60,7 @@ define([
this.old_refresh = null; this.old_refresh = null;
} }
$timeout(this.dashboard.refresh, 0); $timeout(this.dashboard.emit_refresh, 0);
}, },
timeRange: function(parse) { timeRange: function(parse) {
......
...@@ -7,27 +7,33 @@ function (angular, _) { ...@@ -7,27 +7,33 @@ function (angular, _) {
var module = angular.module('kibana.services'); var module = angular.module('kibana.services');
module.service('panelMove', function(dashboard, $rootScope) { module.service('panelMoveSrv', function($rootScope) {
/* each of these can take event,ui,data parameters */ function PanelMoveSrv(dashboard) {
this.dashboard = dashboard;
_.bindAll(this, 'onStart', 'onOver', 'onOut', 'onDrop', 'onStop', 'cleanup');
}
var p = PanelMoveSrv.prototype;
this.onStart = function() { /* each of these can take event,ui,data parameters */
dashboard.panelDragging = true; p.onStart = function() {
this.dashboard.panelDragging = true;
$rootScope.$apply(); $rootScope.$apply();
}; };
this.onOver = function() { p.onOver = function() {
$rootScope.$apply(); $rootScope.$apply();
}; };
this.onOut = function() { p.onOut = function() {
$rootScope.$apply(); $rootScope.$apply();
}; };
/* /*
Use our own drop logic. the $parent.$parent this is ugly. Use our own drop logic. the $parent.$parent this is ugly.
*/ */
this.onDrop = function(event,ui,data) { p.onDrop = function(event,ui,data) {
var var
dragRow = data.draggableScope.$parent.$parent.row.panels, dragRow = data.draggableScope.$parent.$parent.row.panels,
dropRow = data.droppableScope.$parent.$parent.row.panels, dropRow = data.droppableScope.$parent.$parent.row.panels,
...@@ -42,26 +48,32 @@ function (angular, _) { ...@@ -42,26 +48,32 @@ function (angular, _) {
dropRow.splice(dropIndex,0,data.dragItem); dropRow.splice(dropIndex,0,data.dragItem);
} }
dashboard.panelDragging = false; this.dashboard.panelDragging = false;
// Cleanup nulls/undefined left behind // Cleanup nulls/undefined left behind
cleanup(); this.cleanup();
$rootScope.$apply(); $rootScope.$apply();
$rootScope.$broadcast('render'); $rootScope.$broadcast('render');
}; };
this.onStop = function() { p.onStop = function() {
dashboard.panelDragging = false; this.dashboard.panelDragging = false;
cleanup(); this.cleanup();
$rootScope.$apply(); $rootScope.$apply();
}; };
var cleanup = function () { p.cleanup = function () {
_.each(dashboard.current.rows, function(row) { _.each(this.dashboard.rows, function(row) {
row.panels = _.without(row.panels,{}); row.panels = _.without(row.panels,{});
row.panels = _.compact(row.panels); row.panels = _.compact(row.panels);
}); });
}; };
return {
create: function(dashboard) {
return new PanelMoveSrv(dashboard);
}
}
}); });
}); });
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment