support retry multi tasks
This commit is contained in:
parent
65df41f3fd
commit
3645a4f540
|
@ -1,4 +1,5 @@
|
||||||
[global]
|
[global]
|
||||||
|
Operation Result=操作结果
|
||||||
Operation Succeeded=操作成功
|
Operation Succeeded=操作成功
|
||||||
{{name}} is connected={{name}} 已连接
|
{{name}} is connected={{name}} 已连接
|
||||||
Error=错误
|
Error=错误
|
||||||
|
@ -16,6 +17,7 @@ New=新建
|
||||||
Start=开始任务
|
Start=开始任务
|
||||||
Pause=暂停任务
|
Pause=暂停任务
|
||||||
Retry=重试
|
Retry=重试
|
||||||
|
Retry Selected Tasks=重试选中任务
|
||||||
Delete=删除任务
|
Delete=删除任务
|
||||||
Select All=全部选中
|
Select All=全部选中
|
||||||
Select None=全部不选
|
Select None=全部不选
|
||||||
|
@ -113,8 +115,9 @@ No Data=无数据
|
||||||
No connected peers=没有连接到其他节点
|
No connected peers=没有连接到其他节点
|
||||||
Failed to change some tasks state.=修改一些任务状态时失败.
|
Failed to change some tasks state.=修改一些任务状态时失败.
|
||||||
Confirm Retry=确认重试
|
Confirm Retry=确认重试
|
||||||
Are you sure you want to retry this task? AriaNg will create a same task after clicking OK.=您是否要重试这个任务? 点击 "确定" 后, AriaNg 将会创建一个相同的任务.
|
Are you sure you want to retry the selected task? AriaNg will create same task after clicking OK.=您是否要重试选中的任务? 点击 "确定" 后, AriaNg 将会创建相同的任务.
|
||||||
Failed to retry this task.=该任务重试失败.
|
Failed to retry this task.=该任务重试失败.
|
||||||
|
{{successCount}} tasks have been retried and {{failedCount}} tasks are failed.={{successCount}} 个任务重试成功以及 {{failedCount}} 个任务失败.
|
||||||
Confirm Remove=确认删除
|
Confirm Remove=确认删除
|
||||||
Are you sure you want to remove the selected task?=您是否要删除选中的任务?
|
Are you sure you want to remove the selected task?=您是否要删除选中的任务?
|
||||||
Failed to remove some task(s).=删除一些任务时失败.
|
Failed to remove some task(s).=删除一些任务时失败.
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
[global]
|
[global]
|
||||||
|
Operation Result=操作結果
|
||||||
Operation Succeeded=操作成功
|
Operation Succeeded=操作成功
|
||||||
{{name}} is connected={{name}} 已連線
|
{{name}} is connected={{name}} 已連線
|
||||||
Error=錯誤
|
Error=錯誤
|
||||||
|
@ -16,6 +17,7 @@ New=新增
|
||||||
Start=開始工作
|
Start=開始工作
|
||||||
Pause=暫停工作
|
Pause=暫停工作
|
||||||
Retry=重試
|
Retry=重試
|
||||||
|
Retry Selected Tasks=重試選中工作
|
||||||
Delete=刪除工作
|
Delete=刪除工作
|
||||||
Select All=全部選中
|
Select All=全部選中
|
||||||
Select None=全部不選
|
Select None=全部不選
|
||||||
|
@ -113,8 +115,9 @@ No Data=無資料
|
||||||
No connected peers=沒有連線到其他節點
|
No connected peers=沒有連線到其他節點
|
||||||
Failed to change some tasks state.=修改一些工作狀態時失敗.
|
Failed to change some tasks state.=修改一些工作狀態時失敗.
|
||||||
Confirm Retry=確認重試
|
Confirm Retry=確認重試
|
||||||
Are you sure you want to retry this task? AriaNg will create a same task after clicking OK.=您是否要重試這個工作? 點選 "確定" 後, AriaNg 將會建立一個相同的工作.
|
Are you sure you want to retry the selected task? AriaNg will create same task after clicking OK.=您是否要重試選中的工作? 點選 "確定" 後, AriaNg 將會建立相同的工作.
|
||||||
Failed to retry this task.=該工作重試失敗.
|
Failed to retry this task.=該工作重試失敗.
|
||||||
|
{{successCount}} tasks have been retried and {{failedCount}} tasks are failed.={{successCount}} 个工作重試成功以及 {{failedCount}} 个工作失敗.
|
||||||
Confirm Remove=確認刪除
|
Confirm Remove=確認刪除
|
||||||
Are you sure you want to remove the selected task?=您是否要刪除選中的工作?
|
Are you sure you want to remove the selected task?=您是否要刪除選中的工作?
|
||||||
Failed to remove some task(s).=刪除一些工作時失敗.
|
Failed to remove some task(s).=刪除一些工作時失敗.
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
|
|
||||||
angular.module('ariaNg').config(['$translateProvider', 'ariaNgConstants', function ($translateProvider, ariaNgConstants) {
|
angular.module('ariaNg').config(['$translateProvider', 'ariaNgConstants', function ($translateProvider, ariaNgConstants) {
|
||||||
var defaultLanguageResource = {
|
var defaultLanguageResource = {
|
||||||
|
'Operation Result': 'Operation Result',
|
||||||
'Operation Succeeded': 'Operation Succeeded',
|
'Operation Succeeded': 'Operation Succeeded',
|
||||||
'{{name}} is connected': '{{name}} is connected',
|
'{{name}} is connected': '{{name}} is connected',
|
||||||
'Error': 'Error',
|
'Error': 'Error',
|
||||||
|
@ -20,6 +21,7 @@
|
||||||
'Start': 'Start',
|
'Start': 'Start',
|
||||||
'Pause': 'Pause',
|
'Pause': 'Pause',
|
||||||
'Retry': 'Retry',
|
'Retry': 'Retry',
|
||||||
|
'Retry Selected Tasks': 'Retry Selected Tasks',
|
||||||
'Delete': 'Delete',
|
'Delete': 'Delete',
|
||||||
'Select All': 'Select All',
|
'Select All': 'Select All',
|
||||||
'Select None': 'Select None',
|
'Select None': 'Select None',
|
||||||
|
@ -117,8 +119,9 @@
|
||||||
'No connected peers': 'No connected peers',
|
'No connected peers': 'No connected peers',
|
||||||
'Failed to change some tasks state.': 'Failed to change some tasks state.',
|
'Failed to change some tasks state.': 'Failed to change some tasks state.',
|
||||||
'Confirm Retry': 'Confirm Retry',
|
'Confirm Retry': 'Confirm Retry',
|
||||||
'Are you sure you want to retry this task? AriaNg will create a same task after clicking OK.': 'Are you sure you want to retry this task? AriaNg will create a same task after clicking OK.',
|
'Are you sure you want to retry the selected task? AriaNg will create same task after clicking OK.': 'Are you sure you want to retry the selected task? AriaNg will create same task after clicking OK.',
|
||||||
'Failed to retry this task.': 'Failed to retry this task.',
|
'Failed to retry this task.': 'Failed to retry this task.',
|
||||||
|
'{{successCount}} tasks have been retried and {{failedCount}} tasks are failed.': '{{successCount}} tasks have been retried and {{failedCount}} tasks are failed.',
|
||||||
'Confirm Remove': 'Confirm Remove',
|
'Confirm Remove': 'Confirm Remove',
|
||||||
'Are you sure you want to remove the selected task?': 'Are you sure you want to remove the selected task?',
|
'Are you sure you want to remove the selected task?': 'Are you sure you want to remove the selected task?',
|
||||||
'Failed to remove some task(s).': 'Failed to remove some task(s).',
|
'Failed to remove some task(s).': 'Failed to remove some task(s).',
|
||||||
|
|
|
@ -139,7 +139,7 @@
|
||||||
};
|
};
|
||||||
|
|
||||||
$scope.retryTask = function (task) {
|
$scope.retryTask = function (task) {
|
||||||
ariaNgLocalizationService.confirm('Confirm Retry', 'Are you sure you want to retry this task? AriaNg will create a same task after clicking OK.', 'info', function () {
|
ariaNgLocalizationService.confirm('Confirm Retry', 'Are you sure you want to retry the selected task? AriaNg will create same task after clicking OK.', 'info', function () {
|
||||||
$rootScope.loadPromise = aria2TaskService.retryTask(task.gid, function (response) {
|
$rootScope.loadPromise = aria2TaskService.retryTask(task.gid, function (response) {
|
||||||
if (!response.success) {
|
if (!response.success) {
|
||||||
ariaNgLocalizationService.showError('Failed to retry this task.');
|
ariaNgLocalizationService.showError('Failed to retry this task.');
|
||||||
|
@ -167,6 +167,75 @@
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
$scope.isTaskRetryable = function (task) {
|
||||||
|
return task && task.status === 'error' && task.errorDescription && !task.bittorrent;
|
||||||
|
};
|
||||||
|
|
||||||
|
$scope.isSelectedTaskRetryable = function () {
|
||||||
|
var selectedTasks = $rootScope.taskContext.getSelectedTasks();
|
||||||
|
|
||||||
|
if (selectedTasks.length < 1) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (var i = 0; i < selectedTasks.length; i++) {
|
||||||
|
if (!$scope.isTaskRetryable(selectedTasks[i])) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
};
|
||||||
|
|
||||||
|
$scope.retryTasks = function () {
|
||||||
|
var tasks = $rootScope.taskContext.getSelectedTasks();
|
||||||
|
|
||||||
|
if (!tasks || tasks.length < 1) {
|
||||||
|
return;
|
||||||
|
} else if (tasks.length === 1) {
|
||||||
|
return $scope.retryTask(tasks[0]);
|
||||||
|
}
|
||||||
|
|
||||||
|
var retryableTasks = [];
|
||||||
|
var skipCount = 0;
|
||||||
|
|
||||||
|
for (var i = 0; i < tasks.length; i++) {
|
||||||
|
if ($scope.isTaskRetryable(tasks[i])) {
|
||||||
|
retryableTasks.push(tasks[i]);
|
||||||
|
} else {
|
||||||
|
skipCount++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ariaNgLocalizationService.confirm('Confirm Retry', 'Are you sure you want to retry the selected task? AriaNg will create same task after clicking OK.', 'info', function () {
|
||||||
|
$rootScope.loadPromise = aria2TaskService.retryTasks(retryableTasks, function (response) {
|
||||||
|
refreshGlobalStat(true);
|
||||||
|
|
||||||
|
ariaNgLocalizationService.showInfo('Operation Result', '{{successCount}} tasks have been retried and {{failedCount}} tasks are failed.', function () {
|
||||||
|
var actionAfterRetryingTask = ariaNgSettingService.getAfterRetryingTask();
|
||||||
|
|
||||||
|
if (response.hasSuccess) {
|
||||||
|
if (actionAfterRetryingTask === 'task-list-downloading') {
|
||||||
|
if ($location.path() !== '/downloading') {
|
||||||
|
$location.path('/downloading');
|
||||||
|
} else {
|
||||||
|
$route.reload();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$route.reload();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}, {
|
||||||
|
textParams: {
|
||||||
|
successCount: response.successCount,
|
||||||
|
failedCount: response.failedCount,
|
||||||
|
skipCount: skipCount
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}, false);
|
||||||
|
}, true);
|
||||||
|
};
|
||||||
|
|
||||||
$scope.removeTasks = function () {
|
$scope.removeTasks = function () {
|
||||||
var tasks = $rootScope.taskContext.getSelectedTasks();
|
var tasks = $rootScope.taskContext.getSelectedTasks();
|
||||||
|
|
||||||
|
|
|
@ -720,6 +720,63 @@
|
||||||
|
|
||||||
return deferred.promise;
|
return deferred.promise;
|
||||||
},
|
},
|
||||||
|
retryTasks: function (tasks, callback, silent) {
|
||||||
|
if (!callback) {
|
||||||
|
ariaNgLogService.warn('[aria2TaskService.retryTasks] callback is null');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var retryTaskFunc = this.retryTask;
|
||||||
|
|
||||||
|
var deferred = $q.defer();
|
||||||
|
var lastPromise = null;
|
||||||
|
|
||||||
|
var successCount = 0;
|
||||||
|
var failedCount = 0;
|
||||||
|
|
||||||
|
var doRetryFunc = function (task, index) {
|
||||||
|
return retryTaskFunc(task.gid, function (response) {
|
||||||
|
ariaNgLogService.debug('[aria2TaskService.retryTasks] task#' + index + ', gid=' + task.gid + ', result=' + response.success, task);
|
||||||
|
|
||||||
|
if (response.success) {
|
||||||
|
successCount++;
|
||||||
|
} else {
|
||||||
|
failedCount++;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((successCount + failedCount) === tasks.length) {
|
||||||
|
var finalResponse = {
|
||||||
|
successCount: successCount,
|
||||||
|
failedCount: failedCount,
|
||||||
|
hasSuccess: successCount > 0,
|
||||||
|
hasError: failedCount > 0
|
||||||
|
};
|
||||||
|
|
||||||
|
deferred.resolve(finalResponse);
|
||||||
|
callback(finalResponse);
|
||||||
|
}
|
||||||
|
}, silent);
|
||||||
|
};
|
||||||
|
|
||||||
|
for (var i = 0; i < tasks.length; i++) {
|
||||||
|
var task = tasks[i];
|
||||||
|
var currentPromise = null;
|
||||||
|
|
||||||
|
if (!lastPromise) {
|
||||||
|
currentPromise = doRetryFunc(task, i);
|
||||||
|
} else {
|
||||||
|
currentPromise = (function (task, index) {
|
||||||
|
return lastPromise.then(function () {
|
||||||
|
return doRetryFunc(task, index);
|
||||||
|
});
|
||||||
|
})(task, i);
|
||||||
|
}
|
||||||
|
|
||||||
|
lastPromise = currentPromise;
|
||||||
|
}
|
||||||
|
|
||||||
|
return deferred.promise;
|
||||||
|
},
|
||||||
removeTasks: function (tasks, callback, silent) {
|
removeTasks: function (tasks, callback, silent) {
|
||||||
var runningTaskGids = [];
|
var runningTaskGids = [];
|
||||||
var stoppedTaskGids = [];
|
var stoppedTaskGids = [];
|
||||||
|
|
|
@ -15,20 +15,25 @@
|
||||||
getLongDateFormat: function () {
|
getLongDateFormat: function () {
|
||||||
return this.getLocalizedText('format.longdate');
|
return this.getLocalizedText('format.longdate');
|
||||||
},
|
},
|
||||||
showDialog: function (title, text, type, callback) {
|
showDialog: function (title, text, type, callback, extendSettings) {
|
||||||
|
if (!extendSettings) {
|
||||||
|
extendSettings = {};
|
||||||
|
}
|
||||||
|
|
||||||
if (title) {
|
if (title) {
|
||||||
title = this.getLocalizedText(title);
|
title = this.getLocalizedText(title);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (text) {
|
if (text) {
|
||||||
text = this.getLocalizedText(text);
|
text = this.getLocalizedText(text, extendSettings.textParams);
|
||||||
}
|
}
|
||||||
|
|
||||||
var options = {
|
extendSettings.confirmButtonText = this.getLocalizedText('OK');
|
||||||
confirmButtonText: this.getLocalizedText('OK')
|
|
||||||
};
|
|
||||||
|
|
||||||
ariaNgCommonService.showDialog(title, text, type, callback, options);
|
ariaNgCommonService.showDialog(title, text, type, callback, extendSettings);
|
||||||
|
},
|
||||||
|
showInfo: function (title, text, callback, extendSettings) {
|
||||||
|
this.showDialog(title, text, 'info', callback, extendSettings);
|
||||||
},
|
},
|
||||||
showError: function (text, callback) {
|
showError: function (text, callback) {
|
||||||
this.showDialog('Error', text, 'error', callback);
|
this.showDialog('Error', text, 'error', callback);
|
||||||
|
|
|
@ -48,7 +48,7 @@
|
||||||
<a ng-href="#!/task/detail/{{task.gid}}" title="{{'Click to view task detail' | translate}}">
|
<a ng-href="#!/task/detail/{{task.gid}}" title="{{'Click to view task detail' | translate}}">
|
||||||
<span ng-if="task.files" ng-bind="('format.settings.file-count' | translate: {count: task.selectedFileCount})"></span>
|
<span ng-if="task.files" ng-bind="('format.settings.file-count' | translate: {count: task.selectedFileCount})"></span>
|
||||||
</a><i class="icon-error fa fa-times" ng-if="task && task.status === 'error' && task.errorDescription" title="{{task.errorDescription | translate}}"></i><i class="icon-seeder fa fa-arrow-up" ng-if="task && task.status === 'active' && task.seeder" title="{{'Seeding' | translate}}"></i>
|
</a><i class="icon-error fa fa-times" ng-if="task && task.status === 'error' && task.errorDescription" title="{{task.errorDescription | translate}}"></i><i class="icon-seeder fa fa-arrow-up" ng-if="task && task.status === 'active' && task.seeder" title="{{'Seeding' | translate}}"></i>
|
||||||
<a ng-if="task && task.status === 'error' && task.errorDescription && !task.bittorrent" ng-click="retryTask(task)" title="{{'Retry' | translate}}" translate>Retry</a>
|
<a ng-if="isTaskRetryable(task)" ng-click="retryTask(task)" title="{{'Retry' | translate}}" translate>Retry</a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-md-2 col-sm-3 col-xs-12">
|
<div class="col-md-2 col-sm-3 col-xs-12">
|
||||||
|
@ -76,6 +76,13 @@
|
||||||
</div>
|
</div>
|
||||||
<div id="task-table-contextmenu">
|
<div id="task-table-contextmenu">
|
||||||
<ul class="dropdown-menu" role="menu">
|
<ul class="dropdown-menu" role="menu">
|
||||||
|
<li ng-if="isSelectedTaskRetryable()">
|
||||||
|
<a tabindex="-1" class="pointer-cursor" title="{{'Retry Selected Tasks' | translate}}" ng-click="retryTasks()">
|
||||||
|
<i class="fa fa-refresh"></i>
|
||||||
|
<span translate>Retry Selected Tasks</span>
|
||||||
|
</a>
|
||||||
|
</li>
|
||||||
|
<li class="divider" ng-if="isSelectedTaskRetryable()"></li>
|
||||||
<li ng-if="isSpecifiedTaskSelected('paused')">
|
<li ng-if="isSpecifiedTaskSelected('paused')">
|
||||||
<a tabindex="-1" class="pointer-cursor" title="{{'Start' | translate}}" ng-click="changeTasksState('start')">
|
<a tabindex="-1" class="pointer-cursor" title="{{'Start' | translate}}" ng-click="changeTasksState('start')">
|
||||||
<i class="fa fa-play"></i>
|
<i class="fa fa-play"></i>
|
||||||
|
|
Reference in a new issue