summaryrefslogtreecommitdiffstats
path: root/testapi/opnfv_testapi/ui/components/projects/projectsController.js
diff options
context:
space:
mode:
authorthuva4 <tharma.thuva@gmail.com>2018-03-08 15:17:45 +0530
committerthuva4 <tharma.thuva@gmail.com>2018-03-08 15:17:45 +0530
commitbc5a216764b93ad9551830f2459194a4cea9d754 (patch)
treede285f30e3faf77242e52dc9e07d26225852789d /testapi/opnfv_testapi/ui/components/projects/projectsController.js
parentf3a5531761a38cf40d0469209145394b31af2088 (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/projects/projectsController.js')
-rw-r--r--testapi/opnfv_testapi/ui/components/projects/projectsController.js16
1 files changed, 12 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..d4fa962 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'
];
/**
@@ -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) {
var ctrl = this;
ctrl.url = testapiApiUrl + '/projects';
@@ -49,7 +49,6 @@
ctrl.checkBoxList = [];
ctrl.name = '';
ctrl.details = '';
- ctrl.filterText='';
/**
* This will contact the TestAPI to create a new project.
@@ -148,13 +147,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;