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>
.module('testapiApp')
.config(configureRoutes);
+ angular
+ .module('testapiApp')
+ .service("keepState", function(){
+ this.filter = {};
+ });
+
angular
.module('testapiApp')
.directive('dynamicModel', ['$compile', '$parse', function ($compile, $parse) {
.controller('DeployResultsController', DeployResultsController);
DeployResultsController.$inject = [
- '$scope', '$http', '$filter', '$state', 'testapiApiUrl','raiseAlert'
+ '$scope', '$http', '$filter', '$state', 'testapiApiUrl','raiseAlert',
+ 'keepState'
];
/**
* a listing of community uploaded results.
*/
function DeployResultsController($scope, $http, $filter, $state, testapiApiUrl,
- raiseAlert) {
+ raiseAlert, keepState) {
var ctrl = this;
ctrl.open = open;
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' +
PodsController.$inject = [
'$scope', '$http', '$filter', '$state', '$window', '$uibModal', 'testapiApiUrl','raiseAlert',
- 'confirmModal'
+ 'confirmModal', 'keepState'
];
/**
* 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 = []
ctrl.podDelete = podDelete
ctrl.batchDelete = batchDelete;
ctrl.viewPod = viewPod
- ctrl.filterText = ''
ctrl.sortBy = sortBy
function sortBy(field){
function create(pod) {
ctrl.showError = false;
ctrl.showSuccess = false;
- console.log(pod);
if(pod.name != ""){
var pods_url = ctrl.url;
var body = {
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;
* message
*/
function openDeleteModal(name) {
- console.log(name)
confirmModal("Delete", 'pod', ctrl.podDelete, name);
}
ProjectsController.$inject = [
'$scope', '$http', '$filter', '$state', '$window', '$uibModal', 'testapiApiUrl',
- 'raiseAlert', 'confirmModal', 'authenticate'
+ 'raiseAlert', 'confirmModal', 'authenticate', 'keepState'
];
/**
* 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';
ctrl.checkBoxList = [];
ctrl.name = '';
ctrl.details = '';
- ctrl.filterText='';
/**
* This will contact the TestAPI to create a new project.
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;
}]);
ResultsController.$inject = [
- '$scope', '$http', '$filter', '$state', 'testapiApiUrl','raiseAlert'
+ '$scope', '$http', '$filter', '$state', 'testapiApiUrl', 'raiseAlert',
+ 'keepState'
];
/**
* a listing of community uploaded results.
*/
function ResultsController($scope, $http, $filter, $state, testapiApiUrl,
- raiseAlert) {
+ raiseAlert, keepState) {
var ctrl = this;
ctrl.open = open;
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' +
});
ctrl.filterText = ''
}
+
ctrl.filterList();
function clearFilters() {
ctrl.tagArray = {}
ctrl.filter = undefined
+ keepState.filter.resultFilter = {}
ctrl.filterList();
}
}