Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remember grid or list state for the app wall #1199

Merged
merged 3 commits into from
Aug 10, 2017
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Remember grid or list state for the app wall
  • Loading branch information
nwmac committed Jul 27, 2017
commit 059a4edb54651327f2e16676166e30c77492d44c
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@
})
.run(registerApplicationModel);

function registerApplicationModel(appConfig, modelManager, apiManager, cfAppStateService, $q, modelUtils) {
function registerApplicationModel(appConfig, modelManager, apiManager, cfAppStateService, $q, modelUtils, appLocalStorage) {
modelManager.register('cloud-foundry.model.application', new Application(appConfig, apiManager, modelManager,
cfAppStateService, $q, modelUtils));
cfAppStateService, $q, modelUtils, appLocalStorage));
}

/**
Expand All @@ -31,13 +31,14 @@
* @param {object} cfAppStateService - the Application State service
* @param {object} $q - the $q service for promise/deferred objects
* @param {cloud-foundry.model.modelUtils} modelUtils - a service containing general cf model helpers
* @param {appLocalStorage} appLocalStorage - service provides access to the local storage facility of the web browser
* @property {object} data - holding data.
* @property {object} application - the currently focused application.
* @property {string} appStateSwitchTo - the state of currently focused application is switching to.
* @property {number} pageSize - page size for pagination.
* @class
*/
function Application(config, apiManager, modelManager, cfAppStateService, $q, modelUtils) {
function Application(config, apiManager, modelManager, cfAppStateService, $q, modelUtils, appLocalStorage) {
var applicationApi = apiManager.retrieve('cloud-foundry.api.Apps');
var loadingLimit = config.loadingLimit;

Expand All @@ -56,7 +57,8 @@
spaceGuid: 'all'
},
// Controls view of App Wall (Card layout or List layout)
showCardLayout: true,
// Try and get this from Browser local storage, if not, default to card layour
showCardLayout: appLocalStorage.getItem('cf.app.cardLayout', true) === 'true',
// This state should be in the model
clusterCount: 0,
hasApps: false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,10 @@
* @param {object} cfOrganizationModel - the cfOrganizationModel service
* @param {object} cfAppWallActions - service providing collection of actions that can be taken on the app wall (add,
* deploy, etc)
* @param {appLocalStorage} appLocalStorage - service provides access to the local storage facility of the web browser
*/
function ApplicationsListController($scope, $translate, $state, $timeout, $q, $window, modelManager, appErrorService,
appUtilsService, cfOrganizationModel, cfAppWallActions) {
appUtilsService, cfOrganizationModel, cfAppWallActions, appLocalStorage) {

var vm = this;

Expand Down Expand Up @@ -544,6 +545,7 @@
*/
function goToGalleryView(showCardLayout) {
vm.model.showCardLayout = showCardLayout;
appLocalStorage.setItem('cf.app.cardLayout', showCardLayout);
return $state.go('cf.applications.list.gallery-view');
}

Expand Down