support select files by file extension
This commit is contained in:
parent
c21c77ff99
commit
e42884a50f
|
@ -5,6 +5,7 @@ Error=错误
|
|||
OK=确定
|
||||
Confirm=确认
|
||||
Cancel=取消
|
||||
Close=关闭
|
||||
True=是
|
||||
False=否
|
||||
Connecting=连接中
|
||||
|
@ -100,6 +101,9 @@ Pictures=图片
|
|||
Documents=文档
|
||||
Applications=应用程序
|
||||
Archives=存档文件
|
||||
Other=其他
|
||||
Custom=自定义
|
||||
Custom Choose File=自定义选择文件
|
||||
Address=地址
|
||||
Client=客户端
|
||||
Status=状态
|
||||
|
|
|
@ -5,6 +5,7 @@ Error=錯誤
|
|||
OK=確定
|
||||
Confirm=確認
|
||||
Cancel=取消
|
||||
Close=關閉
|
||||
True=是
|
||||
False=否
|
||||
Connecting=連線中
|
||||
|
@ -100,6 +101,9 @@ Pictures=圖片
|
|||
Documents=文件
|
||||
Applications=應用程式
|
||||
Archives=封存檔案
|
||||
Other=其他
|
||||
Custom=自訂
|
||||
Custom Choose File=自訂選擇檔案
|
||||
Address=位址
|
||||
Client=客戶端
|
||||
Status=狀態
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
'OK': 'OK',
|
||||
'Confirm': 'Confirm',
|
||||
'Cancel': 'Cancel',
|
||||
'Close': 'Close',
|
||||
'True': 'True',
|
||||
'False': 'False',
|
||||
'Connecting': 'Connecting',
|
||||
|
@ -104,6 +105,9 @@
|
|||
'Documents': 'Documents',
|
||||
'Applications': 'Applications',
|
||||
'Archives': 'Archives',
|
||||
'Other': 'Other',
|
||||
'Custom': 'Custom',
|
||||
'Custom Choose File': 'Custom Choose File',
|
||||
'Address': 'Address',
|
||||
'Client': 'Client',
|
||||
'Status': 'Status',
|
||||
|
|
|
@ -2,7 +2,9 @@
|
|||
'use strict';
|
||||
|
||||
angular.module('ariaNg').constant('ariaNgFileTypes', {
|
||||
video: [
|
||||
video: {
|
||||
name: 'Videos',
|
||||
extensions: [
|
||||
'.3g2',
|
||||
'.3gp',
|
||||
'.3gp2',
|
||||
|
@ -32,8 +34,11 @@
|
|||
'.ts',
|
||||
'.vob',
|
||||
'.wmv'
|
||||
],
|
||||
audio: [
|
||||
]
|
||||
},
|
||||
audio: {
|
||||
name: 'Audios',
|
||||
extensions: [
|
||||
'.aac',
|
||||
'.ac3',
|
||||
'.adts',
|
||||
|
@ -58,8 +63,11 @@
|
|||
'.wav',
|
||||
'.wma',
|
||||
'.wv'
|
||||
],
|
||||
picture: [
|
||||
]
|
||||
},
|
||||
picture: {
|
||||
name: 'Pictures',
|
||||
extensions: [
|
||||
'.abr',
|
||||
'.bmp',
|
||||
'.emf',
|
||||
|
@ -95,8 +103,11 @@
|
|||
'.webp',
|
||||
'.wmf',
|
||||
'.xif'
|
||||
],
|
||||
document: [
|
||||
]
|
||||
},
|
||||
document: {
|
||||
name: 'Documents',
|
||||
extensions: [
|
||||
'.csv',
|
||||
'.doc',
|
||||
'.docm',
|
||||
|
@ -144,8 +155,11 @@
|
|||
'.xltx',
|
||||
'.xlw',
|
||||
'.xps'
|
||||
],
|
||||
application: [
|
||||
]
|
||||
},
|
||||
application: {
|
||||
name: 'Applications',
|
||||
extensions: [
|
||||
'.apk',
|
||||
'.bat',
|
||||
'.com',
|
||||
|
@ -158,8 +172,11 @@
|
|||
'.msi',
|
||||
'.rpm',
|
||||
'.sh'
|
||||
],
|
||||
archive: [
|
||||
]
|
||||
},
|
||||
archive: {
|
||||
name: 'Archives',
|
||||
extensions: [
|
||||
'.001',
|
||||
'.7z',
|
||||
'.ace',
|
||||
|
@ -190,5 +207,6 @@
|
|||
'.z',
|
||||
'.zip'
|
||||
]
|
||||
}
|
||||
});
|
||||
}());
|
||||
|
|
|
@ -194,6 +194,7 @@
|
|||
currentTab: 'overview',
|
||||
isEnableSpeedChart: ariaNgSettingService.getDownloadTaskRefreshInterval() > 0,
|
||||
showChooseFilesToolbar: false,
|
||||
fileExtensions: [],
|
||||
collapsedDirs: {},
|
||||
btPeers: [],
|
||||
healthPercent: 0,
|
||||
|
@ -342,7 +343,7 @@
|
|||
}
|
||||
|
||||
var files = $scope.task.files;
|
||||
var extensions = ariaNgFileTypes[type];
|
||||
var extensions = ariaNgFileTypes[type].extensions;
|
||||
var fileIndexes = [];
|
||||
var isAllSelected = true;
|
||||
|
||||
|
@ -395,6 +396,143 @@
|
|||
}
|
||||
};
|
||||
|
||||
$scope.showCustomChooseFileModal = function () {
|
||||
if (!$scope.task || !$scope.task.files) {
|
||||
return;
|
||||
}
|
||||
|
||||
var files = $scope.task.files;
|
||||
var extensionsMap = {};
|
||||
|
||||
for (var i = 0; i < files.length; i++) {
|
||||
var file = files[i];
|
||||
|
||||
if (file.isDir) {
|
||||
continue;
|
||||
}
|
||||
|
||||
var extension = ariaNgCommonService.getFileExtension(file.fileName);
|
||||
|
||||
if (extension) {
|
||||
extension = extension.toLowerCase();
|
||||
}
|
||||
|
||||
var extensionInfo = extensionsMap[extension];
|
||||
|
||||
if (!extensionInfo) {
|
||||
var extensionName = extension;
|
||||
|
||||
if (extensionName.length > 0 && extensionName.charAt(0) === '.') {
|
||||
extensionName = extensionName.substring(1);
|
||||
}
|
||||
|
||||
extensionInfo = {
|
||||
extension: extensionName,
|
||||
classified: false,
|
||||
selected: false,
|
||||
selectedCount: 0,
|
||||
unSelectedCount: 0
|
||||
};
|
||||
|
||||
extensionsMap[extension] = extensionInfo;
|
||||
}
|
||||
|
||||
if (file.selected) {
|
||||
extensionInfo.selected = true;
|
||||
extensionInfo.selectedCount++;
|
||||
} else {
|
||||
extensionInfo.unSelectedCount++;
|
||||
}
|
||||
}
|
||||
|
||||
var allClassifiedExtensions = {};
|
||||
|
||||
for (var type in ariaNgFileTypes) {
|
||||
if (!ariaNgFileTypes.hasOwnProperty(type)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
var extensionTypeName = ariaNgFileTypes[type].name;
|
||||
var allExtensions = ariaNgFileTypes[type].extensions;
|
||||
var extensions = [];
|
||||
|
||||
for (var i = 0; i < allExtensions.length; i++) {
|
||||
var extension = allExtensions[i];
|
||||
var extensionInfo = extensionsMap[extension];
|
||||
|
||||
if (extensionInfo) {
|
||||
extensionInfo.classified = true;
|
||||
extensions.push(extensionInfo);
|
||||
}
|
||||
}
|
||||
|
||||
if (extensions.length > 0) {
|
||||
allClassifiedExtensions[type] = {
|
||||
name: extensionTypeName,
|
||||
extensions: extensions
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
var unClassifiedExtensions = [];
|
||||
|
||||
for (var extension in extensionsMap) {
|
||||
if (!extensionsMap.hasOwnProperty(extension)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
var extensionInfo = extensionsMap[extension];
|
||||
|
||||
if (!extensionInfo.classified) {
|
||||
unClassifiedExtensions.push(extensionInfo);
|
||||
}
|
||||
}
|
||||
|
||||
if (unClassifiedExtensions.length > 0) {
|
||||
allClassifiedExtensions.other = {
|
||||
name: 'Other',
|
||||
extensions: unClassifiedExtensions
|
||||
};
|
||||
}
|
||||
|
||||
$scope.context.fileExtensions = allClassifiedExtensions;
|
||||
angular.element('#custom-choose-file-modal').modal();
|
||||
};
|
||||
|
||||
$scope.setSelectedExtension = function (selectedExtension, selected) {
|
||||
if (!$scope.task || !$scope.task.files) {
|
||||
return;
|
||||
}
|
||||
|
||||
var files = $scope.task.files;
|
||||
|
||||
for (var i = 0; i < files.length; i++) {
|
||||
var file = files[i];
|
||||
|
||||
if (file.isDir) {
|
||||
continue;
|
||||
}
|
||||
|
||||
var extension = ariaNgCommonService.getFileExtension(file.fileName);
|
||||
|
||||
if (extension) {
|
||||
extension = extension.toLowerCase();
|
||||
}
|
||||
|
||||
if (extension !== '.' + selectedExtension) {
|
||||
continue;
|
||||
}
|
||||
|
||||
file.selected = selected;
|
||||
}
|
||||
|
||||
updateAllDirNodesSelectedStatus();
|
||||
};
|
||||
|
||||
$('#custom-choose-file-modal').on('hide.bs.modal', function (e) {
|
||||
$scope.context.fileExtensions = null;
|
||||
});
|
||||
|
||||
$scope.setSelectedFile = function (updateNodeSelectedStatus) {
|
||||
if (updateNodeSelectedStatus) {
|
||||
updateAllDirNodesSelectedStatus();
|
||||
|
|
|
@ -235,6 +235,10 @@
|
|||
<i class="fa fa-file-archive-o"></i>
|
||||
<span translate>Archives</span>
|
||||
</button>
|
||||
<button class="btn btn-xs btn-default" ng-click="showCustomChooseFileModal()">
|
||||
<i class="fa fa-filter"></i>
|
||||
<span translate>Custom</span>
|
||||
</button>
|
||||
<button class="btn btn-xs btn-success" ng-click="saveChoosedFiles()" ng-disabled="!isAnyFileSelected()" translate>Confirm</button>
|
||||
<button class="btn btn-xs btn-default" ng-click="cancelChooseFiles()" translate>Cancel</button>
|
||||
</div>
|
||||
|
@ -369,4 +373,32 @@
|
|||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div id="custom-choose-file-modal" class="modal fade" tabindex="-1" role="dialog">
|
||||
<div class="modal-dialog" role="document">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
|
||||
<h4 class="modal-title" translate>Custom Choose File</h4>
|
||||
</div>
|
||||
<div class="modal-body no-padding">
|
||||
<div class="settings-table striped hoverable">
|
||||
<div class="row" ng-repeat="(extensionTypeName, extensionTypeInfo) in context.fileExtensions">
|
||||
<div class="setting-key setting-key-without-desc col-sm-4" ng-bind="extensionTypeInfo.name | translate"></div>
|
||||
<div class="setting-value col-sm-8">
|
||||
<div class="checkbox checkbox-primary checkbox-inline" ng-repeat="info in extensionTypeInfo.extensions">
|
||||
<input id="{{info.extension}}" type="checkbox" ng-model="info.selected"
|
||||
ng-indeterminate="info.selectedCount > 0 && info.unSelectedCount > 0"
|
||||
ng-change="setSelectedExtension(info.extension, info.selected)">
|
||||
<label for="{{info.extension}}" ng-bind="info.extension"></label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-default" data-dismiss="modal" translate>Close</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
|
Reference in a new issue