add removing old task after restart task option

This commit is contained in:
MaysWind 2017-11-04 00:15:19 +08:00
parent 34e299aaa7
commit 6f7e68b06a
8 changed files with 39 additions and 2 deletions

View file

@ -146,6 +146,7 @@ Are you sure you want to remove rpc setting "{{rpcName}}"?=您是否要删除 RP
Global Stat Refresh Interval=全局状态刷新间隔 Global Stat Refresh Interval=全局状态刷新间隔
Download Task Refresh Interval=下载任务刷新间隔 Download Task Refresh Interval=下载任务刷新间隔
Action After Creating New Tasks=创建新任务后执行操作 Action After Creating New Tasks=创建新任务后执行操作
Removing Old Task After Restarting=重试任务后删除原任务
Navigate to Task List Page=转到任务列表页面 Navigate to Task List Page=转到任务列表页面
Navigate to Task Detail Page=转到任务详情页面 Navigate to Task Detail Page=转到任务详情页面
Supported Placeholder=支持的占位符 Supported Placeholder=支持的占位符

View file

@ -146,6 +146,7 @@ Are you sure you want to remove rpc setting "{{rpcName}}"?=您是否要刪除 RP
Global Stat Refresh Interval=全局狀態刷新間隔 Global Stat Refresh Interval=全局狀態刷新間隔
Download Task Refresh Interval=下載任務刷新間隔 Download Task Refresh Interval=下載任務刷新間隔
Action After Creating New Tasks=創建新任務後執行操作 Action After Creating New Tasks=創建新任務後執行操作
Removing Old Task After Restarting=重試任務後刪除原任務
Navigate to Task List Page=轉到任務列表頁面 Navigate to Task List Page=轉到任務列表頁面
Navigate to Task Detail Page=轉到任務詳情頁面 Navigate to Task Detail Page=轉到任務詳情頁面
Supported Placeholder=支持的佔位符 Supported Placeholder=支持的佔位符

View file

@ -31,6 +31,7 @@
extendRpcServers: [], extendRpcServers: [],
globalStatRefreshInterval: 1000, globalStatRefreshInterval: 1000,
downloadTaskRefreshInterval: 1000, downloadTaskRefreshInterval: 1000,
afterCreatingNewTask: 'task-list' afterCreatingNewTask: 'task-list',
removeOldTaskAfterRestarting: false
}); });
}()); }());

View file

@ -150,6 +150,7 @@
'Global Stat Refresh Interval': 'Global Stat Refresh Interval', 'Global Stat Refresh Interval': 'Global Stat Refresh Interval',
'Download Task Refresh Interval': 'Download Task Refresh Interval', 'Download Task Refresh Interval': 'Download Task Refresh Interval',
'Action After Creating New Tasks': 'Action After Creating New Tasks', 'Action After Creating New Tasks': 'Action After Creating New Tasks',
'Removing Old Task After Restarting': 'Removing Old Task After Restarting',
'Navigate to Task List Page': 'Navigate to Task List Page', 'Navigate to Task List Page': 'Navigate to Task List Page',
'Navigate to Task Detail Page': 'Navigate to Task Detail Page', 'Navigate to Task Detail Page': 'Navigate to Task Detail Page',
'Supported Placeholder': 'Supported Placeholder', 'Supported Placeholder': 'Supported Placeholder',

View file

@ -108,6 +108,10 @@
ariaNgSettingService.setAfterCreatingNewTask(value); ariaNgSettingService.setAfterCreatingNewTask(value);
}; };
$scope.setRemoveOldTaskAfterRestarting = function (value) {
ariaNgSettingService.setRemoveOldTaskAfterRestarting(value);
};
$scope.setDebugMode = function (value) { $scope.setDebugMode = function (value) {
ariaNgSettingService.setDebugMode(value); ariaNgSettingService.setDebugMode(value);
}; };

View file

@ -1,7 +1,7 @@
(function () { (function () {
'use strict'; 'use strict';
angular.module('ariaNg').factory('aria2TaskService', ['$q', '$translate', 'bittorrentPeeridService', 'aria2Errors', 'aria2RpcService', 'ariaNgCommonService', 'ariaNgLogService', function ($q, $translate, bittorrentPeeridService, aria2Errors, aria2RpcService, ariaNgCommonService, ariaNgLogService) { angular.module('ariaNg').factory('aria2TaskService', ['$q', '$translate', 'bittorrentPeeridService', 'aria2Errors', 'aria2RpcService', 'ariaNgCommonService', 'ariaNgSettingService', 'ariaNgLogService', function ($q, $translate, bittorrentPeeridService, aria2Errors, aria2RpcService, ariaNgCommonService, ariaNgSettingService, ariaNgLogService) {
var getFileName = function (file) { var getFileName = function (file) {
if (!file) { if (!file) {
ariaNgLogService.warn('[aria2TaskService.getFileName] file is null'); ariaNgLogService.warn('[aria2TaskService.getFileName] file is null');
@ -534,6 +534,18 @@
return; return;
} }
if (ariaNgSettingService.getRemoveOldTaskAfterRestarting()) {
aria2RpcService.removeDownloadResult({
gid: gid,
silent: true,
callback: function (response) {
if (!response.success) {
ariaNgLogService.warn('[aria2TaskService.restartTask] removeDownloadResult response is not success');
}
}
});
}
deferred.resolve(response); deferred.resolve(response);
callback(response); callback(response);
} }

View file

@ -265,6 +265,12 @@
setAfterCreatingNewTask: function (value) { setAfterCreatingNewTask: function (value) {
setOption('afterCreatingNewTask', value); setOption('afterCreatingNewTask', value);
}, },
getRemoveOldTaskAfterRestarting: function () {
return getOption('removeOldTaskAfterRestarting');
},
setRemoveOldTaskAfterRestarting: function (value) {
setOption('removeOldTaskAfterRestarting', value);
},
getBrowserNotification: function () { getBrowserNotification: function () {
return getOption('browserNotification'); return getOption('browserNotification');
}, },

View file

@ -127,6 +127,17 @@
</select> </select>
</div> </div>
</div> </div>
<div class="row">
<div class="setting-key setting-key-without-desc col-sm-4">
<span translate>Removing Old Task After Restarting</span>
</div>
<div class="setting-value col-sm-8">
<select class="form-control" style="width: 100%;" ng-model="context.settings.removeOldTaskAfterRestarting"
ng-change="setRemoveOldTaskAfterRestarting(context.settings.removeOldTaskAfterRestarting)"
ng-options="option.value as (option.name | translate) for option in context.trueFalseOptions">
</select>
</div>
</div>
<div class="row tip no-background no-hover"> <div class="row tip no-background no-hover">
<span class="asterisk">*</span> <span class="asterisk">*</span>
<span translate>Changes to the settings take effect after refreshing page.</span> <span translate>Changes to the settings take effect after refreshing page.</span>