diff options
author | thuva4 <tharma.thuva@gmail.com> | 2018-02-26 09:20:56 +0530 |
---|---|---|
committer | thuva4 <tharma.thuva@gmail.com> | 2018-02-27 15:34:28 +0530 |
commit | 0456189f44c87b51ee3a07a0e7af7507ee1eee6b (patch) | |
tree | b71f07f64627ca240964cd895945049b32bdbd92 /testapi/opnfv_testapi/ui/components/pods/podsController.js | |
parent | 86f8a2036521e9401d8c9431e4b6412878e6d94f (diff) |
Add sorting in pods page
Show the results in sorted order
Provide options to sort the results by name,
role, mode
Change-Id: I8b514769e9b878a0ff4bafcae8e909af3284f7ca
Signed-off-by: thuva4 <tharma.thuva@gmail.com>
Diffstat (limited to 'testapi/opnfv_testapi/ui/components/pods/podsController.js')
-rw-r--r-- | testapi/opnfv_testapi/ui/components/pods/podsController.js | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/testapi/opnfv_testapi/ui/components/pods/podsController.js b/testapi/opnfv_testapi/ui/components/pods/podsController.js index 95e3571..180e0ed 100644 --- a/testapi/opnfv_testapi/ui/components/pods/podsController.js +++ b/testapi/opnfv_testapi/ui/components/pods/podsController.js @@ -35,6 +35,7 @@ ctrl.url = testapiApiUrl + '/pods'; ctrl.checkBox = [] ctrl.checkBoxList = []; + ctrl.sorting = {}; ctrl.create = create; ctrl.listPods = listPods; @@ -47,6 +48,33 @@ ctrl.batchDelete = batchDelete; ctrl.viewPod = viewPod ctrl.filterText = '' + 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 + } + } /** * This is called when the date filter calendar is opened. It @@ -105,6 +133,7 @@ ctrl.podsRequest = $http.get(reqURL).success(function (data) { ctrl.data = data; + ctrl.sortBy("name") }).catch(function (data) { ctrl.data = null; ctrl.showError = true; |