This repository has been archived on 2022-01-02. You can view files and clone it, but cannot push or open issues/pull-requests.
AriaNg/src/scripts/filters/peerOrderBy.js

32 lines
1.2 KiB
JavaScript
Raw Normal View History

(function () {
'use strict';
2016-06-26 08:06:20 +02:00
angular.module('ariaNg').filter('peerOrderBy', ['$filter', 'ariaNgCommonService', function ($filter, ariaNgCommonService) {
return function (array, type) {
if (!angular.isArray(array)) {
return array;
}
var orderType = ariaNgCommonService.parseOrderType(type);
2016-08-01 19:26:10 +02:00
if (orderType === null) {
return array;
}
2016-08-01 19:26:10 +02:00
if (orderType.type === 'address') {
2016-06-26 08:06:20 +02:00
return $filter('orderBy')(array, ['ip', 'port'], orderType.reverse);
2016-08-01 19:26:10 +02:00
} else if (orderType.type === 'client') {
return $filter('orderBy')(array, ['client.name', 'client.version'], orderType.reverse);
2016-08-01 19:26:10 +02:00
} else if (orderType.type === 'percent') {
2016-06-26 08:06:20 +02:00
return $filter('orderBy')(array, ['completePercent'], orderType.reverse);
2016-08-01 19:26:10 +02:00
} else if (orderType.type === 'dspeed') {
2016-06-26 08:06:20 +02:00
return $filter('orderBy')(array, ['downloadSpeed'], orderType.reverse);
2016-08-01 19:26:10 +02:00
} else if (orderType.type === 'uspeed') {
2016-06-26 08:06:20 +02:00
return $filter('orderBy')(array, ['uploadSpeed'], orderType.reverse);
} else {
return array;
}
2016-12-10 18:50:25 +01:00
};
}]);
2016-08-01 16:49:16 +02:00
}());