support select file by file type in task detail page
This commit is contained in:
parent
1d5b8a6ee1
commit
e581a16724
|
@ -3,12 +3,15 @@
|
|||
"Operation Succeeded": "操作成功",
|
||||
"Error": "错误",
|
||||
"OK": "确定",
|
||||
"Confirm": "确认",
|
||||
"Cancel": "取消",
|
||||
"New": "新建",
|
||||
"Start": "开始下载任务",
|
||||
"Pause": "暂停下载任务",
|
||||
"Delete": "删除下载任务",
|
||||
"Select All": "全选",
|
||||
"Select None": "不选",
|
||||
"Select Invert": "反选",
|
||||
"Display Order": "显示顺序",
|
||||
"Search": "搜索",
|
||||
"Default": "默认",
|
||||
|
@ -64,6 +67,13 @@
|
|||
"Connections": "连接数",
|
||||
"Seed Creation Time": "种子创建时间",
|
||||
"Download Dir": "下载路径",
|
||||
"(Choose Files)": "(选择文件)",
|
||||
"Videos": "视频",
|
||||
"Audios": "音频",
|
||||
"Pictures": "图片",
|
||||
"Documents": "文档",
|
||||
"Applications": "应用程序",
|
||||
"Archives": "存档文件",
|
||||
"Address": "地址",
|
||||
"Status": "状态",
|
||||
"Percent": "完成度",
|
||||
|
|
|
@ -9,6 +9,103 @@
|
|||
taskStatStorageCapacity: 300,
|
||||
lazySaveTimeout: 500,
|
||||
errorTooltipDelay: 200
|
||||
}).constant('ariaNgFileTypes', {
|
||||
video: [
|
||||
'.3gp',
|
||||
'.3gpp',
|
||||
'.asf',
|
||||
'.asx',
|
||||
'.avi',
|
||||
'.dat',
|
||||
'.flv',
|
||||
'.m4v',
|
||||
'.mkv',
|
||||
'.mov',
|
||||
'.mp4',
|
||||
'.mpe',
|
||||
'.mpeg',
|
||||
'.mpg',
|
||||
'.rm',
|
||||
'.rmvb',
|
||||
'.vob',
|
||||
'.wmv'
|
||||
],
|
||||
audio: [
|
||||
'.aac',
|
||||
'.amr',
|
||||
'.ape',
|
||||
'.flac',
|
||||
'.m4a',
|
||||
'.mid',
|
||||
'.mp3',
|
||||
'.ogg',
|
||||
'.ra',
|
||||
'.vqf',
|
||||
'.wav',
|
||||
'.wma'
|
||||
],
|
||||
picture: [
|
||||
'.bmp',
|
||||
'.emf',
|
||||
'.gif',
|
||||
'.jp2',
|
||||
'.jpeg',
|
||||
'.jpg',
|
||||
'.png',
|
||||
'.psd',
|
||||
'.raw',
|
||||
'.tga',
|
||||
'.tif',
|
||||
'.tiff',
|
||||
'.wmf'
|
||||
],
|
||||
document: [
|
||||
'.doc',
|
||||
'.docx',
|
||||
'.key',
|
||||
'.numbers',
|
||||
'.odp',
|
||||
'.ods',
|
||||
'.odt',
|
||||
'.pages',
|
||||
'.pdf',
|
||||
'.ppt',
|
||||
'.pptx',
|
||||
'.rtf',
|
||||
'.txt',
|
||||
'.vsd',
|
||||
'.vsdx',
|
||||
'.wps',
|
||||
'.xls',
|
||||
'.xlsx'
|
||||
],
|
||||
application: [
|
||||
'.apk',
|
||||
'.bat',
|
||||
'.com',
|
||||
'.deb',
|
||||
'.dll',
|
||||
'.dmg',
|
||||
'.exe',
|
||||
'.ipa',
|
||||
'.jar',
|
||||
'.rpm',
|
||||
'.sh'
|
||||
],
|
||||
archive: [
|
||||
'.7z',
|
||||
'.arj',
|
||||
'.bz2',
|
||||
'.cab',
|
||||
'.gz',
|
||||
'.iso',
|
||||
'.r',
|
||||
'.rar',
|
||||
'.tar',
|
||||
'.tar',
|
||||
'.z',
|
||||
'.zip'
|
||||
]
|
||||
}).constant('ariaNgDefaultOptions', {
|
||||
language: 'en',
|
||||
rpcHost: '',
|
||||
|
|
|
@ -7,12 +7,15 @@
|
|||
'Operation Succeeded': 'Operation Succeeded',
|
||||
'Error': 'Error',
|
||||
'OK': 'OK',
|
||||
'Confirm': 'Confirm',
|
||||
'Cancel': 'Cancel',
|
||||
'New': 'New',
|
||||
'Start': 'Start',
|
||||
'Pause': 'Pause',
|
||||
'Delete': 'Delete',
|
||||
'Select All': 'Select All',
|
||||
'Select None': 'Select None',
|
||||
'Select Invert': 'Select Invert',
|
||||
'Display Order': 'Display Order',
|
||||
'Search': 'Search',
|
||||
'Default': 'Default',
|
||||
|
@ -68,6 +71,13 @@
|
|||
'Connections': 'Connections',
|
||||
'Seed Creation Time': 'Seed Creation Time',
|
||||
'Download Dir': 'Download Dir',
|
||||
'(Choose Files)': '(Choose Files)',
|
||||
'Videos': 'Videos',
|
||||
'Audios': 'Audios',
|
||||
'Pictures': 'Pictures',
|
||||
'Documents': 'Documents',
|
||||
'Applications': 'Applications',
|
||||
'Archives': 'Archives',
|
||||
'Address': 'Address',
|
||||
'Status': 'Status',
|
||||
'Percent': 'Percent',
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
(function () {
|
||||
'use strict';
|
||||
|
||||
angular.module('ariaNg').controller('TaskDetailController', ['$rootScope', '$scope', '$routeParams', '$interval', 'aria2RpcErrors', 'ariaNgCommonService', 'ariaNgSettingService', 'ariaNgMonitorService', 'aria2TaskService', 'aria2SettingService', function ($rootScope, $scope, $routeParams, $interval, aria2RpcErrors, ariaNgCommonService, ariaNgSettingService, ariaNgMonitorService, aria2TaskService, aria2SettingService) {
|
||||
angular.module('ariaNg').controller('TaskDetailController', ['$rootScope', '$scope', '$routeParams', '$interval', 'aria2RpcErrors', 'ariaNgFileTypes', 'ariaNgCommonService', 'ariaNgSettingService', 'ariaNgMonitorService', 'aria2TaskService', 'aria2SettingService', function ($rootScope, $scope, $routeParams, $interval, aria2RpcErrors, ariaNgFileTypes, ariaNgCommonService, ariaNgSettingService, ariaNgMonitorService, aria2TaskService, aria2SettingService) {
|
||||
var tabOrders = ['overview', 'blocks', 'filelist', 'btpeers'];
|
||||
var downloadTaskRefreshPromise = null;
|
||||
var pauseDownloadTaskRefresh = false;
|
||||
|
@ -74,8 +74,36 @@
|
|||
}, silent);
|
||||
};
|
||||
|
||||
var setSelectFiles = function (silent) {
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
pauseDownloadTaskRefresh = true;
|
||||
|
||||
return aria2TaskService.selectTaskFile(gid, selectedFileIndex, function (response) {
|
||||
pauseDownloadTaskRefresh = false;
|
||||
|
||||
if (response.success) {
|
||||
refreshDownloadTask(false);
|
||||
}
|
||||
}, silent);
|
||||
};
|
||||
|
||||
$scope.context = {
|
||||
currentTab: 'overview',
|
||||
showChooseFilesToolbar: false,
|
||||
btPeers: [],
|
||||
healthPercent: 0,
|
||||
statusData: ariaNgMonitorService.getEmptyStatsData($routeParams.gid),
|
||||
|
@ -135,31 +163,83 @@
|
|||
return ariaNgSettingService.getFileListDisplayOrder();
|
||||
};
|
||||
|
||||
$scope.setSelectedFile = function () {
|
||||
$scope.showChooseFilesToolbar = function () {
|
||||
pauseDownloadTaskRefresh = true;
|
||||
$scope.context.showChooseFilesToolbar = true;
|
||||
};
|
||||
|
||||
$scope.getSelectedFileCount = function () {
|
||||
var count = 0;
|
||||
|
||||
for (var i = 0; i < $scope.task.files.length; i++) {
|
||||
count += $scope.task.files[i].selected ? 1 : 0;
|
||||
}
|
||||
|
||||
return count;
|
||||
};
|
||||
|
||||
$scope.selectFiles = function (type) {
|
||||
if (!$scope.task || !$scope.task.files) {
|
||||
return;
|
||||
}
|
||||
|
||||
var gid = $scope.task.gid;
|
||||
var selectedFileIndex = [];
|
||||
for (var i = 0; i < $scope.task.files.length; i++) {
|
||||
if (type == 'all') {
|
||||
$scope.task.files[i].selected = true;
|
||||
} else if (type == 'none') {
|
||||
$scope.task.files[i].selected = false;
|
||||
} else if (type == 'reverse') {
|
||||
$scope.task.files[i].selected = !$scope.task.files[i].selected;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
$scope.chooseSpecifiedFiles = function (type) {
|
||||
if (!$scope.task || !$scope.task.files || !ariaNgFileTypes[type]) {
|
||||
return;
|
||||
}
|
||||
|
||||
var extensions = ariaNgFileTypes[type];
|
||||
var fileIndexes = [];
|
||||
var isAllSelected = true;
|
||||
|
||||
for (var i = 0; i < $scope.task.files.length; i++) {
|
||||
var file = $scope.task.files[i];
|
||||
var extension = ariaNgCommonService.getFileExtension($scope.task.files[i].fileName);
|
||||
|
||||
if (file && file.selected) {
|
||||
selectedFileIndex.push(file.index);
|
||||
if (extensions.indexOf(extension) >= 0) {
|
||||
fileIndexes.push(i);
|
||||
|
||||
if (!$scope.task.files[i].selected) {
|
||||
isAllSelected = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pauseDownloadTaskRefresh = true;
|
||||
for (var i = 0; i < fileIndexes.length; i++) {
|
||||
var index = fileIndexes[i];
|
||||
$scope.task.files[index].selected = !isAllSelected;
|
||||
}
|
||||
};
|
||||
|
||||
return aria2TaskService.selectTaskFile(gid, selectedFileIndex, function (response) {
|
||||
$scope.saveChoosedFiles = function () {
|
||||
if ($scope.context.showChooseFilesToolbar) {
|
||||
$rootScope.loadPromise = setSelectFiles(false);
|
||||
$scope.context.showChooseFilesToolbar = false;
|
||||
}
|
||||
};
|
||||
|
||||
$scope.cancelChooseFiles = function () {
|
||||
if ($scope.context.showChooseFilesToolbar) {
|
||||
pauseDownloadTaskRefresh = false;
|
||||
|
||||
if (response.success) {
|
||||
refreshDownloadTask(false);
|
||||
refreshDownloadTask(true);
|
||||
$scope.context.showChooseFilesToolbar = false;
|
||||
}
|
||||
};
|
||||
|
||||
$scope.setSelectedFile = function () {
|
||||
if (!$scope.context.showChooseFilesToolbar) {
|
||||
setSelectFiles(true);
|
||||
}
|
||||
}, true);
|
||||
};
|
||||
|
||||
$scope.changePeerListDisplayOrder = function (type, autoSetReverse) {
|
||||
|
|
|
@ -51,6 +51,13 @@
|
|||
}
|
||||
});
|
||||
},
|
||||
getFileExtension: function (filePath) {
|
||||
if (!filePath || filePath.lastIndexOf('.') < 0) {
|
||||
return filePath;
|
||||
}
|
||||
|
||||
return filePath.substring(filePath.lastIndexOf('.'));
|
||||
},
|
||||
extendArray: function (sourceArray, targetArray, keyProperty) {
|
||||
if (!targetArray || !sourceArray || sourceArray.length != targetArray.length) {
|
||||
return false;
|
||||
|
|
|
@ -157,6 +157,7 @@
|
|||
<div class="col-sm-8">
|
||||
<a ng-click="changeFileListDisplayOrder('name:asc', true)" translate>File Name</a>
|
||||
<i class="fa" ng-class="{'fa-sort-asc fa-order-asc': isSetFileListDisplayOrder('name:asc'), 'fa-sort-desc fa-order-desc': isSetFileListDisplayOrder('name:desc')}"></i>
|
||||
<a ng-click="showChooseFilesToolbar()" ng-if="task && (task.status == 'waiting' || task.status == 'paused')" translate>(Choose Files)</a>
|
||||
</div>
|
||||
<div class="col-sm-2">
|
||||
<a ng-click="changeFileListDisplayOrder('percent:desc', true)" translate>Completed Percent</a>
|
||||
|
@ -168,6 +169,41 @@
|
|||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="task-table-title" ng-if="context.showChooseFilesToolbar">
|
||||
<div class="row">
|
||||
<div class="col-sm-12">
|
||||
<button class="btn btn-xs btn-primary" ng-click="selectFiles('all')" translate>Select All</button>
|
||||
<button class="btn btn-xs btn-primary" ng-click="selectFiles('none')" translate>Select None</button>
|
||||
<button class="btn btn-xs btn-primary" ng-click="selectFiles('reverse')" translate>Select Invert</button>
|
||||
<button class="btn btn-xs btn-default" ng-click="chooseSpecifiedFiles('video')">
|
||||
<i class="fa fa-file-video-o"></i>
|
||||
<span translate>Videos</span>
|
||||
</button>
|
||||
<button class="btn btn-xs btn-default" ng-click="chooseSpecifiedFiles('audio')">
|
||||
<i class="fa fa-file-audio-o"></i>
|
||||
<span translate>Audios</span>
|
||||
</button>
|
||||
<button class="btn btn-xs btn-default" ng-click="chooseSpecifiedFiles('picture')">
|
||||
<i class="fa fa-file-picture-o"></i>
|
||||
<span translate>Pictures</span>
|
||||
</button>
|
||||
<button class="btn btn-xs btn-default" ng-click="chooseSpecifiedFiles('document')">
|
||||
<i class="fa fa-file-text-o"></i>
|
||||
<span translate>Documents</span>
|
||||
</button>
|
||||
<button class="btn btn-xs btn-default" ng-click="chooseSpecifiedFiles('application')">
|
||||
<i class="fa fa-file-o"></i>
|
||||
<span translate>Applications</span>
|
||||
</button>
|
||||
<button class="btn btn-xs btn-default" ng-click="chooseSpecifiedFiles('archive')">
|
||||
<i class="fa fa-file-archive-o"></i>
|
||||
<span translate>Archives</span>
|
||||
</button>
|
||||
<button class="btn btn-xs btn-success" ng-click="saveChoosedFiles()" ng-disabled="getSelectedFileCount() < 1" translate>Confirm</button>
|
||||
<button class="btn btn-xs btn-default" ng-click="cancelChooseFiles()" translate>Cancel</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="task-table-body">
|
||||
<div class="row" ng-repeat="file in task.files | fileOrderBy: getFileListOrderType()" data-file-index="{{file.index}}">
|
||||
<div class="col-sm-8">
|
||||
|
|
Reference in a new issue