add 'Confirm Task Removal' setting

This commit is contained in:
Vyacheslav Konovalov 2019-10-08 18:20:31 +05:00 committed by mayswind
parent fc2d9678ee
commit 06d6ee0a8e
6 changed files with 31 additions and 2 deletions

View file

@ -39,6 +39,7 @@
rpcListDisplayOrder: 'recentlyUsed', rpcListDisplayOrder: 'recentlyUsed',
afterCreatingNewTask: 'task-list', afterCreatingNewTask: 'task-list',
removeOldTaskAfterRetrying: false, removeOldTaskAfterRetrying: false,
confirmTaskRemoval: true,
afterRetryingTask: 'task-list-downloading', afterRetryingTask: 'task-list-downloading',
displayOrder: 'default:asc', displayOrder: 'default:asc',
fileListDisplayOrder: 'default:asc', fileListDisplayOrder: 'default:asc',

View file

@ -182,6 +182,7 @@
'Navigate to Downloading Tasks Page': 'Navigate to Downloading Tasks Page', 'Navigate to Downloading Tasks Page': 'Navigate to Downloading Tasks Page',
'Stay on Current Page': 'Stay on Current Page', 'Stay on Current Page': 'Stay on Current Page',
'Remove Old Tasks After Retrying': 'Remove Old Tasks After Retrying', 'Remove Old Tasks After Retrying': 'Remove Old Tasks After Retrying',
'Confirm Task Removal': 'Confirm Task Removal',
'RPC List Display Order': 'RPC List Display Order', 'RPC List Display Order': 'RPC List Display Order',
'Recently Used': 'Recently Used', 'Recently Used': 'Recently Used',
'RPC Alias': 'RPC Alias', 'RPC Alias': 'RPC Alias',

View file

@ -290,7 +290,7 @@
return; return;
} }
ariaNgLocalizationService.confirm('Confirm Remove', 'Are you sure you want to remove the selected task?', 'warning', function () { var removeTasks = function () {
$rootScope.loadPromise = aria2TaskService.removeTasks(tasks, function (response) { $rootScope.loadPromise = aria2TaskService.removeTasks(tasks, function (response) {
if (response.hasError && tasks.length > 1) { if (response.hasError && tasks.length > 1) {
ariaNgLocalizationService.showError('Failed to remove some task(s).'); ariaNgLocalizationService.showError('Failed to remove some task(s).');
@ -310,7 +310,13 @@
} }
} }
}, (tasks.length > 1)); }, (tasks.length > 1));
}); };
if (ariaNgSettingService.getConfirmTaskRemoval()) {
ariaNgLocalizationService.confirm('Confirm Remove', 'Are you sure you want to remove the selected task?', 'warning', removeTasks);
} else {
removeTasks();
};
}; };
$scope.clearStoppedTasks = function () { $scope.clearStoppedTasks = function () {

View file

@ -187,6 +187,10 @@
ariaNgSettingService.setRemoveOldTaskAfterRetrying(value); ariaNgSettingService.setRemoveOldTaskAfterRetrying(value);
}; };
$scope.setConfirmTaskRemoval = function (value) {
ariaNgSettingService.setConfirmTaskRemoval(value);
};
$scope.setAfterRetryingTask = function (value) { $scope.setAfterRetryingTask = function (value) {
ariaNgSettingService.setAfterRetryingTask(value); ariaNgSettingService.setAfterRetryingTask(value);
}; };

View file

@ -381,6 +381,12 @@
setRemoveOldTaskAfterRetrying: function (value) { setRemoveOldTaskAfterRetrying: function (value) {
setOption('removeOldTaskAfterRetrying', value); setOption('removeOldTaskAfterRetrying', value);
}, },
getConfirmTaskRemoval: function () {
return getOption('confirmTaskRemoval');
},
setConfirmTaskRemoval: function (value) {
setOption('confirmTaskRemoval', value);
},
getAfterRetryingTask: function () { getAfterRetryingTask: function () {
return getOption('afterRetryingTask'); return getOption('afterRetryingTask');
}, },

View file

@ -171,6 +171,17 @@
</select> </select>
</div> </div>
</div> </div>
<div class="row">
<div class="setting-key setting-key-without-desc col-sm-4">
<span translate>Confirm Task Removal</span>
</div>
<div class="setting-value col-sm-8">
<select class="form-control" style="width: 100%;" ng-model="context.settings.confirmTaskRemoval"
ng-change="setConfirmTaskRemoval(context.settings.confirmTaskRemoval)"
ng-options="option.value as (option.name | translate) for option in context.trueFalseOptions">
</select>
</div>
</div>
<div class="row"> <div class="row">
<div class="setting-key setting-key-without-desc col-sm-4"> <div class="setting-key setting-key-without-desc col-sm-4">
<span translate>Import / Export AriaNg Settings</span> <span translate>Import / Export AriaNg Settings</span>