add select all failed tasks

This commit is contained in:
MaysWind 2019-04-07 14:23:56 +08:00
parent a6bbc37c5e
commit 74812e9ba6
6 changed files with 78 additions and 4 deletions

View file

@ -23,6 +23,7 @@ Delete=删除任务
Select All=全部选中
Select None=全部不选
Select Invert=反向选择
Select All Failed Task=全选失败任务
Display Order=显示顺序
Copy Download Url=复制下载链接
Copy Magnet Link=复制磁力链接

View file

@ -23,6 +23,7 @@ Delete=刪除工作
Select All=全部選中
Select None=全部不選
Select Invert=反向選擇
Select All Failed Task=全選失敗工作
Display Order=顯示順序
Copy Download Url=複製下載連結
Copy Magnet Link=複製磁力連結

View file

@ -27,6 +27,7 @@
'Select All': 'Select All',
'Select None': 'Select None',
'Select Invert': 'Select Invert',
'Select All Failed Task': 'Select All Failed Task',
'Display Order': 'Display Order',
'Copy Download Url': 'Copy Download Url',
'Copy Magnet Link': 'Copy Magnet Link',

View file

@ -197,8 +197,8 @@
});
};
$scope.isTaskRetryable = function (task) {
return task && task.status === 'error' && task.errorDescription && !task.bittorrent;
$scope.hasRetryableTask = function () {
return $rootScope.taskContext.hasRetryableTask();
};
$scope.isSelectedTaskRetryable = function () {
@ -209,7 +209,7 @@
}
for (var i = 0; i < selectedTasks.length; i++) {
if (!$scope.isTaskRetryable(selectedTasks[i])) {
if (!$rootScope.isTaskRetryable(selectedTasks[i])) {
return false;
}
}
@ -230,7 +230,7 @@
var skipCount = 0;
for (var i = 0; i < tasks.length; i++) {
if ($scope.isTaskRetryable(tasks[i])) {
if ($rootScope.isTaskRetryable(tasks[i])) {
retryableTasks.push(tasks[i]);
} else {
skipCount++;
@ -322,6 +322,10 @@
$rootScope.taskContext.selectAll();
};
$scope.selectAllFailedTasks = function () {
$rootScope.taskContext.selectAllFailed();
};
$scope.copySelectedOneTaskDownloadLink = function () {
var selectedTasks = $rootScope.taskContext.getSelectedTasks();

View file

@ -151,6 +151,21 @@
return isAllSelected;
},
hasRetryableTask: function () {
for (var i = 0; i < this.list.length; i++) {
var task = this.list[i];
if (!$rootScope.filterTask(task)) {
continue;
}
if ($rootScope.isTaskRetryable(task)) {
return true;
}
}
return false;
},
selectAll: function () {
if (!this.list || !this.selected || this.list.length < 1) {
return;
@ -171,6 +186,48 @@
this.selected[task.gid] = !isAllSelected;
}
},
selectAllFailed: function () {
if (!this.list || !this.selected || this.list.length < 1) {
return;
}
if (!this.enableSelectAll) {
return;
}
var isAllFailedSelected = true;
for (var i = 0; i < this.list.length; i++) {
var task = this.list[i];
if (!$rootScope.filterTask(task)) {
continue;
}
if (!$rootScope.isTaskRetryable(task)) {
continue;
}
if (!this.selected[task.gid]) {
isAllFailedSelected = false;
}
}
for (var i = 0; i < this.list.length; i++) {
var task = this.list[i];
if (!$rootScope.filterTask(task)) {
continue;
}
if (!$rootScope.isTaskRetryable(task)) {
this.selected[task.gid] = false;
continue;
}
this.selected[task.gid] = !isAllFailedSelected;
}
}
};
@ -186,6 +243,10 @@
return (task.taskName.toLowerCase().indexOf($rootScope.searchContext.text.toLowerCase()) >= 0);
};
$rootScope.isTaskRetryable = function (task) {
return task && task.status === 'error' && task.errorDescription && !task.bittorrent;
};
$rootScope.swipeActions = {
leftSwipe: function () {
if (isSidebarShowInSmallScreen()) {

View file

@ -164,6 +164,12 @@
<span translate>Select All</span>
</a>
</li>
<li ng-if="hasRetryableTask()">
<a tabindex="-1" class="pointer-cursor" title="{{'Select All Failed Task' | translate}}" ng-click="selectAllFailedTasks()">
<i class="fa fa-fw"></i>
<span translate>Select All Failed Task</span>
</a>
</li>
<li class="divider" ng-if="isSingleUrlTaskSelected() || isSingleBittorrentHasInfoHashTaskSelected()"></li>
<li ng-if="isSingleUrlTaskSelected()">
<a tabindex="-1" class="pointer-cursor" title="{{'Copy Download Url' | translate}}" ng-click="copySelectedOneTaskDownloadLink()">