Skip to content
This repository has been archived by the owner on Jan 24, 2023. It is now read-only.

Commit

Permalink
Merge remote-tracking branch 'upstream/max-list-improvements-services…
Browse files Browse the repository at this point in the history
…' into upstream-merge
  • Loading branch information
richard-cox committed Apr 14, 2020
2 parents eea51bb + fae40fb commit fdb4041
Show file tree
Hide file tree
Showing 110 changed files with 2,065 additions and 833 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 @@ -189,4 +189,32 @@
</mat-card>
</app-tile>
</app-tile-group>
</app-tile-grid>

<!-- Advanced info -->
<app-tile-group>
<app-tile>
<mat-card>
<mat-card-header>
<mat-card-title>Additional Application Info</mat-card-title>
</mat-card-header>
<mat-card-content>
<app-metadata-item icon="fingerprint" label="Application GUID" [clipboardValue]="appSvc.app.entity.guid">{{ appSvc.app.entity.guid }}</app-metadata-item>
<app-metadata-item icon="chevron_right" label="Command">{{ appSvc.app.entity.command || appSvc.app.entity.detected_start_command || '-' }}</app-metadata-item>
<app-metadata-item icon="power" label="Ports">{{ appSvc.app.entity.ports || '-' }}</app-metadata-item>
</mat-card-content>
</mat-card>
</app-tile>
<app-tile>
<mat-card>
<mat-card-header>
<mat-card-title>Health Check Configuration</mat-card-title>
</mat-card-header>
<mat-card-content>
<app-metadata-item icon="favorite_border" label="Health Check Type">{{ appSvc.app.entity.health_check_type }}</app-metadata-item>
<app-metadata-item icon="schedule" label="Health Check Timeout">{{ appSvc.app.entity.health_check_timeout | uptime }}</app-metadata-item>
<app-metadata-item *ngIf="appSvc.app.entity.health_check_type === 'http'" icon="http" label="Health Check HTTP Endpoint">{{ appSvc.app.entity.health_check_http_endpoint }}</app-metadata-item>
</mat-card-content>
</mat-card>
</app-tile>
</app-tile-group>
</app-tile-grid>
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Store } from '@ngrx/store';
import { BehaviorSubject, Observable, of as observableOf, Subject, Subscription } from 'rxjs';
import { BehaviorSubject, of as observableOf, Subject, Subscription } from 'rxjs';
import websocketConnect from 'rxjs-websockets';
import { catchError, combineLatest, filter, first, map, mergeMap, share, switchMap, tap } from 'rxjs/operators';

Expand Down Expand Up @@ -91,7 +91,7 @@ export class DeployApplicationDeployer {
// Status of file transfers
fileTransferStatus$ = new BehaviorSubject<FileTransferStatus>(undefined);

public messages: Observable<string>;
public messages = new BehaviorSubject<string>('');

// Are we deploying?
deploying = false;
Expand Down Expand Up @@ -165,13 +165,14 @@ export class DeployApplicationDeployer {
this.applicationSource = appDetail.applicationSource;
this.applicationOverrides = appDetail.applicationOverrides;
const host = window.location.host;
const appId = this.isRedeploy ? `&app=${this.isRedeploy}` : '';
const streamUrl = (
`wss://${host}/pp/${this.proxyAPIVersion}/${this.cfGuid}/${this.orgGuid}/${this.spaceGuid}/deploy` +
`?org=${org.entity.name}&space=${space.entity.name}`
`?org=${org.entity.name}&space=${space.entity.name}${appId}`
);

this.inputStream = new Subject<string>();
this.messages = websocketConnect(streamUrl)
const buffer = websocketConnect(streamUrl)
.pipe(
switchMap((get) => get(this.inputStream)),
catchError(e => {
Expand All @@ -189,7 +190,16 @@ export class DeployApplicationDeployer {
map((log) => log.message),
share(),
);
this.msgSub = this.messages.subscribe();

// Buffer messages until each newline character
let b = '';
this.msgSub = buffer.subscribe(m => {
b = b + m;
if (b.endsWith('\n')) {
this.messages.next(b);
b = '';
}
});
})
).subscribe();

Expand Down
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>
Loading

0 comments on commit fdb4041

Please sign in to comment.