support set task option
This commit is contained in:
parent
f6e9e9878e
commit
6ec1d0586c
|
@ -551,5 +551,8 @@
|
|||
metalinkOptions: ['follow-metalink', 'metalink-base-uri', 'metalink-language', 'metalink-location', 'metalink-os', 'metalink-version', 'metalink-preferred-protocol', 'metalink-enable-unique-protocol'],
|
||||
rpcOptions: ['enable-rpc', 'pause-metadata', 'rpc-allow-origin-all', 'rpc-listen-all', 'rpc-listen-port', 'rpc-max-request-size', 'rpc-save-upload-metadata', 'rpc-secure'],
|
||||
advancedOptions: ['allow-overwrite', 'allow-piece-length-change', 'always-resume', 'async-dns', 'auto-file-renaming', 'auto-save-interval', 'conditional-get', 'conf-path', 'console-log-level', 'daemon', 'deferred-input', 'disable-ipv6', 'disk-cache', 'download-result', 'dscp', 'rlimit-nofile', 'enable-color', 'enable-mmap', 'event-poll', 'file-allocation', 'force-save', 'hash-check-only', 'human-readable', 'max-download-result', 'max-mmap-limit', 'max-resume-failure-tries', 'min-tls-version', 'log-level', 'piece-length', 'optimize-concurrent-downloads', 'show-console-readout', 'summary-interval', 'max-overall-download-limit', 'max-download-limit', 'no-conf', 'no-file-allocation-limit', 'parameterized-uri', 'quiet', 'realtime-chunk-checksum', 'remove-control-file', 'save-session', 'save-session-interval', 'socket-recv-buffer-size', 'stop', 'truncate-console-readout']
|
||||
}).constant('aria2TaskAvailableOptions', {
|
||||
activeBtOptions: ['max-download-limit', 'max-upload-limit', 'bt-max-peers', 'bt-request-peer-speed-limit', 'bt-remove-unselected-file', 'force-save'],
|
||||
activeOtherOptions: ['max-download-limit', 'max-upload-limit', 'force-save']
|
||||
});
|
||||
})();
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
var location = $location.path().substring($location.path().lastIndexOf('/') + 1);
|
||||
|
||||
var getAvailableOptions = function (type) {
|
||||
var keys = aria2SettingService.getAvailableOptionsKeys(type);
|
||||
var keys = aria2SettingService.getAvailableGlobalOptionsKeys(type);
|
||||
|
||||
if (!keys) {
|
||||
ariaNgCommonService.alert('Type is illegal!');
|
||||
|
|
|
@ -1,15 +1,20 @@
|
|||
(function () {
|
||||
'use strict';
|
||||
|
||||
angular.module('ariaNg').controller('TaskDetailController', ['$rootScope', '$scope', '$routeParams', '$interval', 'ariaNgCommonService', 'ariaNgSettingService', 'aria2TaskService', function ($rootScope, $scope, $routeParams, $interval, ariaNgCommonService, ariaNgSettingService, aria2TaskService) {
|
||||
angular.module('ariaNg').controller('TaskDetailController', ['$rootScope', '$scope', '$routeParams', '$interval', 'ariaNgCommonService', 'ariaNgSettingService', 'aria2TaskService', 'aria2SettingService', function ($rootScope, $scope, $routeParams, $interval, ariaNgCommonService, ariaNgSettingService, aria2TaskService, aria2SettingService) {
|
||||
var tabOrders = ['overview', 'blocks', 'filelist', 'btpeers'];
|
||||
var downloadTaskRefreshPromise = null;
|
||||
|
||||
$scope.context = {
|
||||
currentTab: 'overview'
|
||||
};
|
||||
var getAvailableOptions = function (status, isBittorrent) {
|
||||
var keys = aria2SettingService.getAvailableTaskOptionKeys(status, isBittorrent);
|
||||
|
||||
$scope.healthPercent = 0;
|
||||
if (!keys) {
|
||||
ariaNgCommonService.alert('Type is illegal!');
|
||||
return;
|
||||
}
|
||||
|
||||
return aria2SettingService.getSpecifiedOptions(keys);
|
||||
};
|
||||
|
||||
var refreshBtPeers = function (task) {
|
||||
return aria2TaskService.getBtTaskPeers(task.gid, function (result) {
|
||||
|
@ -31,6 +36,10 @@
|
|||
}
|
||||
}
|
||||
|
||||
if (!$scope.task || $scope.task.status != result.status) {
|
||||
$scope.availableOptions = getAvailableOptions(result.status, !!result.bittorrent);
|
||||
}
|
||||
|
||||
$scope.task = ariaNgCommonService.copyObjectTo(result, $scope.task);
|
||||
|
||||
$rootScope.taskContext.list = [$scope.task];
|
||||
|
@ -39,6 +48,14 @@
|
|||
});
|
||||
};
|
||||
|
||||
$scope.context = {
|
||||
currentTab: 'overview'
|
||||
};
|
||||
|
||||
$scope.healthPercent = 0;
|
||||
$scope.optionStatus = {};
|
||||
$scope.availableOptions = [];
|
||||
|
||||
$rootScope.swipeActions.extentLeftSwipe = function () {
|
||||
var tabIndex = tabOrders.indexOf($scope.context.currentTab);
|
||||
|
||||
|
@ -61,12 +78,6 @@
|
|||
}
|
||||
};
|
||||
|
||||
$scope.loadTaskOption = function (task) {
|
||||
$rootScope.loadPromise = aria2TaskService.getTaskOption(task.gid, function (result) {
|
||||
$scope.options = result;
|
||||
});
|
||||
};
|
||||
|
||||
$scope.changeFileListDisplayOrder = function (type, autoSetReverse) {
|
||||
var oldType = ariaNgCommonService.parseOrderType(ariaNgSettingService.getFileListDisplayOrder());
|
||||
var newType = ariaNgCommonService.parseOrderType(type);
|
||||
|
@ -89,6 +100,24 @@
|
|||
return ariaNgSettingService.getFileListDisplayOrder();
|
||||
};
|
||||
|
||||
$scope.loadTaskOption = function (task) {
|
||||
$rootScope.loadPromise = aria2TaskService.getTaskOptions(task.gid, function (result) {
|
||||
$scope.options = result;
|
||||
});
|
||||
};
|
||||
|
||||
$scope.pendingOption = function (key, value) {
|
||||
$scope.optionStatus[key] = 'pending';
|
||||
};
|
||||
|
||||
$scope.setOption = function (key, value) {
|
||||
$scope.optionStatus[key] = 'saving';
|
||||
|
||||
return aria2TaskService.setTaskOption($scope.task.gid, key, value, function (result) {
|
||||
$scope.optionStatus[key] = 'saved';
|
||||
});
|
||||
};
|
||||
|
||||
if (ariaNgSettingService.getDownloadTaskRefreshInterval() > 0) {
|
||||
downloadTaskRefreshPromise = $interval(function () {
|
||||
refreshDownloadTask();
|
||||
|
|
|
@ -139,6 +139,10 @@
|
|||
};
|
||||
|
||||
$rootScope.$on('$locationChangeStart', function (event) {
|
||||
SweetAlert.close();
|
||||
|
||||
$rootScope.loadPromise = null;
|
||||
|
||||
delete $rootScope.swipeActions.extentLeftSwipe;
|
||||
delete $rootScope.swipeActions.extentRightSwipe;
|
||||
|
||||
|
@ -151,8 +155,6 @@
|
|||
}
|
||||
|
||||
$rootScope.taskContext.enableSelectAll = false;
|
||||
|
||||
SweetAlert.close();
|
||||
});
|
||||
|
||||
$rootScope.$on('$routeChangeStart', function (event, next, current) {
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
option: '=',
|
||||
ngModel: '=',
|
||||
status: '=',
|
||||
beforeChangeValue: '&',
|
||||
onPendingChangeValue: '&',
|
||||
onChangeValue: '&'
|
||||
},
|
||||
link: function (scope, element, attrs, ngModel) {
|
||||
|
@ -42,8 +42,8 @@
|
|||
value: optionValue
|
||||
};
|
||||
|
||||
if (scope.beforeChangeValue) {
|
||||
scope.beforeChangeValue(data);
|
||||
if (scope.onPendingChangeValue) {
|
||||
scope.onPendingChangeValue(data);
|
||||
}
|
||||
|
||||
if (pendingSaveRequest) {
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
(function () {
|
||||
'use strict';
|
||||
|
||||
angular.module('ariaNg').factory('aria2SettingService', ['aria2AllOptions', 'aria2GlobalAvailableOptions', 'aria2RpcService', function (aria2AllOptions, aria2GlobalAvailableOptions, aria2RpcService) {
|
||||
angular.module('ariaNg').factory('aria2SettingService', ['aria2AllOptions', 'aria2GlobalAvailableOptions', 'aria2TaskAvailableOptions', 'aria2RpcService', function (aria2AllOptions, aria2GlobalAvailableOptions, aria2TaskAvailableOptions, aria2RpcService) {
|
||||
var processStatResult = function (stat) {
|
||||
if (!stat) {
|
||||
return stat;
|
||||
|
@ -17,7 +17,7 @@
|
|||
};
|
||||
|
||||
return {
|
||||
getAvailableOptionsKeys: function (type) {
|
||||
getAvailableGlobalOptionsKeys: function (type) {
|
||||
if (type == 'basic') {
|
||||
return aria2GlobalAvailableOptions.basicOptions;
|
||||
} else if (type == 'http-ftp-sftp') {
|
||||
|
@ -38,6 +38,19 @@
|
|||
return false;
|
||||
}
|
||||
},
|
||||
getAvailableTaskOptionKeys: function (status, isBittorrent) {
|
||||
if (status == 'active' && isBittorrent) {
|
||||
return aria2TaskAvailableOptions.activeBtOptions;
|
||||
} else if (status == 'active' && !isBittorrent) {
|
||||
return aria2TaskAvailableOptions.activeOtherOptions;
|
||||
} else if ((status == 'waiting' || status == 'paused') && isBittorrent) {
|
||||
return aria2TaskAvailableOptions.activeBtOptions;
|
||||
} else if ((status == 'waiting' || status == 'paused') && !isBittorrent) {
|
||||
return aria2TaskAvailableOptions.activeOtherOptions;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
},
|
||||
getSpecifiedOptions: function (keys) {
|
||||
var options = [];
|
||||
|
||||
|
|
|
@ -132,12 +132,22 @@
|
|||
}
|
||||
});
|
||||
},
|
||||
getTaskOption: function (gid, callback) {
|
||||
getTaskOptions: function (gid, callback) {
|
||||
return aria2RpcService.getOption({
|
||||
gid: gid,
|
||||
callback: callback
|
||||
});
|
||||
},
|
||||
setTaskOption: function (gid, key, value, callback) {
|
||||
var data = {};
|
||||
data[key] = value;
|
||||
|
||||
return aria2RpcService.changeOption({
|
||||
gid: gid,
|
||||
options: data,
|
||||
callback: callback
|
||||
});
|
||||
},
|
||||
getBtTaskPeers: function (gid, callback) {
|
||||
return aria2RpcService.getPeers({
|
||||
gid: gid,
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<section class="content no-padding">
|
||||
<div class="settings-table">
|
||||
<ng-setting ng-repeat="option in availableOptions" option="option" ng-model="globalOptions[option.key]" status="optionStatus[option.key]"
|
||||
before-change-value="pendingGlobalOption(key, value)" on-change-value="setGlobalOption(key, value)"></ng-setting>
|
||||
on-pending-change-value="pendingOption(key, value)" on-change-value="setGlobalOption(key, value)"></ng-setting>
|
||||
</div>
|
||||
</section>
|
||||
|
|
|
@ -10,10 +10,10 @@
|
|||
<li ng-class="{'active': context.currentTab == 'filelist'}">
|
||||
<a class="pointer-cursor" ng-click="context.currentTab = 'filelist'" translate>File List</a>
|
||||
</li>
|
||||
<li ng-class="{'active': context.currentTab == 'btpeers'}" ng-if="task.status == 'active' && task.bittorrent">
|
||||
<li ng-class="{'active': context.currentTab == 'btpeers'}" ng-if="task && task.status == 'active' && task.bittorrent">
|
||||
<a class="pointer-cursor" ng-click="context.currentTab = 'btpeers'" translate>Peers</a>
|
||||
</li>
|
||||
<li ng-class="{'active': context.currentTab == 'settings'}" class="slim">
|
||||
<li ng-class="{'active': context.currentTab == 'settings'}" ng-if="task && (task.status == 'active' || task.status == 'waiting' || task.status == 'paused')" class="slim">
|
||||
<a class="pointer-cursor" ng-click="context.currentTab = 'settings';loadTaskOption(task);">
|
||||
<i class="fa fa-gear"></i>
|
||||
</a>
|
||||
|
@ -160,7 +160,7 @@
|
|||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="tab-pane" ng-class="{'active': context.currentTab == 'btpeers'}" ng-if="task.status == 'active' && task.bittorrent">
|
||||
<div class="tab-pane" ng-class="{'active': context.currentTab == 'btpeers'}" ng-if="task && task.status == 'active' && task.bittorrent">
|
||||
<div class="task-table task-table-firstrow-noborder">
|
||||
<div class="task-table-title hidden-xs">
|
||||
<div class="row">
|
||||
|
@ -206,9 +206,12 @@
|
|||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="tab-pane" ng-class="{'active': context.currentTab == 'settings'}">
|
||||
<div class="tab-pane" ng-class="{'active': context.currentTab == 'settings'}" ng-if="task && (task.status == 'active' || task.status == 'waiting' || task.status == 'paused')">
|
||||
<div class="settings-table settings-table-firstrow-noborder">
|
||||
|
||||
<ng-setting ng-repeat="option in availableOptions" option="option"
|
||||
ng-model="options[option.key]" status="optionStatus[option.key]"
|
||||
on-pending-change-value="pendingOption(key, value)"
|
||||
on-change-value="setOption(key, value)"></ng-setting>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
Reference in a new issue