show current aria2 rpc host and connection status

This commit is contained in:
MaysWind 2016-08-28 21:47:29 +08:00
parent 2b2dc1c4e3
commit 66b4974c95
5 changed files with 47 additions and 10 deletions

View file

@ -7,6 +7,9 @@ Confirm=确认
Cancel=取消 Cancel=取消
True=是 True=是
False=否 False=否
Connecting=连接中
Connected=已连接
Not Connected=未连接
Global=全局 Global=全局
RPC=RPC RPC=RPC
New=新建 New=新建
@ -116,6 +119,7 @@ Aria2 RPC Host=Aria2 RPC 主机
Aria2 RPC Port=Aria2 RPC 端口 Aria2 RPC Port=Aria2 RPC 端口
Aria2 RPC Protocol=Aria2 RPC 协议 Aria2 RPC Protocol=Aria2 RPC 协议
Aria2 RPC Secret Token=Aria2 RPC 密钥 Aria2 RPC Secret Token=Aria2 RPC 密钥
Aria2 RPC Address=Aria2 RPC 地址
Global Stat Refresh Interval=全局状态刷新间隔 Global Stat Refresh Interval=全局状态刷新间隔
Download Task Refresh Interval=下载任务刷新间隔 Download Task Refresh Interval=下载任务刷新间隔
Supported Placeholder: AriaNg Title ${title}, Downloading Count ${downloading}, Waiting Count ${waiting}, Stopped Count ${stopped}, Download Speed ${downspeed}, Upload Speed ${upspeed}.=支持的占位符: AriaNg 标题 ${title}, 正在下载数量 ${downloading}, 正在等待数量 ${waiting}, 已停止数量 ${stopped}, 下载速度 ${downspeed}, 上传速度: ${upspeed}. Supported Placeholder: AriaNg Title ${title}, Downloading Count ${downloading}, Waiting Count ${waiting}, Stopped Count ${stopped}, Download Speed ${downspeed}, Upload Speed ${upspeed}.=支持的占位符: AriaNg 标题 ${title}, 正在下载数量 ${downloading}, 正在等待数量 ${waiting}, 已停止数量 ${stopped}, 下载速度 ${downspeed}, 上传速度: ${upspeed}.

View file

@ -11,6 +11,9 @@
'Cancel': 'Cancel', 'Cancel': 'Cancel',
'True': 'True', 'True': 'True',
'False': 'False', 'False': 'False',
'Connecting': 'Connecting',
'Connected': 'Connected',
'Not Connected': 'Not Connected',
'Global': 'Global', 'Global': 'Global',
'RPC': 'RPC', 'RPC': 'RPC',
'New': 'New', 'New': 'New',
@ -120,6 +123,7 @@
'Aria2 RPC Port': 'Aria2 RPC Port', 'Aria2 RPC Port': 'Aria2 RPC Port',
'Aria2 RPC Protocol': 'Aria2 RPC Protocol', 'Aria2 RPC Protocol': 'Aria2 RPC Protocol',
'Aria2 RPC Secret Token': 'Aria2 RPC Secret Token', 'Aria2 RPC Secret Token': 'Aria2 RPC Secret Token',
'Aria2 RPC Address': 'Aria2 RPC Address',
'Global Stat Refresh Interval': 'Global Stat Refresh Interval', 'Global Stat Refresh Interval': 'Global Stat Refresh Interval',
'Download Task Refresh Interval': 'Download Task Refresh Interval', 'Download Task Refresh Interval': 'Download Task Refresh Interval',
'Supported Placeholder: AriaNg Title ${title}, Downloading Count ${downloading}, Waiting Count ${waiting}, Stopped Count ${stopped}, Download Speed ${downspeed}, Upload Speed ${upspeed}.': 'Supported Placeholder: AriaNg Title ${title}, Downloading Count ${downloading}, Waiting Count ${waiting}, Stopped Count ${stopped}, Download Speed ${downspeed}, Upload Speed ${upspeed}.', 'Supported Placeholder: AriaNg Title ${title}, Downloading Count ${downloading}, Waiting Count ${waiting}, Stopped Count ${stopped}, Download Speed ${downspeed}, Upload Speed ${upspeed}.': 'Supported Placeholder: AriaNg Title ${title}, Downloading Count ${downloading}, Waiting Count ${waiting}, Stopped Count ${stopped}, Download Speed ${downspeed}, Upload Speed ${upspeed}.',

