mirror of https://github.com/portainer/portainer
feat(agent): delete file
parent
b564395e50
commit
9b02ceaab7
|
@ -2,7 +2,13 @@ angular.module('portainer.agent').controller('HostBrowserController', [
|
||||||
'HostBrowserService',
|
'HostBrowserService',
|
||||||
'Notifications',
|
'Notifications',
|
||||||
'FileSaver',
|
'FileSaver',
|
||||||
function HostBrowserController(HostBrowserService, Notifications, FileSaver) {
|
'ModalService',
|
||||||
|
function HostBrowserController(
|
||||||
|
HostBrowserService,
|
||||||
|
Notifications,
|
||||||
|
FileSaver,
|
||||||
|
ModalService
|
||||||
|
) {
|
||||||
var ctrl = this;
|
var ctrl = this;
|
||||||
ctrl.state = {
|
ctrl.state = {
|
||||||
path: '/'
|
path: '/'
|
||||||
|
@ -12,7 +18,7 @@ angular.module('portainer.agent').controller('HostBrowserController', [
|
||||||
ctrl.browse = browse;
|
ctrl.browse = browse;
|
||||||
ctrl.renameFile = renameFile;
|
ctrl.renameFile = renameFile;
|
||||||
ctrl.downloadFile = downloadFile;
|
ctrl.downloadFile = downloadFile;
|
||||||
ctrl.deleteFile = deleteFile;
|
ctrl.deleteFile = confirmDeleteFile;
|
||||||
ctrl.isRoot = isRoot;
|
ctrl.isRoot = isRoot;
|
||||||
ctrl.$onInit = $onInit;
|
ctrl.$onInit = $onInit;
|
||||||
|
|
||||||
|
@ -73,7 +79,33 @@ angular.module('portainer.agent').controller('HostBrowserController', [
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function deleteFile(name) {}
|
function confirmDeleteFile(name) {
|
||||||
|
var filePath = buildPath(ctrl.state.path, name);
|
||||||
|
|
||||||
|
ModalService.confirmDeletion(
|
||||||
|
'Are you sure that you want to delete ' + filePath + ' ?',
|
||||||
|
function onConfirm(confirmed) {
|
||||||
|
if (!confirmed) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
return deleteFile(filePath);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
function deleteFile(path) {
|
||||||
|
HostBrowserService.delete(path)
|
||||||
|
.then(function onDeleteSuccess() {
|
||||||
|
Notifications.success('File successfully deleted', path);
|
||||||
|
return HostBrowserService.ls(ctrl.state.path);
|
||||||
|
})
|
||||||
|
.then(function onFilesLoaded(data) {
|
||||||
|
ctrl.files = data;
|
||||||
|
})
|
||||||
|
.catch(function notifyOnError(err) {
|
||||||
|
Notifications.error('Failure', err, 'Unable to delete file');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
function $onInit() {
|
function $onInit() {
|
||||||
getFilesForPath('/');
|
getFilesForPath('/');
|
||||||
|
|
Loading…
Reference in New Issue