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) {
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 () {
return aria2RpcService.tellStatus({
params: [$routeParams.gid],
callback: function (result) {
var task = utils.processDownloadTask(result);
if (task.status == 'active' && task.bittorrent) {
refreshPeers();
}
$scope.task = utils.copyObjectTo(task, $scope.task);
}
})

View file

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

View file

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

View file

@ -4,14 +4,14 @@
<li ng-class="{'active': context.currentTab == 'overview'}">
<a class="pointer-cursor" ng-click="context.currentTab = 'overview'" translate>Overview</a>
</li>
<li ng-class="{'active': context.currentTab == 'downloadinfo'}">
<a class="pointer-cursor" ng-click="context.currentTab = 'downloadinfo'" translate>Download Info</a>
<li ng-class="{'active': context.currentTab == 'blocks'}">
<a class="pointer-cursor" ng-click="context.currentTab = 'blocks'" translate>Blocks</a>
</li>
<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 == 'bttrackers'}" ng-if="task.bittorrent">
<a class="pointer-cursor" ng-click="context.currentTab = 'bttrackers'" translate>BT Trackers</a>
<li ng-class="{'active': context.currentTab == 'btpeers'}" ng-if="task.status == 'active' && task.bittorrent">
<a class="pointer-cursor" ng-click="context.currentTab = 'btpeers'" translate>Peers</a>
</li>
</ul>
@ -101,7 +101,7 @@
</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 class="tab-pane" ng-class="{'active': context.currentTab == 'filelist'}">
@ -142,20 +142,45 @@
</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-title hidden-xs">
<div class="row">
<div class="col-sm-12">
<span translate>Tracker</span>
<span ng-bind="'(' + task.bittorrent.announceList.length + ')'"></span>
<div class="col-sm-3">
<span translate>Address</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 class="task-table-body">
<div class="row" ng-repeat="announce in task.bittorrent.announceList">
<div class="col-sm-12">
<span ng-bind="announce"></span>
<div class="row" ng-repeat="peer in peers">
<div class="col-sm-3">
<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>