mirror of
https://github.com/taobataoma/meanTorrent.git
synced 2026-01-22 07:12:31 +01:00
feat(backup): admin delete the backup files
This commit is contained in:
@@ -5,16 +5,17 @@
|
||||
.module('backup')
|
||||
.controller('BackupController', BackupController);
|
||||
|
||||
BackupController.$inject = ['$scope', '$timeout', 'getStorageLangService', 'MeanTorrentConfig', 'BackupService', 'NotifycationService',
|
||||
'DebugConsoleService', '$filter'];
|
||||
BackupController.$inject = ['$scope', '$timeout', 'Authentication', '$translate', 'MeanTorrentConfig', 'BackupService', 'NotifycationService',
|
||||
'DebugConsoleService', '$filter', 'ModalConfirmService'];
|
||||
|
||||
function BackupController($scope, $timeout, getStorageLangService, MeanTorrentConfig, BackupService, NotifycationService,
|
||||
mtDebug, $filter) {
|
||||
function BackupController($scope, $timeout, Authentication, $translate, MeanTorrentConfig, BackupService, NotifycationService,
|
||||
mtDebug, $filter, ModalConfirmService) {
|
||||
var vm = this;
|
||||
vm.lang = getStorageLangService.getLang();
|
||||
vm.appConfig = MeanTorrentConfig.meanTorrentConfig.app;
|
||||
vm.user = Authentication.user;
|
||||
vm.itemsPerPageConfig = MeanTorrentConfig.meanTorrentConfig.itemsPerPage;
|
||||
|
||||
vm.deleteList = [];
|
||||
|
||||
/**
|
||||
* buildPager
|
||||
*/
|
||||
@@ -66,5 +67,51 @@
|
||||
vm.buildPager();
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* deleteSelected
|
||||
*/
|
||||
vm.deleteSelected = function () {
|
||||
vm.deleteList = [];
|
||||
var modalOptions = {
|
||||
closeButtonText: $translate.instant('ABOUT.DELETE_CONFIRM_CANCEL'),
|
||||
actionButtonText: $translate.instant('ABOUT.DELETE_CONFIRM_OK'),
|
||||
headerText: $translate.instant('ABOUT.DELETE_CONFIRM_HEADER_TEXT'),
|
||||
bodyText: $translate.instant('BACKUP.DELETE_CONFIRM_BODY_TEXT')
|
||||
};
|
||||
|
||||
angular.forEach(vm.selected, function (item, id) {
|
||||
if (item) {
|
||||
vm.deleteList.push(id);
|
||||
}
|
||||
});
|
||||
|
||||
mtDebug.info(vm.deleteList);
|
||||
|
||||
if (vm.deleteList.length > 0) {
|
||||
ModalConfirmService.showModal({}, modalOptions)
|
||||
.then(function (result) {
|
||||
BackupService.remove({
|
||||
names: vm.deleteList
|
||||
}, function (res) {
|
||||
var s = [];
|
||||
angular.forEach(vm.fileList, function (f) {
|
||||
if (vm.deleteList.indexOf(f.name) !== -1) {
|
||||
s.push(f);
|
||||
}
|
||||
});
|
||||
|
||||
angular.forEach(s, function (f) {
|
||||
vm.fileList.splice(vm.fileList.indexOf(f), 1);
|
||||
});
|
||||
vm.figureOutItemsToDisplay();
|
||||
|
||||
NotifycationService.showSuccessNotify('BACKUP.DELETED_SUCCESSFULLY');
|
||||
}, function (res) {
|
||||
NotifycationService.showErrorNotify(res.data.message, 'BACKUP.DELETED_ERROR');
|
||||
});
|
||||
});
|
||||
}
|
||||
};
|
||||
}
|
||||
}());
|
||||
|
||||
@@ -28,7 +28,7 @@
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr class="message-item" ng-repeat="f in vm.filteredItems">
|
||||
<tr class="message-item" ng-repeat="f in vm.pagedItems">
|
||||
<td class="td-v-middle">
|
||||
{{f.name}}
|
||||
</td>
|
||||
|
||||
@@ -32,8 +32,24 @@ exports.list = function (req, res) {
|
||||
};
|
||||
|
||||
/**
|
||||
* Delete an collection
|
||||
* delete
|
||||
* @param req
|
||||
* @param res
|
||||
*/
|
||||
exports.delete = function (req, res) {
|
||||
if (req.query.names) {
|
||||
if (Array.isArray(req.query.names)) {
|
||||
req.query.names.forEach(function (n) {
|
||||
var tfile = backupConfig.dir + n;
|
||||
fs.unlinkSync(tfile);
|
||||
});
|
||||
} else {
|
||||
var tfile = backupConfig.dir + req.query.names;
|
||||
fs.unlinkSync(tfile);
|
||||
}
|
||||
return res.status(200).send({
|
||||
message: 'delete successfully'
|
||||
});
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
@@ -549,7 +549,10 @@
|
||||
LIST_ERROR: 'Files list error',
|
||||
FIELD_NAME: 'File name',
|
||||
FIELD_SIZE: 'File size',
|
||||
FIELD_TIME: 'Backup time'
|
||||
FIELD_TIME: 'Backup time',
|
||||
DELETE_CONFIRM_BODY_TEXT: 'Are you sure want to delete these files?',
|
||||
DELETED_SUCCESSFULLY: 'File deleted successfully',
|
||||
DELETED_ERROR: 'File deleted failed'
|
||||
},
|
||||
|
||||
//user settings
|
||||
|
||||
@@ -549,7 +549,10 @@
|
||||
LIST_ERROR: '备份文件列表错误',
|
||||
FIELD_NAME: '文件名',
|
||||
FIELD_SIZE: '文件大小',
|
||||
FIELD_TIME: '备份时间'
|
||||
FIELD_TIME: '备份时间',
|
||||
DELETE_CONFIRM_BODY_TEXT: '您确定要删除这些备份文件吗?',
|
||||
DELETED_SUCCESSFULLY: '备份文件删除成功',
|
||||
DELETED_ERROR: '备份文件删除失败'
|
||||
},
|
||||
|
||||
//user settings
|
||||
|
||||
Reference in New Issue
Block a user