diff --git a/app/index.html b/app/index.html index 763afb5..2f4368f 100644 --- a/app/index.html +++ b/app/index.html @@ -237,10 +237,13 @@ + + + diff --git a/app/scripts/controllers/task-detail.js b/app/scripts/controllers/task-detail.js new file mode 100644 index 0000000..8662abf --- /dev/null +++ b/app/scripts/controllers/task-detail.js @@ -0,0 +1,35 @@ +(function () { + 'use strict'; + + angular.module('ariaNg').controller('TaskDetailController', ['$scope', '$routeParams', '$interval', 'aria2RpcService', 'ariaNgSettingService', 'utils', function ($scope, $routeParams, $interval, aria2RpcService, ariaNgSettingService, utils) { + var downloadTaskRefreshPromise = null; + + var refreshDownloadTask = function () { + return aria2RpcService.tellStatus({ + params: [$routeParams.gid], + callback: function (result) { + var task = utils.processDownloadTask(result); + $scope.task = utils.copyObjectTo(task, $scope.task); + } + }) + }; + + $scope.context = { + currentTab: 'overview' + }; + + $scope.loadPromise = refreshDownloadTask(); + + if (ariaNgSettingService.getDownloadTaskRefreshInterval() > 0) { + downloadTaskRefreshPromise = $interval(function () { + refreshDownloadTask(); + }, ariaNgSettingService.getDownloadTaskRefreshInterval()); + } + + $scope.$on('$destroy', function () { + if (downloadTaskRefreshPromise) { + $interval.cancel(downloadTaskRefreshPromise); + } + }); + }]); +})(); diff --git a/app/scripts/core/router.js b/app/scripts/core/router.js index 1b871e2..c7d7306 100644 --- a/app/scripts/core/router.js +++ b/app/scripts/core/router.js @@ -15,6 +15,10 @@ templateUrl: 'views/list.html', controller: 'DownloadListController' }) + .when('/task/detail/:gid', { + templateUrl: 'views/task-detail.html', + controller: 'TaskDetailController' + }) .when('/settings/ariang', { templateUrl: 'views/settings-ariang.html', controller: 'AriaNgSettingsController' diff --git a/app/scripts/core/utils.js b/app/scripts/core/utils.js index 569624f..7fe638c 100644 --- a/app/scripts/core/utils.js +++ b/app/scripts/core/utils.js @@ -78,8 +78,41 @@ task.taskName = translateFilter('Unknown'); } + if (task.files) { + for (var i = 0; i < task.files.length; i++) { + var file = task.files[i]; + file.length = parseInt(file.length); + file.completedLength = parseInt(file.completedLength); + file.completePercent = (file.length > 0 ? file.completedLength / file.length * 100 : 0); + } + } + return task; }, + copyObjectTo: function (from, to) { + if (!to) { + return from; + } + + for (var name in from) { + if (!from.hasOwnProperty(name)) { + continue; + } + + var fromValue = from[name]; + var toValue = to[name]; + + if (angular.isObject(fromValue) || angular.isArray(fromValue)) { + to[name] = this.copyObjectTo(from[name], to[name]); + } else { + if (fromValue != toValue) { + to[name] = fromValue; + } + } + } + + return to; + }, isUrlMatchUrl2: function (url, url2) { if (url === url2) { return true; diff --git a/app/scripts/filters/filename.js b/app/scripts/filters/filename.js new file mode 100644 index 0000000..5d3de08 --- /dev/null +++ b/app/scripts/filters/filename.js @@ -0,0 +1,9 @@ +(function () { + 'use strict'; + + angular.module("ariaNg").filter('filename', ['utils', function (utils) { + return function (path) { + return utils.getFileNameFromPath(path); + } + }]); +})(); diff --git a/app/scripts/filters/taskStatus.js b/app/scripts/filters/taskStatus.js new file mode 100644 index 0000000..742f0be --- /dev/null +++ b/app/scripts/filters/taskStatus.js @@ -0,0 +1,31 @@ +(function () { + 'use strict'; + + angular.module("ariaNg").filter('taskStatus', ['translateFilter', function (translateFilter) { + return function (task) { + if (!task) { + return ''; + } + + if (task.status == 'active') { + if (task.seeder === true || task.seeder === 'true') { + return translateFilter('Seeding'); + } else { + return translateFilter('Downloading'); + } + } else if (task.status == 'waiting') { + return translateFilter('Waiting'); + } else if (task.status == 'paused') { + return translateFilter('Paused'); + } else if (task.status == 'complete') { + return translateFilter('Completed'); + } else if (task.status == 'error') { + return translateFilter('Error Occurred'); + } else if (task.status == 'removed') { + return translateFilter('Removed'); + } else { + return ''; + } + } + }]); +})(); diff --git a/app/scripts/langs/en-US.js b/app/scripts/langs/en-US.js index 21d3331..ca898b8 100644 --- a/app/scripts/langs/en-US.js +++ b/app/scripts/langs/en-US.js @@ -23,8 +23,14 @@ 'By Remain Time': 'By Remain Time', 'By Download Speed': 'By Download Speed', 'Download': 'Download', + 'Upload': 'Upload', 'Downloading': 'Downloading', + 'Seeding': 'Seeding', 'Waiting': 'Waiting', + 'Paused': 'Paused', + 'Completed': 'Completed', + 'Error Occurred': 'Error Occurred', + 'Removed': 'Removed', 'Downloaded / Stopped': 'Downloaded / Stopped', 'Settings': 'Settings', 'AriaNg Settings': 'AriaNg Settings', @@ -45,6 +51,16 @@ 'Remain Time': 'Remain', 'Download Speed': 'Download Speed', 'Files': 'Files', + 'Overview': 'Overview', + 'Download Info': 'Download Info', + 'File List': 'File List', + 'BT Trackers': 'BT Trackers', + 'Tracker': 'Tracker', + 'Task Status': 'Task Status', + 'Info Hash': 'Info Hash', + 'Seeders': 'Seeders', + 'Connections': 'Connections', + 'Download Dir': 'Download Dir', '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 521b6b4..0203f17 100644 --- a/app/scripts/langs/zh-CN.js +++ b/app/scripts/langs/zh-CN.js @@ -23,8 +23,14 @@ 'By Remain Time': '按剩余时间', 'By Download Speed': '按下载速度', 'Download': '下载', + 'Upload': '上传', 'Downloading': '正在下载', + 'Seeding': '正在做种', 'Waiting': '正在等待', + 'Paused': '已暂停', + 'Completed': '已完成', + 'Error Occurred': '发生错误', + 'Removed': '已删除', 'Downloaded / Stopped': '已完成 / 已停止', 'Settings': '系统设置', 'AriaNg Settings': 'AriaNg 设置', @@ -45,6 +51,16 @@ 'Remain Time': '剩余时间', 'Download Speed': '下载速度', 'Files': '个文件', + 'Overview': '总览', + 'Download Info': '下载信息', + 'File List': '文件列表', + 'BT Trackers': 'BT Trackers', + 'Tracker': 'Tracker', + 'Task Status': '任务状态', + 'Info Hash': '特征值', + 'Seeders': '种子数', + 'Connections': '连接数', + 'Download Dir': '下载路径', 'Language': '语言', 'Aria2 RPC Host': 'Aria2 RPC 主机', 'Aria2 RPC Port': 'Aria2 RPC 端口', diff --git a/app/styles/aria-ng.css b/app/styles/aria-ng.css index b19fb6f..e9a678b 100644 --- a/app/styles/aria-ng.css +++ b/app/styles/aria-ng.css @@ -161,6 +161,39 @@ color: #3c8dbc; } +.skin-aria-ng .nav-tabs-custom { + -webkit-box-shadow: none; + -moz-box-shadow: none; + box-shadow: none; + margin-bottom: 0; +} + +.skin-aria-ng .nav-tabs-custom > .nav-tabs { + border-bottom: 1px dotted #ddd; +} + +.skin-aria-ng .nav-tabs-custom > .nav-tabs > li { + border-top: 0; + margin-top: 1px; + margin-right: 2px; +} + +.skin-aria-ng .nav-tabs-custom > .nav-tabs > li.active { + border-bottom: 2px solid #208fe5; +} + +.skin-aria-ng .nav-tabs-custom > .nav-tabs > li > a { + color: #aaa; + border: 0; +} + +.skin-aria-ng .nav-tabs-custom > .nav-tabs > li > a:hover, +.skin-aria-ng .nav-tabs-custom > .nav-tabs > li > a:active, +.skin-aria-ng .nav-tabs-custom > .nav-tabs > li.active > a{ + color: #208fe5; +} + + /* override */ td { vertical-align: middle !important; @@ -301,7 +334,7 @@ td { display: block; } -.task-table .task-files { +.task-table .task-files, .task-table .task-size { font-size: 12px; display: block; } diff --git a/app/views/task-detail.html b/app/views/task-detail.html new file mode 100644 index 0000000..f770d1d --- /dev/null +++ b/app/views/task-detail.html @@ -0,0 +1,166 @@ +
+ +