diff --git a/src/app/controllers/dashLoader.js b/src/app/controllers/dashLoader.js index 16fa7a84635..2f2edb4dcda 100644 --- a/src/app/controllers/dashLoader.js +++ b/src/app/controllers/dashLoader.js @@ -15,18 +15,18 @@ function (angular, _, moment) { $scope.gist = $scope.gist || {}; $scope.elasticsearch = $scope.elasticsearch || {}; - $rootScope.$on('save-dashboard', function() { + $scope.onAppEvent('save-dashboard', function() { $scope.elasticsearch_save('dashboard', false); }); - $rootScope.$on('zoom-out', function() { + $scope.onAppEvent('zoom-out', function() { $scope.zoom(2); }); }; $scope.exitFullscreen = function() { - $rootScope.$emit('panel-fullscreen-exit'); + $scope.emitAppEvent('panel-fullscreen-exit'); }; $scope.showDropdown = function(type) { @@ -82,27 +82,16 @@ function (angular, _, moment) { }); }; - $scope.elasticsearch_delete = function(id) { + $scope.deleteDashboard = function(id) { if (!confirm('Are you sure you want to delete dashboard?')) { return; } - $scope.dashboard.elasticsearch_delete(id).then( - function(result) { - if(!_.isUndefined(result)) { - if(result.found) { - alertSrv.set('Dashboard Deleted',id+' has been deleted','success',5000); - // Find the deleted dashboard in the cached list and remove it - var toDelete = _.where($scope.elasticsearch.dashboards,{_id:id})[0]; - $scope.elasticsearch.dashboards = _.without($scope.elasticsearch.dashboards,toDelete); - } else { - alertSrv.set('Dashboard Not Found','Could not find '+id+' in Elasticsearch','warning',5000); - } - } else { - alertSrv.set('Dashboard Not Deleted','An error occurred deleting the dashboard','error',5000); - } - } - ); + elastic.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.save_gist = function() { diff --git a/src/app/partials/dashLoader.html b/src/app/partials/dashLoader.html index 7fadb03b57e..d65c5d33efd 100644 --- a/src/app/partials/dashLoader.html +++ b/src/app/partials/dashLoader.html @@ -65,7 +65,6 @@ -
  • diff --git a/src/app/partials/search.html b/src/app/partials/search.html index cddcfe82f2a..93cd8a49f76 100644 --- a/src/app/partials/search.html +++ b/src/app/partials/search.html @@ -77,7 +77,7 @@ - + diff --git a/src/app/routes/all.js b/src/app/routes/all.js index ccbd39cd166..17a829f84be 100644 --- a/src/app/routes/all.js +++ b/src/app/routes/all.js @@ -1,6 +1,7 @@ define([ './dashboard-from-es', './dashboard-from-file', - './dashboard-from-script' + './dashboard-from-script', + './dashboard-default', ], function () {}); \ No newline at end of file diff --git a/src/app/routes/dashboard-default.js b/src/app/routes/dashboard-default.js new file mode 100644 index 00000000000..f0366c11e3b --- /dev/null +++ b/src/app/routes/dashboard-default.js @@ -0,0 +1,24 @@ +define([ + 'angular', + 'config' +], +function (angular, config) { + "use strict"; + + var module = angular.module('kibana.routes'); + + module.config(function($routeProvider) { + $routeProvider + .when('/', { + redirectTo: function() { + if (window.localStorage && window.localStorage.grafanaDashboardDefault) { + return window.localStorage.grafanaDashboardDefault; + } + else { + return config.default_route; + } + } + }); + }); + +}); diff --git a/src/app/routes/dashboard-from-file.js b/src/app/routes/dashboard-from-file.js index 68295cdf9ed..704be8c3dff 100644 --- a/src/app/routes/dashboard-from-file.js +++ b/src/app/routes/dashboard-from-file.js @@ -14,16 +14,6 @@ function (angular, $, config, _) { .when('/dashboard/file/:jsonFile', { templateUrl: 'app/partials/dashboard.html', controller : 'DashFromFileProvider', - }) - .when('/', { - redirectTo: function() { - if (window.localStorage && window.localStorage.grafanaDashboardDefault) { - return window.localStorage.grafanaDashboardDefault; - } - else { - return config.default_route; - } - } }); }); diff --git a/src/app/services/elasticsearch/es-client.js b/src/app/services/elasticsearch/es-client.js index a4fe051fce6..64f84f82095 100644 --- a/src/app/services/elasticsearch/es-client.js +++ b/src/app/services/elasticsearch/es-client.js @@ -39,6 +39,15 @@ function(angular, config) { }); }; + this.deleteDashboard = function(id) { + return this._request('DELETE', '/dashboard/' + id) + .then(function(result) { + return result.data._id; + }, function(err) { + throw err.data; + }); + }; + this.saveForSharing = function(dashboard) { var data = { user: 'guest',