mirror of
https://github.com/grafana/grafana.git
synced 2025-02-12 16:45:43 -06:00
now dashboard deleting works
This commit is contained in:
parent
7dc4484f6a
commit
d0b79ad335
@ -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() {
|
||||
|
@ -65,7 +65,6 @@
|
||||
|
||||
</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>
|
||||
|
@ -77,7 +77,7 @@
|
||||
<tr bindonce
|
||||
ng-repeat="row in results.dashboards"
|
||||
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%">
|
||||
<a href="#/dashboard/elasticsearch/{{row._id}}" bo-text="row._id"></a>
|
||||
</td>
|
||||
|
@ -1,6 +1,7 @@
|
||||
define([
|
||||
'./dashboard-from-es',
|
||||
'./dashboard-from-file',
|
||||
'./dashboard-from-script'
|
||||
'./dashboard-from-script',
|
||||
'./dashboard-default',
|
||||
],
|
||||
function () {});
|
24
src/app/routes/dashboard-default.js
Normal file
24
src/app/routes/dashboard-default.js
Normal file
@ -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;
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
});
|
@ -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;
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
|
@ -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',
|
||||
|
Loading…
Reference in New Issue
Block a user