Skip to content

Commit

Permalink
Remember grid or list state for the app wall (#1199)
Browse files Browse the repository at this point in the history
* Remember grid or list state for the app wall

* Fix e2e tests

* Fix default value (e2e fix now not necessarily needed, but safer with)
  • Loading branch information
nwmac authored and richard-cox committed Aug 10, 2017
1 parent 9162ccb commit 15b1b6e
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 6 deletions.
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 layout
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
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@
appWallConfig3(ngMockE2E.$httpBackend);
helpers.setBrowserNormal();
helpers.loadApp();
applicationWall.setGridView();
});

afterAll(function () {
Expand Down Expand Up @@ -132,6 +133,7 @@
appWallConfig500(ngMockE2E.$httpBackend);
helpers.setBrowserNormal();
helpers.loadApp();
applicationWall.setGridView();
});

afterAll(function () {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,14 @@
// Connect the test admin user to all cnsis in params (required to ensure correct permissions are set when
// creating orgs + spaces)
return resetTo.connectAllCnsi(helpers.getAdminUser(), helpers.getAdminPassword(), true);
}).then(function () {
})
.then(function () {
helpers.setBrowserNormal();
helpers.loadApp();
return loginPage.loginAsAdmin();
})
.then(function () {
return galleryWall.setGridView();
});
// Ensure we don't continue until everything is set up
return browser.driver.wait(init);
Expand Down

0 comments on commit 15b1b6e

Please sign in to comment.