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/taskOrderBy.js

34 lines
1.3 KiB
JavaScript

(function () {
'use strict';
angular.module('ariaNg').filter('taskOrderBy', ['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 == 'name') {
return orderByFilter(array, ['taskName'], orderType.reverse);
} else if (orderType.type == 'size') {
return orderByFilter(array, ['totalLength'], orderType.reverse);
} else if (orderType.type == 'percent') {
return orderByFilter(array, ['completePercent'], orderType.reverse);
} else if (orderType.type == 'remain') {
return orderByFilter(array, ['idle', 'remainTime', 'remainLength'], 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;
}
}
}]);
})();