Skip to content

Commit

Permalink
add 'Confirm Task Removal' setting
Browse files Browse the repository at this point in the history
  • Loading branch information
Vyacheslav Konovalov authored and mayswind committed Oct 8, 2019
1 parent fc2d967 commit 06d6ee0
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/scripts/config/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
rpcListDisplayOrder: 'recentlyUsed',
afterCreatingNewTask: 'task-list',
removeOldTaskAfterRetrying: false,
confirmTaskRemoval: true,
afterRetryingTask: 'task-list-downloading',
displayOrder: 'default:asc',
fileListDisplayOrder: 'default:asc',
Expand Down
1 change: 1 addition & 0 deletions src/scripts/config/defaultLanguage.js
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,7 @@
'Navigate to Downloading Tasks Page': 'Navigate to Downloading Tasks Page',
'Stay on Current Page': 'Stay on Current Page',
'Remove Old Tasks After Retrying': 'Remove Old Tasks After Retrying',
'Confirm Task Removal': 'Confirm Task Removal',
'RPC List Display Order': 'RPC List Display Order',
'Recently Used': 'Recently Used',
'RPC Alias': 'RPC Alias',
Expand Down
10 changes: 8 additions & 2 deletions src/scripts/controllers/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@
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) {
if (response.hasError && tasks.length > 1) {
ariaNgLocalizationService.showError('Failed to remove some task(s).');
Expand All @@ -310,7 +310,13 @@
}
}
}, (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 () {
Expand Down
4 changes: 4 additions & 0 deletions src/scripts/controllers/settings-ariang.js
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,10 @@
ariaNgSettingService.setRemoveOldTaskAfterRetrying(value);
};

$scope.setConfirmTaskRemoval = function (value) {
ariaNgSettingService.setConfirmTaskRemoval(value);
};

$scope.setAfterRetryingTask = function (value) {
ariaNgSettingService.setAfterRetryingTask(value);
};
Expand Down
6 changes: 6 additions & 0 deletions src/scripts/services/ariaNgSettingService.js
Original file line number Diff line number Diff line change
Expand Up @@ -381,6 +381,12 @@
setRemoveOldTaskAfterRetrying: function (value) {
setOption('removeOldTaskAfterRetrying', value);
},
getConfirmTaskRemoval: function () {
return getOption('confirmTaskRemoval');
},
setConfirmTaskRemoval: function (value) {
setOption('confirmTaskRemoval', value);
},
getAfterRetryingTask: function () {
return getOption('afterRetryingTask');
},
Expand Down
11 changes: 11 additions & 0 deletions src/views/settings-ariang.html
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,17 @@
</select>
</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="setting-key setting-key-without-desc col-sm-4">
<span translate>Import / Export AriaNg Settings</span>
Expand Down

0 comments on commit 06d6ee0

Please sign in to comment.