diff --git a/app/scripts/controllers/task-detail.js b/app/scripts/controllers/task-detail.js index 5617f54..3417035 100644 --- a/app/scripts/controllers/task-detail.js +++ b/app/scripts/controllers/task-detail.js @@ -102,6 +102,27 @@ return ariaNgSettingService.getFileListDisplayOrder(); }; + $scope.setSelectedFile = function () { + if (!$scope.task || !$scope.task.files) { + return; + } + + var gid = $scope.task.gid; + var selectedFileIndex = []; + + for (var i = 0; i < $scope.task.files.length; i++) { + var file = $scope.task.files[i]; + + if (file && file.selected) { + selectedFileIndex.push(file.index); + } + } + + return aria2TaskService.selectTaskFile(gid, selectedFileIndex, function () { + refreshDownloadTask(false); + }); + }; + $scope.loadTaskOption = function (task) { $rootScope.loadPromise = aria2TaskService.getTaskOptions(task.gid, function (result) { $scope.options = result; diff --git a/app/scripts/services/aria2TaskService.js b/app/scripts/services/aria2TaskService.js index 741426d..c2d98f8 100644 --- a/app/scripts/services/aria2TaskService.js +++ b/app/scripts/services/aria2TaskService.js @@ -70,6 +70,7 @@ var file = task.files[i]; file.fileName = getFileNameFromPath(file.path); file.length = parseInt(file.length); + file.selected = (file.selected == 'true'); file.completedLength = parseInt(file.completedLength); file.completePercent = (file.length > 0 ? file.completedLength / file.length * 100 : 0); } @@ -150,6 +151,19 @@ callback: callback }); }, + selectTaskFile: function (gid, selectedFileIndexArr, callback) { + var selectedFileIndex = ''; + + for (var i = 0; i < selectedFileIndexArr.length; i++) { + if (selectedFileIndex.length > 0) { + selectedFileIndex += ','; + } + + selectedFileIndex += selectedFileIndexArr[i]; + } + + return this.setTaskOption(gid, 'select-file', selectedFileIndex, callback); + }, getBtTaskPeers: function (gid, callback, silent) { return aria2RpcService.getPeers({ gid: gid, @@ -185,7 +199,7 @@ removeTasks: function (tasks, callback) { var runningTaskGids = []; var stoppedTaskGids = []; - + for (var i = 0; i < tasks.length; i++) { if (tasks[i].status == 'complete' || tasks[i].status == 'error' || tasks[i].status == 'removed') { stoppedTaskGids.push(tasks[i].gid); @@ -193,13 +207,13 @@ runningTaskGids.push(tasks[i].gid); } } - + var promises = []; var results = { - runningResult: null, + runningResult: null, stoppedResult: null }; - + if (runningTaskGids.length > 0) { promises.push(aria2RpcService.forceRemoveMulti({ gids: runningTaskGids, @@ -208,7 +222,7 @@ } })); } - + if (stoppedTaskGids.length > 0) { promises.push(aria2RpcService.removeDownloadResultMulti({ gids: stoppedTaskGids, diff --git a/app/views/task-detail.html b/app/views/task-detail.html index d2442ef..e86212f 100644 --- a/app/views/task-detail.html +++ b/app/views/task-detail.html @@ -136,11 +136,12 @@
-
+
- - + +