diff options
author | thuva4 <tharma.thuva@gmail.com> | 2018-03-08 15:17:45 +0530 |
---|---|---|
committer | thuva4 <tharma.thuva@gmail.com> | 2018-03-08 15:17:45 +0530 |
commit | bc5a216764b93ad9551830f2459194a4cea9d754 (patch) | |
tree | de285f30e3faf77242e52dc9e07d26225852789d /testapi/opnfv_testapi/ui/components/pods | |
parent | f3a5531761a38cf40d0469209145394b31af2088 (diff) |
Keep state when user click back in browser
Add service to keep the filter state for every page.
Filters will reload when user click back in the
browser.
JIRA: RELENG-349
Change-Id: I1d82b3ce6004fa41b07ffd0b87626825aa01c922
Signed-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 | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/testapi/opnfv_testapi/ui/components/pods/podsController.js b/testapi/opnfv_testapi/ui/components/pods/podsController.js index 81f6c0a..95e970d 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' ]; /** @@ -30,7 +30,7 @@ * through pods declared in TestAPI. */ function PodsController($scope, $http, $filter, $state, $window, $uibModal, testapiApiUrl, - raiseAlert, confirmModal) { + raiseAlert, confirmModal, keepState) { var ctrl = this; ctrl.url = testapiApiUrl + '/pods'; ctrl.checkBox = [] @@ -47,7 +47,6 @@ ctrl.podDelete = podDelete ctrl.batchDelete = batchDelete; ctrl.viewPod = viewPod - ctrl.filterText = '' ctrl.sortBy = sortBy function sortBy(field){ @@ -96,7 +95,6 @@ function create(pod) { ctrl.showError = false; ctrl.showSuccess = false; - console.log(pod); if(pod.name != ""){ var pods_url = ctrl.url; var body = { @@ -127,13 +125,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; @@ -195,7 +202,6 @@ * message */ function openDeleteModal(name) { - console.log(name) confirmModal("Delete", 'pod', ctrl.podDelete, name); } |