summaryrefslogtreecommitdiffstats
path: root/testapi
diff options
context:
space:
mode:
authorSerena Feng <feng.xiaowei@zte.com.cn>2018-03-09 06:49:25 +0000
committerGerrit Code Review <gerrit@opnfv.org>2018-03-09 06:49:25 +0000
commit7e2f383c4c36b4e55257a6c39da5b2ee92a3f5bd (patch)
tree6a2931f453f5918efaa8ebbfa5eeb1272cfd2e5f /testapi
parent67f50b5771a27280d2a0038436dcea4011ff6345 (diff)
parentbc5a216764b93ad9551830f2459194a4cea9d754 (diff)
Merge "Keep state when user click back in browser"
Diffstat (limited to 'testapi')
-rw-r--r--testapi/opnfv_testapi/ui/app.js6
-rw-r--r--testapi/opnfv_testapi/ui/components/deploy-results/deployResultsController.js14
-rw-r--r--testapi/opnfv_testapi/ui/components/pods/podsController.js18
-rw-r--r--testapi/opnfv_testapi/ui/components/projects/projectsController.js16
-rw-r--r--testapi/opnfv_testapi/ui/components/results/resultsController.js16
5 files changed, 56 insertions, 14 deletions
diff --git a/testapi/opnfv_testapi/ui/app.js b/testapi/opnfv_testapi/ui/app.js
index def88d2..a64bfcc 100644
--- a/testapi/opnfv_testapi/ui/app.js
+++ b/testapi/opnfv_testapi/ui/app.js
@@ -28,6 +28,12 @@
angular
.module('testapiApp')
+ .service("keepState", function(){
+ this.filter = {};
+ });
+
+ angular
+ .module('testapiApp')
.directive('dynamicModel', ['$compile', '$parse', function ($compile, $parse) {
return {
restrict: 'A',
diff --git a/testapi/opnfv_testapi/ui/components/deploy-results/deployResultsController.js b/testapi/opnfv_testapi/ui/components/deploy-results/deployResultsController.js
index 5230a75..1128825 100644
--- a/testapi/opnfv_testapi/ui/components/deploy-results/deployResultsController.js
+++ b/testapi/opnfv_testapi/ui/components/deploy-results/deployResultsController.js
@@ -20,7 +20,8 @@
.controller('DeployResultsController', DeployResultsController);
DeployResultsController.$inject = [
- '$scope', '$http', '$filter', '$state', 'testapiApiUrl','raiseAlert'
+ '$scope', '$http', '$filter', '$state', 'testapiApiUrl','raiseAlert',
+ 'keepState'
];
/**
@@ -29,7 +30,7 @@
* a listing of community uploaded results.
*/
function DeployResultsController($scope, $http, $filter, $state, testapiApiUrl,
- raiseAlert) {
+ raiseAlert, keepState) {
var ctrl = this;
ctrl.open = open;
@@ -122,6 +123,15 @@
function filterList(){
if(ctrl.filter && ctrl.filterText!="" && ctrl.filterText!=undefined){
ctrl.tagArray[ctrl.filter] = ctrl.filterText;
+ if(!keepState.filter.deployResultFilter){
+ keepState.filter.deployResultFilter = {}
+ }
+ keepState.filter.deployResultFilter[ctrl.filter] = ctrl.filterText
+ }
+ else if(Object.keys(ctrl.tagArray).length==0){
+ if(keepState.filter.deployResultFilter){
+ ctrl.tagArray = keepState.filter.deployResultFilter
+ }
}
ctrl.showError = false;
var content_url = testapiApiUrl + '/deployresults' +
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);
}
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;
diff --git a/testapi/opnfv_testapi/ui/components/results/resultsController.js b/testapi/opnfv_testapi/ui/components/results/resultsController.js
index 24f9f55..13ead6e 100644
--- a/testapi/opnfv_testapi/ui/components/results/resultsController.js
+++ b/testapi/opnfv_testapi/ui/components/results/resultsController.js
@@ -38,7 +38,8 @@
}]);
ResultsController.$inject = [
- '$scope', '$http', '$filter', '$state', 'testapiApiUrl','raiseAlert'
+ '$scope', '$http', '$filter', '$state', 'testapiApiUrl', 'raiseAlert',
+ 'keepState'
];
/**
@@ -47,7 +48,7 @@
* a listing of community uploaded results.
*/
function ResultsController($scope, $http, $filter, $state, testapiApiUrl,
- raiseAlert) {
+ raiseAlert, keepState) {
var ctrl = this;
ctrl.open = open;
@@ -219,6 +220,15 @@
function filterList(){
if(ctrl.filter && ctrl.filterText!="" && ctrl.filterText!=undefined){
ctrl.tagArray[ctrl.filter] = ctrl.filterText;
+ if(!keepState.filter.resultFilter){
+ keepState.filter.resultFilter = {}
+ }
+ keepState.filter.resultFilter[ctrl.filter] = ctrl.filterText
+ }
+ else if(Object.keys(ctrl.tagArray).length==0){
+ if(keepState.filter.resultFilter){
+ ctrl.tagArray = keepState.filter.resultFilter
+ }
}
ctrl.showError = false;
var content_url = testapiApiUrl + '/results' +
@@ -260,6 +270,7 @@
});
ctrl.filterText = ''
}
+
ctrl.filterList();
@@ -283,6 +294,7 @@
function clearFilters() {
ctrl.tagArray = {}
ctrl.filter = undefined
+ keepState.filter.resultFilter = {}
ctrl.filterList();
}
}