View file

@ -1,9 +1,11 @@
(function () { (function () {
'use strict'; 'use strict';
angular.module('ariaNg').controller('Aria2StatusController', ['$rootScope', '$scope', 'ariaNgCommonService', 'aria2SettingService', function ($rootScope, $scope, ariaNgCommonService, aria2SettingService) { angular.module('ariaNg').controller('Aria2StatusController', ['$rootScope', '$scope', 'ariaNgCommonService', 'ariaNgSettingService', 'aria2SettingService', function ($rootScope, $scope, ariaNgCommonService, ariaNgSettingService, aria2SettingService) {
$scope.context = { $scope.context = {
aria2Status: null host: ariaNgSettingService.getJsonRpcUrl(),
status: 'Connecting',
serverStatus: null
}; };
$scope.saveSession = function () { $scope.saveSession = function () {
@ -27,7 +29,10 @@
$rootScope.loadPromise = (function () { $rootScope.loadPromise = (function () {
return aria2SettingService.getAria2Status(function (response) { return aria2SettingService.getAria2Status(function (response) {
if (response.success) { if (response.success) {
$scope.context.aria2Status = response.data; $scope.context.status = 'Connected';
$scope.context.serverStatus = response.data;
} else {
$scope.context.status = 'Not Connected';
} }
}); });
})(); })();

View file

@ -16,7 +16,7 @@
data: context.requestBody data: context.requestBody
}; };
return $http(requestContext).success(function (data, header, config, status) { return $http(requestContext).success(function (data) {
if (!data) { if (!data) {
return; return;
} }
@ -24,9 +24,16 @@
if (context.successCallback) { if (context.successCallback) {
context.successCallback(data.id, data.result); context.successCallback(data.id, data.result);
} }
}).error(function (data, header, config, status) { }).error(function (data) {
if (!data) { if (!data) {
return; data = {
id: '-1',
error: {
// code: '-1',
// message: 'Unknown Error',
innerError: true
}
};
} }
if (context.errorCallback) { if (context.errorCallback) {

View file

@ -2,21 +2,38 @@
<div class="settings-table striped hoverable"> <div class="settings-table striped hoverable">
<div class="row"> <div class="row">
<div class="setting-key col-sm-4"> <div class="setting-key col-sm-4">
<span translate>Aria2 Version</span> <span translate>Aria2 RPC Address</span>
</div> </div>
<div class="setting-value col-sm-8"> <div class="setting-value col-sm-8">
<span ng-bind="context.aria2Status.version"></span> <span ng-bind="context.host"></span>
</div> </div>
</div> </div>
<div class="row"> <div class="row">
<div class="setting-key col-sm-4">
<span translate>Aria2 Status</span>
</div>
<div class="setting-value col-sm-8">
<span class="label" ng-class="{'label-primary': context.status === 'Connecting', 'label-success': context.status === 'Connected', 'label-danger': context.status === 'Not Connected'}"
ng-bind="context.status | translate"></span>
</div>
</div>
<div class="row ng-cloak" ng-if="context.serverStatus">
<div class="setting-key col-sm-4">
<span translate>Aria2 Version</span>
</div>
<div class="setting-value col-sm-8">
<span ng-bind="context.serverStatus.version"></span>
</div>
</div>
<div class="row ng-cloak" ng-if="context.serverStatus">
<div class="setting-key col-sm-4"> <div class="setting-key col-sm-4">
<span translate>Enabled Features</span> <span translate>Enabled Features</span>
</div> </div>
<div class="setting-value col-sm-8"> <div class="setting-value col-sm-8">
<span class="wholeline" ng-repeat="feature in context.aria2Status.enabledFeatures" ng-bind="feature"></span> <span class="wholeline" ng-repeat="feature in context.serverStatus.enabledFeatures" ng-bind="feature"></span>
</div> </div>
</div> </div>
<div class="row ng-cloak" ng-if="context.aria2Status"> <div class="row ng-cloak" ng-if="context.serverStatus">
<div class="setting-key setting-key-without-desc col-sm-4"> <div class="setting-key setting-key-without-desc col-sm-4">
<span translate>Functions</span> <span translate>Functions</span>
</div> </div>