Skip to content

Commit

Permalink
Merge pull request #4211 from cloudfoundry/max-list-improvements-serv…
Browse files Browse the repository at this point in the history
…ices

Maxed list improvements - (load all, configuration and extend to service walls)
  • Loading branch information
richard-cox authored Apr 14, 2020
2 parents 50570dd + fae40fb commit 31ac83e
Show file tree
Hide file tree
Showing 67 changed files with 751 additions and 283 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ export class GetAllApplications extends CFStartAction implements PaginatedAction
'results-per-page': 100,
};
flattenPagination = true;
flattenPaginationMax = 600;
flattenPaginationMax = true;
}

export class GetApplication extends CFStartAction implements ICFAction, EntityInlineParentAction {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ export class GetAllOrgUsers extends CFStartAction implements PaginatedAction, En
'order-direction-field': 'username',
};
flattenPagination = true;
flattenPaginationMax = 600;
flattenPaginationMax = true;
skipValidation: boolean;
populateMissing: boolean;
}
10 changes: 5 additions & 5 deletions src/frontend/packages/cloud-foundry/src/actions/route.actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,10 @@ export class CreateRoute extends BaseRouteAction {
...route,
port: generatePort ? undefined : route.port
}, {
params: new HttpParams(generatePort ? {
fromObject: { generate_port: 'true' }
} : {})
}
params: new HttpParams(generatePort ? {
fromObject: { generate_port: 'true' }
} : {})
}
);
}
actions = [CREATE_ROUTE, CREATE_ROUTE_SUCCESS, CREATE_ROUTE_ERROR];
Expand Down Expand Up @@ -153,6 +153,6 @@ export class GetAllRoutes extends CFStartAction implements PaginatedAction, Enti
'order-direction': 'desc',
'order-direction-field': 'route',
};
flattenPaginationMax = 800;
flattenPaginationMax = true;
flattenPagination = true;
}
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ export class GetServiceInstances
q: []
};
flattenPagination = true;
flattenPaginationMax = true;
}

export class GetServiceInstance
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import { entityCatalog } from '../../../store/src/entity-catalog/entity-catalog.service';
import { HttpRequest } from '@angular/common/http';

import { getActions } from '../../../store/src/actions/action.helper';
import { entityCatalog } from '../../../store/src/entity-catalog/entity-catalog.service';
import { PaginatedAction } from '../../../store/src/types/pagination.types';
import { CF_ENDPOINT_TYPE } from '../cf-types';
import { cfEntityFactory } from '../cf-entity-factory';
import { serviceEntityType, servicePlanEntityType } from '../cf-entity-types';
import { CF_ENDPOINT_TYPE } from '../cf-types';
import { createEntityRelationKey, EntityInlineParentAction } from '../entity-relations/entity-relations.types';
import { CFStartAction } from './cf-action.types';
import { HttpRequest } from '@angular/common/http';

