diff options
Diffstat (limited to 'testapi/opnfv_testapi/ui/components/pods')
-rw-r--r-- | testapi/opnfv_testapi/ui/components/pods/pod/pod.html | 4 | ||||
-rw-r--r-- | testapi/opnfv_testapi/ui/components/pods/pods.html | 29 | ||||
-rw-r--r-- | testapi/opnfv_testapi/ui/components/pods/podsController.js | 37 |
3 files changed, 55 insertions, 15 deletions
diff --git a/testapi/opnfv_testapi/ui/components/pods/pod/pod.html b/testapi/opnfv_testapi/ui/components/pods/pod/pod.html index b78eb2d..6aace92 100644 --- a/testapi/opnfv_testapi/ui/components/pods/pod/pod.html +++ b/testapi/opnfv_testapi/ui/components/pods/pod/pod.html @@ -12,8 +12,8 @@ <td width="90%" class="podsTableLeftTd">{{ctrl.data.name}}</td> </tr> <tr style="padding:9px"> - <td class="podsTableTd">Owner :</td> - <td width="90%" class="podsTableLeftTd">{{ctrl.data.owner}}</td> + <td class="podsTableTd">Creator :</td> + <td width="90%" class="podsTableLeftTd">{{ctrl.data.creator}}</td> </tr> <tr style="padding:9px"> <td class="podsTableTd">Role :</td> diff --git a/testapi/opnfv_testapi/ui/components/pods/pods.html b/testapi/opnfv_testapi/ui/components/pods/pods.html index 4fa8fb1..8e66a9c 100644 --- a/testapi/opnfv_testapi/ui/components/pods/pods.html +++ b/testapi/opnfv_testapi/ui/components/pods/pods.html @@ -22,7 +22,7 @@ </div> <div class="col-sm-3 pull-right"> <span style="margin-top:6px">Search: </span> - <input type="text" class="form-control search" ng-Model="ctrl.filterText" placeholder="Search String"> + <input type="text" class="form-control search" ng-enter="ctrl.listPods()" ng-Model="ctrl.filterText" placeholder="Search String"> </div> </div> <div class="col-md-12"> @@ -42,9 +42,30 @@ <tr style=" text-align: center;"> <th style="width:1%">Bulk Select</th> - <th>Name</th> - <th>Role</th> - <th>Mode</th> + <th>Name + <a class="text-danger" ng-click="ctrl.sortBy('name')" ng-class="{ 'hidden': !ctrl.sorting['name'] }" > + <span class="glyphicon glyphicon-sort-by-alphabet pull-right" aria-hidden="true"></span> + </a> + <a class="text-danger" ng-click="ctrl.sortBy('name')" ng-class="{ 'hidden': ctrl.sorting['name'] }" > + <span class="glyphicon glyphicon-sort-by-alphabet-alt pull-right" aria-hidden="true"></span> + </a> + </th> + <th>Role + <a class="text-danger" ng-click="ctrl.sortBy('role')" ng-class="{ 'hidden': !ctrl.sorting['role']}" > + <span class="glyphicon glyphicon-sort-by-alphabet pull-right" aria-hidden="true"></span> + </a> + <a class="text-danger" ng-click="ctrl.sortBy('role')" ng-class="{ 'hidden': ctrl.sorting['role']}" > + <span class="glyphicon glyphicon-sort-by-alphabet-alt pull-right" aria-hidden="true"></span> + </a> + </th> + <th>Mode + <a class="text-danger" ng-click="ctrl.sortBy('mode')" ng-class="{ 'hidden': !ctrl.sorting['mode'] }" > + <span class="glyphicon glyphicon-sort-by-alphabet pull-right" aria-hidden="true"></span> + </a> + <a class="text-danger" ng-click="ctrl.sortBy('mode')" ng-class="{ 'hidden': ctrl.sorting['mode'] }" > + <span class="glyphicon glyphicon-sort-by-alphabet-alt pull-right" aria-hidden="true"></span> + </a> + </th> <th ng-class="{ 'hidden': !auth.isAuthenticated }">Operation</th> </tr> </thead> diff --git a/testapi/opnfv_testapi/ui/components/pods/podsController.js b/testapi/opnfv_testapi/ui/components/pods/podsController.js index 95e3571..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' + 'confirmModal', 'keepState', 'sortService' ]; /** @@ -30,11 +30,12 @@ * through pods declared in TestAPI. */ function PodsController($scope, $http, $filter, $state, $window, $uibModal, testapiApiUrl, - raiseAlert, confirmModal) { + raiseAlert, confirmModal, keepState, sortService) { var ctrl = this; ctrl.url = testapiApiUrl + '/pods'; ctrl.checkBox = [] ctrl.checkBoxList = []; + ctrl.sorting = {}; ctrl.create = create; ctrl.listPods = listPods; @@ -46,7 +47,12 @@ ctrl.podDelete = podDelete ctrl.batchDelete = batchDelete; ctrl.viewPod = viewPod - ctrl.filterText = '' + ctrl.sortBy = sortBy + + function sortBy(field){ + ctrl.data.pods = sortService.sortFunction(ctrl.data.pods, field , ctrl.sorting[field] ) + ctrl.sorting[field]=!ctrl.sorting[field] + } /** * This is called when the date filter calendar is opened. It @@ -68,7 +74,6 @@ function create(pod) { ctrl.showError = false; ctrl.showSuccess = false; - console.log(pod); if(pod.name != ""){ var pods_url = ctrl.url; var body = { @@ -99,12 +104,22 @@ function listPods() { ctrl.showError = false; var reqURL = ctrl.url; - if(ctrl.filterText!=''){ + if(ctrl.filterText!=undefined){ reqURL = ctrl.url + "?name=" + ctrl.filterText } + else if(keepState.filter.podFilter){ + for (var filter in keepState.filter.podFilter){ + reqURL = ctrl.url + '?' + filter + '=' + keepState.filter.podFilter[filter] + ctrl.filterText = keepState.filter.podFilter[filter] + } + } ctrl.podsRequest = $http.get(reqURL).success(function (data) { ctrl.data = data; + ctrl.sortBy("name") + keepState.filter.podFilter = { + 'name': ctrl.filterText + } }).catch(function (data) { ctrl.data = null; ctrl.showError = true; @@ -137,7 +152,6 @@ function batchDelete(){ var index; var checkedBox = []; - console.log(ctrl.checkBox) for(index in ctrl.checkBox){ if(!ctrl.showError){ if(ctrl.checkBox[index]){ @@ -153,7 +167,13 @@ * message */ function openBatchDeleteModal() { - confirmModal("Delete",ctrl.batchDelete); + var deleteObjects = [] + for(var index in ctrl.checkBox){ + if(ctrl.checkBox[index]){ + deleteObjects.push(ctrl.data.pods[index].name) + } + } + confirmModal("Delete", 'pods', ctrl.batchDelete, deleteObjects); } /** @@ -161,8 +181,7 @@ * message */ function openDeleteModal(name) { - console.log(name) - confirmModal("Delete", ctrl.podDelete, name); + confirmModal("Delete", 'pod', ctrl.podDelete, name); } /** |