Commit d0b79ad3 by Torkel Ödegaard

now dashboard deleting works

parent 7dc4484f
...@@ -15,18 +15,18 @@ function (angular, _, moment) { ...@@ -15,18 +15,18 @@ function (angular, _, moment) {
$scope.gist = $scope.gist || {}; $scope.gist = $scope.gist || {};
$scope.elasticsearch = $scope.elasticsearch || {}; $scope.elasticsearch = $scope.elasticsearch || {};
$rootScope.$on('save-dashboard', function() { $scope.onAppEvent('save-dashboard', function() {
$scope.elasticsearch_save('dashboard', false); $scope.elasticsearch_save('dashboard', false);
}); });
$rootScope.$on('zoom-out', function() { $scope.onAppEvent('zoom-out', function() {
$scope.zoom(2); $scope.zoom(2);
}); });
}; };
$scope.exitFullscreen = function() { $scope.exitFullscreen = function() {
$rootScope.$emit('panel-fullscreen-exit'); $scope.emitAppEvent('panel-fullscreen-exit');
}; };
$scope.showDropdown = function(type) { $scope.showDropdown = function(type) {
...@@ -82,27 +82,16 @@ function (angular, _, moment) { ...@@ -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?')) { if (!confirm('Are you sure you want to delete dashboard?')) {
return; return;
} }
$scope.dashboard.elasticsearch_delete(id).then( elastic.deleteDashboard(id).then(function(id) {
function(result) { alertSrv.set('Dashboard Deleted', id + ' has been deleted', 'success', 5000);
if(!_.isUndefined(result)) { }, function() {
if(result.found) { alertSrv.set('Dashboard Not Deleted', 'An error occurred deleting the dashboard', 'error', 5000);
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);
}
}
);
}; };
$scope.save_gist = function() { $scope.save_gist = function() {
......
...@@ -65,7 +65,6 @@ ...@@ -65,7 +65,6 @@
</li> </li>
<li class="grafana-menu-home"><a bs-tooltip="'Goto saved default'" data-placement="bottom" href='#/'><i class='icon-home'></i></a></li> <li class="grafana-menu-home"><a bs-tooltip="'Goto saved default'" data-placement="bottom" href='#/'><i class='icon-home'></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-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>
......
...@@ -77,7 +77,7 @@ ...@@ -77,7 +77,7 @@
<tr bindonce <tr bindonce
ng-repeat="row in results.dashboards" ng-repeat="row in results.dashboards"
ng-class="{'selected': $index === selectedIndex }"> ng-class="{'selected': $index === selectedIndex }">
<td><a confirm-click="elasticsearch_delete(row._id)" confirmation="Are you sure you want to delete the {{row._id}} dashboard"><i class="icon-remove"></i></a></td> <td><a confirm-click="deleteDashboard(row._id)" confirmation="Are you sure you want to delete the {{row._id}} dashboard"><i class="icon-remove"></i></a></td>
<td style="width:100%"> <td style="width:100%">
<a href="#/dashboard/elasticsearch/{{row._id}}" bo-text="row._id"></a> <a href="#/dashboard/elasticsearch/{{row._id}}" bo-text="row._id"></a>
</td> </td>
......
define([ define([
'./dashboard-from-es', './dashboard-from-es',
'./dashboard-from-file', './dashboard-from-file',
'./dashboard-from-script' './dashboard-from-script',
'./dashboard-default',
], ],
function () {}); function () {});
\ No newline at end of file
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;
}
}
});
});
});
...@@ -14,16 +14,6 @@ function (angular, $, config, _) { ...@@ -14,16 +14,6 @@ function (angular, $, config, _) {
.when('/dashboard/file/:jsonFile', { .when('/dashboard/file/:jsonFile', {
templateUrl: 'app/partials/dashboard.html', templateUrl: 'app/partials/dashboard.html',
controller : 'DashFromFileProvider', controller : 'DashFromFileProvider',
})
.when('/', {
redirectTo: function() {
if (window.localStorage && window.localStorage.grafanaDashboardDefault) {
return window.localStorage.grafanaDashboardDefault;
}
else {
return config.default_route;
}
}
}); });
}); });
......
...@@ -39,6 +39,15 @@ function(angular, config) { ...@@ -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) { this.saveForSharing = function(dashboard) {
var data = { var data = {
user: 'guest', user: 'guest',
......
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