diff --git a/app/index.html b/app/index.html index 6a40d20..bf7b333 100644 --- a/app/index.html +++ b/app/index.html @@ -293,6 +293,7 @@ + diff --git a/app/langs/zh_CN.json b/app/langs/zh_CN.json index 8d7c9ec..1c83a6f 100644 --- a/app/langs/zh_CN.json +++ b/app/langs/zh_CN.json @@ -64,7 +64,7 @@ "Address": "地址", "Status": "状态", "Percent": "完成度", - "Download / Upload Speed": "下载 / 上传速度", + "Speed": "速度", "No Data": "无数据", "No connected peers": "没有连接到其他节点", "Failed to change some tasks state.": "修改一些任务状态时失败.", diff --git a/app/scripts/config/defaultLanguage.js b/app/scripts/config/defaultLanguage.js index fc69afd..5e0a5bf 100644 --- a/app/scripts/config/defaultLanguage.js +++ b/app/scripts/config/defaultLanguage.js @@ -68,7 +68,7 @@ 'Address': 'Address', 'Status': 'Status', 'Percent': 'Percent', - 'Download / Upload Speed': 'Download / Upload Speed', + 'Speed': 'Speed', 'No Data': 'No Data', 'No connected peers': 'No connected peers', 'Failed to change some tasks state.': 'Failed to change some tasks state.', diff --git a/app/scripts/controllers/task-detail.js b/app/scripts/controllers/task-detail.js index 974673f..fe6350d 100644 --- a/app/scripts/controllers/task-detail.js +++ b/app/scripts/controllers/task-detail.js @@ -152,6 +152,28 @@ }, true); }; + $scope.changePeerListDisplayOrder = function (type, autoSetReverse) { + var oldType = ariaNgCommonService.parseOrderType(ariaNgSettingService.getPeerListDisplayOrder()); + var newType = ariaNgCommonService.parseOrderType(type); + + if (autoSetReverse && newType.type == oldType.type) { + newType.reverse = !oldType.reverse; + } + + ariaNgSettingService.setPeerListDisplayOrder(newType.getValue()); + }; + + $scope.isSetPeerListDisplayOrder = function (type) { + var orderType = ariaNgCommonService.parseOrderType(ariaNgSettingService.getPeerListDisplayOrder()); + var targetType = ariaNgCommonService.parseOrderType(type); + + return orderType.equals(targetType); + }; + + $scope.getPeerListOrderType = function () { + return ariaNgSettingService.getPeerListDisplayOrder(); + }; + $scope.loadTaskOption = function (task) { $rootScope.loadPromise = aria2TaskService.getTaskOptions(task.gid, function (response) { if (response.success) { diff --git a/app/scripts/filters/peerOrderBy.js b/app/scripts/filters/peerOrderBy.js new file mode 100644 index 0000000..a49b2d4 --- /dev/null +++ b/app/scripts/filters/peerOrderBy.js @@ -0,0 +1,29 @@ +(function () { + 'use strict'; + + angular.module('ariaNg').filter('peerOrderBy', ['orderByFilter', 'ariaNgCommonService', function (orderByFilter, ariaNgCommonService) { + return function (array, type) { + if (!angular.isArray(array)) { + return array; + } + + var orderType = ariaNgCommonService.parseOrderType(type); + + if (orderType == null) { + return array; + } + + if (orderType.type == 'address') { + return orderByFilter(array, ['ip', 'port'], orderType.reverse); + } else if (orderType.type == 'percent') { + return orderByFilter(array, ['completePercent'], orderType.reverse); + } else if (orderType.type == 'dspeed') { + return orderByFilter(array, ['downloadSpeed'], orderType.reverse); + } else if (orderType.type == 'uspeed') { + return orderByFilter(array, ['uploadSpeed'], orderType.reverse); + } else { + return array; + } + } + }]); +})(); diff --git a/app/scripts/services/ariaNgSettingService.js b/app/scripts/services/ariaNgSettingService.js index 3096335..9904fe8 100644 --- a/app/scripts/services/ariaNgSettingService.js +++ b/app/scripts/services/ariaNgSettingService.js @@ -140,6 +140,18 @@ }, setFileListDisplayOrder: function (value) { setOption('fileListDisplayOrder', value); + }, + getPeerListDisplayOrder: function () { + var value = getOption('peerListDisplayOrder'); + + if (!value) { + value = 'default:asc'; + } + + return value; + }, + setPeerListDisplayOrder: function (value) { + setOption('peerListDisplayOrder', value); } }; }]); diff --git a/app/views/task-detail.html b/app/views/task-detail.html index 9642a11..2665fa0 100644 --- a/app/views/task-detail.html +++ b/app/views/task-detail.html @@ -191,21 +191,28 @@