add rpc server port setting
This commit is contained in:
parent
f8195b600c
commit
048507bb8e
|
@ -3,9 +3,12 @@
|
|||
|
||||
angular.module('ariaNg').constant('ariaNgConstants', {
|
||||
title: 'Aria Ng',
|
||||
appPrefix: 'AriaNg'
|
||||
appPrefix: 'AriaNg',
|
||||
optionStorageKey: 'Options'
|
||||
}).constant('ariaNgDefaultOptions', {
|
||||
language: 'en-US',
|
||||
rpcHost: '',
|
||||
rpcPort: '6800',
|
||||
protocol: 'http',
|
||||
globalStatRefreshInterval: 1000,
|
||||
downloadTaskRefreshInterval: 1000
|
||||
|
|
|
@ -22,6 +22,7 @@
|
|||
'AriaNg Settings': 'AriaNg Settings',
|
||||
'Language': 'Language',
|
||||
'Aria2 RPC Host': 'Aria2 RPC Host',
|
||||
'Aria2 RPC Port': 'Aria2 RPC Port',
|
||||
'Aria2 RPC Protocol': 'Aria2 RPC Protocol',
|
||||
'Toggle Navigation': 'Toggle Navigation',
|
||||
'Loading': 'Loading...',
|
||||
|
|
|
@ -22,6 +22,7 @@
|
|||
'AriaNg Settings': 'AriaNg 设置',
|
||||
'Language': '语言',
|
||||
'Aria2 RPC Host': 'Aria2 RPC 主机',
|
||||
'Aria2 RPC Port': 'Aria2 RPC 端口',
|
||||
'Aria2 RPC Protocol': 'Aria2 RPC 协议',
|
||||
'Toggle Navigation': '切换导航',
|
||||
'Loading': '正在加载...',
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
'use strict';
|
||||
|
||||
angular.module('ariaNg').factory('aria2HttpRpcService', ['$http', 'ariaNgSettingService', function ($http, ariaNgSettingService) {
|
||||
var rpcUrl = ariaNgSettingService.getJsonRpcUrl('http');
|
||||
var rpcUrl = ariaNgSettingService.getJsonRpcUrl();
|
||||
|
||||
return {
|
||||
request: function (context) {
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
'use strict';
|
||||
|
||||
angular.module('ariaNg').factory('aria2WebSocketRpcService', ['$websocket', 'ariaNgSettingService', function ($websocket, ariaNgSettingService) {
|
||||
var rpcUrl = ariaNgSettingService.getJsonRpcUrl('ws');
|
||||
var rpcUrl = ariaNgSettingService.getJsonRpcUrl();
|
||||
var socketClient = null;
|
||||
var sendIdMapping = {};
|
||||
|
||||
|
|
|
@ -1,18 +1,17 @@
|
|||
(function () {
|
||||
'use strict';
|
||||
|
||||
angular.module('ariaNg').factory('ariaNgSettingService', ['$location', '$translate', 'amMoment', 'localStorageService', 'ariaNgDefaultOptions', function ($location, $translate, amMoment, localStorageService, ariaNgDefaultOptions) {
|
||||
var getDefaultJsonRpcHost = function () {
|
||||
var rpcHost = $location.$$host + ':6800';
|
||||
return rpcHost;
|
||||
angular.module('ariaNg').factory('ariaNgSettingService', ['$location', '$translate', 'amMoment', 'localStorageService', 'ariaNgConstants', 'ariaNgDefaultOptions', function ($location, $translate, amMoment, localStorageService, ariaNgConstants, ariaNgDefaultOptions) {
|
||||
var getDefaultRpcHost = function () {
|
||||
return $location.$$host;
|
||||
};
|
||||
|
||||
var setOptions = function (options) {
|
||||
return localStorageService.set('Options', options);
|
||||
return localStorageService.set(ariaNgConstants.optionStorageKey, options);
|
||||
};
|
||||
|
||||
var getOptions = function () {
|
||||
var options = localStorageService.get('Options');
|
||||
var options = localStorageService.get(ariaNgConstants.optionStorageKey);
|
||||
|
||||
if (!options) {
|
||||
options = angular.extend({}, ariaNgDefaultOptions);
|
||||
|
@ -44,8 +43,8 @@
|
|||
getAllOptions: function () {
|
||||
var options = angular.extend({}, ariaNgDefaultOptions, getOptions());
|
||||
|
||||
if (!options.aria2RpcHost) {
|
||||
options.aria2RpcHost = getDefaultJsonRpcHost();
|
||||
if (!options.rpcHost) {
|
||||
options.rpcHost = getDefaultRpcHost();
|
||||
}
|
||||
|
||||
return options;
|
||||
|
@ -61,17 +60,22 @@
|
|||
$translate.use(value);
|
||||
amMoment.changeLocale(value);
|
||||
},
|
||||
getJsonRpcUrl: function (protocol) {
|
||||
var rpcHost = getOption('aria2RpcHost');
|
||||
getJsonRpcUrl: function () {
|
||||
var protocol = getOption('protocol');
|
||||
var rpcHost = getOption('rpcHost');
|
||||
var rpcPort = getOption('rpcPort');
|
||||
|
||||
if (!rpcHost) {
|
||||
rpcHost = getDefaultJsonRpcHost();
|
||||
rpcHost = getDefaultRpcHost();
|
||||
}
|
||||
|
||||
return protocol + '://' + rpcHost + '/jsonrpc';
|
||||
return protocol + '://' + rpcHost + ':' + rpcPort + '/jsonrpc';
|
||||
},
|
||||
setJsonRpcHost: function (value) {
|
||||
setOption('aria2RpcHost', value);
|
||||
setRpcHost: function (value) {
|
||||
setOption('rpcHost', value);
|
||||
},
|
||||
setRpcPort: function (value) {
|
||||
setOption('rpcPort', value);
|
||||
},
|
||||
getProtocol: function () {
|
||||
return getOption('protocol');
|
||||
|
|
|
@ -308,6 +308,10 @@ td {
|
|||
background-color: #f5f5f5;
|
||||
}
|
||||
|
||||
.settings-table .input-group-addon {
|
||||
background-color: #eee;
|
||||
}
|
||||
|
||||
.settings-table .setting-key {
|
||||
padding-top: 6px;
|
||||
}
|
||||
|
@ -317,7 +321,7 @@ td {
|
|||
}
|
||||
|
||||
.settings-table .tip {
|
||||
background-color: #fff;
|
||||
background-color: #fff !important;
|
||||
font-size: 12px;
|
||||
padding: 4px;
|
||||
}
|
||||
|
|
|
@ -16,8 +16,22 @@
|
|||
<span translate>Aria2 RPC Host</span>
|
||||
<span class="asterisk">*</span>
|
||||
</div>
|
||||
<div class="setting-value col-md-8" translate>
|
||||
<input class="form-control" ng-model="settings.aria2RpcHost" ng-change="settingService.setJsonRpcHost(settings.aria2RpcHost)" />
|
||||
<div class="setting-value col-md-8">
|
||||
<div class="input-group">
|
||||
<span class="input-group-addon" ng-bind="settings.protocol + '://'"></span>
|
||||
<input class="form-control" type="text" ng-model="settings.rpcHost" ng-change="settingService.setRpcHost(settings.rpcHost)"/>
|
||||
<span class="input-group-addon" style="border-left: 0">:</span>
|
||||
<span class="input-group-addon" style="border-left: 0" ng-bind="settings.rpcPort"></span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="setting-key col-md-4">
|
||||
<span translate>Aria2 RPC Port</span>
|
||||
<span class="asterisk">*</span>
|
||||
</div>
|
||||
<div class="setting-value col-md-8">
|
||||
<input class="form-control" type="text" ng-model="settings.rpcPort" ng-change="settingService.setRpcPort(settings.rpcPort)"/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
|
|
Reference in a new issue