mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Added DS deletion confirmation modal
This commit is contained in:
53
public/app/features/datasources/list_ctrl.ts
Normal file
53
public/app/features/datasources/list_ctrl.ts
Normal file
@@ -0,0 +1,53 @@
|
||||
///<reference path="../../headers/common.d.ts" />
|
||||
|
||||
import angular from 'angular';
|
||||
import _ from 'lodash';
|
||||
import coreModule from '../../core/core_module';
|
||||
|
||||
export class DataSourcesCtrl {
|
||||
datasources: any;
|
||||
|
||||
/** @ngInject */
|
||||
constructor(private $scope, private $location, private $http, private backendSrv, private datasourceSrv) {
|
||||
backendSrv.get('/api/datasources')
|
||||
.then((result) => {
|
||||
this.datasources = result;
|
||||
});
|
||||
}
|
||||
|
||||
removeDataSourceConfirmed(ds) {
|
||||
///_.remove(this.playlistsd, { id: playlist.id });
|
||||
|
||||
this.backendSrv.delete('/api/datasources/' + ds.id)
|
||||
.then(() => {
|
||||
this.$scope.appEvent('alert-success', ['Datasource deleted', '']);
|
||||
}, () => {
|
||||
this.$scope.appEvent('alert-error', ['Unable to delete datasource', '']);
|
||||
}).then(() => {
|
||||
this.backendSrv.get('/api/datasources')
|
||||
.then((result) => {
|
||||
this.datasources = result;
|
||||
});
|
||||
this.backendSrv.get('/api/frontend/settings')
|
||||
.then((settings) => {
|
||||
this.datasourceSrv.init(settings.datasources);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
removeDataSource(ds) {
|
||||
|
||||
this.$scope.appEvent('confirm-modal', {
|
||||
title: 'Confirm delete datasource',
|
||||
text: 'Are you sure you want to delete datasource ' + ds.name + '?',
|
||||
yesText: "Delete",
|
||||
icon: "fa-warning",
|
||||
onConfirm: () => {
|
||||
this.removeDataSourceConfirmed(ds);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
coreModule.controller('DataSourcesCtrl', DataSourcesCtrl);
|
||||
Reference in New Issue
Block a user