diff options
author | thuva4 <tharma.thuva@gmail.com> | 2018-03-10 00:10:46 +0530 |
---|---|---|
committer | thuva4 <tharma.thuva@gmail.com> | 2018-03-10 00:13:38 +0530 |
commit | 0f4b6dd80c7e2d4468025486e7b0dc58505125d4 (patch) | |
tree | e349ee280a129d4edf5c0623532bc831737597c2 /testapi/opnfv_testapi/ui/components/pods | |
parent | bc5a216764b93ad9551830f2459194a4cea9d754 (diff) |
Add sorting service to module
Show the results in sorted order
Provide options to sort the results by fields
in pods and project page
Change-Id: I9b73fbe98146d4bdf9edbb4a3ef3b3e0717500a7
qSigned-off-by: thuva4 <tharma.thuva@gmail.com>
Diffstat (limited to 'testapi/opnfv_testapi/ui/components/pods')
-rw-r--r-- | testapi/opnfv_testapi/ui/components/pods/podsController.js | 29 |
1 files changed, 4 insertions, 25 deletions
diff --git a/testapi/opnfv_testapi/ui/components/pods/podsController.js b/testapi/opnfv_testapi/ui/components/pods/podsController.js index 95e970d..f405ecb 100644 --- a/testapi/opnfv_testapi/ui/components/pods/podsController.js +++ b/testapi/opnfv_testapi/ui/components/pods/podsController.js @@ -21,7 +21,7 @@ PodsController.$inject = [ '$scope', '$http', '$filter', '$state', '$window', '$uibModal', 'testapiApiUrl','raiseAlert', - 'confirmModal', 'keepState' + 'confirmModal', 'keepState', 'sortService' ]; /** @@ -30,7 +30,7 @@ * through pods declared in TestAPI. */ function PodsController($scope, $http, $filter, $state, $window, $uibModal, testapiApiUrl, - raiseAlert, confirmModal, keepState) { + raiseAlert, confirmModal, keepState, sortService) { var ctrl = this; ctrl.url = testapiApiUrl + '/pods'; ctrl.checkBox = [] @@ -50,29 +50,8 @@ ctrl.sortBy = sortBy function sortBy(field){ - if(ctrl.sorting[field]){ - ctrl.data.pods.sort(function(a,b) { - if (a[field].toLowerCase() > b[field].toLowerCase()) { - return -1; - } - if (a[field].toLowerCase() < b[field].toLowerCase()) { - return 1; - } - return 0; - }); - ctrl.sorting[field] = false - }else{ - ctrl.data.pods.sort(function(a,b) { - if (a[field].toLowerCase() < b[field].toLowerCase()) { - return -1; - } - if (a[field].toLowerCase() > b[field].toLowerCase()) { - return 1; - } - return 0; - }); - ctrl.sorting[field] = true - } + ctrl.data.pods = sortService.sortFunction(ctrl.data.pods, field , ctrl.sorting[field] ) + ctrl.sorting[field]=!ctrl.sorting[field] } /** |