export class GetAllServices extends CFStartAction implements PaginatedAction, EntityInlineParentAction {
constructor(
Expand Down Expand Up @@ -34,6 +35,7 @@ export class GetAllServices extends CFStartAction implements PaginatedAction, En
'order-direction-field': 'label',
};
flattenPagination = true;
flattenPaginationMax = true;
}
export class GetService extends CFStartAction implements EntityInlineParentAction {
constructor(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { EntityCatalogEntityConfig } from '../../../store/src/entity-catalog/entity-catalog.types';
import { HttpRequest } from '@angular/common/http';

import { getActions } from '../../../store/src/actions/action.helper';
import { EntityCatalogEntityConfig } from '../../../store/src/entity-catalog/entity-catalog.types';
import { endpointSchemaKey } from '../../../store/src/helpers/entity-factory';
import { QParam, QParamJoiners } from '../shared/q-param';
import { PaginatedAction } from '../../../store/src/types/pagination.types';
import { ICFAction } from '../../../store/src/types/request.types';
import { cfEntityFactory } from '../cf-entity-factory';
Expand All @@ -18,8 +19,8 @@ import {
createEntityRelationPaginationKey,
EntityInlineParentAction,
} from '../entity-relations/entity-relations.types';
import { QParam, QParamJoiners } from '../shared/q-param';
import { CFStartAction } from './cf-action.types';
import { HttpRequest } from '@angular/common/http';

export const getUserProvidedServiceInstanceRelations = [
createEntityRelationKey(userProvidedServiceInstanceEntityType, spaceWithOrgEntityType),
Expand Down Expand Up @@ -59,6 +60,7 @@ export class GetAllUserProvidedServices extends CFStartAction implements Paginat
q: []
};
flattenPagination = true;
flattenPaginationMax = true;
paginationKey: string;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ export class GetAllUsersAsAdmin extends CFStartAction implements PaginatedAction
'order-direction-field': 'username',
};
flattenPagination = true;
flattenPaginationMax = 600;
flattenPaginationMax = true;
static is(action: any): boolean {
return !!action.isGetAllUsersAsAdmin;
}
Expand Down
58 changes: 54 additions & 4 deletions src/frontend/packages/cloud-foundry/src/cf-entity-generator.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
import { Store } from '@ngrx/store';
import * as moment from 'moment';
import { combineLatest, of } from 'rxjs';
import { map } from 'rxjs/operators';

import {
IService,
Expand Down Expand Up @@ -26,6 +29,7 @@ import {
} from '../../core/src/core/cf-api.types';
import { urlValidationExpression } from '../../core/src/core/utils.service';
import { BaseEndpointAuth } from '../../core/src/features/endpoints/endpoint-auth';
import { AppState } from '../../store/src/app-state';
import {
StratosBaseCatalogEntity,
StratosCatalogEndpointEntity,
Expand All @@ -41,8 +45,10 @@ import {
} from '../../store/src/entity-request-pipeline/entity-request-base-handlers/handle-multi-endpoints.pipe';
import { JetstreamResponse } from '../../store/src/entity-request-pipeline/entity-request-pipeline.types';
import { EntitySchema } from '../../store/src/helpers/entity-schema';
import { selectSessionData } from '../../store/src/reducers/auth.reducer';
import { endpointDisconnectRemoveEntitiesReducer } from '../../store/src/reducers/endpoint-disconnect-application.reducer';
import { APIResource } from '../../store/src/types/api.types';
import { PaginatedAction } from '../../store/src/types/pagination.types';
import { IFavoriteMetadata } from '../../store/src/types/user-favorites.types';
import { cfEntityFactory } from './cf-entity-factory';
import { addCfQParams, addCfRelationParams } from './cf-entity-relations.getters';
Expand Down Expand Up @@ -199,7 +205,45 @@ export function generateCFEntities(): StratosBaseCatalogEntity[] {
Object.values(responseWithPages).reduce((all, response: CFResponse | CFResponse[]) => {
return all + (response[0] || response).total_results;
}, 0),
getPaginationParameters: (page: number) => ({ page: page + '' })
getPaginationParameters: (page: number) => ({ page: page + '' }),
canIgnoreMaxedState: (store: Store<AppState>) => {
// Does entity type support? Yes
// Does BE support ignore?
return store.select(selectSessionData()).pipe(
map(sessionData => !!sessionData.config.listAllowLoadMaxed)
);
},
maxedStateStartAt: (store: Store<AppState>, action: PaginatedAction) => {
// Disable via the action?
// Only allowed maxed process if enabled by action. This will be removed via #4204
if (!action.flattenPaginationMax) {
return of(null);
}

// Maxed Count from Backend?
const beValue$ = store.select(selectSessionData()).pipe(
map(sessionData => sessionData.config.listMaxSize)
);

// TODO: See #4205
// Maxed count as per user config
const userOverride$ = of(null);
// const userOverride$ = store.select(selectSessionData()).pipe(
// // Check that the user is allowed to load all, if so they can set their own max number
// map(sessionData => !!sessionData.config.listAllowLoadMaxed ? null : null)
// );

// Maxed count from entity type
const entityTypeDefault = 600;

// Choose in order of priority
return combineLatest([
beValue$,
userOverride$
]).pipe(
map(([beValue, userOverride]) => userOverride || beValue || entityTypeDefault)
);
},
}
};
return [
Expand Down Expand Up @@ -259,7 +303,9 @@ function generateCFAppEnvVarEntity(endpointDefinition: StratosEndpointExtensionD
getEntitiesFromResponse: (response) => response,
getTotalPages: (responses: JetstreamResponse<CFResponse>) => Object.values(responses).length,
getTotalEntities: (responses: JetstreamResponse<CFResponse>) => 1,
getPaginationParameters: (page: number) => ({ page: '1' })
getPaginationParameters: (page: number) => ({ page: '1' }),
canIgnoreMaxedState: () => of(false),
maxedStateStartAt: () => of(null),
},
successfulRequestDataMapper: (data, endpointGuid, guid, entityType, endpointType, action) => {
return {
Expand Down Expand Up @@ -409,7 +455,9 @@ function generateCFAppStatsEntity(endpointDefinition: StratosEndpointExtensionDe
getTotalEntities: (responses: JetstreamResponse) => Object.values(responses).reduce((count, response) => {
return count + Object.keys(response).length;
}, 0),
getPaginationParameters: (page: number) => ({ page: page + '' })
getPaginationParameters: (page: number) => ({ page: page + '' }),
canIgnoreMaxedState: () => of(false),
maxedStateStartAt: () => of(null),
},
successfulRequestDataMapper: (data, endpointGuid, guid, entityType, endpointType, action) => {
if (data) {
Expand Down Expand Up @@ -837,7 +885,9 @@ function generateFeatureFlagEntity(endpointDefinition: StratosEndpointExtensionD
},
getTotalPages: (responses: JetstreamResponse) => 1,
getTotalEntities: (responses: JetstreamResponse) => responses.length,
getPaginationParameters: (page: number) => ({ page: page + '' })
getPaginationParameters: (page: number) => ({ page: page + '' }),
canIgnoreMaxedState: () => of(false),
maxedStateStartAt: () => of(null),
}
};
return new StratosCatalogEntity<IBasicCFMetaData, IFeatureFlag>(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
import { HttpParams, HttpRequest } from '@angular/common/http';

import { InternalAppState } from '../../store/src/app-state';
import { StratosBaseCatalogEntity } from '../../store/src/entity-catalog/entity-catalog-entity';
import { entityCatalog } from '../../store/src/entity-catalog/entity-catalog.service';
import { EntityCatalogEntityConfig } from '../../store/src/entity-catalog/entity-catalog.types';
import { InternalAppState } from '../../store/src/app-state';
import {
getPaginationParams,
} from '../../store/src/entity-request-pipeline/pagination-request-base-handlers/get-params.pipe';
import { QParam } from './shared/q-param';
import { selectPaginationState } from '../../store/src/selectors/pagination.selectors';
import { isPaginatedAction, PaginatedAction, PaginationParam } from '../../store/src/types/pagination.types';
import { EntityRequestAction } from '../../store/src/types/request.types';
import { listEntityRelations } from './entity-relations/entity-relations';
import { EntityInlineParentAction, isEntityInlineParentAction } from './entity-relations/entity-relations.types';
import { QParam } from './shared/q-param';

export function getEntityRelationsForEntityRequest(action: EntityInlineParentAction & EntityRequestAction) {
return listEntityRelations(
Expand Down Expand Up @@ -101,8 +101,12 @@ export function addCfQParams(
// Add initial params from action
const newParamsFromAction = setQParams(newParams, action.initialParams);

// If __forcedPageEntityConfig__ has been set we're in a multi action list scenario and params should come from the base action. In this
// instance it's the entity details from the action, not the catalogueEntity that's passed in (type of entity that we're requesting)
const entityKey = action.__forcedPageEntityConfig__ ? entityCatalog.getEntityKey(action) : catalogEntity.entityKey;

// Overwrite initial params with params from store
const paginationState = selectPaginationState(catalogEntity.entityKey, action.paginationKey)(appState);
const paginationState = selectPaginationState(entityKey, action.paginationKey)(appState);
const paginationParams = getPaginationParams(paginationState);
const paramsFromPagination = setQParams(newParamsFromAction, paginationParams);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,6 @@ <h1>Applications</h1>
}"></app-no-content-message>
</ng-template>

<ng-template #noEntriesMaxedResults>
<app-no-content-message [icon]="'apps'" [firstLine]="'There are too many applications to show'" [secondLine]="{
text: 'Please use the the Cloud Foundry, Organization or Space filters'
}"></app-no-content-message>
</ng-template>
<app-list class="app-wall" [noEntries]="noEntries" [noEntriesForCurrentFilter]="noEntriesForCurrentFilter"
[noEntriesMaxedResults]="noEntriesMaxedResults"
*ngIf="!!(cloudFoundryService.hasRegisteredCFEndpoints$ | async) && !!(cloudFoundryService.hasConnectedCFEndpoints$ | async)">
</app-list>
Original file line number Diff line number Diff line change
Expand Up @@ -363,7 +363,7 @@ export function fetchTotalResults(

export const cfOrgSpaceFilter = (entities: APIResource[], paginationState: PaginationEntityState) => {
// Filtering is done remotely when maxedResults are hit (see `setMultiFilter`)
if (!!paginationState.maxedMode) {
if (!!paginationState.maxedState.isMaxedMode && !paginationState.maxedState.ignoreMaxed) {
return entities;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,6 @@
}"></app-no-content-message>
</ng-template>

<ng-template #noEntriesMaxedResults>
<app-no-content-message [icon]="'people'" [firstLine]="'There are too many users to show'"></app-no-content-message>
</ng-template>

<app-cf-admin-add-user-warning></app-cf-admin-add-user-warning>
<app-cloud-foundry-invite-user-link></app-cloud-foundry-invite-user-link>
<app-list [noEntries]="noEntries" [noEntriesForCurrentFilter]="noEntriesForCurrentFilter"
[noEntriesMaxedResults]="noEntriesMaxedResults"></app-list>
<app-list [noEntries]="noEntries" [noEntriesForCurrentFilter]="noEntriesForCurrentFilter"></app-list>
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,6 @@
}"></app-no-content-message>
</ng-template>

<ng-template #noEntriesMaxedResults>
<app-no-content-message [icon]="'people'" [firstLine]="'There are too many users to show'" [secondLine]="{
text: 'Please navigate to a Space users list'
}"></app-no-content-message>
</ng-template>

<app-cf-admin-add-user-warning></app-cf-admin-add-user-warning>
<app-cloud-foundry-invite-user-link></app-cloud-foundry-invite-user-link>
<app-list [noEntries]="noEntries" [noEntriesForCurrentFilter]="noEntriesForCurrentFilter"
[noEntriesMaxedResults]="noEntriesMaxedResults"></app-list>
<app-list [noEntries]="noEntries" [noEntriesForCurrentFilter]="noEntriesForCurrentFilter"></app-list>
Original file line number Diff line number Diff line change
@@ -1,6 +1 @@
<ng-template #noEntriesMaxedResults>
<app-no-content-message [icon]="'apps'" [firstLine]="'There are too many routes to show'" [secondLine]="{
text: 'Please use the Organization or Space filters'
}"></app-no-content-message>
</ng-template>
<app-list [noEntriesMaxedResults]="noEntriesMaxedResults"></app-list>
<app-list></app-list>
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,4 @@
}"></app-no-content-message>
</ng-template>

<ng-template #noEntriesMaxedResults>
<app-no-content-message [icon]="'people'" [firstLine]="'There are too many users to show'" [secondLine]="{
text: 'Please navigate to an Organization or Space users list'
}"></app-no-content-message>
</ng-template>

<app-list [noEntries]="noEntries" [noEntriesForCurrentFilter]="noEntriesForCurrentFilter"
[noEntriesMaxedResults]="noEntriesMaxedResults"></app-list>
<app-list [noEntries]="noEntries" [noEntriesForCurrentFilter]="noEntriesForCurrentFilter"></app-list>
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { UtilsService } from '../../../../../../../core/src/core/utils.service';
import {
createTableColumnFavorite,
} from '../../../../../../../core/src/shared/components/list/list-table/table-cell-favorite/table-cell-favorite.component';
import { ITableColumn } from '../../../../../../../core/src/shared/components/list/list-table/table.types';
import { ITableColumn, ITableText } from '../../../../../../../core/src/shared/components/list/list-table/table.types';
import {
IListConfig,
IListMultiFilterConfig,
Expand Down Expand Up @@ -136,10 +136,16 @@ export class CfAppConfigService extends ListConfig<APIResource> implements IList
}),
];
viewType = ListViewTypes.BOTH;
text = {
text: ITableText = {
title: '',
filter: 'Search by name',
noEntries: 'There are no applications'
noEntries: 'There are no applications',
maxedResults: {
icon: 'apps',
canIgnoreMaxFirstLine: 'Fetching all applications might take a long time',
cannotIgnoreMaxFirstLine: 'There are too many applications to fetch',
filterLine: 'Please use the Cloud Foundry, Organization or Space filters'
}
};
enableTextFilter = true;
cardComponent = CardAppComponent;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,6 @@ import { cfOrgSpaceFilter, getRowMetadata } from '../../../../../features/cloud-
import { CFListDataSource } from '../../../../cf-list-data-source';
import { createCfOrSpaceMultipleFilterFn } from '../../../../data-services/cf-org-space-service.service';

// export function createGetAllAppAction(paginationKey): GetAllApplications {
// return new GetAllApplications(paginationKey, null, [
// createEntityRelationKey(applicationEntityType, spaceEntityType),
// createEntityRelationKey(spaceEntityType, organizationEntityType),
// createEntityRelationKey(applicationEntityType, routeEntityType),
// ]);
// }

export class CfAppsDataSource extends CFListDataSource<APIResource> {

public static paginationKey = 'applicationWall';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,6 @@ export class CfOrgUsersListConfigService extends CfUserListConfigService {
(user: CfUser): boolean => cfUserService.hasRolesInOrg(user, activeRouteCfOrgSpace.orgGuid, false),
cfOrgService.org$
);
this.text.maxedResults.filterLine = 'Please navigate to a Space Users list';
}
}
Loading

0 comments on commit 31ac83e

Please sign in to comment.