From 910136ee9b9432c54783a939445240acbb07dc84 Mon Sep 17 00:00:00 2001 From: Anthony Lapenna Date: Tue, 19 Sep 2017 18:24:41 +0200 Subject: [PATCH] feat(containers): store show all filter value in a cookie (#1203) --- app/components/containers/containersController.js | 15 ++++++++------- app/services/localStorage.js | 10 ++++++++++ 2 files changed, 18 insertions(+), 7 deletions(-) diff --git a/app/components/containers/containersController.js b/app/components/containers/containersController.js index afd310b9e..4f9ac54b3 100644 --- a/app/components/containers/containersController.js +++ b/app/components/containers/containersController.js @@ -1,16 +1,16 @@ angular.module('containers', []) - .controller('ContainersController', ['$q', '$scope', '$filter', 'Container', 'ContainerService', 'ContainerHelper', 'SystemService', 'Notifications', 'Pagination', 'EntityListService', 'ModalService', 'ResourceControlService', 'EndpointProvider', - function ($q, $scope, $filter, Container, ContainerService, ContainerHelper, SystemService, Notifications, Pagination, EntityListService, ModalService, ResourceControlService, EndpointProvider) { + .controller('ContainersController', ['$q', '$scope', '$filter', 'Container', 'ContainerService', 'ContainerHelper', 'SystemService', 'Notifications', 'Pagination', 'EntityListService', 'ModalService', 'ResourceControlService', 'EndpointProvider', 'LocalStorage', + function ($q, $scope, $filter, Container, ContainerService, ContainerHelper, SystemService, Notifications, Pagination, EntityListService, ModalService, ResourceControlService, EndpointProvider, LocalStorage) { $scope.state = {}; $scope.state.pagination_count = Pagination.getPaginationCount('containers'); - $scope.state.displayAll = true; + $scope.state.displayAll = LocalStorage.getFilterContainerShowAll(); $scope.state.displayIP = false; $scope.sortType = 'State'; $scope.sortReverse = false; $scope.state.selectedItemCount = 0; $scope.truncate_size = 40; $scope.showMore = true; - + $scope.order = function (sortType) { $scope.sortReverse = ($scope.sortType === sortType) ? !$scope.sortReverse : false; $scope.sortType = sortType; @@ -133,6 +133,7 @@ angular.module('containers', []) }; $scope.toggleGetAll = function () { + LocalStorage.storeFilterContainerShowAll($scope.state.displayAll); update({all: $scope.state.displayAll ? 1 : 0}); }; @@ -163,8 +164,8 @@ angular.module('containers', []) $scope.removeAction = function () { batch($scope.containers, Container.remove, 'Removed'); }; - - + + $scope.truncateMore = function(size) { $scope.truncate_size = 80; $scope.showMore = false; @@ -214,7 +215,7 @@ angular.module('containers', []) if(container.Status === 'paused') { $scope.state.noPausedItemsSelected = false; - } else if(container.Status === 'stopped' || + } else if(container.Status === 'stopped' || container.Status === 'created') { $scope.state.noStoppedItemsSelected = false; } else if(container.Status === 'running') { diff --git a/app/services/localStorage.js b/app/services/localStorage.js index ae991ddea..89cd98483 100644 --- a/app/services/localStorage.js +++ b/app/services/localStorage.js @@ -43,6 +43,16 @@ angular.module('portainer.services') }, clean: function() { localStorageService.clearAll(); + }, + storeFilterContainerShowAll: function(filter) { + localStorageService.cookie.set('filter_containerShowAll', filter); + }, + getFilterContainerShowAll: function() { + var filter = localStorageService.cookie.get('filter_containerShowAll'); + if (filter === null) { + filter = true; + } + return filter; } }; }]);