diff options
Diffstat (limited to 'testapi/opnfv_testapi/ui/components/projects/projectsController.js')
-rw-r--r-- | testapi/opnfv_testapi/ui/components/projects/projectsController.js | 23 |
1 files changed, 19 insertions, 4 deletions
diff --git a/testapi/opnfv_testapi/ui/components/projects/projectsController.js b/testapi/opnfv_testapi/ui/components/projects/projectsController.js index 0d0ec99..07a58fe 100644 --- a/testapi/opnfv_testapi/ui/components/projects/projectsController.js +++ b/testapi/opnfv_testapi/ui/components/projects/projectsController.js @@ -21,7 +21,7 @@ ProjectsController.$inject = [ '$scope', '$http', '$filter', '$state', '$window', '$uibModal', 'testapiApiUrl', - 'raiseAlert', 'confirmModal', 'authenticate' + 'raiseAlert', 'confirmModal', 'authenticate', 'keepState', 'sortService' ]; /** @@ -30,7 +30,7 @@ * through projects declared in TestAPI. */ function ProjectsController($scope, $http, $filter, $state, $window, $uibModal, testapiApiUrl, - raiseAlert, confirmModal, authenticate) { + raiseAlert, confirmModal, authenticate, keepState, sortService) { var ctrl = this; ctrl.url = testapiApiUrl + '/projects'; @@ -44,12 +44,13 @@ ctrl.openBatchDeleteModal = openBatchDeleteModal; ctrl.projectDelete = projectDelete; ctrl.batchDelete = batchDelete; + ctrl.sortByName = sortByName ctrl.checkBox = []; ctrl.checkBoxList = []; ctrl.name = ''; ctrl.details = ''; - ctrl.filterText=''; + ctrl.ascending = false; /** * This will contact the TestAPI to create a new project. @@ -73,6 +74,11 @@ }); } + function sortByName(){ + ctrl.data.projects = sortService.sortFunction(ctrl.data.projects, 'name', ctrl.ascending) + ctrl.ascending = !ctrl.ascending + } + /** * This will open the modal that will show the create * project view @@ -148,13 +154,22 @@ ctrl.showError = false; var content_url = ctrl.url + '?'; var filterText = ctrl.filterText; - if(filterText != ''){ + if(filterText != undefined){ content_url = content_url + 'name=' + filterText; } + else if(keepState.filter.projectFilter){ + for (var filter in keepState.filter.projectFilter){ + content_url = content_url + filter + '=' + keepState.filter.projectFilter[filter] + ctrl.filterText = keepState.filter.projectFilter[filter] + } + } ctrl.resultsRequest = $http.get(content_url).success(function (data) { ctrl.data = data; + keepState.filter.projectFilter = { + 'name': ctrl.filterText + } }).catch(function (data) { ctrl.data = null; ctrl.showError = true; |