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(); 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) { $scope.loadTaskOption = function (task) {
$rootScope.loadPromise = aria2TaskService.getTaskOptions(task.gid, function (result) { $rootScope.loadPromise = aria2TaskService.getTaskOptions(task.gid, function (result) {
$scope.options = result; $scope.options = result;

View file

@ -70,6 +70,7 @@
var file = task.files[i]; var file = task.files[i];
file.fileName = getFileNameFromPath(file.path); file.fileName = getFileNameFromPath(file.path);
file.length = parseInt(file.length); file.length = parseInt(file.length);
file.selected = (file.selected == 'true');
file.completedLength = parseInt(file.completedLength); file.completedLength = parseInt(file.completedLength);
file.completePercent = (file.length > 0 ? file.completedLength / file.length * 100 : 0); file.completePercent = (file.length > 0 ? file.completedLength / file.length * 100 : 0);
} }
@ -150,6 +151,19 @@
callback: callback 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) { getBtTaskPeers: function (gid, callback, silent) {
return aria2RpcService.getPeers({ return aria2RpcService.getPeers({
gid: gid, gid: gid,

View file

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