code refactor and add option filter in new task page
This commit is contained in:
parent
6323fe2ae8
commit
ec839b3ecd
|
@ -35,6 +35,7 @@ By Progress=按进度
|
||||||
By Remain Time=按剩余时间
|
By Remain Time=按剩余时间
|
||||||
By Download Speed=按下载速度
|
By Download Speed=按下载速度
|
||||||
By Upload Speed=按上传速度
|
By Upload Speed=按上传速度
|
||||||
|
Filters=过滤器
|
||||||
Download=下载
|
Download=下载
|
||||||
Upload=上传
|
Upload=上传
|
||||||
Downloading=正在下载
|
Downloading=正在下载
|
||||||
|
@ -165,6 +166,7 @@ WebSocket (Security)=WebSocket (安全)
|
||||||
POST=POST
|
POST=POST
|
||||||
GET=GET
|
GET=GET
|
||||||
Disabled=禁用
|
Disabled=禁用
|
||||||
|
BitTorrent=BitTorrent
|
||||||
Changes to the settings take effect after refreshing page.=设置将在页面刷新后生效.
|
Changes to the settings take effect after refreshing page.=设置将在页面刷新后生效.
|
||||||
Type is illegal!=类型错误!
|
Type is illegal!=类型错误!
|
||||||
Parameter is invalid!=请求参数无效
|
Parameter is invalid!=请求参数无效
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
(function () {
|
(function () {
|
||||||
'use strict';
|
'use strict';
|
||||||
angular.module('ariaNg').constant('aria2AllOptions', {
|
angular.module('ariaNg').constant('aria2AllOptions', {
|
||||||
// EXAMPLE:
|
// Aria2 Option Defination EXAMPLE:
|
||||||
// 'option key': {
|
// 'option key': {
|
||||||
// [since: '',] //This option is supported by this or higher aria2 version
|
// [since: '',] //This option is supported by this or higher aria2 version
|
||||||
// type: 'string|integer|float|text|boolean|option',
|
// type: 'string|integer|float|text|boolean|option',
|
||||||
|
@ -809,6 +809,10 @@
|
||||||
defaultValue: 'true'
|
defaultValue: 'true'
|
||||||
}
|
}
|
||||||
}).constant('aria2GlobalAvailableOptions', {
|
}).constant('aria2GlobalAvailableOptions', {
|
||||||
|
// Aria2 Setting Page Defination EXAMPLE:
|
||||||
|
// 'category key': [
|
||||||
|
// 'option key 1', 'option key 2', // more options if possible
|
||||||
|
// ]
|
||||||
basicOptions: [
|
basicOptions: [
|
||||||
'dir', 'log', 'max-concurrent-downloads', 'check-integrity', 'continue'
|
'dir', 'log', 'max-concurrent-downloads', 'check-integrity', 'continue'
|
||||||
],
|
],
|
||||||
|
@ -858,118 +862,132 @@
|
||||||
'save-session', 'save-session-interval', 'socket-recv-buffer-size', 'stop', 'truncate-console-readout'
|
'save-session', 'save-session-interval', 'socket-recv-buffer-size', 'stop', 'truncate-console-readout'
|
||||||
]
|
]
|
||||||
}).constant('aria2TaskAvailableOptions', {
|
}).constant('aria2TaskAvailableOptions', {
|
||||||
|
// Aria2 Task Option Defination EXAMPLE:
|
||||||
|
// {
|
||||||
|
// key: 'option key',
|
||||||
|
// category: 'global|http|bittorrent',
|
||||||
|
// [canShow: 'new|active|waiting|paused',] // possible to show in specific status, supporting multiple choice. if not set, always show
|
||||||
|
// [canUpdate: 'new|active|waiting|paused',] // possible to write in specific status, supporting multiple choice. if not set, always writable
|
||||||
|
// }
|
||||||
taskOptions: [
|
taskOptions: [
|
||||||
{
|
{
|
||||||
key: 'dir',
|
key: 'dir',
|
||||||
newOnly: true
|
category: 'global',
|
||||||
|
canUpdate: 'new'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
key: 'out',
|
key: 'out',
|
||||||
httpOnly: true,
|
category: 'http',
|
||||||
newOnly: true
|
canUpdate: 'new'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
key: 'allow-overwrite',
|
key: 'allow-overwrite',
|
||||||
newOnly: true
|
category: 'global',
|
||||||
|
canShow: 'new'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
key: 'max-download-limit'
|
key: 'max-download-limit',
|
||||||
|
category: 'global'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
key: 'max-upload-limit',
|
key: 'max-upload-limit',
|
||||||
btOnly: true
|
category: 'bittorrent'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
key: 'split',
|
key: 'split',
|
||||||
httpOnly: true,
|
category: 'http',
|
||||||
activeReadonly: true
|
canUpdate: 'new|waiting|paused'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
key: 'min-split-size',
|
key: 'min-split-size',
|
||||||
httpOnly: true,
|
category: 'http',
|
||||||
activeReadonly: true
|
canUpdate: 'new|waiting|paused'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
key: 'max-connection-per-server',
|
key: 'max-connection-per-server',
|
||||||
httpOnly: true,
|
category: 'http',
|
||||||
activeReadonly: true
|
canUpdate: 'new|waiting|paused'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
key: 'lowest-speed-limit',
|
key: 'lowest-speed-limit',
|
||||||
httpOnly: true,
|
category: 'http',
|
||||||
activeReadonly: true
|
canUpdate: 'new|waiting|paused'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
key: 'stream-piece-selector',
|
key: 'stream-piece-selector',
|
||||||
httpOnly: true,
|
category: 'http',
|
||||||
activeReadonly: true
|
canUpdate: 'new|waiting|paused'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
key: 'all-proxy',
|
key: 'all-proxy',
|
||||||
httpOnly: true,
|
category: 'http',
|
||||||
activeReadonly: true
|
canUpdate: 'new|waiting|paused'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
key: 'all-proxy-user',
|
key: 'all-proxy-user',
|
||||||
httpOnly: true,
|
category: 'http',
|
||||||
activeReadonly: true
|
canUpdate: 'new|waiting|paused'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
key: 'all-proxy-passwd',
|
key: 'all-proxy-passwd',
|
||||||
httpOnly: true,
|
category: 'http',
|
||||||
activeReadonly: true
|
canUpdate: 'new|waiting|paused'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
key: 'header',
|
key: 'header',
|
||||||
httpOnly: true,
|
category: 'http',
|
||||||
newOnly: true
|
canUpdate: 'new'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
key: 'bt-max-peers',
|
key: 'bt-max-peers',
|
||||||
btOnly: true
|
category: 'bittorrent'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
key: 'bt-request-peer-speed-limit',
|
key: 'bt-request-peer-speed-limit',
|
||||||
btOnly: true
|
category: 'bittorrent'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
key: 'bt-remove-unselected-file',
|
key: 'bt-remove-unselected-file',
|
||||||
btOnly: true
|
category: 'bittorrent'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
key: 'bt-stop-timeout',
|
key: 'bt-stop-timeout',
|
||||||
btOnly: true,
|
category: 'bittorrent',
|
||||||
activeReadonly: true
|
canUpdate: 'new|waiting|paused'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
key: 'bt-tracker',
|
key: 'bt-tracker',
|
||||||
btOnly: true,
|
category: 'bittorrent',
|
||||||
activeReadonly: true
|
canUpdate: 'new|waiting|paused'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
key: 'seed-ratio',
|
key: 'seed-ratio',
|
||||||
btOnly: true,
|
category: 'bittorrent',
|
||||||
activeReadonly: true
|
canUpdate: 'new|waiting|paused'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
key: 'seed-time',
|
key: 'seed-time',
|
||||||
btOnly: true,
|
category: 'bittorrent',
|
||||||
activeReadonly: true
|
canUpdate: 'new|waiting|paused'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
key: 'conditional-get',
|
key: 'conditional-get',
|
||||||
newOnly: true
|
category: 'global',
|
||||||
|
canShow: 'new'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
key: 'file-allocation',
|
key: 'file-allocation',
|
||||||
newOnly: true
|
category: 'global',
|
||||||
|
canShow: 'new'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
key: 'parameterized-uri ',
|
key: 'parameterized-uri',
|
||||||
newOnly: true
|
category: 'global',
|
||||||
|
canShow: 'new'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
key: 'force-save'
|
key: 'force-save',
|
||||||
|
category: 'global'
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
});
|
});
|
||||||
|
|
|
@ -39,6 +39,7 @@
|
||||||
'By Remain Time': 'By Remain Time',
|
'By Remain Time': 'By Remain Time',
|
||||||
'By Download Speed': 'By Download Speed',
|
'By Download Speed': 'By Download Speed',
|
||||||
'By Upload Speed': 'By Upload Speed',
|
'By Upload Speed': 'By Upload Speed',
|
||||||
|
'Filters': 'Filters',
|
||||||
'Download': 'Download',
|
'Download': 'Download',
|
||||||
'Upload': 'Upload',
|
'Upload': 'Upload',
|
||||||
'Downloading': 'Downloading',
|
'Downloading': 'Downloading',
|
||||||
|
@ -169,6 +170,7 @@
|
||||||
'POST': 'POST',
|
'POST': 'POST',
|
||||||
'GET': 'GET',
|
'GET': 'GET',
|
||||||
'Disabled': 'Disabled',
|
'Disabled': 'Disabled',
|
||||||
|
'BitTorrent': 'BitTorrent',
|
||||||
'Changes to the settings take effect after refreshing page.': 'Changes to the settings take effect after refreshing page.',
|
'Changes to the settings take effect after refreshing page.': 'Changes to the settings take effect after refreshing page.',
|
||||||
'Type is illegal!': 'Type is illegal!',
|
'Type is illegal!': 'Type is illegal!',
|
||||||
'Parameter is invalid!': 'Parameter is invalid!',
|
'Parameter is invalid!': 'Parameter is invalid!',
|
||||||
|
|
|
@ -13,7 +13,12 @@
|
||||||
return aria2SettingService.getSpecifiedOptions(keys);
|
return aria2SettingService.getSpecifiedOptions(keys);
|
||||||
})(),
|
})(),
|
||||||
globalOptions: null,
|
globalOptions: null,
|
||||||
options: {}
|
options: {},
|
||||||
|
optionFilter: {
|
||||||
|
global: true,
|
||||||
|
http: true,
|
||||||
|
bittorrent: true
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
$scope.changeTab = function (tabName) {
|
$scope.changeTab = function (tabName) {
|
||||||
|
|
|
@ -45,20 +45,21 @@
|
||||||
for (var i = 0; i < allOptions.length; i++) {
|
for (var i = 0; i < allOptions.length; i++) {
|
||||||
var option = allOptions[i];
|
var option = allOptions[i];
|
||||||
var optionKey = {
|
var optionKey = {
|
||||||
key: option.key
|
key: option.key,
|
||||||
|
category: option.category
|
||||||
};
|
};
|
||||||
|
|
||||||
if (option.newOnly) {
|
if (option.canShow && option.canShow.indexOf(status) < 0) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (option.httpOnly && isBittorrent) {
|
if (option.category === 'http' && isBittorrent) {
|
||||||
continue;
|
continue;
|
||||||
} else if (option.btOnly && !isBittorrent) {
|
} else if (option.category === 'bittorrent' && !isBittorrent) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (option.activeReadonly && status === 'active') {
|
if (option.canUpdate && option.canUpdate.indexOf(status) < 0) {
|
||||||
optionKey.readonly = true;
|
optionKey.readonly = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -74,9 +75,18 @@
|
||||||
for (var i = 0; i < allOptions.length; i++) {
|
for (var i = 0; i < allOptions.length; i++) {
|
||||||
var option = allOptions[i];
|
var option = allOptions[i];
|
||||||
var optionKey = {
|
var optionKey = {
|
||||||
key: option.key
|
key: option.key,
|
||||||
|
category: option.category
|
||||||
};
|
};
|
||||||
|
|
||||||
|
if (option.canShow && option.canShow.indexOf('new') < 0) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (option.canUpdate && option.canUpdate.indexOf('new') < 0) {
|
||||||
|
optionKey.readonly = true;
|
||||||
|
}
|
||||||
|
|
||||||
availableOptions.push(optionKey);
|
availableOptions.push(optionKey);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -88,12 +98,14 @@
|
||||||
for (var i = 0; i < keys.length; i++) {
|
for (var i = 0; i < keys.length; i++) {
|
||||||
var key = keys[i];
|
var key = keys[i];
|
||||||
var readonly = false;
|
var readonly = false;
|
||||||
|
var category = null;
|
||||||
|
|
||||||
if (angular.isObject(key)) {
|
if (angular.isObject(key)) {
|
||||||
var optionKey = key;
|
var optionKey = key;
|
||||||
|
|
||||||
key = optionKey.key;
|
key = optionKey.key;
|
||||||
readonly = !!optionKey.readonly;
|
readonly = !!optionKey.readonly;
|
||||||
|
category = optionKey.category;
|
||||||
}
|
}
|
||||||
|
|
||||||
var option = aria2AllOptions[key];
|
var option = aria2AllOptions[key];
|
||||||
|
@ -108,6 +120,10 @@
|
||||||
descriptionKey: 'options.' + key + '.description'
|
descriptionKey: 'options.' + key + '.description'
|
||||||
}, option);
|
}, option);
|
||||||
|
|
||||||
|
if (category) {
|
||||||
|
option.category = category;
|
||||||
|
}
|
||||||
|
|
||||||
if (option.type === 'boolean') {
|
if (option.type === 'boolean') {
|
||||||
option.options = ['true', 'false'];
|
option.options = ['true', 'false'];
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,3 +22,7 @@
|
||||||
display: block;
|
display: block;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.settings-table .new-task-filter-title {
|
||||||
|
padding-top: 6px;
|
||||||
|
}
|
||||||
|
|
|
@ -4,6 +4,16 @@
|
||||||
margin-right: 15px;
|
margin-right: 15px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.settings-table .settings-table-title {
|
||||||
|
font-size: 12px;
|
||||||
|
padding-top: 4px;
|
||||||
|
padding-bottom: 4px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.settings-table .settings-table-title a {
|
||||||
|
color: #000;
|
||||||
|
}
|
||||||
|
|
||||||
.settings-table > div.row {
|
.settings-table > div.row {
|
||||||
padding-top: 8px;
|
padding-top: 8px;
|
||||||
padding-bottom: 8px;
|
padding-bottom: 8px;
|
||||||
|
|
|
@ -23,7 +23,7 @@
|
||||||
<button type="submit" class="btn btn-sm"
|
<button type="submit" class="btn btn-sm"
|
||||||
ng-class="{'btn-default': newTaskForm.$invalid, 'btn-success': !newTaskForm.$invalid}"
|
ng-class="{'btn-default': newTaskForm.$invalid, 'btn-success': !newTaskForm.$invalid}"
|
||||||
ng-disabled="newTaskForm.$invalid" translate>Start Download
|
ng-disabled="newTaskForm.$invalid" translate>Start Download
|
||||||
</button>
|
</button>
|
||||||
<button type="button" class="btn btn-sm dropdown-toggle"
|
<button type="button" class="btn btn-sm dropdown-toggle"
|
||||||
ng-class="{'btn-default': newTaskForm.$invalid, 'btn-success': !newTaskForm.$invalid}"
|
ng-class="{'btn-default': newTaskForm.$invalid, 'btn-success': !newTaskForm.$invalid}"
|
||||||
ng-disabled="newTaskForm.$invalid" data-toggle="dropdown">
|
ng-disabled="newTaskForm.$invalid" data-toggle="dropdown">
|
||||||
|
@ -57,8 +57,27 @@
|
||||||
</div>
|
</div>
|
||||||
<div class="tab-pane" ng-class="{'active': context.currentTab == 'options'}">
|
<div class="tab-pane" ng-class="{'active': context.currentTab == 'options'}">
|
||||||
<div class="settings-table striped hoverable">
|
<div class="settings-table striped hoverable">
|
||||||
<ng-setting ng-repeat="option in context.availableOptions" option="option" lazy-save-timeout="0"
|
<div class="settings-table-title new-task-filter-title">
|
||||||
default-value="context.globalOptions[option.key]"
|
<div class="row">
|
||||||
|
<div class="col-sm-12">
|
||||||
|
<span translate>Filters</span><span>:</span>
|
||||||
|
<div class="checkbox checkbox-inline checkbox-primary">
|
||||||
|
<input id="optionFilterGlobal" type="checkbox" ng-model="context.optionFilter['global']"/>
|
||||||
|
<label for="optionFilterGlobal" translate>Global</label>
|
||||||
|
</div>
|
||||||
|
<div class="checkbox checkbox-inline checkbox-primary">
|
||||||
|
<input id="optionFilterHttp" type="checkbox" ng-model="context.optionFilter['http']"/>
|
||||||
|
<label for="optionFilterHttp" translate>Http</label>
|
||||||
|
</div>
|
||||||
|
<div class="checkbox checkbox-inline checkbox-primary">
|
||||||
|
<input id="optionFilterBittorrent" type="checkbox" ng-model="context.optionFilter['bittorrent']"/>
|
||||||
|
<label for="optionFilterBittorrent" translate>BitTorrent</label>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<ng-setting ng-repeat="option in context.availableOptions" ng-if="context.optionFilter[option.category]"
|
||||||
|
option="option" lazy-save-timeout="0" default-value="context.globalOptions[option.key]"
|
||||||
on-change-value="setOption(key, value, optionStatus)"></ng-setting>
|
on-change-value="setOption(key, value, optionStatus)"></ng-setting>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
Reference in a new issue