support select task files

This commit is contained in:
MaysWind 2016-06-06 23:15:46 +08:00
parent 75e420622d
commit 320165515c
3 changed files with 44 additions and 8 deletions

View file

@ -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;

View file

@ -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,

View file

@ -136,11 +136,12 @@
</div>
</div>
<div class="task-table-body">
<div class="row" ng-repeat="file in task.files | fileOrderBy: getFileListOrderType()">
<div class="row" ng-repeat="file in task.files | fileOrderBy: getFileListOrderType()" data-file-index="{{file.index}}">
<div class="col-sm-8">
<div class="checkbox checkbox-primary">
<input id="{{'file_' + $index}}" type="checkbox" ng-checked="file.selected == 'true'" disabled="disabled"/>
<label for="{{'file_' + $index}}" ng-bind="file.fileName"></label>
<input id="{{'file_' + file.index}}" type="checkbox" ng-disabled="!task || !task.files || task.files.length < 2 || (task.status != 'waiting' && task.status != 'paused')"
ng-model="file.selected" ng-change="setSelectedFile()"/>
<label for="{{'file_' + file.index}}" ng-bind="file.fileName"></label>
</div>
</div>
<div class="col-sm-2">