support sort peer list in task detail page
This commit is contained in:
parent
feb79aca2c
commit
4febf421e3
|
@ -293,6 +293,7 @@
|
||||||
<script src="scripts/directives/setting.js"></script>
|
<script src="scripts/directives/setting.js"></script>
|
||||||
<script src="scripts/filters/dateDuration.js"></script>
|
<script src="scripts/filters/dateDuration.js"></script>
|
||||||
<script src="scripts/filters/fileOrderBy.js"></script>
|
<script src="scripts/filters/fileOrderBy.js"></script>
|
||||||
|
<script src="scripts/filters/peerOrderBy.js"></script>
|
||||||
<script src="scripts/filters/percent.js"></script>
|
<script src="scripts/filters/percent.js"></script>
|
||||||
<script src="scripts/filters/taskOrderBy.js"></script>
|
<script src="scripts/filters/taskOrderBy.js"></script>
|
||||||
<script src="scripts/filters/taskStatus.js"></script>
|
<script src="scripts/filters/taskStatus.js"></script>
|
||||||
|
|
|
@ -64,7 +64,7 @@
|
||||||
"Address": "地址",
|
"Address": "地址",
|
||||||
"Status": "状态",
|
"Status": "状态",
|
||||||
"Percent": "完成度",
|
"Percent": "完成度",
|
||||||
"Download / Upload Speed": "下载 / 上传速度",
|
"Speed": "速度",
|
||||||
"No Data": "无数据",
|
"No Data": "无数据",
|
||||||
"No connected peers": "没有连接到其他节点",
|
"No connected peers": "没有连接到其他节点",
|
||||||
"Failed to change some tasks state.": "修改一些任务状态时失败.",
|
"Failed to change some tasks state.": "修改一些任务状态时失败.",
|
||||||
|
|
|
@ -68,7 +68,7 @@
|
||||||
'Address': 'Address',
|
'Address': 'Address',
|
||||||
'Status': 'Status',
|
'Status': 'Status',
|
||||||
'Percent': 'Percent',
|
'Percent': 'Percent',
|
||||||
'Download / Upload Speed': 'Download / Upload Speed',
|
'Speed': 'Speed',
|
||||||
'No Data': 'No Data',
|
'No Data': 'No Data',
|
||||||
'No connected peers': 'No connected peers',
|
'No connected peers': 'No connected peers',
|
||||||
'Failed to change some tasks state.': 'Failed to change some tasks state.',
|
'Failed to change some tasks state.': 'Failed to change some tasks state.',
|
||||||
|
|
|
@ -152,6 +152,28 @@
|
||||||
}, true);
|
}, 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) {
|
$scope.loadTaskOption = function (task) {
|
||||||
$rootScope.loadPromise = aria2TaskService.getTaskOptions(task.gid, function (response) {
|
$rootScope.loadPromise = aria2TaskService.getTaskOptions(task.gid, function (response) {
|
||||||
if (response.success) {
|
if (response.success) {
|
||||||
|
|
29
app/scripts/filters/peerOrderBy.js
Normal file
29
app/scripts/filters/peerOrderBy.js
Normal file
|
@ -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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}]);
|
||||||
|
})();
|
|
@ -140,6 +140,18 @@
|
||||||
},
|
},
|
||||||
setFileListDisplayOrder: function (value) {
|
setFileListDisplayOrder: function (value) {
|
||||||
setOption('fileListDisplayOrder', value);
|
setOption('fileListDisplayOrder', value);
|
||||||
|
},
|
||||||
|
getPeerListDisplayOrder: function () {
|
||||||
|
var value = getOption('peerListDisplayOrder');
|
||||||
|
|
||||||
|
if (!value) {
|
||||||
|
value = 'default:asc';
|
||||||
|
}
|
||||||
|
|
||||||
|
return value;
|
||||||
|
},
|
||||||
|
setPeerListDisplayOrder: function (value) {
|
||||||
|
setOption('peerListDisplayOrder', value);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}]);
|
}]);
|
||||||
|
|
|
@ -191,21 +191,28 @@
|
||||||
<div class="task-table-title hidden-xs">
|
<div class="task-table-title hidden-xs">
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-sm-3">
|
<div class="col-sm-3">
|
||||||
<span translate>Address</span>
|
<a ng-click="changePeerListDisplayOrder('address:asc', true)" translate>Address</a>
|
||||||
|
<i class="fa" ng-class="{'fa-sort-asc fa-order-asc': isSetPeerListDisplayOrder('address:asc'), 'fa-sort-desc fa-order-desc': isSetPeerListDisplayOrder('address:desc')}"></i>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-sm-3">
|
<div class="col-sm-3">
|
||||||
<span translate>Status</span>
|
<span translate>Status</span>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-sm-2 col-xs-4">
|
<div class="col-sm-2 col-xs-4">
|
||||||
<span translate>Percent</span>
|
<a ng-click="changePeerListDisplayOrder('percent:desc', true)" translate>Percent</a>
|
||||||
|
<i class="fa" ng-class="{'fa-sort-asc fa-order-asc': isSetPeerListDisplayOrder('percent:asc'), 'fa-sort-desc fa-order-desc': isSetPeerListDisplayOrder('percent:desc')}"></i>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-sm-4 col-xs-4">
|
<div class="col-sm-4 col-xs-4">
|
||||||
<span translate>Download / Upload Speed</span>
|
<a ng-click="changePeerListDisplayOrder('dspeed:desc', true)" translate>Download</a>
|
||||||
|
<i class="fa" ng-class="{'fa-sort-asc fa-order-asc': isSetPeerListDisplayOrder('dspeed:asc'), 'fa-sort-desc fa-order-desc': isSetPeerListDisplayOrder('dspeed:desc')}"></i>
|
||||||
|
<span>/</span>
|
||||||
|
<a ng-click="changePeerListDisplayOrder('uspeed:desc', true)" translate>Upload</a>
|
||||||
|
<i class="fa" ng-class="{'fa-sort-asc fa-order-asc': isSetPeerListDisplayOrder('uspeed:asc'), 'fa-sort-desc fa-order-desc': isSetPeerListDisplayOrder('uspeed:desc')}"></i>
|
||||||
|
<span translate>Speed</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="task-table-body">
|
<div class="task-table-body">
|
||||||
<div class="row" ng-repeat="peer in peers">
|
<div class="row" ng-repeat="peer in peers | peerOrderBy: getPeerListOrderType()">
|
||||||
<div class="col-sm-3">
|
<div class="col-sm-3">
|
||||||
<span ng-bind="peer.ip + ':' + peer.port"></span>
|
<span ng-bind="peer.ip + ':' + peer.port"></span>
|
||||||
</div>
|
</div>
|
||||||
|
|
Reference in a new issue