support displaying bt peers in task detail page

This commit is contained in:
MaysWind 2016-05-24 23:30:33 +08:00
parent 6746de57f6
commit bee3e2af94
4 changed files with 65 additions and 18 deletions

View file

@ -4,11 +4,27 @@
angular.module('ariaNg').controller('TaskDetailController', ['$scope', '$routeParams', '$interval', 'aria2RpcService', 'ariaNgSettingService', 'utils', function ($scope, $routeParams, $interval, aria2RpcService, ariaNgSettingService, utils) { angular.module('ariaNg').controller('TaskDetailController', ['$scope', '$routeParams', '$interval', 'aria2RpcService', 'ariaNgSettingService', 'utils', function ($scope, $routeParams, $interval, aria2RpcService, ariaNgSettingService, utils) {
var downloadTaskRefreshPromise = null; var downloadTaskRefreshPromise = null;
var refreshPeers = function () {
return aria2RpcService.getPeers({
params: [$routeParams.gid],
callback: function (result) {
if (!utils.extendArray(result, $scope.peers, 'peerId')) {
$scope.peers = result;
}
}
})
};
var refreshDownloadTask = function () { var refreshDownloadTask = function () {
return aria2RpcService.tellStatus({ return aria2RpcService.tellStatus({
params: [$routeParams.gid], params: [$routeParams.gid],
callback: function (result) { callback: function (result) {
var task = utils.processDownloadTask(result); var task = utils.processDownloadTask(result);
if (task.status == 'active' && task.bittorrent) {
refreshPeers();
}
$scope.task = utils.copyObjectTo(task, $scope.task); $scope.task = utils.copyObjectTo(task, $scope.task);
} }
}) })

View file

@ -50,17 +50,20 @@
'Completed Percent': 'Percent', 'Completed Percent': 'Percent',
'Remain Time': 'Remain', 'Remain Time': 'Remain',
'Download Speed': 'Download Speed', 'Download Speed': 'Download Speed',
'Upload Speed': 'Upload Speed',
'Files': 'Files', 'Files': 'Files',
'Overview': 'Overview', 'Overview': 'Overview',
'Download Info': 'Download Info', 'Blocks': 'Blocks',
'File List': 'File List', 'File List': 'File List',
'BT Trackers': 'BT Trackers', 'Peers': 'Peers',
'Tracker': 'Tracker',
'Task Status': 'Task Status', 'Task Status': 'Task Status',
'Info Hash': 'Info Hash', 'Info Hash': 'Info Hash',
'Seeders': 'Seeders', 'Seeders': 'Seeders',
'Connections': 'Connections', 'Connections': 'Connections',
'Download Dir': 'Download Dir', 'Download Dir': 'Download Dir',
'Address': 'Address',
'Status': 'Status',
'Percent': 'Percent',
'Language': 'Language', 'Language': 'Language',
'Aria2 RPC Host': 'Aria2 RPC Host', 'Aria2 RPC Host': 'Aria2 RPC Host',
'Aria2 RPC Port': 'Aria2 RPC Port', 'Aria2 RPC Port': 'Aria2 RPC Port',

View file

@ -50,17 +50,20 @@
'Completed Percent': '进度', 'Completed Percent': '进度',
'Remain Time': '剩余时间', 'Remain Time': '剩余时间',
'Download Speed': '下载速度', 'Download Speed': '下载速度',
'Upload Speed': '上传速度',
'Files': '个文件', 'Files': '个文件',
'Overview': '总览', 'Overview': '总览',
'Download Info': '下载信息', 'Blocks': '区块信息',
'File List': '文件列表', 'File List': '文件列表',
'BT Trackers': 'BT Trackers', 'Peers': '连接状态',
'Tracker': 'Tracker',
'Task Status': '任务状态', 'Task Status': '任务状态',
'Info Hash': '特征值', 'Info Hash': '特征值',
'Seeders': '种子数', 'Seeders': '种子数',
'Connections': '连接数', 'Connections': '连接数',
'Download Dir': '下载路径', 'Download Dir': '下载路径',
'Address': '地址',
'Status': '状态',
'Percent': '完成度',
'Language': '语言', 'Language': '语言',
'Aria2 RPC Host': 'Aria2 RPC 主机', 'Aria2 RPC Host': 'Aria2 RPC 主机',
'Aria2 RPC Port': 'Aria2 RPC 端口', 'Aria2 RPC Port': 'Aria2 RPC 端口',

View file

@ -4,14 +4,14 @@
<li ng-class="{'active': context.currentTab == 'overview'}"> <li ng-class="{'active': context.currentTab == 'overview'}">
<a class="pointer-cursor" ng-click="context.currentTab = 'overview'" translate>Overview</a> <a class="pointer-cursor" ng-click="context.currentTab = 'overview'" translate>Overview</a>
</li> </li>
<li ng-class="{'active': context.currentTab == 'downloadinfo'}"> <li ng-class="{'active': context.currentTab == 'blocks'}">
<a class="pointer-cursor" ng-click="context.currentTab = 'downloadinfo'" translate>Download Info</a> <a class="pointer-cursor" ng-click="context.currentTab = 'blocks'" translate>Blocks</a>
</li> </li>
<li ng-class="{'active': context.currentTab == 'filelist'}"> <li ng-class="{'active': context.currentTab == 'filelist'}">
<a class="pointer-cursor" ng-click="context.currentTab = 'filelist'" translate>File List</a> <a class="pointer-cursor" ng-click="context.currentTab = 'filelist'" translate>File List</a>
</li> </li>
<li ng-class="{'active': context.currentTab == 'bttrackers'}" ng-if="task.bittorrent"> <li ng-class="{'active': context.currentTab == 'btpeers'}" ng-if="task.status == 'active' && task.bittorrent">
<a class="pointer-cursor" ng-click="context.currentTab = 'bttrackers'" translate>BT Trackers</a> <a class="pointer-cursor" ng-click="context.currentTab = 'btpeers'" translate>Peers</a>
</li> </li>
</ul> </ul>
@ -101,7 +101,7 @@
</div> </div>
</div> </div>
</div> </div>
<div class="tab-pane" ng-class="{'active': context.currentTab == 'downloadinfo'}"> <div class="tab-pane" ng-class="{'active': context.currentTab == 'blocks'}">
</div> </div>
<div class="tab-pane" ng-class="{'active': context.currentTab == 'filelist'}"> <div class="tab-pane" ng-class="{'active': context.currentTab == 'filelist'}">
@ -142,20 +142,45 @@
</div> </div>
</div> </div>
</div> </div>
<div class="tab-pane" ng-class="{'active': context.currentTab == 'bttrackers'}" ng-if="task.bittorrent"> <div class="tab-pane" ng-class="{'active': context.currentTab == 'btpeers'}" ng-if="task.status == 'active' && task.bittorrent">
<div class="task-table"> <div class="task-table">
<div class="task-table-title hidden-xs"> <div class="task-table-title hidden-xs">
<div class="row"> <div class="row">
<div class="col-sm-12"> <div class="col-sm-3">
<span translate>Tracker</span> <span translate>Address</span>
<span ng-bind="'(' + task.bittorrent.announceList.length + ')'"></span> </div>
<div class="col-sm-6">
<span translate>Status</span>
</div>
<div class="col-sm-1 col-xs-4">
<span translate>Percent</span>
</div>
<div class="col-sm-1 col-xs-4">
<span translate>Download Speed</span>
</div>
<div class="col-sm-1 col-xs-4">
<span translate>Upload Speed</span>
</div> </div>
</div> </div>
</div> </div>
<div class="task-table-body"> <div class="task-table-body">
<div class="row" ng-repeat="announce in task.bittorrent.announceList"> <div class="row" ng-repeat="peer in peers">
<div class="col-sm-12"> <div class="col-sm-3">
<span ng-bind="announce"></span> <span ng-bind="peer.ip + ':' + peer.port"></span>
</div>
<div class="col-sm-6">
</div>
<div class="col-sm-1 col-xs-4">
<!--<span ng-bind="(peer.completePercent | percent: 2) + '%'"></span>-->
</div>
<div class="col-sm-1 col-xs-4">
<i class="fa fa-arrow-down visible-xs-inline-block"></i>
<span class="task-download-speed" ng-bind="(peer.downloadSpeed | readableVolumn) + '/s'"></span>
</div>
<div class="col-sm-1 col-xs-4">
<i class="fa fa-arrow-up visible-xs-inline-block"></i>
<span class="task-download-speed" ng-bind="(peer.uploadSpeed | readableVolumn) + '/s'"></span>
</div> </div>
</div> </div>
</div> </div>