From bee3e2af94f2615cf63774ca645257e1e0a9e42c Mon Sep 17 00:00:00 2001 From: MaysWind Date: Tue, 24 May 2016 23:30:33 +0800 Subject: [PATCH] support displaying bt peers in task detail page --- app/scripts/controllers/task-detail.js | 16 +++++++++ app/scripts/langs/en-US.js | 9 +++-- app/scripts/langs/zh-CN.js | 9 +++-- app/views/task-detail.html | 49 +++++++++++++++++++------- 4 files changed, 65 insertions(+), 18 deletions(-) diff --git a/app/scripts/controllers/task-detail.js b/app/scripts/controllers/task-detail.js index 8662abf..8ee9c6c 100644 --- a/app/scripts/controllers/task-detail.js +++ b/app/scripts/controllers/task-detail.js @@ -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); } }) diff --git a/app/scripts/langs/en-US.js b/app/scripts/langs/en-US.js index ca898b8..8181a59 100644 --- a/app/scripts/langs/en-US.js +++ b/app/scripts/langs/en-US.js @@ -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', diff --git a/app/scripts/langs/zh-CN.js b/app/scripts/langs/zh-CN.js index 0203f17..1965288 100644 --- a/app/scripts/langs/zh-CN.js +++ b/app/scripts/langs/zh-CN.js @@ -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 端口', diff --git a/app/views/task-detail.html b/app/views/task-detail.html index f770d1d..b3a8d1d 100644 --- a/app/views/task-detail.html +++ b/app/views/task-detail.html @@ -4,14 +4,14 @@
  • Overview
  • -
  • - Download Info +
  • + Blocks
  • File List
  • -
  • - BT Trackers +
  • + Peers
  • @@ -101,7 +101,7 @@ -
    +
    @@ -142,20 +142,45 @@
    -
    +