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

32 lines
1.2 KiB
JavaScript
Raw Normal View History

2016-05-13 18:09:12 +02:00
(function () {
'use strict';
angular.module("ariaNg").filter('taskOrderBy', ['orderByFilter', 'utils', function (orderByFilter, utils) {
2016-05-13 18:09:12 +02:00
return function (array, type) {
if (!angular.isArray(array)) {
return array;
}
2016-05-28 16:31:07 +02:00
var orderType = utils.parseOrderType(type);
2016-05-28 16:31:07 +02:00
if (orderType == null) {
return array;
}
2016-05-13 18:09:12 +02:00
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') {
2016-05-28 16:31:07 +02:00
return orderByFilter(array, ['idle', 'remainTime', 'remainPercent'], orderType.reverse);
} else if (orderType.type == 'dspeed') {
return orderByFilter(array, ['downloadSpeed'], orderType.reverse);
2016-05-13 18:09:12 +02:00
} else {
return array;
}
}
}]);
})();