From a728c34afde0bf37e85bbf386a6577208105b5e2 Mon Sep 17 00:00:00 2001 From: Richard Cox Date: Thu, 18 Jun 2020 10:29:16 +0100 Subject: [PATCH 01/12] WIP --- .../src/actions/cf-event.actions.ts | 2 +- .../src/actions/domains.actions.ts | 5 +- .../src/actions/feature-flags.actions.ts | 2 +- .../cloud-foundry/src/actions/stack.action.ts | 2 +- .../actions/user-provided-service.actions.ts | 2 +- .../src/actions/users.actions.ts | 2 +- .../src/cloud-foundry-test.module.ts | 2 +- ...te-instances-routes-list-config.service.ts | 2 +- .../cli-info-application.component.ts | 18 +- .../create-organization-step.component.ts | 2 +- .../edit-organization-step.component.ts | 2 +- .../quota-definition-form.component.ts | 2 +- .../cloud-foundry-endpoint.service.ts | 11 +- .../space-quota-definition-form.component.ts | 2 +- .../user-invites/user-invite.service.ts | 7 +- .../users/manage-users/cf-roles.service.ts | 2 +- .../services/services-wall.service.ts | 2 +- .../table-cell-cf-cell.component.ts | 4 +- .../cf-buildpacks-data-source.ts | 2 +- .../cf-endpoints/cf-endpoints-data-source.ts | 4 +- .../cf-quotas-data-source.service.ts | 8 +- .../cf-security-groups-data-source.ts | 2 +- .../cf-services/cf-services-data-source.ts | 2 +- .../cf-space-quotas-data-source.service.ts | 9 +- .../long-running-cf-op.service.ts | 2 + .../services/cf-org-space-label.service.ts | 2 +- .../current-user-permissions.service.spec.ts | 2 +- .../src/store/reducers/cf-users.reducer.ts | 3 +- .../test-framework/cf-test-helper.ts | 2 +- src/frontend/packages/core/src/app.module.ts | 4 +- .../packages/core/src/base-entity-schemas.ts | 40 ++-- .../packages/core/src/base-entity-types.ts | 110 ---------- .../current-user-permissions.service.spec.ts | 2 +- .../current-user-permissions.service.ts | 9 +- .../core/src/core/user-profile.service.ts | 75 +++---- .../backup-endpoints.component.ts | 20 +- .../restore-endpoints.component.ts | 4 +- .../src/features/endpoints/connect.service.ts | 57 +---- .../create-endpoint-cf-step-1.component.ts | 61 ++---- .../edit-endpoint-step.component.ts | 44 ++-- .../error-page/error-page.component.ts | 12 +- .../endpoint/base-endpoints-data-source.ts | 6 +- .../endpoint/endpoint-list.helpers.ts | 54 ++--- .../endpoint/endpoints-data-source.ts | 4 +- .../table-cell-endpoint-address.component.ts | 9 +- .../table-cell-endpoint-name.component.ts | 15 +- .../recent-entities.component.ts | 2 +- .../packages/core/src/shared/entity.tokens.ts | 4 +- .../core/src/stratos-entity-generator.ts | 136 ++++++++++++ .../core/test-framework/core-test.modules.ts | 2 +- .../store/src/actions/endpoint.actions.ts | 173 ++++++++++----- .../store/src/actions/system.actions.ts | 26 ++- .../user-favourites.actions.ts | 14 ++ .../store/src/actions/user-profile.actions.ts | 33 ++- .../store/src/effects/auth.effects.ts | 7 +- .../effects/endpoint-api-errors.effects.ts | 2 +- .../store/src/effects/endpoint.effects.ts | 101 +++------ .../store/src/effects/system.effects.ts | 29 +-- .../store/src/effects/user-profile.effects.ts | 107 ++++----- .../endpoint-errors.handler.ts | 2 +- .../jetstream-error.handler.ts | 2 +- .../store/src/helpers/entity-factory.ts | 32 --- .../src/helpers/stratos-entity-factory.ts | 47 ++++ .../recently-visited.reducer.ts | 7 +- .../store/src/reducers/endpoints.reducer.ts | 13 +- .../src/reducers/internal-events.reducer.ts | 18 +- .../pagination.reducer.spec.ts | 6 +- .../src/reducers/system-endpoints.reducer.ts | 1 + .../store/src/selectors/endpoint.selectors.ts | 3 +- .../store/src/stratos-entity-catalog.ts | 207 ++++++++++++++++++ .../store/src/types/endpoint.types.ts | 2 +- .../packages/store/src/types/system.types.ts | 19 +- 72 files changed, 897 insertions(+), 733 deletions(-) delete mode 100644 src/frontend/packages/core/src/base-entity-types.ts create mode 100644 src/frontend/packages/core/src/stratos-entity-generator.ts create mode 100644 src/frontend/packages/store/src/actions/user-favourites-actions/user-favourites.actions.ts delete mode 100644 src/frontend/packages/store/src/helpers/entity-factory.ts create mode 100644 src/frontend/packages/store/src/helpers/stratos-entity-factory.ts create mode 100644 src/frontend/packages/store/src/stratos-entity-catalog.ts diff --git a/src/frontend/packages/cloud-foundry/src/actions/cf-event.actions.ts b/src/frontend/packages/cloud-foundry/src/actions/cf-event.actions.ts index ad2daf059f..8b60ff4103 100644 --- a/src/frontend/packages/cloud-foundry/src/actions/cf-event.actions.ts +++ b/src/frontend/packages/cloud-foundry/src/actions/cf-event.actions.ts @@ -1,6 +1,6 @@ import { HttpParams, HttpRequest } from '@angular/common/http'; -import { endpointSchemaKey } from '../../../store/src/helpers/entity-factory'; +import { endpointSchemaKey } from '../../../store/src/helpers/stratos-entity-factory'; import { PaginatedAction } from '../../../store/src/types/pagination.types'; import { cfEntityFactory } from '../cf-entity-factory'; import { cfEventEntityType } from '../cf-entity-types'; diff --git a/src/frontend/packages/cloud-foundry/src/actions/domains.actions.ts b/src/frontend/packages/cloud-foundry/src/actions/domains.actions.ts index 6d56f47d8d..8320c9cc55 100644 --- a/src/frontend/packages/cloud-foundry/src/actions/domains.actions.ts +++ b/src/frontend/packages/cloud-foundry/src/actions/domains.actions.ts @@ -1,11 +1,12 @@ -import { endpointSchemaKey } from '../../../store/src/helpers/entity-factory'; +import { HttpRequest } from '@angular/common/http'; + +import { endpointSchemaKey } from '../../../store/src/helpers/stratos-entity-factory'; import { PaginatedAction } from '../../../store/src/types/pagination.types'; import { ICFAction } from '../../../store/src/types/request.types'; import { cfEntityFactory } from '../cf-entity-factory'; import { domainEntityType } from '../cf-entity-types'; import { createEntityRelationPaginationKey } from '../entity-relations/entity-relations.types'; import { CFStartAction } from './cf-action.types'; -import { HttpRequest } from '@angular/common/http'; export const GET_DOMAIN = '[domain] Get domain '; export const GET_DOMAIN_SUCCESS = '[domain] Get domain success'; diff --git a/src/frontend/packages/cloud-foundry/src/actions/feature-flags.actions.ts b/src/frontend/packages/cloud-foundry/src/actions/feature-flags.actions.ts index 6ec461e70b..b2b63f94bc 100644 --- a/src/frontend/packages/cloud-foundry/src/actions/feature-flags.actions.ts +++ b/src/frontend/packages/cloud-foundry/src/actions/feature-flags.actions.ts @@ -1,7 +1,7 @@ import { HttpRequest } from '@angular/common/http'; import { getActions } from '../../../store/src/actions/action.helper'; -import { endpointSchemaKey } from '../../../store/src/helpers/entity-factory'; +import { endpointSchemaKey } from '../../../store/src/helpers/stratos-entity-factory'; import { PaginatedAction } from '../../../store/src/types/pagination.types'; import { RequestEntityLocation } from '../../../store/src/types/request.types'; import { cfEntityFactory } from '../cf-entity-factory'; diff --git a/src/frontend/packages/cloud-foundry/src/actions/stack.action.ts b/src/frontend/packages/cloud-foundry/src/actions/stack.action.ts index b4a274ee38..c1795145f6 100644 --- a/src/frontend/packages/cloud-foundry/src/actions/stack.action.ts +++ b/src/frontend/packages/cloud-foundry/src/actions/stack.action.ts @@ -2,7 +2,7 @@ import { HttpRequest } from '@angular/common/http'; import { getActions } from '../../../store/src/actions/action.helper'; import { entityCatalog } from '../../../store/src/entity-catalog/entity-catalog'; -import { endpointSchemaKey } from '../../../store/src/helpers/entity-factory'; +import { endpointSchemaKey } from '../../../store/src/helpers/stratos-entity-factory'; import { PaginatedAction } from '../../../store/src/types/pagination.types'; import { ICFAction } from '../../../store/src/types/request.types'; import { stackEntityType } from '../cf-entity-types'; diff --git a/src/frontend/packages/cloud-foundry/src/actions/user-provided-service.actions.ts b/src/frontend/packages/cloud-foundry/src/actions/user-provided-service.actions.ts index 0080cf6962..7f447bc860 100644 --- a/src/frontend/packages/cloud-foundry/src/actions/user-provided-service.actions.ts +++ b/src/frontend/packages/cloud-foundry/src/actions/user-provided-service.actions.ts @@ -2,7 +2,7 @@ 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 { endpointSchemaKey } from '../../../store/src/helpers/stratos-entity-factory'; import { PaginatedAction } from '../../../store/src/types/pagination.types'; import { ICFAction } from '../../../store/src/types/request.types'; import { cfEntityFactory } from '../cf-entity-factory'; diff --git a/src/frontend/packages/cloud-foundry/src/actions/users.actions.ts b/src/frontend/packages/cloud-foundry/src/actions/users.actions.ts index 40f7d57afc..46e4dee569 100644 --- a/src/frontend/packages/cloud-foundry/src/actions/users.actions.ts +++ b/src/frontend/packages/cloud-foundry/src/actions/users.actions.ts @@ -1,8 +1,8 @@ import { HttpRequest } from '@angular/common/http'; import { getActions } from '../../../store/src/actions/action.helper'; -import { endpointSchemaKey } from '../../../store/src/helpers/entity-factory'; import { EntitySchema } from '../../../store/src/helpers/entity-schema'; +import { endpointSchemaKey } from '../../../store/src/helpers/stratos-entity-factory'; import { PaginatedAction } from '../../../store/src/types/pagination.types'; import { EntityRequestAction } from '../../../store/src/types/request.types'; import { cfEntityFactory } from '../cf-entity-factory'; diff --git a/src/frontend/packages/cloud-foundry/src/cloud-foundry-test.module.ts b/src/frontend/packages/cloud-foundry/src/cloud-foundry-test.module.ts index 11769b81a4..c39f9fd41d 100644 --- a/src/frontend/packages/cloud-foundry/src/cloud-foundry-test.module.ts +++ b/src/frontend/packages/cloud-foundry/src/cloud-foundry-test.module.ts @@ -3,9 +3,9 @@ import { NgModule } from '@angular/core'; import { EffectsModule } from '@ngrx/effects'; import { generateASEntities } from '../../cf-autoscaler/src/store/autoscaler-entity-generator'; -import { generateStratosEntities } from '../../core/src/base-entity-types'; import { getGitHubAPIURL, GITHUB_API_URL } from '../../core/src/core/github.helpers'; import { LoggerService } from '../../core/src/core/logger.service'; +import { generateStratosEntities } from '../../core/src/stratos-entity-generator'; import { CATALOGUE_ENTITIES, EntityCatalogFeatureModule } from '../../store/src/entity-catalog.module'; import { entityCatalog, TestEntityCatalog } from '../../store/src/entity-catalog/entity-catalog'; import { testSCFEndpointGuid } from '../../store/testing/public-api'; diff --git a/src/frontend/packages/cloud-foundry/src/features/applications/application-delete/delete-app-instances/app-delete-instances-routes-list-config.service.ts b/src/frontend/packages/cloud-foundry/src/features/applications/application-delete/delete-app-instances/app-delete-instances-routes-list-config.service.ts index 91f805f77c..59a07fe363 100644 --- a/src/frontend/packages/cloud-foundry/src/features/applications/application-delete/delete-app-instances/app-delete-instances-routes-list-config.service.ts +++ b/src/frontend/packages/cloud-foundry/src/features/applications/application-delete/delete-app-instances/app-delete-instances-routes-list-config.service.ts @@ -12,7 +12,7 @@ import { import { CurrentUserPermissionsService } from '../../../../../../core/src/core/permissions/current-user-permissions.service'; import { RowState } from '../../../../../../core/src/shared/components/list/data-sources-controllers/list-data-source-types'; import { ListViewTypes } from '../../../../../../core/src/shared/components/list/list.component.types'; -import { endpointSchemaKey } from '../../../../../../store/src/helpers/entity-factory'; +import { endpointSchemaKey } from '../../../../../../store/src/helpers/stratos-entity-factory'; import { PaginationMonitorFactory } from '../../../../../../store/src/monitors/pagination-monitor.factory'; import { APIResource } from '../../../../../../store/src/types/api.types'; import { IServiceBinding } from '../../../../cf-api-svc.types'; diff --git a/src/frontend/packages/cloud-foundry/src/features/applications/cli-info-application/cli-info-application.component.ts b/src/frontend/packages/cloud-foundry/src/features/applications/cli-info-application/cli-info-application.component.ts index 9785603d75..3f260c0155 100644 --- a/src/frontend/packages/cloud-foundry/src/features/applications/cli-info-application/cli-info-application.component.ts +++ b/src/frontend/packages/cloud-foundry/src/features/applications/cli-info-application/cli-info-application.component.ts @@ -2,11 +2,10 @@ import { Component, OnInit } from '@angular/core'; import { BehaviorSubject, combineLatest, Observable } from 'rxjs'; import { filter, first, map } from 'rxjs/operators'; -import { EntityService } from '../../../../../store/src/entity-service'; -import { EntityServiceFactory } from '../../../../../store/src/entity-service-factory.service'; import { getFullEndpointApiUrl } from '../../../../../core/src/features/endpoints/endpoint-helpers'; import { IHeaderBreadcrumb } from '../../../../../core/src/shared/components/page-header/page-header.types'; -import { GetAllEndpoints } from '../../../../../store/src/actions/endpoint.actions'; +import { EntityService } from '../../../../../store/src/entity-service'; +import { stratosEntityCatalog } from '../../../../../store/src/stratos-entity-catalog'; import { EndpointModel } from '../../../../../store/src/types/endpoint.types'; import { CFAppCLIInfoContext } from '../../../shared/components/cli-info/cli-info.component'; import { ApplicationService } from '../application.service'; @@ -29,7 +28,7 @@ export class CliInfoApplicationComponent implements OnInit { constructor( private applicationService: ApplicationService, - private entityServiceFactory: EntityServiceFactory + // private entityServiceFactory: EntityServiceFactory // TODO: RC Search fo ) { this.breadcrumbs$ = new BehaviorSubject([]); } @@ -41,10 +40,13 @@ export class CliInfoApplicationComponent implements OnInit { } private setupObservables(cfGuid: string) { - this.cfEndpointEntityService = this.entityServiceFactory.create( - cfGuid, - new GetAllEndpoints() - ); + this.cfEndpointEntityService = stratosEntityCatalog.endpoint.store.getEntityService(cfGuid); + + // TODO: RC EXAMPLE + // this.cfEndpointEntityService = this.entityServiceFactory.create( + // cfGuid, + // new GetAllEndpoints() // TODO: RC single/multi actions? + // ); this.context$ = combineLatest( this.applicationService.application$, diff --git a/src/frontend/packages/cloud-foundry/src/features/cloud-foundry/add-organization/create-organization-step/create-organization-step.component.ts b/src/frontend/packages/cloud-foundry/src/features/cloud-foundry/add-organization/create-organization-step/create-organization-step.component.ts index c5e99f073c..3fc1011631 100644 --- a/src/frontend/packages/cloud-foundry/src/features/cloud-foundry/add-organization/create-organization-step/create-organization-step.component.ts +++ b/src/frontend/packages/cloud-foundry/src/features/cloud-foundry/add-organization/create-organization-step/create-organization-step.component.ts @@ -14,7 +14,7 @@ import { import { selectCfRequestInfo } from '../../../../../../cloud-foundry/src/store/selectors/api.selectors'; import { StepOnNextFunction } from '../../../../../../core/src/shared/components/stepper/step/step.component'; import { entityCatalog } from '../../../../../../store/src/entity-catalog/entity-catalog'; -import { endpointSchemaKey } from '../../../../../../store/src/helpers/entity-factory'; +import { endpointSchemaKey } from '../../../../../../store/src/helpers/stratos-entity-factory'; import { PaginationMonitorFactory } from '../../../../../../store/src/monitors/pagination-monitor.factory'; import { getPaginationObservables } from '../../../../../../store/src/reducers/pagination-reducer/pagination-reducer.helper'; import { APIResource } from '../../../../../../store/src/types/api.types'; diff --git a/src/frontend/packages/cloud-foundry/src/features/cloud-foundry/edit-organization/edit-organization-step/edit-organization-step.component.ts b/src/frontend/packages/cloud-foundry/src/features/cloud-foundry/edit-organization/edit-organization-step/edit-organization-step.component.ts index cc3e90927d..52980790b1 100644 --- a/src/frontend/packages/cloud-foundry/src/features/cloud-foundry/edit-organization/edit-organization-step/edit-organization-step.component.ts +++ b/src/frontend/packages/cloud-foundry/src/features/cloud-foundry/edit-organization/edit-organization-step/edit-organization-step.component.ts @@ -11,7 +11,7 @@ import { } from '../../../../../../cloud-foundry/src/entity-relations/entity-relations.types'; import { safeUnsubscribe } from '../../../../../../core/src/core/utils.service'; import { StepOnNextFunction } from '../../../../../../core/src/shared/components/stepper/step/step.component'; -import { endpointSchemaKey } from '../../../../../../store/src/helpers/entity-factory'; +import { endpointSchemaKey } from '../../../../../../store/src/helpers/stratos-entity-factory'; import { PaginationMonitorFactory } from '../../../../../../store/src/monitors/pagination-monitor.factory'; import { ActionState } from '../../../../../../store/src/reducers/api-request-reducer/types'; import { getPaginationObservables } from '../../../../../../store/src/reducers/pagination-reducer/pagination-reducer.helper'; diff --git a/src/frontend/packages/cloud-foundry/src/features/cloud-foundry/quota-definition-form/quota-definition-form.component.ts b/src/frontend/packages/cloud-foundry/src/features/cloud-foundry/quota-definition-form/quota-definition-form.component.ts index f271b4ec36..2f3a0c3df7 100644 --- a/src/frontend/packages/cloud-foundry/src/features/cloud-foundry/quota-definition-form/quota-definition-form.component.ts +++ b/src/frontend/packages/cloud-foundry/src/features/cloud-foundry/quota-definition-form/quota-definition-form.component.ts @@ -8,7 +8,7 @@ import { createEntityRelationPaginationKey } from '../../../../../cloud-foundry/ import { ActiveRouteCfOrgSpace } from '../../../../../cloud-foundry/src/features/cloud-foundry/cf-page.types'; import { getActiveRouteCfOrgSpaceProvider } from '../../../../../cloud-foundry/src/features/cloud-foundry/cf.helpers'; import { safeUnsubscribe } from '../../../../../core/src/core/utils.service'; -import { endpointSchemaKey } from '../../../../../store/src/helpers/entity-factory'; +import { endpointSchemaKey } from '../../../../../store/src/helpers/stratos-entity-factory'; import { IQuotaDefinition } from '../../../cf-api.types'; export interface QuotaFormValues { diff --git a/src/frontend/packages/cloud-foundry/src/features/cloud-foundry/services/cloud-foundry-endpoint.service.ts b/src/frontend/packages/cloud-foundry/src/features/cloud-foundry/services/cloud-foundry-endpoint.service.ts index 7f489dbfb6..04de31f668 100644 --- a/src/frontend/packages/cloud-foundry/src/features/cloud-foundry/services/cloud-foundry-endpoint.service.ts +++ b/src/frontend/packages/cloud-foundry/src/features/cloud-foundry/services/cloud-foundry-endpoint.service.ts @@ -17,13 +17,12 @@ import { createEntityRelationPaginationKey, } from '../../../../../cloud-foundry/src/entity-relations/entity-relations.types'; import { CfApplicationState } from '../../../../../cloud-foundry/src/store/types/application.types'; -import { GetAllEndpoints } from '../../../../../store/src/actions/endpoint.actions'; import { EntityService } from '../../../../../store/src/entity-service'; -import { EntityServiceFactory } from '../../../../../store/src/entity-service-factory.service'; -import { endpointSchemaKey } from '../../../../../store/src/helpers/entity-factory'; +import { endpointSchemaKey } from '../../../../../store/src/helpers/stratos-entity-factory'; import { PaginationMonitorFactory } from '../../../../../store/src/monitors/pagination-monitor.factory'; import { getPaginationObservables } from '../../../../../store/src/reducers/pagination-reducer/pagination-reducer.helper'; import { PaginationObservables } from '../../../../../store/src/reducers/pagination-reducer/pagination-reducer.types'; +import { stratosEntityCatalog } from '../../../../../store/src/stratos-entity-catalog'; import { APIResource, EntityInfo } from '../../../../../store/src/types/api.types'; import { EndpointModel, EndpointUser } from '../../../../../store/src/types/endpoint.types'; import { PaginatedAction } from '../../../../../store/src/types/pagination.types'; @@ -138,16 +137,12 @@ export class CloudFoundryEndpointService { constructor( public activeRouteCfOrgSpace: ActiveRouteCfOrgSpace, private store: Store, - private entityServiceFactory: EntityServiceFactory, private cfUserService: CfUserService, private pmf: PaginationMonitorFactory, ) { this.cfGuid = activeRouteCfOrgSpace.cfGuid; - this.cfEndpointEntityService = this.entityServiceFactory.create( - this.cfGuid, - new GetAllEndpoints() - ); + this.cfEndpointEntityService = stratosEntityCatalog.endpoint.store.getEntityService(this.cfGuid); this.cfInfoEntityService = cfEntityCatalog.cfInfo.store.getEntityService(this.cfGuid) this.constructCoreObservables(); diff --git a/src/frontend/packages/cloud-foundry/src/features/cloud-foundry/space-quota-definition-form/space-quota-definition-form.component.ts b/src/frontend/packages/cloud-foundry/src/features/cloud-foundry/space-quota-definition-form/space-quota-definition-form.component.ts index a6bacfc2c6..4e698b0c77 100644 --- a/src/frontend/packages/cloud-foundry/src/features/cloud-foundry/space-quota-definition-form/space-quota-definition-form.component.ts +++ b/src/frontend/packages/cloud-foundry/src/features/cloud-foundry/space-quota-definition-form/space-quota-definition-form.component.ts @@ -9,7 +9,7 @@ import { createEntityRelationPaginationKey } from '../../../../../cloud-foundry/ import { ActiveRouteCfOrgSpace } from '../../../../../cloud-foundry/src/features/cloud-foundry/cf-page.types'; import { getActiveRouteCfOrgSpaceProvider } from '../../../../../cloud-foundry/src/features/cloud-foundry/cf.helpers'; import { safeUnsubscribe } from '../../../../../core/src/core/utils.service'; -import { endpointSchemaKey } from '../../../../../store/src/helpers/entity-factory'; +import { endpointSchemaKey } from '../../../../../store/src/helpers/stratos-entity-factory'; import { IQuotaDefinition } from '../../../cf-api.types'; diff --git a/src/frontend/packages/cloud-foundry/src/features/cloud-foundry/user-invites/user-invite.service.ts b/src/frontend/packages/cloud-foundry/src/features/cloud-foundry/user-invites/user-invite.service.ts index 755128bd1b..7331193e11 100644 --- a/src/frontend/packages/cloud-foundry/src/features/cloud-foundry/user-invites/user-invite.service.ts +++ b/src/frontend/packages/cloud-foundry/src/features/cloud-foundry/user-invites/user-invite.service.ts @@ -10,7 +10,7 @@ import { CurrentUserPermissionsService } from '../../../../../core/src/core/perm import { environment } from '../../../../../core/src/environments/environment.prod'; import { ConfirmationDialogConfig } from '../../../../../core/src/shared/components/confirmation-dialog.config'; import { ConfirmationDialogService } from '../../../../../core/src/shared/components/confirmation-dialog.service'; -import { GetSystemInfo } from '../../../../../store/src/actions/system.actions'; +import { stratosEntityCatalog } from '../../../../../store/src/stratos-entity-catalog'; import { CfCurrentUserPermissions } from '../../../user-permissions/cf-user-permissions-checkers'; import { ActiveRouteCfOrgSpace } from '../cf-page.types'; import { waitForCFPermissions } from '../cf.helpers'; @@ -57,7 +57,6 @@ interface UserInviteSend { export class UserInviteConfigureService { constructor( - private store: Store, private http: HttpClient, private snackBar: MatSnackBar, private confirmDialog: ConfirmationDialogService, @@ -70,7 +69,7 @@ export class UserInviteConfigureService { const url = `/pp/${proxyAPIVersion}/invite/${cfGUID}`; const obs$ = this.http.post(url, formData).pipe( map(v => { - this.store.dispatch(new GetSystemInfo()); + stratosEntityCatalog.systemInfo.api.getSystemInfo() return { error: false }; @@ -99,7 +98,7 @@ export class UserInviteConfigureService { const url = `/pp/${proxyAPIVersion}/invite/${cfGUID}`; this.http.delete(url).pipe( map(v => { - this.store.dispatch(new GetSystemInfo()); + stratosEntityCatalog.systemInfo.api.getSystemInfo() return { error: false, errorMessage: '' diff --git a/src/frontend/packages/cloud-foundry/src/features/cloud-foundry/users/manage-users/cf-roles.service.ts b/src/frontend/packages/cloud-foundry/src/features/cloud-foundry/users/manage-users/cf-roles.service.ts index 56a88ed334..add83ee686 100644 --- a/src/frontend/packages/cloud-foundry/src/features/cloud-foundry/users/manage-users/cf-roles.service.ts +++ b/src/frontend/packages/cloud-foundry/src/features/cloud-foundry/users/manage-users/cf-roles.service.ts @@ -18,7 +18,7 @@ import { createEntityRelationPaginationKey, } from '../../../../../../cloud-foundry/src/entity-relations/entity-relations.types'; import { CurrentUserPermissionsService } from '../../../../../../core/src/core/permissions/current-user-permissions.service'; -import { endpointSchemaKey } from '../../../../../../store/src/helpers/entity-factory'; +import { endpointSchemaKey } from '../../../../../../store/src/helpers/stratos-entity-factory'; import { APIResource, EntityInfo } from '../../../../../../store/src/types/api.types'; import { UsersRolesSetChanges } from '../../../../actions/users-roles.actions'; import { IOrganization, ISpace } from '../../../../cf-api.types'; diff --git a/src/frontend/packages/cloud-foundry/src/features/services/services/services-wall.service.ts b/src/frontend/packages/cloud-foundry/src/features/services/services/services-wall.service.ts index c6ebd18e85..cafebb88e6 100644 --- a/src/frontend/packages/cloud-foundry/src/features/services/services/services-wall.service.ts +++ b/src/frontend/packages/cloud-foundry/src/features/services/services/services-wall.service.ts @@ -3,7 +3,7 @@ import { Observable } from 'rxjs'; import { filter, map, publishReplay, refCount } from 'rxjs/operators'; import { serviceEntityType } from '../../../../../cloud-foundry/src/cf-entity-types'; -import { endpointSchemaKey } from '../../../../../store/src/helpers/entity-factory'; +import { endpointSchemaKey } from '../../../../../store/src/helpers/stratos-entity-factory'; import { APIResource } from '../../../../../store/src/types/api.types'; import { IService } from '../../../cf-api-svc.types'; import { cfEntityCatalog } from '../../../cf-entity-catalog'; diff --git a/src/frontend/packages/cloud-foundry/src/shared/components/list/list-types/app-instance/table-cell-cf-cell/table-cell-cf-cell.component.ts b/src/frontend/packages/cloud-foundry/src/shared/components/list/list-types/app-instance/table-cell-cf-cell/table-cell-cf-cell.component.ts index 64ccc8b4f4..345c4ec2da 100644 --- a/src/frontend/packages/cloud-foundry/src/shared/components/list/list-types/app-instance/table-cell-cf-cell/table-cell-cf-cell.component.ts +++ b/src/frontend/packages/cloud-foundry/src/shared/components/list/list-types/app-instance/table-cell-cf-cell/table-cell-cf-cell.component.ts @@ -2,8 +2,8 @@ import { Component, Input, OnDestroy } from '@angular/core'; import { Observable, Subscription } from 'rxjs'; import { filter, map, tap } from 'rxjs/operators'; -import { EntityService } from '../../../../../../../../store/src/entity-service'; import { TableCellCustom } from '../../../../../../../../core/src/shared/components/list/list.types'; +import { EntityService } from '../../../../../../../../store/src/entity-service'; import { IMetricMatrixResult, IMetrics } from '../../../../../../../../store/src/types/base-metric.types'; import { IMetricCell } from '../../../../../../../../store/src/types/metric.types'; import { ListAppInstance } from '../app-instance-types'; @@ -21,7 +21,7 @@ export class TableCellCfCellComponent extends TableCellCustom i @Input('config') set config(config: { - metricEntityService: EntityService>> + metricEntityService: EntityService>> // TODO: RC search for metricEntityService cfGuid: string }) { if (!config) { diff --git a/src/frontend/packages/cloud-foundry/src/shared/components/list/list-types/cf-buildpacks/cf-buildpacks-data-source.ts b/src/frontend/packages/cloud-foundry/src/shared/components/list/list-types/cf-buildpacks/cf-buildpacks-data-source.ts index ae5065e46e..7e399f7bda 100644 --- a/src/frontend/packages/cloud-foundry/src/shared/components/list/list-types/cf-buildpacks/cf-buildpacks-data-source.ts +++ b/src/frontend/packages/cloud-foundry/src/shared/components/list/list-types/cf-buildpacks/cf-buildpacks-data-source.ts @@ -9,7 +9,7 @@ import { ListDataSource, } from '../../../../../../../core/src/shared/components/list/data-sources-controllers/list-data-source'; import { IListConfig } from '../../../../../../../core/src/shared/components/list/list.component.types'; -import { endpointSchemaKey } from '../../../../../../../store/src/helpers/entity-factory'; +import { endpointSchemaKey } from '../../../../../../../store/src/helpers/stratos-entity-factory'; import { getRowMetadata } from '../../../../../../../store/src/public-api'; import { APIResource } from '../../../../../../../store/src/types/api.types'; import { cfEntityCatalog } from '../../../../../cf-entity-catalog'; diff --git a/src/frontend/packages/cloud-foundry/src/shared/components/list/list-types/cf-endpoints/cf-endpoints-data-source.ts b/src/frontend/packages/cloud-foundry/src/shared/components/list/list-types/cf-endpoints/cf-endpoints-data-source.ts index a9e6b2856e..591c35bf58 100644 --- a/src/frontend/packages/cloud-foundry/src/shared/components/list/list-types/cf-endpoints/cf-endpoints-data-source.ts +++ b/src/frontend/packages/cloud-foundry/src/shared/components/list/list-types/cf-endpoints/cf-endpoints-data-source.ts @@ -9,7 +9,7 @@ import { IListConfig } from '../../../../../../../core/src/shared/components/lis import { EntityMonitorFactory } from '../../../../../../../store/src/monitors/entity-monitor.factory.service'; import { InternalEventMonitorFactory } from '../../../../../../../store/src/monitors/internal-event-monitor.factory'; import { PaginationMonitorFactory } from '../../../../../../../store/src/monitors/pagination-monitor.factory'; -import { GetAllEndpoints } from '../../../../../../../store/src/actions/endpoint.actions'; +import { stratosEntityCatalog } from '../../../../../../../store/src/stratos-entity-catalog'; import { EndpointModel } from '../../../../../../../store/src/types/endpoint.types'; export class CFEndpointsDataSource extends BaseEndpointsDataSource { @@ -22,7 +22,7 @@ export class CFEndpointsDataSource extends BaseEndpointsDataSource { entityMonitorFactory: EntityMonitorFactory, internalEventMonitorFactory: InternalEventMonitorFactory ) { - const action = new GetAllEndpoints(); + const action = stratosEntityCatalog.endpoint.actions.getAll(); const paginationKey = 'cf-endpoints'; // We do this here to ensure we sync up with main endpoint table data. syncPaginationSection(store, action, paginationKey); diff --git a/src/frontend/packages/cloud-foundry/src/shared/components/list/list-types/cf-quotas/cf-quotas-data-source.service.ts b/src/frontend/packages/cloud-foundry/src/shared/components/list/list-types/cf-quotas/cf-quotas-data-source.service.ts index f2bf84af31..e7a620600f 100644 --- a/src/frontend/packages/cloud-foundry/src/shared/components/list/list-types/cf-quotas/cf-quotas-data-source.service.ts +++ b/src/frontend/packages/cloud-foundry/src/shared/components/list/list-types/cf-quotas/cf-quotas-data-source.service.ts @@ -11,10 +11,10 @@ import { getDefaultRowState, } from '../../../../../../../core/src/shared/components/list/data-sources-controllers/list-data-source-types'; import { IListConfig } from '../../../../../../../core/src/shared/components/list/list.component.types'; -import { endpointSchemaKey } from '../../../../../../../store/src/helpers/entity-factory'; -import { EntityMonitor } from '../../../../../../../store/src/monitors/entity-monitor'; +import { endpointSchemaKey } from '../../../../../../../store/src/helpers/stratos-entity-factory'; import { APIResource } from '../../../../../../../store/src/types/api.types'; import { CFAppState } from '../../../../../cf-app-state'; +import { cfEntityCatalog } from '../../../../../cf-entity-catalog'; import { cfEntityFactory } from '../../../../../cf-entity-factory'; import { quotaDefinitionEntityType } from '../../../../../cf-entity-types'; import { createEntityRelationPaginationKey } from '../../../../../entity-relations/entity-relations.types'; @@ -44,8 +44,8 @@ export class CfQuotasDataSourceService extends ListDataSource { if (!this.sourceScheme || !row) { return of(getDefaultRowState()); } - const entityMonitor = new EntityMonitor(this.store, this.getRowUniqueId(row), this.entityKey, this.sourceScheme); - return entityMonitor.entityRequest$.pipe( + // TODO: RC test + return cfEntityCatalog.quotaDefinition.store.getEntityMonitor(this.getRowUniqueId(row)).entityRequest$.pipe( distinctUntilChanged(), map(requestInfo => ({ deleting: requestInfo.deleting.busy, diff --git a/src/frontend/packages/cloud-foundry/src/shared/components/list/list-types/cf-security-groups/cf-security-groups-data-source.ts b/src/frontend/packages/cloud-foundry/src/shared/components/list/list-types/cf-security-groups/cf-security-groups-data-source.ts index 42b046e9dd..620bdcbb5b 100644 --- a/src/frontend/packages/cloud-foundry/src/shared/components/list/list-types/cf-security-groups/cf-security-groups-data-source.ts +++ b/src/frontend/packages/cloud-foundry/src/shared/components/list/list-types/cf-security-groups/cf-security-groups-data-source.ts @@ -10,7 +10,7 @@ import { ListDataSource, } from '../../../../../../../core/src/shared/components/list/data-sources-controllers/list-data-source'; import { IListConfig } from '../../../../../../../core/src/shared/components/list/list.component.types'; -import { endpointSchemaKey } from '../../../../../../../store/src/helpers/entity-factory'; +import { endpointSchemaKey } from '../../../../../../../store/src/helpers/stratos-entity-factory'; import { APIResource } from '../../../../../../../store/src/types/api.types'; import { cfEntityCatalog } from '../../../../../cf-entity-catalog'; import { cfEntityFactory } from '../../../../../cf-entity-factory'; diff --git a/src/frontend/packages/cloud-foundry/src/shared/components/list/list-types/cf-services/cf-services-data-source.ts b/src/frontend/packages/cloud-foundry/src/shared/components/list/list-types/cf-services/cf-services-data-source.ts index 334d992dd6..018c2d1920 100644 --- a/src/frontend/packages/cloud-foundry/src/shared/components/list/list-types/cf-services/cf-services-data-source.ts +++ b/src/frontend/packages/cloud-foundry/src/shared/components/list/list-types/cf-services/cf-services-data-source.ts @@ -11,7 +11,7 @@ import { } from '../../../../../../../core/src/shared/components/list/data-sources-controllers/list-data-source'; import { IListConfig } from '../../../../../../../core/src/shared/components/list/list.component.types'; import { entityCatalog } from '../../../../../../../store/src/entity-catalog/entity-catalog'; -import { endpointSchemaKey } from '../../../../../../../store/src/helpers/entity-factory'; +import { endpointSchemaKey } from '../../../../../../../store/src/helpers/stratos-entity-factory'; import { APIResource } from '../../../../../../../store/src/types/api.types'; import { PaginationEntityState } from '../../../../../../../store/src/types/pagination.types'; import { cfEntityCatalog } from '../../../../../cf-entity-catalog'; diff --git a/src/frontend/packages/cloud-foundry/src/shared/components/list/list-types/cf-space-quotas/cf-space-quotas-data-source.service.ts b/src/frontend/packages/cloud-foundry/src/shared/components/list/list-types/cf-space-quotas/cf-space-quotas-data-source.service.ts index 4a880b804b..0c36d99046 100644 --- a/src/frontend/packages/cloud-foundry/src/shared/components/list/list-types/cf-space-quotas/cf-space-quotas-data-source.service.ts +++ b/src/frontend/packages/cloud-foundry/src/shared/components/list/list-types/cf-space-quotas/cf-space-quotas-data-source.service.ts @@ -10,11 +10,11 @@ import { getDefaultRowState, } from '../../../../../../../core/src/shared/components/list/data-sources-controllers/list-data-source-types'; import { IListConfig } from '../../../../../../../core/src/shared/components/list/list.component.types'; -import { endpointSchemaKey } from '../../../../../../../store/src/helpers/entity-factory'; -import { EntityMonitor } from '../../../../../../../store/src/monitors/entity-monitor'; +import { endpointSchemaKey } from '../../../../../../../store/src/helpers/stratos-entity-factory'; import { APIResource } from '../../../../../../../store/src/types/api.types'; import { GetOrganizationSpaceQuotaDefinitions } from '../../../../../actions/quota-definitions.actions'; import { CFAppState } from '../../../../../cf-app-state'; +import { cfEntityCatalog } from '../../../../../cf-entity-catalog'; import { cfEntityFactory } from '../../../../../cf-entity-factory'; import { spaceQuotaEntityType } from '../../../../../cf-entity-types'; import { createEntityRelationPaginationKey } from '../../../../../entity-relations/entity-relations.types'; @@ -44,8 +44,9 @@ export class CfOrgSpaceQuotasDataSourceService extends ListDataSource ({ deleting: requestInfo.deleting.busy, diff --git a/src/frontend/packages/cloud-foundry/src/shared/data-services/long-running-cf-op.service.ts b/src/frontend/packages/cloud-foundry/src/shared/data-services/long-running-cf-op.service.ts index 443247c3a3..8060984845 100644 --- a/src/frontend/packages/cloud-foundry/src/shared/data-services/long-running-cf-op.service.ts +++ b/src/frontend/packages/cloud-foundry/src/shared/data-services/long-running-cf-op.service.ts @@ -25,6 +25,7 @@ export class LongRunningCfOperationsService extends LongRunningOperationsService Please refresh the service instance list to check it's status`; this.store.dispatch(new ShowSnackBar(message, 'Dismiss')); // Also attempt to fetch the service instance, this will update the `last operation` value to `update` and `in progress` + // TODO: RC FIX this.store.dispatch(new GetServiceInstance(serviceInstanceGuid, cfGuid)); } @@ -33,6 +34,7 @@ export class LongRunningCfOperationsService extends LongRunningOperationsService Please refresh the service instance list to check it's status`; this.store.dispatch(new ShowSnackBar(message, 'Dismiss')); // Also attempt to fetch the service instance, this will update the `last operation` value to `delete` and `in progress` + // TODO: RC FIX this.store.dispatch(new GetServiceInstance(serviceInstanceGuid, cfGuid)); } diff --git a/src/frontend/packages/cloud-foundry/src/shared/services/cf-org-space-label.service.ts b/src/frontend/packages/cloud-foundry/src/shared/services/cf-org-space-label.service.ts index 585f41ed42..5be5a76e5c 100644 --- a/src/frontend/packages/cloud-foundry/src/shared/services/cf-org-space-label.service.ts +++ b/src/frontend/packages/cloud-foundry/src/shared/services/cf-org-space-label.service.ts @@ -4,7 +4,7 @@ import { filter, first, map } from 'rxjs/operators'; import { STRATOS_ENDPOINT_TYPE } from '../../../../core/src/base-entity-schemas'; import { entityCatalog } from '../../../../store/src/entity-catalog/entity-catalog'; -import { endpointSchemaKey } from '../../../../store/src/helpers/entity-factory'; +import { endpointSchemaKey } from '../../../../store/src/helpers/stratos-entity-factory'; import { selectEntity } from '../../../../store/src/selectors/api.selectors'; import { APIResource } from '../../../../store/src/types/api.types'; import { EndpointModel } from '../../../../store/src/types/endpoint.types'; diff --git a/src/frontend/packages/cloud-foundry/src/shared/services/current-user-permissions.service.spec.ts b/src/frontend/packages/cloud-foundry/src/shared/services/current-user-permissions.service.spec.ts index 99dcb96deb..5b2a2debb8 100644 --- a/src/frontend/packages/cloud-foundry/src/shared/services/current-user-permissions.service.spec.ts +++ b/src/frontend/packages/cloud-foundry/src/shared/services/current-user-permissions.service.spec.ts @@ -13,10 +13,10 @@ import { CfScopeStrings, } from '../../../../cloud-foundry/src/user-permissions/cf-user-permissions-checkers'; import { endpointEntitySchema } from '../../../../core/src/base-entity-schemas'; -import { generateStratosEntities } from '../../../../core/src/base-entity-types'; import { PermissionConfig } from '../../../../core/src/core/permissions/current-user-permissions.config'; import { CurrentUserPermissionsService } from '../../../../core/src/core/permissions/current-user-permissions.service'; import { StratosScopeStrings } from '../../../../core/src/core/permissions/stratos-user-permissions.checker'; +import { generateStratosEntities } from '../../../../core/src/stratos-entity-generator'; import { AppTestModule } from '../../../../core/test-framework/core-test.helper'; import { AppState } from '../../../../store/src/app-state'; import { EntityCatalogTestModule, TEST_CATALOGUE_ENTITIES } from '../../../../store/src/entity-catalog-test.module'; diff --git a/src/frontend/packages/cloud-foundry/src/store/reducers/cf-users.reducer.ts b/src/frontend/packages/cloud-foundry/src/store/reducers/cf-users.reducer.ts index 71079d216e..2395df2ff6 100644 --- a/src/frontend/packages/cloud-foundry/src/store/reducers/cf-users.reducer.ts +++ b/src/frontend/packages/cloud-foundry/src/store/reducers/cf-users.reducer.ts @@ -12,6 +12,7 @@ import { } from '../../actions/users.actions'; import { IOrganization, ISpace } from '../../cf-api.types'; import { cfUserEntityType } from '../../cf-entity-types'; +import { CF_ENDPOINT_TYPE } from '../../cf-types'; import { CfUser, CfUserMissingOrgRoles, @@ -61,7 +62,7 @@ export function cfUserReducer(state: IRequestEntityTypeState } export function endpointDisconnectUserReducer(state: IRequestEntityTypeState>, action: DisconnectEndpoint) { - if (action.endpointType === 'cf') { + if (action.endpointType === CF_ENDPOINT_TYPE) { switch (action.type) { case DISCONNECT_ENDPOINTS_SUCCESS: const cfGuid = action.guid; diff --git a/src/frontend/packages/cloud-foundry/test-framework/cf-test-helper.ts b/src/frontend/packages/cloud-foundry/test-framework/cf-test-helper.ts index 0ef667db7e..64dff3cf63 100644 --- a/src/frontend/packages/cloud-foundry/test-framework/cf-test-helper.ts +++ b/src/frontend/packages/cloud-foundry/test-framework/cf-test-helper.ts @@ -1,7 +1,7 @@ +import { generateStratosEntities } from '../../core/src/stratos-entity-generator'; import { BaseTestModules } from '../../core/test-framework/core-test.helper'; import { EntityCatalogTestModule, TEST_CATALOGUE_ENTITIES } from '../../store/src/entity-catalog-test.module'; import { generateCFEntities } from '../src/cf-entity-generator'; -import { generateStratosEntities } from '../../core/src/base-entity-types'; export const CFBaseTestModules = [ ...BaseTestModules, diff --git a/src/frontend/packages/core/src/app.module.ts b/src/frontend/packages/core/src/app.module.ts index 7ba9fb46a1..4e734c8e0c 100644 --- a/src/frontend/packages/core/src/app.module.ts +++ b/src/frontend/packages/core/src/app.module.ts @@ -17,7 +17,7 @@ import { EntityCatalogModule } from '../../store/src/entity-catalog.module'; import { entityCatalog } from '../../store/src/entity-catalog/entity-catalog'; import { EntityCatalogHelper } from '../../store/src/entity-catalog/entity-catalog-entity/entity-catalog.service'; import { EntityCatalogHelpers } from '../../store/src/entity-catalog/entity-catalog.helper'; -import { endpointSchemaKey } from '../../store/src/helpers/entity-factory'; +import { endpointSchemaKey } from '../../store/src/helpers/stratos-entity-factory'; import { getAPIRequestDataState, selectEntity } from '../../store/src/selectors/api.selectors'; import { internalEventStateSelector } from '../../store/src/selectors/internal-events.selectors'; import { recentlyVisitedSelector } from '../../store/src/selectors/recently-visitied.selectors'; @@ -29,7 +29,6 @@ import { XSRFModule } from '../xsrf.module'; import { AppComponent } from './app.component'; import { RouteModule } from './app.routing'; import { STRATOS_ENDPOINT_TYPE } from './base-entity-schemas'; -import { generateStratosEntities } from './base-entity-types'; import { CoreModule } from './core/core.module'; import { CustomizationService } from './core/customizations.types'; import { DynamicExtensionRoutes } from './core/extension/dynamic-extension-routes'; @@ -50,6 +49,7 @@ import { FavoritesConfigMapper } from './shared/components/favorites-meta-card/f import { endpointEventKey, GlobalEventData, GlobalEventService } from './shared/global-events.service'; import { SidePanelService } from './shared/services/side-panel.service'; import { SharedModule } from './shared/shared.module'; +import { generateStratosEntities } from './stratos-entity-generator'; // Create action for router navigation. See // - https://github.com/ngrx/platform/issues/68 diff --git a/src/frontend/packages/core/src/base-entity-schemas.ts b/src/frontend/packages/core/src/base-entity-schemas.ts index 19da225c8b..193079eecf 100644 --- a/src/frontend/packages/core/src/base-entity-schemas.ts +++ b/src/frontend/packages/core/src/base-entity-schemas.ts @@ -1,24 +1,24 @@ -import { - endpointSchemaKey, - entityFactory, - systemInfoSchemaKey, - userFavouritesSchemaKey, - userProfileSchemaKey, -} from '../../store/src/helpers/entity-factory'; -import { EntitySchema } from '../../store/src/helpers/entity-schema'; +// import { +// endpointSchemaKey, +// entityFactory, +// systemInfoSchemaKey, +// userFavouritesSchemaKey, +// userProfileSchemaKey, +// } from '../../store/src/helpers/entity-factory'; +// import { EntitySchema } from '../../store/src/helpers/entity-schema'; -export const metricEntityType = 'metrics'; +// export const metricEntityType = 'metrics'; -export const STRATOS_ENDPOINT_TYPE = 'stratos'; -export const ENDPOINT_TYPE = 'endpoint'; +// export const STRATOS_ENDPOINT_TYPE = 'stratos'; +// export const ENDPOINT_TYPE = 'endpoint'; -class StratosEntitySchema extends EntitySchema { - constructor(entityType: string) { - super(entityType, STRATOS_ENDPOINT_TYPE); - } -} +// class StratosEntitySchema extends EntitySchema { +// constructor(entityType: string) { +// super(entityType, STRATOS_ENDPOINT_TYPE); +// } +// } -export const userFavoritesEntitySchema = new StratosEntitySchema(entityFactory(userFavouritesSchemaKey).entityType); -export const endpointEntitySchema = new StratosEntitySchema(entityFactory(endpointSchemaKey).entityType); -export const userProfileEntitySchema = new StratosEntitySchema(entityFactory(userProfileSchemaKey).entityType); -export const systemInfoEntitySchema = new StratosEntitySchema(entityFactory(systemInfoSchemaKey).entityType); +// export const userFavoritesEntitySchema = new StratosEntitySchema(entityFactory(userFavouritesSchemaKey).entityType); +// export const endpointEntitySchema = new StratosEntitySchema(entityFactory(endpointSchemaKey).entityType); +// export const userProfileEntitySchema = new StratosEntitySchema(entityFactory(userProfileSchemaKey).entityType); +// export const systemInfoEntitySchema = new StratosEntitySchema(entityFactory(systemInfoSchemaKey).entityType); diff --git a/src/frontend/packages/core/src/base-entity-types.ts b/src/frontend/packages/core/src/base-entity-types.ts deleted file mode 100644 index bdb004deea..0000000000 --- a/src/frontend/packages/core/src/base-entity-types.ts +++ /dev/null @@ -1,110 +0,0 @@ -import { - StratosCatalogEndpointEntity, - StratosCatalogEntity, -} from '../../store/src/entity-catalog/entity-catalog-entity/entity-catalog-entity'; -import { - addOrUpdateUserFavoriteMetadataReducer, - deleteUserFavoriteMetadataReducer, -} from '../../store/src/reducers/favorite.reducer'; -import { systemEndpointsReducer } from '../../store/src/reducers/system-endpoints.reducer'; -import { - endpointEntitySchema, - STRATOS_ENDPOINT_TYPE, - systemInfoEntitySchema, - userFavoritesEntitySchema, - userProfileEntitySchema, -} from './base-entity-schemas'; -import { BaseEndpointAuth } from './features/endpoints/endpoint-auth'; -import { - MetricsEndpointDetailsComponent, -} from './features/metrics/metrics-endpoint-details/metrics-endpoint-details.component'; - -// -// These types are used to represent the base stratos types. -// - -/** - * This is used as a fake endpoint type to allow the store to be initiated correctly - */ -const stratosType = { - logoUrl: '', - authTypes: [], - type: STRATOS_ENDPOINT_TYPE, - schema: null -}; - -/** - * DefaultEndpointEntityType is used to represent a general endpoint - * This should not be used to actually attempt to render an endpoint and is instead used as a way to fill the - */ -class DefaultEndpointCatalogEntity extends StratosCatalogEntity { - constructor() { - super({ - schema: endpointEntitySchema, - type: endpointEntitySchema.entityType, - endpoint: stratosType, - }, { - dataReducers: [ - systemEndpointsReducer - ] - }); - } -} - -class UserFavoriteCatalogEntity extends StratosCatalogEntity { - constructor() { - super({ - schema: userFavoritesEntitySchema, - type: userFavoritesEntitySchema.entityType, - endpoint: stratosType, - }, { - dataReducers: [ - addOrUpdateUserFavoriteMetadataReducer, - deleteUserFavoriteMetadataReducer, - ] - }); - } -} - -class UserProfileCatalogEntity extends StratosCatalogEntity { - constructor() { - super({ - schema: userProfileEntitySchema, - type: userProfileEntitySchema.entityType, - endpoint: stratosType, - }); - } -} - -class SystemInfoCatalogEntity extends StratosCatalogEntity { - constructor() { - super({ - schema: systemInfoEntitySchema, - type: systemInfoEntitySchema.entityType, - endpoint: stratosType, - }); - } -} - -export function generateStratosEntities() { - return [ - new DefaultEndpointCatalogEntity(), - new SystemInfoCatalogEntity(), - new UserFavoriteCatalogEntity(), - new UserProfileCatalogEntity(), - // TODO: metrics location to be sorted - STRAT-152 - new StratosCatalogEndpointEntity({ - type: 'metrics', - label: 'Metrics', - labelPlural: 'Metrics', - tokenSharing: true, - logoUrl: '/core/assets/endpoint-icons/metrics.svg', - authTypes: [BaseEndpointAuth.UsernamePassword, BaseEndpointAuth.None], - renderPriority: 1, - listDetailsComponent: MetricsEndpointDetailsComponent, - }, - metadata => `/endpoints/metrics/${metadata.guid}` - ) - ]; -} - diff --git a/src/frontend/packages/core/src/core/permissions/current-user-permissions.service.spec.ts b/src/frontend/packages/core/src/core/permissions/current-user-permissions.service.spec.ts index e8e69c7782..29daf4d426 100644 --- a/src/frontend/packages/core/src/core/permissions/current-user-permissions.service.spec.ts +++ b/src/frontend/packages/core/src/core/permissions/current-user-permissions.service.spec.ts @@ -10,7 +10,7 @@ import { BaseEntityValues } from '../../../../store/src/types/entity.types'; import { PaginationState } from '../../../../store/src/types/pagination.types'; import { AppTestModule } from '../../../test-framework/core-test.helper'; import { endpointEntitySchema } from '../../base-entity-schemas'; -import { generateStratosEntities } from '../../base-entity-types'; +import { generateStratosEntities } from '../../stratos-entity-generator'; import { PermissionConfig } from './current-user-permissions.config'; import { CurrentUserPermissionsService } from './current-user-permissions.service'; import { StratosPermissionStrings, StratosPermissionTypes, StratosScopeStrings } from './stratos-user-permissions.checker'; diff --git a/src/frontend/packages/core/src/core/permissions/current-user-permissions.service.ts b/src/frontend/packages/core/src/core/permissions/current-user-permissions.service.ts index 0a7490fb0c..69628b47e1 100644 --- a/src/frontend/packages/core/src/core/permissions/current-user-permissions.service.ts +++ b/src/frontend/packages/core/src/core/permissions/current-user-permissions.service.ts @@ -4,10 +4,7 @@ import { combineLatest, Observable, of } from 'rxjs'; import { distinctUntilChanged, map, switchMap } from 'rxjs/operators'; import { InternalAppState } from '../../../../store/src/app-state'; -import { entityCatalog } from '../../../../store/src/entity-catalog/entity-catalog'; -import { selectEntity } from '../../../../store/src/selectors/api.selectors'; -import { EndpointModel } from '../../../../store/src/types/endpoint.types'; -import { ENDPOINT_TYPE, STRATOS_ENDPOINT_TYPE } from '../../base-entity-schemas'; +import { stratosEntityCatalog } from '../../../../store/src/stratos-entity-catalog'; import { LoggerService } from '../logger.service'; import { CurrentUserPermissions, @@ -79,8 +76,8 @@ export class CurrentUserPermissionsService { } else if (actionConfig) { return this.getSimplePermission(actionConfig, endpointGuid, ...args); } else if (endpointGuid) { - const key = entityCatalog.getEntityKey(STRATOS_ENDPOINT_TYPE, ENDPOINT_TYPE); - return this.store.select(selectEntity(key, endpointGuid)).pipe( + // TODO: RC test + return stratosEntityCatalog.endpoint.store.getEntityMonitor(endpointGuid).entity$.pipe( switchMap(endpoint => endpoint ? this.getFallbackPermission(endpointGuid, endpoint.cnsi_type) : of(false) diff --git a/src/frontend/packages/core/src/core/user-profile.service.ts b/src/frontend/packages/core/src/core/user-profile.service.ts index f83b16a256..72924925d9 100644 --- a/src/frontend/packages/core/src/core/user-profile.service.ts +++ b/src/frontend/packages/core/src/core/user-profile.service.ts @@ -1,24 +1,15 @@ import { Injectable } from '@angular/core'; import { Store } from '@ngrx/store'; -import { combineLatest, Observable, of as observableOf, of } from 'rxjs'; +import { combineLatest, Observable, of as observableOf } from 'rxjs'; import { filter, first, map, publishReplay, refCount, switchMap } from 'rxjs/operators'; -import { - FetchUserProfileAction, - UpdateUserPasswordAction, - UpdateUserProfileAction, -} from '../../../store/src/actions/user-profile.actions'; import { AppState } from '../../../store/src/app-state'; -import { userProfilePasswordUpdatingKey } from '../../../store/src/effects/user-profile.effects'; -import { entityCatalog } from '../../../store/src/entity-catalog/entity-catalog'; import { EntityService } from '../../../store/src/entity-service'; -import { EntityServiceFactory } from '../../../store/src/entity-service-factory.service'; -import { ActionState, getDefaultActionState, rootUpdatingKey } from '../../../store/src/reducers/api-request-reducer/types'; +import { ActionState, getDefaultActionState } from '../../../store/src/reducers/api-request-reducer/types'; import { AuthState } from '../../../store/src/reducers/auth.reducer'; -import { selectRequestInfo, selectUpdateInfo } from '../../../store/src/selectors/api.selectors'; +import { stratosEntityCatalog } from '../../../store/src/stratos-entity-catalog'; import { SessionData } from '../../../store/src/types/auth.types'; import { UserProfileInfo, UserProfileInfoEmail, UserProfileInfoUpdates } from '../../../store/src/types/user-profile.types'; -import { userProfileEntitySchema } from '../base-entity-schemas'; @Injectable() @@ -32,21 +23,31 @@ export class UserProfileService { userProfile$: Observable; - private stratosUserConfig = entityCatalog.getEntity(userProfileEntitySchema.endpointType, userProfileEntitySchema.entityType); + private userGuid$: Observable; + + // private stratosUserConfig = entityCatalog.getEntity(userProfileEntitySchema.endpointType, userProfileEntitySchema.entityType); constructor( private store: Store, - esf: EntityServiceFactory + // esf: EntityServiceFactory // TODO: RC Search ) { - if (!this.stratosUserConfig) { - console.error('Can not get user profile entity'); - this.userProfile$ = of({} as UserProfileInfo); - return; - } + // if (!this.stratosUserConfig) { + // console.error('Can not get user profile entity'); + // this.userProfile$ = of({} as UserProfileInfo); + // return; + // } - this.entityService = this.createFetchUserAction().pipe( + this.userGuid$ = this.store.select(s => s.auth).pipe( + filter((auth: AuthState) => !!(auth && auth.sessionData)), + map((auth: AuthState) => auth.sessionData), + filter((sessionData: SessionData) => !!sessionData.user), first(), - map(action => esf.create(action.guid, action)), + map(data => data.user.guid) + ); + + this.entityService = this.userGuid$.pipe( + first(), + map(userGuid => stratosEntityCatalog.userProfile.store.getEntityService(userGuid)), publishReplay(1), refCount() ); @@ -60,27 +61,16 @@ export class UserProfileService { switchMap(service => service.isFetchingEntity$) ); - this.isError$ = this.store.select(selectRequestInfo(this.stratosUserConfig.entityKey, FetchUserProfileAction.guid)).pipe( + this.isError$ = this.entityService.pipe( + switchMap(es => es.entityMonitor.entityRequest$), filter(requestInfo => !!requestInfo && !requestInfo.fetching), map(requestInfo => requestInfo.error) - ); - } - - private createFetchUserAction(): Observable { - return this.store.select(s => s.auth).pipe( - filter((auth: AuthState) => !!(auth && auth.sessionData)), - map((auth: AuthState) => auth.sessionData), - filter((sessionData: SessionData) => !!sessionData.user), - first(), - map(data => new FetchUserProfileAction(data.user.guid)) - ); + ) } fetchUserProfile() { // Once we have the user's guid, fetch their profile - this.createFetchUserAction().pipe(first()).subscribe(action => { - this.store.dispatch(action); - }); + this.userGuid$.pipe(first()).subscribe(userGuid => stratosEntityCatalog.userProfile.api.get(userGuid)); } getPrimaryEmailAddress(profile: UserProfileInfo): string { @@ -135,11 +125,8 @@ export class UserProfileService { if (profileChanges.emailAddress) { this.setPrimaryEmailAddress(updatedProfile, profileChanges.emailAddress); } - this.store.dispatch(new UpdateUserProfileAction(updatedProfile, profileChanges.currentPassword)); - const actionState = selectUpdateInfo(this.stratosUserConfig.entityKey, - FetchUserProfileAction.guid, - rootUpdatingKey); - return this.store.select(actionState).pipe( + + return stratosEntityCatalog.userProfile.api.updateProfile(updatedProfile, profileChanges.currentPassword).pipe( filter(item => item && !item.busy) ); } @@ -149,11 +136,7 @@ export class UserProfileService { oldPassword: profileChanges.currentPassword, password: profileChanges.newPassword }; - this.store.dispatch(new UpdateUserPasswordAction(profile.id, passwordUpdates)); - const actionState = selectUpdateInfo(this.stratosUserConfig.entityKey, - FetchUserProfileAction.guid, - userProfilePasswordUpdatingKey); - return this.store.select(actionState).pipe( + return stratosEntityCatalog.userProfile.api.updatePassword(profile.id, passwordUpdates).pipe( filter(item => item && !item.busy) ); } diff --git a/src/frontend/packages/core/src/features/endpoints/backup-restore/backup-endpoints/backup-endpoints.component.ts b/src/frontend/packages/core/src/features/endpoints/backup-restore/backup-endpoints/backup-endpoints.component.ts index 3ad6856b48..c95a7f9330 100644 --- a/src/frontend/packages/core/src/features/endpoints/backup-restore/backup-endpoints/backup-endpoints.component.ts +++ b/src/frontend/packages/core/src/features/endpoints/backup-restore/backup-endpoints/backup-endpoints.component.ts @@ -1,15 +1,11 @@ import { Component } from '@angular/core'; import { FormControl, FormGroup, Validators } from '@angular/forms'; -import { Store } from '@ngrx/store'; import * as moment from 'moment'; import { Observable, of, Subject } from 'rxjs'; import { filter, first, map } from 'rxjs/operators'; -import { GetAllEndpoints } from '../../../../../../store/src/actions/endpoint.actions'; -import { AppState } from '../../../../../../store/src/app-state'; import { entityCatalog } from '../../../../../../store/src/entity-catalog/entity-catalog'; -import { PaginationMonitorFactory } from '../../../../../../store/src/monitors/pagination-monitor.factory'; -import { getPaginationObservables } from '../../../../../../store/src/reducers/pagination-reducer/pagination-reducer.helper'; +import { stratosEntityCatalog } from '../../../../../../store/src/stratos-entity-catalog'; import { EndpointModel } from '../../../../../../store/src/types/endpoint.types'; import { httpErrorResponseToSafeString } from '../../../../jetstream.helpers'; import { ConfirmationDialogConfig } from '../../../../shared/components/confirmation-dialog.config'; @@ -74,8 +70,6 @@ export class BackupEndpointsComponent { constructor( public service: BackupEndpointsService, - private store: Store, - private paginationMonitorFactory: PaginationMonitorFactory, private confirmDialog: ConfirmationDialogService, ) { this.setupSelectStep(); @@ -84,17 +78,7 @@ export class BackupEndpointsComponent { setupSelectStep() { - const action = new GetAllEndpoints(); - const endpointObs = getPaginationObservables({ - store: this.store, - action, - paginationMonitor: this.paginationMonitorFactory.create( - action.paginationKey, - action, - true - ) - }, true); - + const endpointObs = stratosEntityCatalog.endpoint.store.getAll.getPaginationService(); const endpoints$ = endpointObs.entities$.pipe( filter(entities => !!entities), diff --git a/src/frontend/packages/core/src/features/endpoints/backup-restore/restore-endpoints/restore-endpoints.component.ts b/src/frontend/packages/core/src/features/endpoints/backup-restore/restore-endpoints/restore-endpoints.component.ts index c3483dca50..c7f8698d0c 100644 --- a/src/frontend/packages/core/src/features/endpoints/backup-restore/restore-endpoints/restore-endpoints.component.ts +++ b/src/frontend/packages/core/src/features/endpoints/backup-restore/restore-endpoints/restore-endpoints.component.ts @@ -5,8 +5,8 @@ import { Store } from '@ngrx/store'; import { Observable, of, Subject } from 'rxjs'; import { first, map } from 'rxjs/operators'; -import { GetAllEndpoints } from '../../../../../../store/src/actions/endpoint.actions'; import { GeneralEntityAppState } from '../../../../../../store/src/app-state'; +import { stratosEntityCatalog } from '../../../../../../store/src/stratos-entity-catalog'; import { getEventFiles } from '../../../../core/browser-helper'; import { httpErrorResponseToSafeString } from '../../../../jetstream.helpers'; import { ConfirmationDialogConfig } from '../../../../shared/components/confirmation-dialog.config'; @@ -79,7 +79,7 @@ export class RestoreEndpointsComponent { }; const restoreSuccess = () => { - this.store.dispatch(new GetAllEndpoints()); + stratosEntityCatalog.endpoint.api.getAll() result.next({ success: true, redirect: true, diff --git a/src/frontend/packages/core/src/features/endpoints/connect.service.ts b/src/frontend/packages/core/src/features/endpoints/connect.service.ts index 015ff5b14d..b5417bc17f 100644 --- a/src/frontend/packages/core/src/features/endpoints/connect.service.ts +++ b/src/frontend/packages/core/src/features/endpoints/connect.service.ts @@ -1,4 +1,3 @@ -import { Store } from '@ngrx/store'; import { combineLatest, Observable, of, Subject, Subscription } from 'rxjs'; import { delay, @@ -13,16 +12,10 @@ import { } from 'rxjs/operators'; import { AuthParams, ConnectEndpoint } from '../../../../store/src/actions/endpoint.actions'; -import { GetSystemInfo } from '../../../../store/src/actions/system.actions'; -import { EndpointOnlyAppState } from '../../../../store/src/app-state'; -import { EndpointsEffect } from '../../../../store/src/effects/endpoint.effects'; -import { SystemEffects } from '../../../../store/src/effects/system.effects'; import { entityCatalog } from '../../../../store/src/entity-catalog/entity-catalog'; -import { endpointSchemaKey } from '../../../../store/src/helpers/entity-factory'; import { ActionState } from '../../../../store/src/reducers/api-request-reducer/types'; -import { selectEntity, selectRequestInfo, selectUpdateInfo } from '../../../../store/src/selectors/api.selectors'; +import { stratosEntityCatalog } from '../../../../store/src/stratos-entity-catalog'; import { EndpointModel } from '../../../../store/src/types/endpoint.types'; -import { STRATOS_ENDPOINT_TYPE } from '../../base-entity-schemas'; import { EndpointsService } from '../../core/endpoints.service'; import { EndpointType } from '../../core/extension/extension-types'; import { safeUnsubscribe } from '../../core/utils.service'; @@ -65,15 +58,12 @@ export class ConnectEndpointService { private hasAttemptedConnect: boolean; private pData: ConnectEndpointData; - private endpointEntityKey = entityCatalog.getEntityKey(STRATOS_ENDPOINT_TYPE, endpointSchemaKey); - // We need a delay to ensure the BE has finished registering the endpoint. // If we don't do this and if we're quick enough, we can navigate to the application page // and end up with an empty list where we should have results. private connectDelay = 1000; constructor( - private store: Store, private endpointsService: EndpointsService, public config: ConnectEndpointConfig, ) { @@ -87,7 +77,7 @@ export class ConnectEndpointService { ).subscribe(([oldVal, newVal]) => { if (!newVal.error && (oldVal.busy && !newVal.busy)) { // Has finished fetching - this.store.dispatch(new GetSystemInfo()); + stratosEntityCatalog.endpoint.api.get(this.config.guid); // TODO: RC Test } })); @@ -101,19 +91,16 @@ export class ConnectEndpointService { } private setupObservables() { - this.update$ = this.store.select( - this.getUpdateSelector() - ).pipe(filter(update => !!update)); + this.update$ = stratosEntityCatalog.endpoint.store.getEntityMonitor(this.config.guid).getUpdatingSection(ConnectEndpoint.UpdatingKey) + .pipe(filter(update => !!update)); - this.fetchingInfo$ = this.store.select( - this.getRequestSelector() - ).pipe( + // TODO: RC Endpoint entity vs system endpoint (SystemEffects.guid) + this.fetchingInfo$ = stratosEntityCatalog.endpoint.store.getEntityMonitor(this.config.guid).entityRequest$.pipe( filter(request => !!request), - map(request => request.fetching)); + map(request => request.fetching) + ); - this.connected$ = this.store.select( - this.getEntitySelector() - ).pipe( + this.connected$ = stratosEntityCatalog.endpoint.store.getEntityMonitor(this.config.guid).entity$.pipe( map(endpoint => { const isConnected = !!(endpoint && endpoint.api_endpoint && endpoint.user); return [isConnected, endpoint] as [boolean, EndpointModel]; @@ -149,28 +136,6 @@ export class ConnectEndpointService { ); } - private getUpdateSelector() { - return selectUpdateInfo( - this.endpointEntityKey, - this.config.guid, - EndpointsEffect.connectingKey - ); - } - - private getRequestSelector() { - return selectRequestInfo( - this.endpointEntityKey, - SystemEffects.guid - ); - } - - private getEntitySelector() { - return selectEntity( - this.endpointEntityKey, - this.config.guid, - ); - } - public setData(data: ConnectEndpointData) { this.pData = data; } @@ -179,14 +144,14 @@ export class ConnectEndpointService { this.hasAttemptedConnect = true; const { authType, authVal, systemShared, bodyContent } = this.pData; - this.store.dispatch(new ConnectEndpoint( + stratosEntityCatalog.endpoint.api.connect( this.config.guid, this.config.type, authType, authVal, systemShared, bodyContent, - )); + ); return this.isBusy$.pipe( pairwise(), diff --git a/src/frontend/packages/core/src/features/endpoints/create-endpoint/create-endpoint-cf-step-1/create-endpoint-cf-step-1.component.ts b/src/frontend/packages/core/src/features/endpoints/create-endpoint/create-endpoint-cf-step-1/create-endpoint-cf-step-1.component.ts index a046dc6b62..a1a047e61c 100644 --- a/src/frontend/packages/core/src/features/endpoints/create-endpoint/create-endpoint-cf-step-1/create-endpoint-cf-step-1.component.ts +++ b/src/frontend/packages/core/src/features/endpoints/create-endpoint/create-endpoint-cf-step-1/create-endpoint-cf-step-1.component.ts @@ -6,18 +6,16 @@ import { denormalize } from 'normalizr'; import { Observable } from 'rxjs'; import { filter, map, pairwise, withLatestFrom } from 'rxjs/operators'; -import { GetAllEndpoints, RegisterEndpoint } from '../../../../../../store/src/actions/endpoint.actions'; import { ShowSnackBar } from '../../../../../../store/src/actions/snackBar.actions'; import { GeneralEntityAppState } from '../../../../../../store/src/app-state'; -import { EndpointsEffect } from '../../../../../../store/src/effects/endpoint.effects'; import { entityCatalog } from '../../../../../../store/src/entity-catalog/entity-catalog'; import { StratosCatalogEndpointEntity, } from '../../../../../../store/src/entity-catalog/entity-catalog-entity/entity-catalog-entity'; -import { endpointSchemaKey } from '../../../../../../store/src/helpers/entity-factory'; -import { getAPIRequestDataState, selectUpdateInfo } from '../../../../../../store/src/selectors/api.selectors'; -import { selectPaginationState } from '../../../../../../store/src/selectors/pagination.selectors'; -import { endpointEntitySchema, STRATOS_ENDPOINT_TYPE } from '../../../../base-entity-schemas'; +import { ActionState } from '../../../../../../store/src/reducers/api-request-reducer/types'; +import { getAPIRequestDataState } from '../../../../../../store/src/selectors/api.selectors'; +import { stratosEntityCatalog } from '../../../../../../store/src/stratos-entity-catalog'; +import { endpointEntitySchema } from '../../../../base-entity-schemas'; import { getIdFromRoute } from '../../../../core/utils.service'; import { IStepperStep, StepOnNextFunction } from '../../../../shared/components/stepper/step/step.component'; import { ConnectEndpointConfig } from '../../connect.service'; @@ -58,23 +56,24 @@ export class CreateEndpointCfStep1Component implements IStepperStep, AfterConten endpointTypeSupportsSSO = false; endpoint: StratosCatalogEndpointEntity; - private endpointEntityKey = entityCatalog.getEntityKey(STRATOS_ENDPOINT_TYPE, endpointSchemaKey); + // private endpointEntityKey = entityCatalog.getEntityKey(STRATOS_ENDPOINT_TYPE, endpointSchemaKey); constructor(private store: Store, activatedRoute: ActivatedRoute, ) { - - this.existingEndpoints = store.select(selectPaginationState(this.endpointEntityKey, GetAllEndpoints.storeKey)) - .pipe( - withLatestFrom(store.select(getAPIRequestDataState)), - map(([pagination, entities]) => { - const pages = Object.values(pagination.ids); - const page = [].concat.apply([], pages); - const endpoints = page.length ? denormalize(page, [endpointEntitySchema], entities) : []; - return { - names: endpoints.map(ep => ep.name), - urls: endpoints.map(ep => getFullEndpointApiUrl(ep)), - }; - }) - ); + const paginationState$ = stratosEntityCatalog.endpoint.store.getAll.getPaginationMonitor().pagination$; + + // TODO: RC Fix me, this is madness + this.existingEndpoints = paginationState$.pipe( + withLatestFrom(store.select(getAPIRequestDataState)), + map(([pagination, entities]) => { + const pages = Object.values(pagination.ids); + const page = [].concat.apply([], pages); + const endpoints = page.length ? denormalize(page, [endpointEntitySchema], entities) : []; + return { + names: endpoints.map(ep => ep.name), + urls: endpoints.map(ep => getFullEndpointApiUrl(ep)), + }; + }) + ); const epType = getIdFromRoute(activatedRoute, 'type'); const epSubType = getIdFromRoute(activatedRoute, 'subtype'); @@ -87,7 +86,7 @@ export class CreateEndpointCfStep1Component implements IStepperStep, AfterConten onNext: StepOnNextFunction = () => { const { subType, type } = this.endpoint.getTypeAndSubtype(); - const action = new RegisterEndpoint( + return stratosEntityCatalog.endpoint.api.register( type, subType, this.nameField.value, @@ -96,15 +95,8 @@ export class CreateEndpointCfStep1Component implements IStepperStep, AfterConten this.clientIDField ? this.clientIDField.value : '', this.clientSecretField ? this.clientSecretField.value : '', this.ssoAllowedField ? !!this.ssoAllowedField.value : false, - ); - - this.store.dispatch(action); - - const update$ = this.store.select( - this.getUpdateSelector(action.guid()) - ).pipe(filter(update => !!update)); - - return update$.pipe(pairwise(), + ).pipe( + pairwise(), filter(([oldVal, newVal]) => (oldVal.busy && !newVal.busy)), map(([oldVal, newVal]) => newVal), map(result => { @@ -129,13 +121,6 @@ export class CreateEndpointCfStep1Component implements IStepperStep, AfterConten ); } - private getUpdateSelector(guid) { - return selectUpdateInfo( - this.endpointEntityKey, - guid, - EndpointsEffect.registeringKey, - ); - } ngAfterContentInit() { this.validate = this.form.statusChanges.pipe( diff --git a/src/frontend/packages/core/src/features/endpoints/edit-endpoint/edit-endpoint-step/edit-endpoint-step.component.ts b/src/frontend/packages/core/src/features/endpoints/edit-endpoint/edit-endpoint-step/edit-endpoint-step.component.ts index 1376e3e6b7..327c7dcb58 100644 --- a/src/frontend/packages/core/src/features/endpoints/edit-endpoint/edit-endpoint-step/edit-endpoint-step.component.ts +++ b/src/frontend/packages/core/src/features/endpoints/edit-endpoint/edit-endpoint-step/edit-endpoint-step.component.ts @@ -1,21 +1,18 @@ import { Component, OnDestroy } from '@angular/core'; import { FormControl, FormGroup, Validators } from '@angular/forms'; import { ActivatedRoute } from '@angular/router'; -import { Store } from '@ngrx/store'; import { Observable, Subscription } from 'rxjs'; import { filter, first, map, pairwise, switchMap } from 'rxjs/operators'; -import { AppState } from '../../../../../../store/src/app-state'; import { entityCatalog } from '../../../../../../store/src/entity-catalog/entity-catalog'; -import { selectUpdateInfo } from '../../../../../../store/src/selectors/api.selectors'; +import { ActionState } from '../../../../../../store/src/reducers/api-request-reducer/types'; +import { stratosEntityCatalog } from '../../../../../../store/src/stratos-entity-catalog'; import { StepOnNextFunction } from '../../../../shared/components/stepper/step/step.component'; import { getFullEndpointApiUrl, getSSOClientRedirectURI } from '../../endpoint-helpers'; -import { UpdateEndpoint } from './../../../../../../store/src/actions/endpoint.actions'; import { EntityCatalogSchemas, IStratosEndpointDefinition, } from './../../../../../../store/src/entity-catalog/entity-catalog.types'; -import { endpointEntitiesSelector } from './../../../../../../store/src/selectors/endpoint.selectors'; import { EndpointModel } from './../../../../../../store/src/types/endpoint.types'; import { getIdFromRoute, safeUnsubscribe } from './../../../../core/utils.service'; import { IStepperStep } from './../../../../shared/components/stepper/step/step.component'; @@ -41,12 +38,11 @@ export class EditEndpointStepComponent implements OnDestroy, IStepperStep { existingEndpoints: Observable; endpoint$: Observable; definition$: Observable>; - existingEndpoinNames$: Observable; + existingEndpointNames$: Observable; formChangeSub: Subscription; setClientInfo = false; constructor( - private store: Store, activatedRoute: ActivatedRoute, ) { this.editEndpoint = new FormGroup({ @@ -65,9 +61,14 @@ export class EditEndpointStepComponent implements OnDestroy, IStepperStep { this.endpointID = getIdFromRoute(activatedRoute, 'id'); - this.existingEndpoints = this.store.select(endpointEntitiesSelector); + this.existingEndpoints = stratosEntityCatalog.endpoint.store.getAll.getPaginationMonitor().currentPage$.pipe( + map(endpoints => endpoints.reduce((res, endpoint) => { + res[endpoint.guid] = endpoint; + return res; + }, {})) + ); - this.existingEndpoinNames$ = this.existingEndpoints.pipe( + this.existingEndpointNames$ = this.existingEndpoints.pipe( map(endpoints => Object.values(endpoints).filter((ep: EndpointModel) => ep.guid !== this.endpointID)), map((endpoints: EndpointModel[]) => endpoints.map(ep => ep.name)) ); @@ -127,20 +128,19 @@ export class EditEndpointStepComponent implements OnDestroy, IStepperStep { return this.endpoint$.pipe( first(), switchMap(endpoint => { - const action = new UpdateEndpoint( - endpoint.cnsi_type, + return stratosEntityCatalog.endpoint.api.update( this.endpointID, - this.editEndpoint.value.name, - this.editEndpoint.value.skipSSL, - this.editEndpoint.value.setClientInfo, - this.editEndpoint.value.clientID, - this.editEndpoint.value.clientSecret, - this.editEndpoint.value.allowSSO, - ); - - this.store.dispatch(action); - - return this.store.select(selectUpdateInfo('stratosEndpoint', this.endpointID, 'updating')).pipe( + this.endpointID, { + endpointType: endpoint.cnsi_type, + id: this.endpointID, + name: this.editEndpoint.value.name, + skipSSL: this.editEndpoint.value.skipSSL, + setClientInfo: this.editEndpoint.value.setClientInfo, + clientID: this.editEndpoint.value.clientID, + clientSecret: this.editEndpoint.value.clientSecret, + allowSSO: this.editEndpoint.value.allowSSO, + } + ).pipe( pairwise(), filter(([oldV, newV]) => oldV.busy && !newV.busy), map(([, newV]) => newV), diff --git a/src/frontend/packages/core/src/features/error-page/error-page/error-page.component.ts b/src/frontend/packages/core/src/features/error-page/error-page/error-page.component.ts index 9b6ab439b4..f820100541 100644 --- a/src/frontend/packages/core/src/features/error-page/error-page/error-page.component.ts +++ b/src/frontend/packages/core/src/features/error-page/error-page/error-page.component.ts @@ -7,13 +7,12 @@ import { first, map, withLatestFrom } from 'rxjs/operators'; import { SendClearEndpointEventsAction } from '../../../../../store/src/actions/internal-events.actions'; import { AppState } from '../../../../../store/src/app-state'; -import { endpointSchemaKey } from '../../../../../store/src/helpers/entity-factory'; -import { EntityMonitor } from '../../../../../store/src/monitors/entity-monitor'; +import { endpointSchemaKey } from '../../../../../store/src/helpers/stratos-entity-factory'; import { InternalEventMonitorFactory } from '../../../../../store/src/monitors/internal-event-monitor.factory'; +import { stratosEntityCatalog } from '../../../../../store/src/stratos-entity-catalog'; import { EndpointModel } from '../../../../../store/src/types/endpoint.types'; import { InternalEventState } from '../../../../../store/src/types/internal-events.types'; import { getPreviousRoutingState } from '../../../../../store/src/types/routing.type'; -import { endpointEntitySchema } from '../../../base-entity-schemas'; import { StratosStatus } from '../../../shared/shared.types'; import { eventReturnUrlParam } from '../../event-page/events-page/events-page.component'; @@ -36,12 +35,7 @@ export class ErrorPageComponent implements OnInit { ngOnInit() { const endpointId = this.activatedRoute.snapshot.params.endpointId; if (endpointId) { - const endpointMonitor = new EntityMonitor( - this.store, - endpointId, - endpointEntitySchema.key, - endpointEntitySchema - ); + const endpointMonitor = stratosEntityCatalog.endpoint.store.getEntityMonitor(endpointId); const cfEndpointEventMonitor = this.internalEventMonitorFactory.getMonitor(endpointSchemaKey, of([endpointId])); this.errorDetails$ = cfEndpointEventMonitor.hasErroredOverTimeNoPoll(30).pipe( withLatestFrom(endpointMonitor.entity$), diff --git a/src/frontend/packages/core/src/shared/components/list/list-types/endpoint/base-endpoints-data-source.ts b/src/frontend/packages/core/src/shared/components/list/list-types/endpoint/base-endpoints-data-source.ts index 7f420a1f8c..ad79f48315 100644 --- a/src/frontend/packages/core/src/shared/components/list/list-types/endpoint/base-endpoints-data-source.ts +++ b/src/frontend/packages/core/src/shared/components/list/list-types/endpoint/base-endpoints-data-source.ts @@ -5,7 +5,7 @@ import { map, pairwise, tap, withLatestFrom } from 'rxjs/operators'; import { GetAllEndpoints } from '../../../../../../../store/src/actions/endpoint.actions'; import { CreatePagination } from '../../../../../../../store/src/actions/pagination.actions'; import { AppState } from '../../../../../../../store/src/app-state'; -import { endpointSchemaKey } from '../../../../../../../store/src/helpers/entity-factory'; +import { endpointSchemaKey } from '../../../../../../../store/src/helpers/stratos-entity-factory'; import { EntityMonitorFactory } from '../../../../../../../store/src/monitors/entity-monitor.factory.service'; import { InternalEventMonitorFactory } from '../../../../../../../store/src/monitors/internal-event-monitor.factory'; import { PaginationMonitorFactory } from '../../../../../../../store/src/monitors/pagination-monitor.factory'; @@ -55,7 +55,7 @@ export class BaseEndpointsDataSource extends ListDataSource { const { rowStateManager, sub } = rowStateHelper.getRowStateManager( paginationMonitorFactory, entityMonitorFactory, - GetAllEndpoints.storeKey, + action.paginationKey, action, EndpointRowStateSetUpManager, false @@ -111,7 +111,7 @@ export class BaseEndpointsDataSource extends ListDataSource { metricsAvailable: false, sso_allowed: false, }), - paginationKey: GetAllEndpoints.storeKey, + paginationKey: action.paginationKey, isLocal: true, transformEntities: [ { diff --git a/src/frontend/packages/core/src/shared/components/list/list-types/endpoint/endpoint-list.helpers.ts b/src/frontend/packages/core/src/shared/components/list/list-types/endpoint/endpoint-list.helpers.ts index b621bc2513..3213d959f0 100644 --- a/src/frontend/packages/core/src/shared/components/list/list-types/endpoint/endpoint-list.helpers.ts +++ b/src/frontend/packages/core/src/shared/components/list/list-types/endpoint/endpoint-list.helpers.ts @@ -4,17 +4,13 @@ import { Store } from '@ngrx/store'; import { combineLatest, Observable } from 'rxjs'; import { map, pairwise } from 'rxjs/operators'; -import { DisconnectEndpoint, UnregisterEndpoint } from '../../../../../../../store/src/actions/endpoint.actions'; import { RouterNav } from '../../../../../../../store/src/actions/router.actions'; import { ShowSnackBar } from '../../../../../../../store/src/actions/snackBar.actions'; -import { GetSystemInfo } from '../../../../../../../store/src/actions/system.actions'; import { AppState } from '../../../../../../../store/src/app-state'; -import { EndpointsEffect } from '../../../../../../../store/src/effects/endpoint.effects'; import { entityCatalog } from '../../../../../../../store/src/entity-catalog/entity-catalog'; -import { endpointSchemaKey } from '../../../../../../../store/src/helpers/entity-factory'; -import { selectDeletionInfo, selectUpdateInfo } from '../../../../../../../store/src/selectors/api.selectors'; +import { ActionState } from '../../../../../../../store/src/reducers/api-request-reducer/types'; +import { stratosEntityCatalog } from '../../../../../../../store/src/stratos-entity-catalog'; import { EndpointModel } from '../../../../../../../store/src/types/endpoint.types'; -import { STRATOS_ENDPOINT_TYPE } from '../../../../../base-entity-schemas'; import { LoggerService } from '../../../../../core/logger.service'; import { CurrentUserPermissionsService } from '../../../../../core/permissions/current-user-permissions.service'; import { StratosCurrentUserPermissions } from '../../../../../core/permissions/stratos-user-permissions.checker'; @@ -43,7 +39,6 @@ function isEndpointListDetailsComponent(obj: any): EndpointListDetailsComponent @Injectable() export class EndpointListHelper { - private endpointEntityKey = entityCatalog.getEntityKey(STRATOS_ENDPOINT_TYPE, endpointSchemaKey); constructor( private store: Store, private dialog: MatDialog, @@ -63,10 +58,10 @@ export class EndpointListHelper { false ); this.confirmDialog.open(confirmation, () => { - this.store.dispatch(new DisconnectEndpoint(item.guid, item.cnsi_type)); - this.handleUpdateAction(item, EndpointsEffect.disconnectingKey, ([oldVal, newVal]) => { + const obs$ = stratosEntityCatalog.endpoint.api.disconnect(item.guid, item.cnsi_type); + this.handleAction(obs$, () => { this.store.dispatch(new ShowSnackBar(`Disconnected endpoint '${item.name}'`)); - this.store.dispatch(new GetSystemInfo()); + stratosEntityCatalog.endpoint.api.get(item.guid); }); }); }, @@ -112,8 +107,8 @@ export class EndpointListHelper { true ); this.confirmDialog.open(confirmation, () => { - this.store.dispatch(new UnregisterEndpoint(item.guid, item.cnsi_type)); - this.handleDeleteAction(item, ([oldVal, newVal]) => { + const obs$ = stratosEntityCatalog.endpoint.api.unregister(item.guid, item.cnsi_type); + this.handleAction(obs$, () => { this.store.dispatch(new ShowSnackBar(`Unregistered ${item.name}`)); }); }); @@ -134,31 +129,16 @@ export class EndpointListHelper { ]; } - private handleUpdateAction(item, effectKey, handleChange) { - this.handleAction(selectUpdateInfo( - this.endpointEntityKey, - item.guid, - effectKey, - ), handleChange); - } - - private handleDeleteAction(item, handleChange) { - this.handleAction(selectDeletionInfo( - this.endpointEntityKey, - item.guid, - ), handleChange); - } - - private handleAction(storeSelect, handleChange) { - const disSub = this.store.select(storeSelect).pipe( - pairwise()) - .subscribe(([oldVal, newVal]) => { - // https://github.com/SUSE/stratos/issues/29 Generic way to handle errors ('Failed to disconnect X') - if (!newVal.error && (oldVal.busy && !newVal.busy)) { - handleChange([oldVal, newVal]); - disSub.unsubscribe(); - } - }); + private handleAction(obs$: Observable, handleChange: ([o, n]: [ActionState, ActionState]) => void) { + const disSub = obs$.pipe( + pairwise() + ).subscribe(([oldVal, newVal]) => { + // https://github.com/SUSE/stratos/issues/29 Generic way to handle errors ('Failed to disconnect X') + if (!newVal.error && (oldVal.busy && !newVal.busy)) { + handleChange([oldVal, newVal]); + disSub.unsubscribe(); + } + }); } createEndpointDetails(listDetailsComponent: any, container: ViewContainerRef, componentFactoryResolver: ComponentFactoryResolver): diff --git a/src/frontend/packages/core/src/shared/components/list/list-types/endpoint/endpoints-data-source.ts b/src/frontend/packages/core/src/shared/components/list/list-types/endpoint/endpoints-data-source.ts index 1f2999e41b..cdb066f099 100644 --- a/src/frontend/packages/core/src/shared/components/list/list-types/endpoint/endpoints-data-source.ts +++ b/src/frontend/packages/core/src/shared/components/list/list-types/endpoint/endpoints-data-source.ts @@ -1,10 +1,10 @@ import { Store } from '@ngrx/store'; -import { GetAllEndpoints } from '../../../../../../../store/src/actions/endpoint.actions'; import { AppState } from '../../../../../../../store/src/app-state'; import { EntityMonitorFactory } from '../../../../../../../store/src/monitors/entity-monitor.factory.service'; import { InternalEventMonitorFactory } from '../../../../../../../store/src/monitors/internal-event-monitor.factory'; import { PaginationMonitorFactory } from '../../../../../../../store/src/monitors/pagination-monitor.factory'; +import { stratosEntityCatalog } from '../../../../../../../store/src/stratos-entity-catalog'; import { EndpointModel } from '../../../../../../../store/src/types/endpoint.types'; import { IListConfig } from '../../list.component.types'; import { BaseEndpointsDataSource } from './base-endpoints-data-source'; @@ -23,7 +23,7 @@ export class EndpointsDataSource extends BaseEndpointsDataSource { super( store, listConfig, - new GetAllEndpoints(), + stratosEntityCatalog.endpoint.actions.getAll(), null, paginationMonitorFactory, entityMonitorFactory, diff --git a/src/frontend/packages/core/src/shared/components/list/list-types/endpoint/table-cell-endpoint-address/table-cell-endpoint-address.component.ts b/src/frontend/packages/core/src/shared/components/list/list-types/endpoint/table-cell-endpoint-address/table-cell-endpoint-address.component.ts index 32956ffa4b..a09f3f7446 100644 --- a/src/frontend/packages/core/src/shared/components/list/list-types/endpoint/table-cell-endpoint-address/table-cell-endpoint-address.component.ts +++ b/src/frontend/packages/core/src/shared/components/list/list-types/endpoint/table-cell-endpoint-address/table-cell-endpoint-address.component.ts @@ -2,8 +2,7 @@ import { Component, Input } from '@angular/core'; import { Observable } from 'rxjs'; import { map } from 'rxjs/operators'; -import { GetAllEndpoints } from '../../../../../../../../store/src/actions/endpoint.actions'; -import { EntityServiceFactory } from '../../../../../../../../store/src/entity-service-factory.service'; +import { stratosEntityCatalog } from '../../../../../../../../store/src/stratos-entity-catalog'; import { EndpointModel } from '../../../../../../../../store/src/types/endpoint.types'; import { getFullEndpointApiUrl } from '../../../../../../features/endpoints/endpoint-helpers'; import { TableCellCustom } from '../../../list.types'; @@ -17,15 +16,11 @@ import { RowWithEndpointId } from '../table-cell-endpoint-name/table-cell-endpoi export class TableCellEndpointAddressComponent extends TableCellCustom { public endpointAddress$: Observable; - constructor(private entityServiceFactory: EntityServiceFactory) { - super(); - } - @Input('row') set row(row: EndpointModel | RowWithEndpointId) { /* tslint:disable-next-line:no-string-literal */ const id = row['endpointId'] || row['guid']; - this.endpointAddress$ = this.entityServiceFactory.create(id, new GetAllEndpoints()).waitForEntity$.pipe( + this.endpointAddress$ = stratosEntityCatalog.endpoint.store.getEntityService(id).waitForEntity$.pipe( map(data => data.entity), map((data: any) => getFullEndpointApiUrl(data)) ); diff --git a/src/frontend/packages/core/src/shared/components/list/list-types/endpoint/table-cell-endpoint-name/table-cell-endpoint-name.component.ts b/src/frontend/packages/core/src/shared/components/list/list-types/endpoint/table-cell-endpoint-name/table-cell-endpoint-name.component.ts index 62928cef55..98224d0f18 100644 --- a/src/frontend/packages/core/src/shared/components/list/list-types/endpoint/table-cell-endpoint-name/table-cell-endpoint-name.component.ts +++ b/src/frontend/packages/core/src/shared/components/list/list-types/endpoint/table-cell-endpoint-name/table-cell-endpoint-name.component.ts @@ -2,9 +2,8 @@ import { Component, Input } from '@angular/core'; import { Observable } from 'rxjs'; import { map } from 'rxjs/internal/operators/map'; -import { GetAllEndpoints } from '../../../../../../../../store/src/actions/endpoint.actions'; import { entityCatalog } from '../../../../../../../../store/src/entity-catalog/entity-catalog'; -import { EntityServiceFactory } from '../../../../../../../../store/src/entity-service-factory.service'; +import { stratosEntityCatalog } from '../../../../../../../../store/src/stratos-entity-catalog'; import { EndpointModel } from '../../../../../../../../store/src/types/endpoint.types'; import { EndpointsService } from '../../../../../../core/endpoints.service'; import { TableCellCustom } from '../../../list.types'; @@ -22,21 +21,11 @@ export class TableCellEndpointNameComponent extends TableCellCustom; - constructor( - private entityServiceFactory: EntityServiceFactory, - - ) { - super(); - } - @Input('row') set row(row: EndpointModel | RowWithEndpointId) { /* tslint:disable-next-line:no-string-literal */ const id = row['endpointId'] || row['guid']; - this.endpoint$ = this.entityServiceFactory.create( - id, - new GetAllEndpoints() - ).waitForEntity$.pipe( + this.endpoint$ = stratosEntityCatalog.endpoint.store.getEntityService(id).waitForEntity$.pipe( map(data => data.entity), map((data: any) => { const ep = entityCatalog.getEndpoint(data.cnsi_type, data.sub_type).definition; diff --git a/src/frontend/packages/core/src/shared/components/recent-entities/recent-entities.component.ts b/src/frontend/packages/core/src/shared/components/recent-entities/recent-entities.component.ts index fcd86c1dc6..c07b99ef1a 100644 --- a/src/frontend/packages/core/src/shared/components/recent-entities/recent-entities.component.ts +++ b/src/frontend/packages/core/src/shared/components/recent-entities/recent-entities.component.ts @@ -5,7 +5,7 @@ import { Observable, of as observableOf } from 'rxjs'; import { filter, map } from 'rxjs/operators'; import { AppState } from '../../../../../store/src/app-state'; -import { endpointSchemaKey } from '../../../../../store/src/helpers/entity-factory'; +import { endpointSchemaKey } from '../../../../../store/src/helpers/stratos-entity-factory'; import { endpointEntitiesSelector } from '../../../../../store/src/selectors/endpoint.selectors'; import { recentlyVisitedSelector } from '../../../../../store/src/selectors/recently-visitied.selectors'; import { diff --git a/src/frontend/packages/core/src/shared/entity.tokens.ts b/src/frontend/packages/core/src/shared/entity.tokens.ts index 76df701c07..ad4c9476e6 100644 --- a/src/frontend/packages/core/src/shared/entity.tokens.ts +++ b/src/frontend/packages/core/src/shared/entity.tokens.ts @@ -1,5 +1,7 @@ -import { InjectionToken, Injectable } from '@angular/core'; +import { InjectionToken } from '@angular/core'; + import { EntityService } from '../../../store/src/entity-service'; + export const CF_GUID = new InjectionToken('cfGuid'); export const APP_GUID = new InjectionToken('appGuid'); diff --git a/src/frontend/packages/core/src/stratos-entity-generator.ts b/src/frontend/packages/core/src/stratos-entity-generator.ts new file mode 100644 index 0000000000..1c94af4f33 --- /dev/null +++ b/src/frontend/packages/core/src/stratos-entity-generator.ts @@ -0,0 +1,136 @@ +import { + StratosCatalogEndpointEntity, + StratosCatalogEntity, +} from '../../store/src/entity-catalog/entity-catalog-entity/entity-catalog-entity'; +import { + endpointSchemaKey, + STRATOS_ENDPOINT_TYPE, + stratosEntityFactory, + systemInfoSchemaKey, + userFavouritesSchemaKey, +} from '../../store/src/helpers/stratos-entity-factory'; +import { + addOrUpdateUserFavoriteMetadataReducer, + deleteUserFavoriteMetadataReducer, +} from '../../store/src/reducers/favorite.reducer'; +import { systemEndpointsReducer } from '../../store/src/reducers/system-endpoints.reducer'; +import { + EndpointActionBuilder, + endpointActionBuilder, + stratosEntityCatalog, + SystemInfoActionBuilder, + systemInfoActionBuilder, + UserProfileActionBuilder, + userProfileActionBuilder, +} from '../../store/src/stratos-entity-catalog'; +import { EndpointModel } from '../../store/src/types/endpoint.types'; +import { BaseEndpointAuth } from './features/endpoints/endpoint-auth'; +import { + MetricsEndpointDetailsComponent, +} from './features/metrics/metrics-endpoint-details/metrics-endpoint-details.component'; + +// +// These types are used to represent the base stratos types. +// + +/** + * This is used as a fake endpoint type to allow the store to be initiated correctly + */ +const stratosType = { + logoUrl: '', + authTypes: [], + type: STRATOS_ENDPOINT_TYPE, + schema: null +}; + +/** + * DefaultEndpointEntityType is used to represent a general endpoint + * This should not be used to actually attempt to render an endpoint and is instead used as a way to fill the + */ +class DefaultEndpointCatalogEntity extends StratosCatalogEntity< + any,//TODO: RC + EndpointModel, + EndpointActionBuilder + > { + constructor() { + super({ + schema: stratosEntityFactory(endpointSchemaKey), + type: endpointSchemaKey, + endpoint: stratosType, + }, { + dataReducers: [ + systemEndpointsReducer + ], + actionBuilders: endpointActionBuilder + }); + } +} + +class UserFavoriteCatalogEntity extends StratosCatalogEntity { + constructor() { + super({ + schema: stratosEntityFactory(userFavouritesSchemaKey), + type: userFavouritesSchemaKey, + endpoint: stratosType, + }, { + dataReducers: [ + addOrUpdateUserFavoriteMetadataReducer, + deleteUserFavoriteMetadataReducer, + ] + }); + } +} + +class UserProfileCatalogEntity extends StratosCatalogEntity< + any, + any, //TODO: RC + UserProfileActionBuilder> { + constructor() { + super({ + schema: stratosEntityFactory(userFavouritesSchemaKey), + type: userFavouritesSchemaKey, + endpoint: stratosType, + }, { + actionBuilders: userProfileActionBuilder + }); + } +} + +class SystemInfoCatalogEntity extends StratosCatalogEntity< + any, + any, //TODO: RC + SystemInfoActionBuilder + > { + constructor() { + super({ + schema: stratosEntityFactory(systemInfoSchemaKey), + type: systemInfoSchemaKey, + endpoint: stratosType, + }, { + actionBuilders: systemInfoActionBuilder + }); + } +} + +export function generateStratosEntities() { + stratosEntityCatalog.endpoint = new DefaultEndpointCatalogEntity(); + stratosEntityCatalog.systemInfo = new SystemInfoCatalogEntity() + stratosEntityCatalog.userFavorite = new UserFavoriteCatalogEntity() + stratosEntityCatalog.userProfile = new UserProfileCatalogEntity() + // TODO: metrics location to be sorted - STRAT-152 + stratosEntityCatalog.metricsEndpoint = new StratosCatalogEndpointEntity({ + type: 'metrics', + label: 'Metrics', + labelPlural: 'Metrics', + tokenSharing: true, + logoUrl: '/core/assets/endpoint-icons/metrics.svg', + authTypes: [BaseEndpointAuth.UsernamePassword, BaseEndpointAuth.None], + renderPriority: 1, + listDetailsComponent: MetricsEndpointDetailsComponent, + }, + metadata => `/endpoints/metrics/${metadata.guid}` + ) + + return Object.values(stratosEntityCatalog); +} + diff --git a/src/frontend/packages/core/test-framework/core-test.modules.ts b/src/frontend/packages/core/test-framework/core-test.modules.ts index f2e0bc6e7a..5242adfc91 100644 --- a/src/frontend/packages/core/test-framework/core-test.modules.ts +++ b/src/frontend/packages/core/test-framework/core-test.modules.ts @@ -1,8 +1,8 @@ import { NgModule } from '@angular/core'; -import { generateStratosEntities } from '../../core/src/base-entity-types'; import { CATALOGUE_ENTITIES, EntityCatalogFeatureModule } from '../../store/src/entity-catalog.module'; import { entityCatalog, TestEntityCatalog } from '../../store/src/entity-catalog/entity-catalog'; +import { generateStratosEntities } from '../src/stratos-entity-generator'; @NgModule({ imports: [ diff --git a/src/frontend/packages/store/src/actions/endpoint.actions.ts b/src/frontend/packages/store/src/actions/endpoint.actions.ts index cd4540b8eb..885fe4fdb9 100644 --- a/src/frontend/packages/store/src/actions/endpoint.actions.ts +++ b/src/frontend/packages/store/src/actions/endpoint.actions.ts @@ -2,14 +2,15 @@ import { Action } from '@ngrx/store'; import { STRATOS_ENDPOINT_TYPE } from '../../../core/src/base-entity-schemas'; import { EndpointType } from '../../../core/src/core/extension/extension-types'; -import { endpointSchemaKey } from '../helpers/entity-factory'; +import { endpointSchemaKey } from '../helpers/stratos-entity-factory'; import { NormalizedResponse } from '../types/api.types'; -import { endpointListKey, EndpointModel, INewlyConnectedEndpointInfo } from '../types/endpoint.types'; +import { endpointListKey, EndpointModel } from '../types/endpoint.types'; import { PaginatedAction } from '../types/pagination.types'; +import { EntityRequestAction } from '../types/request.types'; export const GET_ENDPOINTS = '[Endpoints] Get all'; -export const GET_ENDPOINTS_START = '[Endpoints] Get all start'; -export const GET_ENDPOINTS_LOGIN = '[Endpoints] Get all at login'; +export const GET_ENDPOINTS_START = '[Endpoints] Get all start'; // TODO: RD HUH +export const GET_ENDPOINTS_LOGIN = '[Endpoints] Get all at login'; // TODO: RD HUH export const GET_ENDPOINTS_SUCCESS = '[Endpoints] Get all success'; export const GET_ENDPOINTS_FAILED = '[Endpoints] Get all failed'; @@ -33,18 +34,54 @@ export const UPDATE_ENDPOINT = '[Endpoints] Update'; export const UPDATE_ENDPOINT_SUCCESS = '[Endpoints] Update succeed'; export const UPDATE_ENDPOINT_FAILED = '[Endpoints] Update failed'; -export class EndpointActionComplete implements Action { +// TODO: RC delete +// export class EndpointActionComplete implements Action { +// constructor( +// public type: string, +// public guid: string, +// public endpointType: EndpointType, +// public endpoint: EndpointModel | INewlyConnectedEndpointInfo +// ) { } +// } + + +// export class EndpointAction implements Action { +// type: string; +// endpointType: EndpointType; +// } + +export class GetAllEndpointsSuccess implements Action { + constructor(public payload: NormalizedResponse, public login = false) { } + type = GET_ENDPOINTS_SUCCESS; +} + +abstract class BaseEndpointAction implements EntityRequestAction { + public entityType = endpointSchemaKey; + public endpointType = STRATOS_ENDPOINT_TYPE; + public subType = ''; + constructor(public type: string) { } + actions: string[]; + // TODO: RC SCHEMAS everywhere +} + +abstract class SingleBaseEndpointAction extends BaseEndpointAction { constructor( - public type: string, - public guid: string, - public endpointType: EndpointType, - public endpoint: EndpointModel | INewlyConnectedEndpointInfo - ) { } + type: string, + public guid: string + ) { + super(type); + + } } -export class EndpointAction implements Action { - type: string; - endpointType: EndpointType; +abstract class MultipleBaseEndpointAction extends BaseEndpointAction implements PaginatedAction { + constructor( + type: string, + public paginationKey: string + ) { + super(type); + + } } // Different Auth Type support for connecting to Endpoints @@ -60,13 +97,16 @@ export interface AuthParamsToken { // All supported auth params types export type AuthParams = AuthParamsUsernamePassword | AuthParamsToken; -export class GetAllEndpoints implements PaginatedAction { +export class GetAllEndpoints extends MultipleBaseEndpointAction { public static storeKey = endpointListKey; - constructor(public login = false) { } - entityType = endpointSchemaKey; - endpointType = STRATOS_ENDPOINT_TYPE; - paginationKey = GetAllEndpoints.storeKey; - type = GET_ENDPOINTS; + constructor( + public login = false + ) { + super( + GET_ENDPOINTS, + GetAllEndpoints.storeKey + ) + } actions = [ GET_ENDPOINTS_START, GET_ENDPOINTS_SUCCESS, @@ -80,51 +120,66 @@ export class GetAllEndpoints implements PaginatedAction { }; } -export class GetAllEndpointsSuccess implements Action { - constructor(public payload: NormalizedResponse, public login = false) { } - type = GET_ENDPOINTS_SUCCESS; -} - -export class GetAllEndpointsFailed implements Action { - constructor(public message: string, public login = false) { } - type = GET_ENDPOINTS_FAILED; -} - -export class ConnectEndpoint extends EndpointAction { +export class ConnectEndpoint extends SingleBaseEndpointAction { + static UpdatingKey = 'connectingKey' constructor( - public guid: string, + guid: string, public endpointType: EndpointType, public authType: string, public authValues: AuthParams, public systemShared: boolean, public body: string, ) { - super(); + super( + CONNECT_ENDPOINTS, + guid + ); } - type = CONNECT_ENDPOINTS; + updatingKey = ConnectEndpoint.UpdatingKey; + actions = [ + CONNECT_ENDPOINTS, + CONNECT_ENDPOINTS_SUCCESS, + CONNECT_ENDPOINTS_FAILED + ] } -export class DisconnectEndpoint extends EndpointAction { +export class DisconnectEndpoint extends SingleBaseEndpointAction { + static UpdatingKey = 'disconnecting' constructor( - public guid: string, + guid: string, public endpointType: EndpointType, ) { - super(); + super( + DISCONNECT_ENDPOINTS, + guid + ); } - type = DISCONNECT_ENDPOINTS; + updatingKey = DisconnectEndpoint.UpdatingKey; + actions = [ + DISCONNECT_ENDPOINTS, + DISCONNECT_ENDPOINTS_SUCCESS, + DISCONNECT_ENDPOINTS_FAILED + ]; } -export class UnregisterEndpoint extends EndpointAction { +export class UnregisterEndpoint extends SingleBaseEndpointAction { constructor( - public guid: string, + guid: string, public endpointType: EndpointType, ) { - super(); + super( + UNREGISTER_ENDPOINTS, + guid + ); } - type = UNREGISTER_ENDPOINTS; + actions = [ + UNREGISTER_ENDPOINTS, + UNREGISTER_ENDPOINTS_SUCCESS, + UNREGISTER_ENDPOINTS_FAILED + ]; } -export class RegisterEndpoint extends EndpointAction { +export class RegisterEndpoint extends SingleBaseEndpointAction { constructor( public endpointType: EndpointType, public endpointSubType: string = null, @@ -135,21 +190,22 @@ export class RegisterEndpoint extends EndpointAction { public clientSecret = '', public ssoAllowed: boolean, ) { - super(); - } - type = REGISTER_ENDPOINTS; - - public guid(): string { - return '' + this.name; + super( + REGISTER_ENDPOINTS, + '' + name + ); } + updatingKey = 'registering' + actions = [ + REGISTER_ENDPOINTS, + REGISTER_ENDPOINTS_SUCCESS, + REGISTER_ENDPOINTS_FAILED + ]; } -export class UpdateEndpoint extends EndpointAction { - - type = UPDATE_ENDPOINT; - +export class UpdateEndpoint extends SingleBaseEndpointAction { constructor( - public endpointType: EndpointType, + public endpointType: EndpointType, // TODO: RC test different types public id: string, public name: string, public skipSSL: boolean, @@ -158,6 +214,15 @@ export class UpdateEndpoint extends EndpointAction { public clientSecret: string, public allowSSO: boolean, ) { - super(); + super( + UPDATE_ENDPOINT, + id + ); } + updatingKey = 'updating' + actions = [ + UPDATE_ENDPOINT, + UPDATE_ENDPOINT_SUCCESS, + UPDATE_ENDPOINT_FAILED + ]; } diff --git a/src/frontend/packages/store/src/actions/system.actions.ts b/src/frontend/packages/store/src/actions/system.actions.ts index c916b62398..271c361442 100644 --- a/src/frontend/packages/store/src/actions/system.actions.ts +++ b/src/frontend/packages/store/src/actions/system.actions.ts @@ -1,5 +1,8 @@ import { Action } from '@ngrx/store'; +import { STRATOS_ENDPOINT_TYPE } from '../../../core/src/base-entity-schemas'; +import { stratosEntityFactory, systemInfoSchemaKey } from '../helpers/stratos-entity-factory'; +import { EntityRequestAction } from '../types/request.types'; import { SystemInfo } from '../types/system.types'; import { GetAllEndpoints } from './endpoint.actions'; @@ -7,13 +10,24 @@ export const GET_SYSTEM_INFO = '[System] Get info'; export const GET_SYSTEM_INFO_SUCCESS = '[System] Get info success'; export const GET_SYSTEM_INFO_FAILED = '[System] Get info failed'; -export class GetSystemInfo implements Action { +export class GetSystemInfo implements EntityRequestAction { + guid = 'info'; constructor(public login = false, public associatedAction?: GetAllEndpoints) { - if (!associatedAction) { - this.associatedAction = new GetAllEndpoints(login); + if (!this.associatedAction) { + this.associatedAction = new GetAllEndpoints(login); // TODO: RC } } + // TODO: RC WHERE SHOULD THIS BE STORED + schemaKey = systemInfoSchemaKey; + entity = [stratosEntityFactory(systemInfoSchemaKey)] + entityType = systemInfoSchemaKey; + endpointType = STRATOS_ENDPOINT_TYPE; type = GET_SYSTEM_INFO; + actions = [ + GET_SYSTEM_INFO, + GET_SYSTEM_INFO_SUCCESS, + GET_SYSTEM_INFO_FAILED + ] } export class GetSystemSuccess implements Action { @@ -21,7 +35,7 @@ export class GetSystemSuccess implements Action { type = GET_SYSTEM_INFO_SUCCESS; } -export class GetSystemFailed implements Action { - type = GET_SYSTEM_INFO_FAILED; -} +// export class GetSystemFailed implements Action { +// type = GET_SYSTEM_INFO_FAILED; +// } diff --git a/src/frontend/packages/store/src/actions/user-favourites-actions/user-favourites.actions.ts b/src/frontend/packages/store/src/actions/user-favourites-actions/user-favourites.actions.ts new file mode 100644 index 0000000000..e3d267383f --- /dev/null +++ b/src/frontend/packages/store/src/actions/user-favourites-actions/user-favourites.actions.ts @@ -0,0 +1,14 @@ +import { EntityRequestAction } from '../../types/request.types'; + +export class BaseUserFavoritesAction implements EntityRequestAction { + constructor( + actionType: string, + ) { + this.type = actionType; + } + public type: string; + public url = '/user-favorites'; + + public entityType: userFavoritesEntitySchema.entityType, + public endpointType: userFavoritesEntitySchema.endpointType, +} diff --git a/src/frontend/packages/store/src/actions/user-profile.actions.ts b/src/frontend/packages/store/src/actions/user-profile.actions.ts index 00234f772e..bc1a349ab1 100644 --- a/src/frontend/packages/store/src/actions/user-profile.actions.ts +++ b/src/frontend/packages/store/src/actions/user-profile.actions.ts @@ -1,6 +1,6 @@ -import { Action } from '@ngrx/store'; - import { userProfileEntitySchema } from '../../../core/src/base-entity-schemas'; +import { userProfilePasswordUpdatingKey } from '../effects/user-profile.effects'; +import { rootUpdatingKey } from '../reducers/api-request-reducer/types'; import { EntityRequestAction } from '../types/request.types'; import { UserProfileInfo, UserProfilePasswordUpdate } from '../types/user-profile.types'; @@ -8,21 +8,30 @@ export const GET_USERPROFILE = '[UserProfile] Get'; export const UPDATE_USERPROFILE = '[UserProfile] Update'; export const UPDATE_USERPASSWORD = '[UserPassword] Update'; -export class FetchUserProfileAction implements EntityRequestAction { +abstract class BaseProfileAction implements EntityRequestAction { static guid = 'userProfile'; - type = GET_USERPROFILE; - constructor(public userGuid: string) { } + guid = BaseProfileAction.guid; entityType = userProfileEntitySchema.entityType; endpointType = userProfileEntitySchema.endpointType; - guid = FetchUserProfileAction.guid; + constructor(public type: string) { } +} + +export class FetchUserProfileAction extends BaseProfileAction { + constructor(public userGuid: string) { + super(GET_USERPROFILE); + } } -export class UpdateUserProfileAction implements Action { - type = UPDATE_USERPROFILE; - constructor(public profile: UserProfileInfo, public password: string) { } +export class UpdateUserProfileAction extends BaseProfileAction { + constructor(public profile: UserProfileInfo, public password: string) { + super(UPDATE_USERPROFILE) + } + updatingKey = rootUpdatingKey } -export class UpdateUserPasswordAction implements Action { - type = UPDATE_USERPASSWORD; - constructor(public id: string, public passwordChanges: UserProfilePasswordUpdate) { } +export class UpdateUserPasswordAction extends BaseProfileAction { + constructor(public id: string, public passwordChanges: UserProfilePasswordUpdate) { + super(UPDATE_USERPASSWORD); + } + updatingKey = userProfilePasswordUpdatingKey } diff --git a/src/frontend/packages/store/src/effects/auth.effects.ts b/src/frontend/packages/store/src/effects/auth.effects.ts index 38c8883ba8..3a5c754d5e 100644 --- a/src/frontend/packages/store/src/effects/auth.effects.ts +++ b/src/frontend/packages/store/src/effects/auth.effects.ts @@ -27,9 +27,9 @@ import { } from '../actions/auth.actions'; import { HydrateDashboardStateAction } from '../actions/dashboard-actions'; import { GET_ENDPOINTS_SUCCESS, GetAllEndpointsSuccess } from '../actions/endpoint.actions'; -import { GetSystemInfo } from '../actions/system.actions'; import { DispatchOnlyAppState } from '../app-state'; import { getDashboardStateSessionId } from '../helpers/store-helpers'; +import { stratosEntityCatalog } from '../stratos-entity-catalog'; import { SessionData } from '../types/auth.types'; const SETUP_HEADER = 'stratos-setup-required'; @@ -84,7 +84,10 @@ export class AuthEffect { const sessionData = response.body; sessionData.sessionExpiresOn = parseInt(response.headers.get('x-cap-session-expires-on'), 10) * 1000; this.rehydrateDashboardState(this.store, sessionData); - return [new GetSystemInfo(true), new VerifiedSession(sessionData, action.updateEndpoints)]; + return [ + stratosEntityCatalog.systemInfo.actions.getSystemInfo(true), + new VerifiedSession(sessionData, action.updateEndpoints) + ]; }), catchError((err, caught) => { let setupMode = false; diff --git a/src/frontend/packages/store/src/effects/endpoint-api-errors.effects.ts b/src/frontend/packages/store/src/effects/endpoint-api-errors.effects.ts index 8aa64ed80f..8686993327 100644 --- a/src/frontend/packages/store/src/effects/endpoint-api-errors.effects.ts +++ b/src/frontend/packages/store/src/effects/endpoint-api-errors.effects.ts @@ -6,7 +6,7 @@ import { map } from 'rxjs/operators'; import { SendEventAction } from '../actions/internal-events.actions'; import { RequestTypes } from '../actions/request.actions'; import { InternalAppState } from '../app-state'; -import { endpointSchemaKey } from '../helpers/entity-factory'; +import { endpointSchemaKey } from '../helpers/stratos-entity-factory'; import { InternalEventSeverity } from '../types/internal-events.types'; import { WrapperRequestActionFailed } from '../types/request.types'; diff --git a/src/frontend/packages/store/src/effects/endpoint.effects.ts b/src/frontend/packages/store/src/effects/endpoint.effects.ts index 3ebaf0694a..b0e6a5b74a 100644 --- a/src/frontend/packages/store/src/effects/endpoint.effects.ts +++ b/src/frontend/packages/store/src/effects/endpoint.effects.ts @@ -4,39 +4,29 @@ import { Actions, Effect, ofType } from '@ngrx/effects'; import { Store } from '@ngrx/store'; import { catchError, mergeMap } from 'rxjs/operators'; -import { STRATOS_ENDPOINT_TYPE } from '../../../core/src/base-entity-schemas'; import { EndpointType } from '../../../core/src/core/extension/extension-types'; import { BrowserStandardEncoder } from '../../../core/src/helper'; import { CONNECT_ENDPOINTS, - CONNECT_ENDPOINTS_FAILED, - CONNECT_ENDPOINTS_SUCCESS, ConnectEndpoint, DISCONNECT_ENDPOINTS, - DISCONNECT_ENDPOINTS_FAILED, - DISCONNECT_ENDPOINTS_SUCCESS, DisconnectEndpoint, - EndpointActionComplete, GET_ENDPOINTS, GetAllEndpoints, GetAllEndpointsSuccess, REGISTER_ENDPOINTS, - REGISTER_ENDPOINTS_FAILED, - REGISTER_ENDPOINTS_SUCCESS, RegisterEndpoint, UNREGISTER_ENDPOINTS, - UNREGISTER_ENDPOINTS_FAILED, - UNREGISTER_ENDPOINTS_SUCCESS, UnregisterEndpoint, } from '../actions/endpoint.actions'; import { SendClearEventAction } from '../actions/internal-events.actions'; import { ClearPaginationOfEntity } from '../actions/pagination.actions'; -import { GET_SYSTEM_INFO_SUCCESS, GetSystemInfo, GetSystemSuccess } from '../actions/system.actions'; +import { GET_SYSTEM_INFO_SUCCESS, GetSystemSuccess } from '../actions/system.actions'; import { GetUserFavoritesAction } from '../actions/user-favourites-actions/get-user-favorites-action'; import { DispatchOnlyAppState } from '../app-state'; import { entityCatalog } from '../entity-catalog/entity-catalog'; -import { endpointSchemaKey } from '../helpers/entity-factory'; import { ApiRequestTypes } from '../reducers/api-request-reducer/request-helpers'; +import { stratosEntityCatalog } from '../stratos-entity-catalog'; import { NormalizedResponse } from '../types/api.types'; import { EndpointModel } from '../types/endpoint.types'; import { @@ -45,23 +35,13 @@ import { WrapperRequestActionFailed, WrapperRequestActionSuccess, } from '../types/request.types'; -import { - UPDATE_ENDPOINT, - UPDATE_ENDPOINT_FAILED, - UPDATE_ENDPOINT_SUCCESS, - UpdateEndpoint, -} from './../actions/endpoint.actions'; +import { UPDATE_ENDPOINT, UpdateEndpoint } from './../actions/endpoint.actions'; import { PaginatedAction } from './../types/pagination.types'; @Injectable() export class EndpointsEffect { - static connectingKey = 'connecting'; - static disconnectingKey = 'disconnecting'; - static registeringKey = 'registering'; - static updatingKey = 'updating'; - constructor( private http: HttpClient, private actions$: Actions, @@ -70,20 +50,22 @@ export class EndpointsEffect { @Effect() getAllEndpointsBySystemInfo$ = this.actions$.pipe( ofType(GET_ENDPOINTS), - mergeMap((action: GetAllEndpoints) => [new GetSystemInfo(false, action)]) + mergeMap((action: GetAllEndpoints) => [ + stratosEntityCatalog.systemInfo.actions.getSystemInfo(false, action) + ]) ); @Effect() getAllEndpoints$ = this.actions$.pipe( ofType(GET_SYSTEM_INFO_SUCCESS), mergeMap(action => { - const endpointEntityKey = entityCatalog.getEntityKey(STRATOS_ENDPOINT_TYPE, endpointSchemaKey); const { associatedAction } = action; - const actionType = 'fetch'; + // TODO: RC test service instance wall + const entityKey = entityCatalog.getEntityKey(associatedAction); const endpoints = action.payload.endpoints; // Data is an array of endpoints const mappedData = { entities: { - [endpointEntityKey]: {} + [entityKey]: {} }, result: [] } as NormalizedResponse; @@ -91,7 +73,7 @@ export class EndpointsEffect { Object.keys(endpoints).forEach((type: string) => { const endpointsForType = endpoints[type]; Object.values(endpointsForType).forEach(endpointInfo => { - mappedData.entities[endpointEntityKey][endpointInfo.guid] = { + mappedData.entities[entityKey][endpointInfo.guid] = { ...endpointInfo, connectionStatus: endpointInfo.user ? 'connected' : 'disconnected', }; @@ -102,7 +84,7 @@ export class EndpointsEffect { // Order is important. Need to ensure data is written (none cf action success) before we notify everything is loaded // (endpoint success) return [ - new WrapperRequestActionSuccess(mappedData, associatedAction, actionType), + new WrapperRequestActionSuccess(mappedData, associatedAction, 'fetch'), new GetAllEndpointsSuccess(mappedData, associatedAction.login), ]; })); @@ -119,8 +101,6 @@ export class EndpointsEffect { return []; } - const apiAction = this.getEndpointUpdateAction(action.guid, action.type, EndpointsEffect.connectingKey); - let fromObject: any; let body = action.body as any; @@ -152,11 +132,10 @@ export class EndpointsEffect { }); return this.doEndpointAction( - apiAction, + action, '/pp/v1/auth/login/cnsi', params, null, - [CONNECT_ENDPOINTS_SUCCESS, CONNECT_ENDPOINTS_FAILED], action.endpointType, body, response => response && response.error && response.error.error ? response.error.error : 'Could not connect, please try again' @@ -166,8 +145,6 @@ export class EndpointsEffect { @Effect() disconnect$ = this.actions$.pipe( ofType(DISCONNECT_ENDPOINTS), mergeMap(action => { - - const apiAction = this.getEndpointUpdateAction(action.guid, action.type, EndpointsEffect.disconnectingKey); const params: HttpParams = new HttpParams({ fromObject: { cnsi_guid: action.guid @@ -175,11 +152,10 @@ export class EndpointsEffect { }); return this.doEndpointAction( - apiAction, + action, '/pp/v1/auth/logout/cnsi', params, null, - [DISCONNECT_ENDPOINTS_SUCCESS, DISCONNECT_ENDPOINTS_FAILED], action.endpointType ); })); @@ -187,8 +163,6 @@ export class EndpointsEffect { @Effect() unregister$ = this.actions$.pipe( ofType(UNREGISTER_ENDPOINTS), mergeMap(action => { - - const apiAction = this.getEndpointDeleteAction(action.guid, action.type); const params: HttpParams = new HttpParams({ fromObject: { cnsi_guid: action.guid @@ -196,11 +170,10 @@ export class EndpointsEffect { }); return this.doEndpointAction( - apiAction, + action, '/pp/v1/unregister', params, 'delete', - [UNREGISTER_ENDPOINTS_SUCCESS, UNREGISTER_ENDPOINTS_FAILED], action.endpointType ); })); @@ -209,7 +182,6 @@ export class EndpointsEffect { ofType(REGISTER_ENDPOINTS), mergeMap(action => { - const apiAction = this.getEndpointUpdateAction(action.guid(), action.type, EndpointsEffect.registeringKey); const paramsObj = { cnsi_name: action.name, api_endpoint: action.endpoint, @@ -230,11 +202,10 @@ export class EndpointsEffect { }); return this.doEndpointAction( - apiAction, + action, '/pp/v1/register/' + action.endpointType, new HttpParams({}), 'create', - [REGISTER_ENDPOINTS_SUCCESS, REGISTER_ENDPOINTS_FAILED], action.endpointType, body, this.processRegisterError @@ -243,8 +214,7 @@ export class EndpointsEffect { @Effect() updateEndpoint$ = this.actions$.pipe( ofType(UPDATE_ENDPOINT), - mergeMap(action => { - const apiAction = this.getEndpointUpdateAction(action.id, action.type, EndpointsEffect.updatingKey); + mergeMap((action: UpdateEndpoint) => { const paramsObj = { name: action.name, skipSSL: action.skipSSL, @@ -261,11 +231,10 @@ export class EndpointsEffect { }); return this.doEndpointAction( - apiAction, + action, '/pp/v1/endpoint/' + action.id, new HttpParams({}), 'update', - [UPDATE_ENDPOINT_SUCCESS, UPDATE_ENDPOINT_FAILED], action.endpointType, body, this.processUpdateError @@ -291,35 +260,17 @@ export class EndpointsEffect { } return message; } - private getEndpointUpdateAction(guid: string, type: string, updatingKey: string) { - const entityType = entityCatalog.getEntityKey(STRATOS_ENDPOINT_TYPE, endpointSchemaKey); - return { - entityType, - guid, - type, - updatingKey, - } as EntityRequestAction; - } - - private getEndpointDeleteAction(guid, type) { - const entityType = entityCatalog.getEntityKey(STRATOS_ENDPOINT_TYPE, endpointSchemaKey); - return { - entityType, - guid, - type, - } as EntityRequestAction; - } private doEndpointAction( apiAction: EntityRequestAction | PaginatedAction, url: string, params: HttpParams, apiActionType: ApiRequestTypes = 'update', - actionStrings: [string, string] = [null, null], - endpointType: EndpointType = 'cf', + endpointType: EndpointType, body?: string, errorMessageHandler?: (e: any) => string, ) { + const endpointEntityKey = entityCatalog.getEntityKey(apiAction); this.store.dispatch(new StartRequestAction(apiAction, apiActionType)); return this.http.post(url, body || {}, { @@ -328,8 +279,8 @@ export class EndpointsEffect { mergeMap((endpoint: EndpointModel) => { const actions = []; let response: NormalizedResponse; - if (actionStrings[0]) { - actions.push(new EndpointActionComplete(actionStrings[0], apiAction.guid, endpointType, endpoint)); + if (apiAction.actions[1]) { + actions.push(new EndpointActionComplete(apiAction.actions[1], apiAction.guid, endpointType, endpoint)); } if (apiActionType === 'delete') { @@ -338,7 +289,7 @@ export class EndpointsEffect { } if (apiActionType === 'create') { - actions.push(new GetSystemInfo()); + actions.push(stratosEntityCatalog.systemInfo.actions.getSystemInfo()); response = { entities: { [endpointEntityKey]: { @@ -350,10 +301,10 @@ export class EndpointsEffect { } if (apiActionType === 'update') { - actions.push(new GetSystemInfo()); + actions.push(stratosEntityCatalog.systemInfo.actions.getSystemInfo()); } - if (apiAction.updatingKey === EndpointsEffect.disconnectingKey || apiActionType === 'create' || apiActionType === 'delete' + if (apiAction.updatingKey === DisconnectEndpoint.UpdatingKey || apiActionType === 'create' || apiActionType === 'delete' || apiActionType === 'update') { actions.push(this.clearEndpointInternalEvents(apiAction.guid, endpointEntityKey)); } @@ -364,8 +315,8 @@ export class EndpointsEffect { ), catchError(e => { const actions = []; - if (actionStrings[1]) { - actions.push({ type: actionStrings[1], guid: apiAction.guid }); + if (apiAction.actions[2]) { + actions.push({ type: apiAction.actions[2], guid: apiAction.guid }); } const errorMessage = errorMessageHandler ? errorMessageHandler(e) : 'Could not perform action'; actions.push(new WrapperRequestActionFailed(errorMessage, apiAction, apiActionType)); diff --git a/src/frontend/packages/store/src/effects/system.effects.ts b/src/frontend/packages/store/src/effects/system.effects.ts index 962280aebb..dc6880d368 100644 --- a/src/frontend/packages/store/src/effects/system.effects.ts +++ b/src/frontend/packages/store/src/effects/system.effects.ts @@ -4,12 +4,10 @@ import { Actions, Effect, ofType } from '@ngrx/effects'; import { Store } from '@ngrx/store'; import { catchError, mergeMap } from 'rxjs/operators'; -import { EntityRequestAction } from '../types/request.types'; -import { GET_SYSTEM_INFO, GetSystemFailed, GetSystemInfo, GetSystemSuccess } from '../actions/system.actions'; -import { StartRequestAction, WrapperRequestActionFailed, WrapperRequestActionSuccess } from '../types/request.types'; -import { SystemInfo, systemStoreNames } from '../types/system.types'; +import { GET_SYSTEM_INFO, GetSystemInfo, GetSystemSuccess } from '../actions/system.actions'; import { InternalAppState } from '../app-state'; -import { STRATOS_ENDPOINT_TYPE } from '../../../core/src/base-entity-schemas'; +import { StartRequestAction, WrapperRequestActionFailed, WrapperRequestActionSuccess } from '../types/request.types'; +import { SystemInfo } from '../types/system.types'; @Injectable() export class SystemEffects { @@ -19,32 +17,27 @@ export class SystemEffects { private store: Store ) { } - static guid = 'info'; + // // TODO: RC + // static guid = 'info'; @Effect() getInfo$ = this.actions$.pipe( ofType(GET_SYSTEM_INFO), mergeMap(action => { - const apiAction = { - entityType: systemStoreNames.type, - endpointType: STRATOS_ENDPOINT_TYPE, - guid: SystemEffects.guid, - type: action.type, - } as EntityRequestAction; - this.store.dispatch(new StartRequestAction(apiAction)); + this.store.dispatch(new StartRequestAction(action)); const { associatedAction } = action; - const actionType = 'fetch'; - this.store.dispatch(new StartRequestAction(associatedAction, actionType)); + this.store.dispatch(new StartRequestAction(associatedAction, 'fetch')); return this.httpClient.get('/pp/v1/info').pipe( mergeMap((info: SystemInfo) => { return [ new GetSystemSuccess(info, action.login, associatedAction), - new WrapperRequestActionSuccess({ entities: {}, result: [] }, apiAction) + new WrapperRequestActionSuccess({ entities: {}, result: [] }, action) ]; }), catchError((e) => { return [ - new GetSystemFailed(), + // new GetSystemFailed(), + { type: action.actions[2] }, new WrapperRequestActionFailed('Could not get system endpoints', associatedAction), - new WrapperRequestActionFailed('Could not fetch system info', apiAction) + new WrapperRequestActionFailed('Could not fetch system info', action) ]; })); })); diff --git a/src/frontend/packages/store/src/effects/user-profile.effects.ts b/src/frontend/packages/store/src/effects/user-profile.effects.ts index 745d4e11cc..3dc5da78d3 100644 --- a/src/frontend/packages/store/src/effects/user-profile.effects.ts +++ b/src/frontend/packages/store/src/effects/user-profile.effects.ts @@ -15,15 +15,9 @@ import { UpdateUserProfileAction, } from '../actions/user-profile.actions'; import { entityCatalog } from '../entity-catalog/entity-catalog'; -import { rootUpdatingKey } from '../reducers/api-request-reducer/types'; import { UserProfileInfo } from '../types/user-profile.types'; import { DispatchOnlyAppState } from './../app-state'; -import { - EntityRequestAction, - StartRequestAction, - WrapperRequestActionFailed, - WrapperRequestActionSuccess, -} from './../types/request.types'; +import { StartRequestAction, WrapperRequestActionFailed, WrapperRequestActionSuccess } from './../types/request.types'; const { proxyAPIVersion } = environment; @@ -34,8 +28,6 @@ export const userProfilePasswordUpdatingKey = 'password'; export class UserProfileEffect { stratosUserConfig = entityCatalog.getEntity(userProfileEntitySchema.endpointType, userProfileEntitySchema.entityType); - private stratosUserEntityType = userProfileEntitySchema.entityType; - private stratosUserEndpointType = userProfileEntitySchema.endpointType; constructor( private actions$: Actions, @@ -47,85 +39,82 @@ export class UserProfileEffect { ofType(GET_USERPROFILE), mergeMap(action => { this.store.dispatch(new StartRequestAction(action)); + const entityKey = entityCatalog.getEntityKey(action); return this.httpClient.get(`/pp/${proxyAPIVersion}/users/${action.userGuid}`).pipe( - mergeMap((info: UserProfileInfo) => { - return [ - new WrapperRequestActionSuccess({ - entities: { [this.stratosUserConfig.entityKey]: { [action.guid]: info } }, - result: [action.guid] - }, action) - ]; - }), catchError((e) => { - return [ - new WrapperRequestActionFailed('Could not get User Profile Info', action), - ]; - })); + mergeMap((info: UserProfileInfo) => [ + new WrapperRequestActionSuccess({ + entities: { [entityKey]: { [action.guid]: info } }, + result: [action.guid] + }, action) + ]), + catchError((e) => [ + new WrapperRequestActionFailed('Could not get User Profile Info', action), + ]) + ); })); @Effect() updateUserProfileInfo$ = this.actions$.pipe( ofType(UPDATE_USERPROFILE), - mergeMap(action => { - const apiAction = { - entityType: this.stratosUserEntityType, - endpointType: this.stratosUserEndpointType, - guid: FetchUserProfileAction.guid, - type: action.type, - updatingKey: rootUpdatingKey - } as EntityRequestAction; - const actionType = 'update'; - this.store.dispatch(new StartRequestAction(apiAction, actionType)); - const guid = action.profile.id; + mergeMap((action: UpdateUserProfileAction) => { + // const apiAction = { + // entityType: this.stratosUserEntityType, + // endpointType: this.stratosUserEndpointType, // TODO: RC remove this completely + // guid: FetchUserProfileAction.guid, + // type: action.type, + // updatingKey: rootUpdatingKey // TODO: RC Transfer in + // } as EntityRequestAction; + // const actionType = 'update'; + this.store.dispatch(new StartRequestAction(action, 'update')); + const userGuid = action.profile.id; const version = action.profile.meta.version; const headers = { 'If-Match': version.toString() }; if (action.password) { headers['x-stratos-password'] = action.password; } - return this.httpClient.put(`/pp/${proxyAPIVersion}/users/${guid}`, action.profile, { headers }).pipe( - mergeMap((info: UserProfileInfo) => { + return this.httpClient.put(`/pp/${proxyAPIVersion}/users/${userGuid}`, action.profile, { headers }).pipe( + mergeMap((info: UserProfileInfo) => {// TODO: RC push result back into store?? return [ new WrapperRequestActionSuccess({ entities: {}, result: [] - }, apiAction), - ]; - }), catchError((e) => { - return [ - new WrapperRequestActionFailed('Could not update User Profile Info', apiAction), + }, action), ]; - })); + }), + catchError((e) => [ + new WrapperRequestActionFailed('Could not update User Profile Info', action), + ])); })); @Effect() updateUserPassword$ = this.actions$.pipe( ofType(UPDATE_USERPASSWORD), - mergeMap(action => { - const apiAction = { - entityType: this.stratosUserEntityType, - endpointType: this.stratosUserEndpointType, - guid: FetchUserProfileAction.guid, - type: action.type, - updatingKey: userProfilePasswordUpdatingKey - } as EntityRequestAction; + mergeMap((action: UpdateUserPasswordAction) => { + // const apiAction = { + // entityType: this.stratosUserEntityType, + // endpointType: this.stratosUserEndpointType, + // guid: FetchUserProfileAction.guid, + // type: action.type, + // // updatingKey: userProfilePasswordUpdatingKey + // } as EntityRequestAction; // Use the creating action for password change - const actionType = 'update'; - this.store.dispatch(new StartRequestAction(apiAction, actionType)); - const guid = action.id; + this.store.dispatch(new StartRequestAction(action, 'update')); + const userGuid = action.id; const headers = { 'x-stratos-password': action.passwordChanges.oldPassword, 'x-stratos-password-new': action.passwordChanges.password }; - return this.httpClient.put(`/pp/${proxyAPIVersion}/users/${guid}/password`, action.passwordChanges, { headers }).pipe( - switchMap((info: UserProfileInfo) => { + return this.httpClient.put(`/pp/${proxyAPIVersion}/users/${userGuid}/password`, action.passwordChanges, { headers }).pipe( + switchMap((info: UserProfileInfo) => {// TODO: RC push result back into store?? return [ new WrapperRequestActionSuccess({ entities: {}, result: [] - }, apiAction) - ]; - }), catchError((e) => { - return [ - new WrapperRequestActionFailed('Could not update User Password', apiAction), + }, action) ]; - })); + }), + catchError((e) => [ + new WrapperRequestActionFailed('Could not update User Password', action), + ]) + ); })); } diff --git a/src/frontend/packages/store/src/entity-request-pipeline/entity-request-base-handlers/endpoint-errors.handler.ts b/src/frontend/packages/store/src/entity-request-pipeline/entity-request-base-handlers/endpoint-errors.handler.ts index 8b6fc07532..0106903103 100644 --- a/src/frontend/packages/store/src/entity-request-pipeline/entity-request-base-handlers/endpoint-errors.handler.ts +++ b/src/frontend/packages/store/src/entity-request-pipeline/entity-request-base-handlers/endpoint-errors.handler.ts @@ -1,6 +1,6 @@ import { SendEventAction } from '../../actions/internal-events.actions'; import { StratosBaseCatalogEntity } from '../../entity-catalog/entity-catalog-entity/entity-catalog-entity'; -import { endpointSchemaKey } from '../../helpers/entity-factory'; +import { endpointSchemaKey } from '../../helpers/stratos-entity-factory'; import { ApiRequestTypes } from '../../reducers/api-request-reducer/request-helpers'; import { InternalEventSeverity, InternalEventStateMetadata } from '../../types/internal-events.types'; import { APISuccessOrFailedAction, EntityRequestAction } from '../../types/request.types'; diff --git a/src/frontend/packages/store/src/entity-request-pipeline/entity-request-base-handlers/jetstream-error.handler.ts b/src/frontend/packages/store/src/entity-request-pipeline/entity-request-base-handlers/jetstream-error.handler.ts index d68ddd27ab..f9541342fd 100644 --- a/src/frontend/packages/store/src/entity-request-pipeline/entity-request-base-handlers/jetstream-error.handler.ts +++ b/src/frontend/packages/store/src/entity-request-pipeline/entity-request-base-handlers/jetstream-error.handler.ts @@ -1,7 +1,7 @@ import { SendEventAction } from '../../actions/internal-events.actions'; import { RecursiveDeleteFailed } from '../../effects/recursive-entity-delete.effect'; import { StratosBaseCatalogEntity } from '../../entity-catalog/entity-catalog-entity/entity-catalog-entity'; -import { endpointSchemaKey } from '../../helpers/entity-factory'; +import { endpointSchemaKey } from '../../helpers/stratos-entity-factory'; import { ApiRequestTypes, getFailApiRequestActions } from '../../reducers/api-request-reducer/request-helpers'; import { GLOBAL_EVENT, InternalEventSeverity, InternalEventStateMetadata } from '../../types/internal-events.types'; import { EntityRequestAction } from '../../types/request.types'; diff --git a/src/frontend/packages/store/src/helpers/entity-factory.ts b/src/frontend/packages/store/src/helpers/entity-factory.ts deleted file mode 100644 index c10311c3de..0000000000 --- a/src/frontend/packages/store/src/helpers/entity-factory.ts +++ /dev/null @@ -1,32 +0,0 @@ -import { EntitySchema } from './entity-schema'; - -export const userFavouritesSchemaKey = 'userFavorites'; -export const endpointSchemaKey = 'endpoint'; -export const userProfileSchemaKey = 'userProfile'; -export const systemInfoSchemaKey = 'system'; - -const entityCache: { - [key: string]: EntitySchema -} = {}; - -// Note - The cache entry is added as a secondary step. This helps keep the child entity definition's clear and easier to spot circular -// dependencies which would otherwise be hidden (if we assigned directly to entityCache and references via entityCache in other entities) -const UserFavouritesSchema = new EntitySchema(userFavouritesSchemaKey, null, {}, { idAttribute: 'id' }); -entityCache[userFavouritesSchemaKey] = UserFavouritesSchema; - -const SystemInfoSchema = new EntitySchema(systemInfoSchemaKey, null, {}, { idAttribute: 'id' }); -entityCache[systemInfoSchemaKey] = SystemInfoSchema; - -const EndpointSchema = new EntitySchema(endpointSchemaKey, null, {}, { idAttribute: 'guid' }); -entityCache[endpointSchemaKey] = EndpointSchema; - -const UserProfileInfoSchema = new EntitySchema(userProfileSchemaKey, null, {}, { idAttribute: 'id' }); -entityCache[userProfileSchemaKey] = UserProfileInfoSchema; - -export function entityFactory(key: string): EntitySchema { - const entity = entityCache[key]; - if (!entity) { - throw new Error(`Unknown entity schema type: ${key}`); - } - return entity; -} diff --git a/src/frontend/packages/store/src/helpers/stratos-entity-factory.ts b/src/frontend/packages/store/src/helpers/stratos-entity-factory.ts new file mode 100644 index 0000000000..e95019a75d --- /dev/null +++ b/src/frontend/packages/store/src/helpers/stratos-entity-factory.ts @@ -0,0 +1,47 @@ +import { EntitySchema } from './entity-schema'; + +export const userFavouritesSchemaKey = 'userFavorites'; +export const endpointSchemaKey = 'endpoint'; +export const userProfileSchemaKey = 'userProfile'; +export const systemInfoSchemaKey = 'system'; + +export const metricEntityType = 'metrics'; + +export const STRATOS_ENDPOINT_TYPE = 'stratos'; + +const entityCache: { + [key: string]: EntitySchema +} = {}; + +class StratosEntitySchema extends EntitySchema { + constructor(entityType: string, idAttribute: string) { + super(entityType, STRATOS_ENDPOINT_TYPE, {}, { idAttribute }); + } +} + +// Note - The cache entry is added as a secondary step. This helps keep the child entity definition's clear and easier to spot circular +// dependencies which would otherwise be hidden (if we assigned directly to entityCache and references via entityCache in other entities) +const UserFavouritesSchema = new StratosEntitySchema(userFavouritesSchemaKey, 'id'); +entityCache[userFavouritesSchemaKey] = UserFavouritesSchema; + +const SystemInfoSchema = new StratosEntitySchema(systemInfoSchemaKey, 'id'); +entityCache[systemInfoSchemaKey] = SystemInfoSchema; + +const EndpointSchema = new StratosEntitySchema(endpointSchemaKey, 'guid'); +entityCache[endpointSchemaKey] = EndpointSchema; + +const UserProfileInfoSchema = new StratosEntitySchema(userProfileSchemaKey, 'id'); +entityCache[userProfileSchemaKey] = UserProfileInfoSchema; + +export function stratosEntityFactory(key: string): EntitySchema { + const entity = entityCache[key]; + if (!entity) { + throw new Error(`Unknown entity schema type: ${key}`); + } + return entity; +} + +// export const userFavoritesEntitySchema = new StratosEntitySchema(entityFactory(userFavouritesSchemaKey).entityType); +// export const endpointEntitySchema = new StratosEntitySchema(entityFactory(endpointSchemaKey).entityType); +// export const userProfileEntitySchema = new StratosEntitySchema(entityFactory(userProfileSchemaKey).entityType); +// export const systemInfoEntitySchema = new StratosEntitySchema(entityFactory(systemInfoSchemaKey).entityType); \ No newline at end of file diff --git a/src/frontend/packages/store/src/reducers/current-user-roles-reducer/recently-visited.reducer.ts b/src/frontend/packages/store/src/reducers/current-user-roles-reducer/recently-visited.reducer.ts index 2a83934d21..d4cbac1c03 100644 --- a/src/frontend/packages/store/src/reducers/current-user-roles-reducer/recently-visited.reducer.ts +++ b/src/frontend/packages/store/src/reducers/current-user-roles-reducer/recently-visited.reducer.ts @@ -1,18 +1,17 @@ import { Action } from '@ngrx/store'; +import { STRATOS_ENDPOINT_TYPE } from '../../../../core/src/base-entity-schemas'; import { DISCONNECT_ENDPOINTS_SUCCESS, DisconnectEndpoint, GET_ENDPOINTS_SUCCESS, - GetAllEndpointsSuccess, UNREGISTER_ENDPOINTS_SUCCESS, } from '../../actions/endpoint.actions'; import { AddRecentlyVisitedEntityAction, SetRecentlyVisitedEntityAction } from '../../actions/recently-visited.actions'; +import { entityCatalog } from '../../entity-catalog/entity-catalog'; +import { endpointSchemaKey } from '../../helpers/stratos-entity-factory'; import { IRecentlyVisitedState } from '../../types/recently-visited.types'; import { addNewHit, cleanRecentsList, getDefaultRecentState } from './recently-visited.reducer.helpers'; -import { entityCatalog } from '../../entity-catalog/entity-catalog'; -import { STRATOS_ENDPOINT_TYPE } from '../../../../core/src/base-entity-schemas'; -import { endpointSchemaKey } from '../../helpers/entity-factory'; export function recentlyVisitedReducer( state: IRecentlyVisitedState = getDefaultRecentState(), diff --git a/src/frontend/packages/store/src/reducers/endpoints.reducer.ts b/src/frontend/packages/store/src/reducers/endpoints.reducer.ts index 1a5796c694..662f1c0ebb 100644 --- a/src/frontend/packages/store/src/reducers/endpoints.reducer.ts +++ b/src/frontend/packages/store/src/reducers/endpoints.reducer.ts @@ -1,11 +1,14 @@ import { GET_ENDPOINTS, GET_ENDPOINTS_FAILED, GET_ENDPOINTS_SUCCESS } from '../actions/endpoint.actions'; import { EndpointState } from '../types/endpoint.types'; -export function endpointsReducer(state: EndpointState = { - loading: false, - error: false, - message: '' -}, action): EndpointState { +export function endpointsReducer( + state: EndpointState = { + loading: false, + error: false, + message: '' + }, + action +): EndpointState { switch (action.type) { case GET_ENDPOINTS: return { ...state, loading: true, message: '', error: false }; diff --git a/src/frontend/packages/store/src/reducers/internal-events.reducer.ts b/src/frontend/packages/store/src/reducers/internal-events.reducer.ts index c6b2a9ec59..b65b2da873 100644 --- a/src/frontend/packages/store/src/reducers/internal-events.reducer.ts +++ b/src/frontend/packages/store/src/reducers/internal-events.reducer.ts @@ -1,22 +1,22 @@ -import { UPDATE_ENDPOINT_SUCCESS } from './../actions/endpoint.actions'; import { Action } from '@ngrx/store'; +import { + CONNECT_ENDPOINTS_SUCCESS, + DISCONNECT_ENDPOINTS_SUCCESS, + DisconnectEndpoint, + UNREGISTER_ENDPOINTS_SUCCESS, +} from '../actions/endpoint.actions'; import { SendClearEndpointEventsAction, SendClearEventAction, SendEventAction } from '../actions/internal-events.actions'; +import { endpointSchemaKey } from '../helpers/stratos-entity-factory'; import { + CLEAR_ENDPOINT_ERROR_EVENTS, CLEAR_EVENTS, GLOBAL_EVENT, InternalEventsState, InternalEventState, SEND_EVENT, - CLEAR_ENDPOINT_ERROR_EVENTS, } from '../types/internal-events.types'; -import { endpointSchemaKey } from './../helpers/entity-factory'; -import { - DISCONNECT_ENDPOINTS_SUCCESS, - DisconnectEndpoint, - UNREGISTER_ENDPOINTS_SUCCESS, - CONNECT_ENDPOINTS_SUCCESS -} from '../actions/endpoint.actions'; +import { UPDATE_ENDPOINT_SUCCESS } from './../actions/endpoint.actions'; const defaultState: InternalEventsState = { types: { diff --git a/src/frontend/packages/store/src/reducers/pagination-reducer/pagination.reducer.spec.ts b/src/frontend/packages/store/src/reducers/pagination-reducer/pagination.reducer.spec.ts index d3c48a2ad2..4a5caa3539 100644 --- a/src/frontend/packages/store/src/reducers/pagination-reducer/pagination.reducer.spec.ts +++ b/src/frontend/packages/store/src/reducers/pagination-reducer/pagination.reducer.spec.ts @@ -1,10 +1,10 @@ import { HttpRequest } from '@angular/common/http'; -import { ENDPOINT_TYPE, endpointEntitySchema, STRATOS_ENDPOINT_TYPE } from '../../../../core/src/base-entity-schemas'; import { RequestTypes } from '../../actions/request.actions'; import { entityCatalog } from '../../entity-catalog/entity-catalog'; import { EntityCatalogHelpers } from '../../entity-catalog/entity-catalog.helper'; import { EntitySchema } from '../../helpers/entity-schema'; +import { endpointSchemaKey, STRATOS_ENDPOINT_TYPE, stratosEntityFactory } from '../../helpers/stratos-entity-factory'; import { PaginatedAction } from '../../types/pagination.types'; import { StartRequestAction, WrapperRequestActionFailed, WrapperRequestActionSuccess } from '../../types/request.types'; import { createPaginationReducer } from './pagination.reducer'; @@ -20,8 +20,8 @@ function getReducer() { class MockPagAction implements PaginatedAction { actions = ['ONE', 'TWO', 'THREE']; options = new HttpRequest('GET', 'fake123'); - entity = endpointEntitySchema; - entityType = ENDPOINT_TYPE; + entity = stratosEntityFactory(endpointSchemaKey); + entityType = endpointSchemaKey; endpointType = STRATOS_ENDPOINT_TYPE; paginationKey = 'PaginationKey'; type = RequestTypes.START; diff --git a/src/frontend/packages/store/src/reducers/system-endpoints.reducer.ts b/src/frontend/packages/store/src/reducers/system-endpoints.reducer.ts index 40fdc63271..5a6d41894d 100644 --- a/src/frontend/packages/store/src/reducers/system-endpoints.reducer.ts +++ b/src/frontend/packages/store/src/reducers/system-endpoints.reducer.ts @@ -28,6 +28,7 @@ export function systemEndpointsReducer(state: IRequestEntityTypeState(endpointEntityKey); export const endpointOfType = (type: string) => diff --git a/src/frontend/packages/store/src/stratos-entity-catalog.ts b/src/frontend/packages/store/src/stratos-entity-catalog.ts new file mode 100644 index 0000000000..0ac5400b25 --- /dev/null +++ b/src/frontend/packages/store/src/stratos-entity-catalog.ts @@ -0,0 +1,207 @@ +import { EndpointType } from '../../core/src/core/extension/extension-types'; +import { + AuthParams, + ConnectEndpoint, + DisconnectEndpoint, + GetAllEndpoints, + RegisterEndpoint, + UnregisterEndpoint, + UpdateEndpoint, +} from './actions/endpoint.actions'; +import { GetSystemInfo } from './actions/system.actions'; +import { FetchUserProfileAction, UpdateUserPasswordAction, UpdateUserProfileAction } from './actions/user-profile.actions'; +import { OrchestratedActionBuilders } from './entity-catalog/action-orchestrator/action-orchestrator'; +import { + StratosCatalogEndpointEntity, + StratosCatalogEntity, +} from './entity-catalog/entity-catalog-entity/entity-catalog-entity'; +import { EndpointModel } from './types/endpoint.types'; +import { UserProfileInfo, UserProfilePasswordUpdate } from './types/user-profile.types'; + +// TODO: RC Test all of these actions + + +export interface EndpointActionBuilder extends OrchestratedActionBuilders { + get: ( + guid: string + ) => null, // TODO: RC + getAll: ( + login?: boolean + ) => GetAllEndpoints, + getMultiple: ( + endpointGuid?: string, + paginationKey?: string, + args?: { login: boolean } + ) => GetAllEndpoints, + connect: ( + guid: string, + endpointType: EndpointType, + authType: string, + authValues: AuthParams, + systemShared: boolean, + body: string, + ) => ConnectEndpoint, + disconnect: ( + guid: string, + endpointType: EndpointType, + ) => DisconnectEndpoint, + unregister: ( + guid: string, + endpointType: EndpointType, + ) => UnregisterEndpoint, + register: ( + endpointType: EndpointType, + endpointSubType: string, + name: string, + endpoint: string, + skipSslValidation: boolean, + clientID?: string, + clientSecret?: string, + ssoAllowed?: boolean, + ) => RegisterEndpoint, + update: ( + guid: string, + endpointGuid: string, + args: { + endpointType: EndpointType, // TODO: RC test different types + id: string, + name: string, + skipSSL: boolean, + setClientInfo: boolean, + clientID: string, + clientSecret: string, + allowSSO: boolean, + } + ) => UpdateEndpoint, +} +export const endpointActionBuilder: EndpointActionBuilder = { + get: (guid: string) => null, + getAll: (login: boolean) => new GetAllEndpoints(login), + getMultiple: ( + endpointGuid?: string, + paginationKey?: string, + args?: { login: boolean } + ) => new GetAllEndpoints(args ? args.login : false), + connect: ( + guid: string, + endpointType: EndpointType, + authType: string, + authValues: AuthParams, + systemShared: boolean, + body: string, + ) => new ConnectEndpoint(guid, endpointType, authType, authValues, systemShared, body), + disconnect: (guid: string, endpointType: EndpointType) => new DisconnectEndpoint(guid, endpointType), + // TODO: RC not used?????? + unregister: (guid: string, endpointType: EndpointType) => new UnregisterEndpoint(guid, endpointType), + register: ( + endpointType: EndpointType, + endpointSubType: string, + name: string, + endpoint: string, + skipSslValidation: boolean, + clientID?: string, + clientSecret?: string, + ssoAllowed?: boolean, + ) => new RegisterEndpoint( + endpointType, + endpointSubType, + name, + endpoint, + skipSslValidation, + clientID, + clientSecret, + ssoAllowed, + ), + update: ( + guid: string, + endpointGuid: string, + args: { + endpointType: EndpointType, // TODO: RC test different types + // id: string, + name: string, + skipSSL: boolean, + setClientInfo: boolean, + clientID: string, + clientSecret: string, + allowSSO: boolean, + } + ) => new UpdateEndpoint( + args.endpointType, + guid, + args.name, + args.skipSSL, + args.setClientInfo, + args.clientID, + args.clientSecret, + args.allowSSO + ), +} + +export interface SystemInfoActionBuilder extends OrchestratedActionBuilders { + getSystemInfo: ( + login?: boolean, + associatedAction?: GetAllEndpoints + ) => GetSystemInfo +} +export const systemInfoActionBuilder: SystemInfoActionBuilder = { + getSystemInfo: ( + login?: false, + associatedAction?: GetAllEndpoints + ) => new GetSystemInfo(login, associatedAction) +} + +export interface UserFavoriteActionBuilder extends OrchestratedActionBuilders { + +} + +// TODO: Schemas +export interface UserProfileActionBuilder extends OrchestratedActionBuilders { + get: ( + userGuid: string + ) => FetchUserProfileAction + updateProfile: ( // TODO: RC + profile: UserProfileInfo, + password: string + ) => UpdateUserProfileAction + updatePassword: ( + guid: string, + passwordChanges: UserProfilePasswordUpdate + ) => UpdateUserPasswordAction +} +export const userProfileActionBuilder: UserProfileActionBuilder = { + get: (userGuid: string) => new FetchUserProfileAction(userGuid), + updateProfile: (profile: UserProfileInfo, password: string) => new UpdateUserProfileAction(profile, password), + updatePassword: (guid: string, passwordChanges: UserProfilePasswordUpdate) => new UpdateUserPasswordAction(guid, passwordChanges) +} + +export class StratosEntityCatalog { + // TODO: RC transfer types to base-entity-types + endpoint: StratosCatalogEntity< + any,//TODO: RC + EndpointModel, + EndpointActionBuilder + > + + systemInfo: StratosCatalogEntity< + any, + any, //TODO: RC + SystemInfoActionBuilder + > + + userFavorite: StratosCatalogEntity< + any, + any, //TODO: RC + UserFavoriteActionBuilder + > + + userProfile: StratosCatalogEntity< + any, + any, //TODO: RC + UserProfileActionBuilder + > + + metricsEndpoint: StratosCatalogEndpointEntity; +} + +export const stratosEntityCatalog = new StratosEntityCatalog(); + diff --git a/src/frontend/packages/store/src/types/endpoint.types.ts b/src/frontend/packages/store/src/types/endpoint.types.ts index 317c1aab7e..2fcc8b8c95 100644 --- a/src/frontend/packages/store/src/types/endpoint.types.ts +++ b/src/frontend/packages/store/src/types/endpoint.types.ts @@ -1,7 +1,7 @@ import { EndpointType } from '../../../core/src/core/extension/extension-types'; import { StratosScopeStrings } from '../../../core/src/core/permissions/stratos-user-permissions.checker'; import { MetricsAPITargets, MetricsStratosInfo } from '../actions/metrics-api.actions'; -import { endpointSchemaKey } from '../helpers/entity-factory'; +import { endpointSchemaKey } from '../helpers/stratos-entity-factory'; import { RequestSectionKeys, TRequestTypeKeys } from '../reducers/api-request-reducer/types'; export const endpointListKey = 'endpoint-list'; diff --git a/src/frontend/packages/store/src/types/system.types.ts b/src/frontend/packages/store/src/types/system.types.ts index 2e66f11a2f..29c0aa32bf 100644 --- a/src/frontend/packages/store/src/types/system.types.ts +++ b/src/frontend/packages/store/src/types/system.types.ts @@ -1,6 +1,5 @@ -import { RequestSectionKeys, TRequestTypeKeys } from '../reducers/api-request-reducer/types'; -import { EndpointUser, EndpointModel } from './endpoint.types'; -import { entityFactory, systemInfoSchemaKey } from '../helpers/entity-factory'; +import { EndpointModel, EndpointUser } from './endpoint.types'; + export interface SystemInfo { version: { proxy_version: string, @@ -14,10 +13,10 @@ export interface SystemInfo { }; } -export const systemStoreNames: { - section: TRequestTypeKeys, - type: string -} = { - section: RequestSectionKeys.Other, - type: entityFactory(systemInfoSchemaKey).entityType -}; +// export const systemStoreNames: { +// section: TRequestTypeKeys, +// type: string +// } = { +// section: RequestSectionKeys.Other, +// type: entityFactory(systemInfoSchemaKey).entityType +// }; From 2625c99c14dda27adbfb0249dcd9129d6fcf2a87 Mon Sep 17 00:00:00 2001 From: Richard Cox Date: Thu, 18 Jun 2020 15:16:03 +0100 Subject: [PATCH 02/12] WIP --- .../src/cloud-foundry-test.module.ts | 2 +- .../current-user-permissions.service.spec.ts | 2 +- .../test-framework/cf-test-helper.ts | 3 +-- src/frontend/packages/core/src/app.module.ts | 2 +- .../current-user-permissions.service.spec.ts | 2 +- .../endpoint/base-endpoints-data-source.ts | 6 +++--- .../core/test-framework/core-test.modules.ts | 2 +- .../base-user-favorites-action.ts | 20 +++++++++---------- .../user-favourites.actions.ts | 6 ++++-- .../store/src/stratos-entity-catalog.ts | 2 +- .../src/stratos-entity-generator.ts | 0 11 files changed, 24 insertions(+), 23 deletions(-) rename src/frontend/packages/{core => store}/src/stratos-entity-generator.ts (100%) diff --git a/src/frontend/packages/cloud-foundry/src/cloud-foundry-test.module.ts b/src/frontend/packages/cloud-foundry/src/cloud-foundry-test.module.ts index 128aed0b52..99bfc37bbd 100644 --- a/src/frontend/packages/cloud-foundry/src/cloud-foundry-test.module.ts +++ b/src/frontend/packages/cloud-foundry/src/cloud-foundry-test.module.ts @@ -5,9 +5,9 @@ import { EffectsModule } from '@ngrx/effects'; import { generateASEntities } from '../../cf-autoscaler/src/store/autoscaler-entity-generator'; import { getGitHubAPIURL, GITHUB_API_URL } from '../../core/src/core/github.helpers'; import { LoggerService } from '../../core/src/core/logger.service'; -import { generateStratosEntities } from '../../store/src/base-entity-types'; import { CATALOGUE_ENTITIES, EntityCatalogFeatureModule } from '../../store/src/entity-catalog.module'; import { entityCatalog, TestEntityCatalog } from '../../store/src/entity-catalog/entity-catalog'; +import { generateStratosEntities } from '../../store/src/stratos-entity-generator'; import { testSCFEndpointGuid } from '../../store/testing/public-api'; import { BaseCfOrgSpaceRouteMock } from '../test-framework/cloud-foundry-endpoint-service.helper'; import { generateCFEntities } from './cf-entity-generator'; diff --git a/src/frontend/packages/cloud-foundry/src/shared/services/current-user-permissions.service.spec.ts b/src/frontend/packages/cloud-foundry/src/shared/services/current-user-permissions.service.spec.ts index d24a0c4bef..e6e6809326 100644 --- a/src/frontend/packages/cloud-foundry/src/shared/services/current-user-permissions.service.spec.ts +++ b/src/frontend/packages/cloud-foundry/src/shared/services/current-user-permissions.service.spec.ts @@ -17,10 +17,10 @@ import { CurrentUserPermissionsService } from '../../../../core/src/core/permiss import { StratosScopeStrings } from '../../../../core/src/core/permissions/stratos-user-permissions.checker'; import { AppTestModule } from '../../../../core/test-framework/core-test.helper'; import { AppState } from '../../../../store/src/app-state'; -import { generateStratosEntities } from '../../../../store/src/base-entity-types'; import { EntityCatalogTestModule, TEST_CATALOGUE_ENTITIES } from '../../../../store/src/entity-catalog-test.module'; import { EntityCatalogEntityConfig } from '../../../../store/src/entity-catalog/entity-catalog.types'; import { endpointSchemaKey, stratosEntityFactory } from '../../../../store/src/helpers/stratos-entity-factory'; +import { generateStratosEntities } from '../../../../store/src/stratos-entity-generator'; import { APIResource } from '../../../../store/src/types/api.types'; import { EndpointModel } from '../../../../store/src/types/endpoint.types'; import { BaseEntityValues } from '../../../../store/src/types/entity.types'; diff --git a/src/frontend/packages/cloud-foundry/test-framework/cf-test-helper.ts b/src/frontend/packages/cloud-foundry/test-framework/cf-test-helper.ts index b8421deaf8..c22514e227 100644 --- a/src/frontend/packages/cloud-foundry/test-framework/cf-test-helper.ts +++ b/src/frontend/packages/cloud-foundry/test-framework/cf-test-helper.ts @@ -1,7 +1,6 @@ -import { generateStratosEntities } from '../../core/src/stratos-entity-generator'; import { BaseTestModules } from '../../core/test-framework/core-test.helper'; -import { generateStratosEntities } from '../../store/src/base-entity-types'; import { EntityCatalogTestModule, TEST_CATALOGUE_ENTITIES } from '../../store/src/entity-catalog-test.module'; +import { generateStratosEntities } from '../../store/src/stratos-entity-generator'; import { generateCFEntities } from '../src/cf-entity-generator'; export const CFBaseTestModules = [ diff --git a/src/frontend/packages/core/src/app.module.ts b/src/frontend/packages/core/src/app.module.ts index d79244939f..6be47000e0 100644 --- a/src/frontend/packages/core/src/app.module.ts +++ b/src/frontend/packages/core/src/app.module.ts @@ -13,7 +13,6 @@ import { UpdateUserFavoriteMetadataAction, } from '../../store/src/actions/user-favourites-actions/update-user-favorite-metadata-action'; import { GeneralEntityAppState, GeneralRequestDataState } from '../../store/src/app-state'; -import { generateStratosEntities } from '../../store/src/base-entity-types'; import { EntityCatalogModule } from '../../store/src/entity-catalog.module'; import { entityCatalog } from '../../store/src/entity-catalog/entity-catalog'; import { EntityCatalogHelper } from '../../store/src/entity-catalog/entity-catalog-entity/entity-catalog.service'; @@ -23,6 +22,7 @@ import { getAPIRequestDataState, selectEntity } from '../../store/src/selectors/ import { internalEventStateSelector } from '../../store/src/selectors/internal-events.selectors'; import { recentlyVisitedSelector } from '../../store/src/selectors/recently-visitied.selectors'; import { AppStoreModule } from '../../store/src/store.module'; +import { generateStratosEntities } from '../../store/src/stratos-entity-generator'; import { EndpointModel } from '../../store/src/types/endpoint.types'; import { IFavoriteMetadata, UserFavorite } from '../../store/src/types/user-favorites.types'; import { TabNavService } from '../tab-nav.service'; diff --git a/src/frontend/packages/core/src/core/permissions/current-user-permissions.service.spec.ts b/src/frontend/packages/core/src/core/permissions/current-user-permissions.service.spec.ts index a968f4309e..1c30c078f2 100644 --- a/src/frontend/packages/core/src/core/permissions/current-user-permissions.service.spec.ts +++ b/src/frontend/packages/core/src/core/permissions/current-user-permissions.service.spec.ts @@ -3,10 +3,10 @@ import { createBasicStoreModule, createEntityStoreState, TestStoreEntity } from import { first, tap } from 'rxjs/operators'; import { AppState } from '../../../../store/src/app-state'; -import { generateStratosEntities } from '../../../../store/src/base-entity-types'; import { EntityCatalogTestModule, TEST_CATALOGUE_ENTITIES } from '../../../../store/src/entity-catalog-test.module'; import { EntityCatalogEntityConfig } from '../../../../store/src/entity-catalog/entity-catalog.types'; import { endpointSchemaKey, stratosEntityFactory } from '../../../../store/src/helpers/stratos-entity-factory'; +import { generateStratosEntities } from '../../../../store/src/stratos-entity-generator'; import { EndpointModel } from '../../../../store/src/types/endpoint.types'; import { BaseEntityValues } from '../../../../store/src/types/entity.types'; import { PaginationState } from '../../../../store/src/types/pagination.types'; diff --git a/src/frontend/packages/core/src/shared/components/list/list-types/endpoint/base-endpoints-data-source.ts b/src/frontend/packages/core/src/shared/components/list/list-types/endpoint/base-endpoints-data-source.ts index 7b4e1d5b24..5c09125f76 100644 --- a/src/frontend/packages/core/src/shared/components/list/list-types/endpoint/base-endpoints-data-source.ts +++ b/src/frontend/packages/core/src/shared/components/list/list-types/endpoint/base-endpoints-data-source.ts @@ -5,8 +5,7 @@ import { map, pairwise, tap, withLatestFrom } from 'rxjs/operators'; import { GetAllEndpoints } from '../../../../../../../store/src/actions/endpoint.actions'; import { CreatePagination } from '../../../../../../../store/src/actions/pagination.actions'; import { AppState } from '../../../../../../../store/src/app-state'; -import { endpointEntitySchema } from '../../../../../../../store/src/base-entity-schemas'; -import { endpointSchemaKey } from '../../../../../../../store/src/helpers/stratos-entity-factory'; +import { endpointSchemaKey, stratosEntityFactory } from '../../../../../../../store/src/helpers/stratos-entity-factory'; import { EntityMonitorFactory } from '../../../../../../../store/src/monitors/entity-monitor.factory.service'; import { InternalEventMonitorFactory } from '../../../../../../../store/src/monitors/internal-event-monitor.factory'; import { PaginationMonitorFactory } from '../../../../../../../store/src/monitors/pagination-monitor.factory'; @@ -92,6 +91,7 @@ export class BaseEndpointsDataSource extends ListDataSource { this.dsEndpointType = dsEndpointType; } + // TODO: RC what is this? static getEndpointConfig( store: Store, action: GetAllEndpoints, @@ -103,7 +103,7 @@ export class BaseEndpointsDataSource extends ListDataSource { return { store, action, - schema: endpointEntitySchema, + schema: stratosEntityFactory(endpointSchemaKey), getRowUniqueId: object => object.guid, getEmptyType: () => ({ name: '', diff --git a/src/frontend/packages/core/test-framework/core-test.modules.ts b/src/frontend/packages/core/test-framework/core-test.modules.ts index f433ecb5e6..0110b5e1d5 100644 --- a/src/frontend/packages/core/test-framework/core-test.modules.ts +++ b/src/frontend/packages/core/test-framework/core-test.modules.ts @@ -1,8 +1,8 @@ import { NgModule } from '@angular/core'; -import { generateStratosEntities } from '../../store/src/base-entity-types'; import { CATALOGUE_ENTITIES, EntityCatalogFeatureModule } from '../../store/src/entity-catalog.module'; import { entityCatalog, TestEntityCatalog } from '../../store/src/entity-catalog/entity-catalog'; +import { generateStratosEntities } from '../../store/src/stratos-entity-generator'; @NgModule({ imports: [ diff --git a/src/frontend/packages/store/src/actions/user-favourites-actions/base-user-favorites-action.ts b/src/frontend/packages/store/src/actions/user-favourites-actions/base-user-favorites-action.ts index c7bfabd239..b5438b6161 100644 --- a/src/frontend/packages/store/src/actions/user-favourites-actions/base-user-favorites-action.ts +++ b/src/frontend/packages/store/src/actions/user-favourites-actions/base-user-favorites-action.ts @@ -1,11 +1,11 @@ -import { Action } from '@ngrx/store'; +// import { Action } from '@ngrx/store'; -export class BaseUserFavoritesAction implements Action { - constructor( - actionType: string, - ) { - this.type = actionType; - } - public type: string; - public url = '/user-favorites'; -} +// export class BaseUserFavoritesAction implements Action { +// constructor( +// actionType: string, +// ) { +// this.type = actionType; +// } +// public type: string; +// public url = '/user-favorites'; +// } diff --git a/src/frontend/packages/store/src/actions/user-favourites-actions/user-favourites.actions.ts b/src/frontend/packages/store/src/actions/user-favourites-actions/user-favourites.actions.ts index e3d267383f..f24e18fec6 100644 --- a/src/frontend/packages/store/src/actions/user-favourites-actions/user-favourites.actions.ts +++ b/src/frontend/packages/store/src/actions/user-favourites-actions/user-favourites.actions.ts @@ -1,3 +1,4 @@ +import { STRATOS_ENDPOINT_TYPE, stratosEntityFactory, userFavouritesSchemaKey } from '../../helpers/stratos-entity-factory'; import { EntityRequestAction } from '../../types/request.types'; export class BaseUserFavoritesAction implements EntityRequestAction { @@ -9,6 +10,7 @@ export class BaseUserFavoritesAction implements EntityRequestAction { public type: string; public url = '/user-favorites'; - public entityType: userFavoritesEntitySchema.entityType, - public endpointType: userFavoritesEntitySchema.endpointType, + public entity = [stratosEntityFactory(userFavouritesSchemaKey)] + public entityType = userFavouritesSchemaKey; + public endpointType = STRATOS_ENDPOINT_TYPE; } diff --git a/src/frontend/packages/store/src/stratos-entity-catalog.ts b/src/frontend/packages/store/src/stratos-entity-catalog.ts index 0ac5400b25..658e44bcb0 100644 --- a/src/frontend/packages/store/src/stratos-entity-catalog.ts +++ b/src/frontend/packages/store/src/stratos-entity-catalog.ts @@ -1,4 +1,3 @@ -import { EndpointType } from '../../core/src/core/extension/extension-types'; import { AuthParams, ConnectEndpoint, @@ -15,6 +14,7 @@ import { StratosCatalogEndpointEntity, StratosCatalogEntity, } from './entity-catalog/entity-catalog-entity/entity-catalog-entity'; +import { EndpointType } from './extension-types'; import { EndpointModel } from './types/endpoint.types'; import { UserProfileInfo, UserProfilePasswordUpdate } from './types/user-profile.types'; diff --git a/src/frontend/packages/core/src/stratos-entity-generator.ts b/src/frontend/packages/store/src/stratos-entity-generator.ts similarity index 100% rename from src/frontend/packages/core/src/stratos-entity-generator.ts rename to src/frontend/packages/store/src/stratos-entity-generator.ts From 62784f4101006986171bbb913261c60039455271 Mon Sep 17 00:00:00 2001 From: Richard Cox Date: Fri, 19 Jun 2020 16:05:58 +0100 Subject: [PATCH 03/12] WIP --- .../src/store/autoscaler-entity-factory.ts | 2 +- .../src/store/autoscaler-entity-generator.ts | 2 +- .../src/actions/cf-event.actions.ts | 4 +- .../src/actions/domains.actions.ts | 4 +- .../src/actions/feature-flags.actions.ts | 4 +- .../cloud-foundry/src/actions/stack.action.ts | 4 +- .../actions/user-provided-service.actions.ts | 4 +- .../src/actions/users.actions.ts | 4 +- .../cloud-foundry/src/cf-entity-factory.ts | 36 ++-- .../cloud-foundry/src/cf-entity-generator.ts | 2 +- ...te-instances-routes-list-config.service.ts | 4 +- .../applications/application.service.ts | 28 +-- .../application/application-base.component.ts | 24 +-- .../application-polling.service.ts | 15 +- .../application-tabs-base.component.ts | 9 +- .../build-tab/build-tab.component.spec.ts | 9 +- .../tabs/build-tab/build-tab.component.ts | 11 +- .../cli-info-application.component.ts | 5 +- .../create-organization-step.component.ts | 4 +- .../edit-organization-step.component.ts | 4 +- .../quota-definition-form.component.ts | 4 +- .../cloud-foundry-endpoint.service.ts | 10 +- .../space-quota-definition-form.component.ts | 4 +- .../cloud-foundry-cell-base.component.ts | 2 +- .../users/manage-users/cf-roles.service.ts | 4 +- .../services/services-wall.service.ts | 4 +- .../table-cell-cf-cell.component.ts | 2 +- .../cf-buildpacks-data-source.ts | 4 +- .../cf-cell-apps-list-config.service.ts | 5 +- .../cf-cell-apps/cf-cell-apps-source.ts | 19 +- .../cf-quotas-data-source.service.ts | 4 +- .../cf-security-groups-data-source.ts | 4 +- .../cf-services/cf-services-data-source.ts | 4 +- .../cf-space-quotas-data-source.service.ts | 4 +- .../data-services/cloud-foundry.service.ts | 13 +- .../long-running-cf-op.service.ts | 8 +- .../services/cf-org-space-label.service.ts | 6 +- .../current-user-permissions.service.spec.ts | 4 +- src/frontend/packages/core/src/app.module.ts | 14 +- .../current-user-permissions.service.spec.ts | 4 +- .../core/src/core/user-profile.service.ts | 9 - .../dashboard-base.component.ts | 4 +- .../connect-endpoint-dialog.component.ts | 5 +- .../create-endpoint-cf-step-1.component.ts | 4 +- .../create-endpoint-connect.component.ts | 5 +- .../error-page/error-page.component.ts | 4 +- .../metrics/services/metrics-service.ts | 15 +- .../favorites-meta-card.component.ts | 11 +- .../endpoint/base-endpoints-data-source.ts | 16 +- .../endpoint/endpoint-data-source.helpers.ts | 8 +- .../recent-entities.component.ts | 4 +- .../packages/core/src/shared/entity.tokens.ts | 4 - .../test-framework/entity-service.helper.ts | 28 --- .../store/src/actions/endpoint.actions.ts | 68 +++--- .../store/src/actions/metrics.actions.ts | 2 +- .../store/src/actions/system.actions.ts | 23 +- .../base-user-favorites-action.ts | 11 - .../get-user-favorites-action.ts | 30 --- .../remove-user-favorite-action.ts | 21 -- .../save-user-favorite-action.ts | 25 --- .../toggle-user-favorite-action.ts | 13 -- .../update-user-favorite-metadata-action.ts | 21 -- .../user-favourites.actions.ts | 16 -- .../src/actions/user-favourites.actions.ts | 145 +++++++++++++ .../store/src/actions/user-profile.actions.ts | 9 +- .../effects/endpoint-api-errors.effects.ts | 4 +- .../store/src/effects/endpoint.effects.ts | 15 +- .../store/src/effects/system.effects.ts | 4 +- .../src/effects/user-favorites-effect.ts | 81 ++++--- .../entity-catalog-entity.ts | 16 +- .../src/entity-catalog/entity-catalog.ts | 2 +- .../endpoint-errors.handler.ts | 4 +- .../jetstream-error.handler.ts | 4 +- .../packages/store/src/entity-service.spec.ts | 15 -- .../src/helpers/stratos-entity-factory.ts | 34 ++- .../recently-visited.reducer.ts | 4 +- .../user-favorites-groups.reducer.ts | 6 +- .../store/src/reducers/favorite.reducer.ts | 8 +- .../src/reducers/internal-events.reducer.ts | 4 +- ...agination-reducer-clear-pagination-type.ts | 5 +- .../pagination.reducer.spec.ts | 8 +- .../store/src/selectors/endpoint.selectors.ts | 7 +- .../selectors/favorite-groups.selectors.ts | 4 +- .../store/src/stratos-action-builders.ts | 200 ++++++++++++++++++ .../store/src/stratos-entity-catalog.ts | 180 +--------------- .../store/src/stratos-entity-generator.ts | 183 +++++++++------- .../store/src/types/endpoint.types.ts | 11 - .../store/src/user-favorite-manager.ts | 4 +- 88 files changed, 785 insertions(+), 821 deletions(-) delete mode 100644 src/frontend/packages/core/test-framework/entity-service.helper.ts delete mode 100644 src/frontend/packages/store/src/actions/user-favourites-actions/base-user-favorites-action.ts delete mode 100644 src/frontend/packages/store/src/actions/user-favourites-actions/get-user-favorites-action.ts delete mode 100644 src/frontend/packages/store/src/actions/user-favourites-actions/remove-user-favorite-action.ts delete mode 100644 src/frontend/packages/store/src/actions/user-favourites-actions/save-user-favorite-action.ts delete mode 100644 src/frontend/packages/store/src/actions/user-favourites-actions/toggle-user-favorite-action.ts delete mode 100644 src/frontend/packages/store/src/actions/user-favourites-actions/update-user-favorite-metadata-action.ts delete mode 100644 src/frontend/packages/store/src/actions/user-favourites-actions/user-favourites.actions.ts create mode 100644 src/frontend/packages/store/src/actions/user-favourites.actions.ts create mode 100644 src/frontend/packages/store/src/stratos-action-builders.ts diff --git a/src/frontend/packages/cf-autoscaler/src/store/autoscaler-entity-factory.ts b/src/frontend/packages/cf-autoscaler/src/store/autoscaler-entity-factory.ts index 21df01c5dd..13c1ff8089 100644 --- a/src/frontend/packages/cf-autoscaler/src/store/autoscaler-entity-factory.ts +++ b/src/frontend/packages/cf-autoscaler/src/store/autoscaler-entity-factory.ts @@ -1,8 +1,8 @@ import { Schema, schema } from 'normalizr'; import { getAPIResourceGuid } from '../../../cloud-foundry/src/store/selectors/api.selectors'; -import { metricEntityType } from '../../../store/src/base-entity-schemas'; import { EntitySchema } from '../../../store/src/helpers/entity-schema'; +import { metricEntityType } from '../../../store/src/helpers/stratos-entity-factory'; export const appAutoscalerInfoEntityType = 'autoscalerInfo'; export const appAutoscalerHealthEntityType = 'autoscalerHealth'; diff --git a/src/frontend/packages/cf-autoscaler/src/store/autoscaler-entity-generator.ts b/src/frontend/packages/cf-autoscaler/src/store/autoscaler-entity-generator.ts index ec1414cb64..4e71099074 100644 --- a/src/frontend/packages/cf-autoscaler/src/store/autoscaler-entity-generator.ts +++ b/src/frontend/packages/cf-autoscaler/src/store/autoscaler-entity-generator.ts @@ -1,10 +1,10 @@ import { IOrgFavMetadata } from '../../../cloud-foundry/src/cf-metadata-types'; -import { metricEntityType } from '../../../store/src/base-entity-schemas'; import { StratosBaseCatalogEntity, StratosCatalogEntity, } from '../../../store/src/entity-catalog/entity-catalog-entity/entity-catalog-entity'; import { IStratosEndpointDefinition } from '../../../store/src/entity-catalog/entity-catalog.types'; +import { metricEntityType } from '../../../store/src/helpers/stratos-entity-factory'; import { APIResource } from '../../../store/src/types/api.types'; import { IFavoriteMetadata } from '../../../store/src/types/user-favorites.types'; import { AppAutoscalerEvent, AppAutoscalerHealth, AppAutoscalerPolicy, AppScalingTrigger } from './app-autoscaler.types'; diff --git a/src/frontend/packages/cloud-foundry/src/actions/cf-event.actions.ts b/src/frontend/packages/cloud-foundry/src/actions/cf-event.actions.ts index 8b60ff4103..c6bb0e3aff 100644 --- a/src/frontend/packages/cloud-foundry/src/actions/cf-event.actions.ts +++ b/src/frontend/packages/cloud-foundry/src/actions/cf-event.actions.ts @@ -1,6 +1,6 @@ import { HttpParams, HttpRequest } from '@angular/common/http'; -import { endpointSchemaKey } from '../../../store/src/helpers/stratos-entity-factory'; +import { endpointEntityType } from '../../../store/src/helpers/stratos-entity-factory'; import { PaginatedAction } from '../../../store/src/types/pagination.types'; import { cfEntityFactory } from '../cf-entity-factory'; import { cfEventEntityType } from '../cf-entity-types'; @@ -18,7 +18,7 @@ export class GetAllCfEvents extends CFStartAction implements PaginatedAction { constructor(public paginationKey: string, public endpointGuid) { super(); - this.paginationKey = this.paginationKey || createEntityRelationPaginationKey(endpointSchemaKey, endpointGuid); + this.paginationKey = this.paginationKey || createEntityRelationPaginationKey(endpointEntityType, endpointGuid); this.options = new HttpRequest( 'GET', 'events', diff --git a/src/frontend/packages/cloud-foundry/src/actions/domains.actions.ts b/src/frontend/packages/cloud-foundry/src/actions/domains.actions.ts index 8320c9cc55..d593428b5f 100644 --- a/src/frontend/packages/cloud-foundry/src/actions/domains.actions.ts +++ b/src/frontend/packages/cloud-foundry/src/actions/domains.actions.ts @@ -1,6 +1,6 @@ import { HttpRequest } from '@angular/common/http'; -import { endpointSchemaKey } from '../../../store/src/helpers/stratos-entity-factory'; +import { endpointEntityType } from '../../../store/src/helpers/stratos-entity-factory'; import { PaginatedAction } from '../../../store/src/types/pagination.types'; import { ICFAction } from '../../../store/src/types/request.types'; import { cfEntityFactory } from '../cf-entity-factory'; @@ -36,7 +36,7 @@ export class FetchAllDomains extends CFStartAction implements PaginatedAction { 'GET', 'domains', ); - this.paginationKey = this.paginationKey || createEntityRelationPaginationKey(endpointSchemaKey, endpointGuid); + this.paginationKey = this.paginationKey || createEntityRelationPaginationKey(endpointEntityType, endpointGuid); } actions = [GET_ALL_DOMAIN, GET_ALL_DOMAIN_SUCCESS, GET_ALL_DOMAIN_FAILED]; entity = [cfEntityFactory(domainEntityType)]; diff --git a/src/frontend/packages/cloud-foundry/src/actions/feature-flags.actions.ts b/src/frontend/packages/cloud-foundry/src/actions/feature-flags.actions.ts index b2b63f94bc..5c1967a0c1 100644 --- a/src/frontend/packages/cloud-foundry/src/actions/feature-flags.actions.ts +++ b/src/frontend/packages/cloud-foundry/src/actions/feature-flags.actions.ts @@ -1,7 +1,7 @@ import { HttpRequest } from '@angular/common/http'; import { getActions } from '../../../store/src/actions/action.helper'; -import { endpointSchemaKey } from '../../../store/src/helpers/stratos-entity-factory'; +import { endpointEntityType } from '../../../store/src/helpers/stratos-entity-factory'; import { PaginatedAction } from '../../../store/src/types/pagination.types'; import { RequestEntityLocation } from '../../../store/src/types/request.types'; import { cfEntityFactory } from '../cf-entity-factory'; @@ -12,7 +12,7 @@ import { CFStartAction } from './cf-action.types'; export class GetAllFeatureFlags extends CFStartAction implements PaginatedAction { constructor(public endpointGuid: string, public paginationKey: string = null) { super(); - this.paginationKey = this.paginationKey || createEntityRelationPaginationKey(endpointSchemaKey, this.endpointGuid); + this.paginationKey = this.paginationKey || createEntityRelationPaginationKey(endpointEntityType, this.endpointGuid); this.options = new HttpRequest( 'GET', `config/feature_flags` diff --git a/src/frontend/packages/cloud-foundry/src/actions/stack.action.ts b/src/frontend/packages/cloud-foundry/src/actions/stack.action.ts index c1795145f6..ac77391430 100644 --- a/src/frontend/packages/cloud-foundry/src/actions/stack.action.ts +++ b/src/frontend/packages/cloud-foundry/src/actions/stack.action.ts @@ -2,7 +2,7 @@ import { HttpRequest } from '@angular/common/http'; import { getActions } from '../../../store/src/actions/action.helper'; import { entityCatalog } from '../../../store/src/entity-catalog/entity-catalog'; -import { endpointSchemaKey } from '../../../store/src/helpers/stratos-entity-factory'; +import { endpointEntityType } from '../../../store/src/helpers/stratos-entity-factory'; import { PaginatedAction } from '../../../store/src/types/pagination.types'; import { ICFAction } from '../../../store/src/types/request.types'; import { stackEntityType } from '../cf-entity-types'; @@ -38,7 +38,7 @@ export class GetAllStacks extends CFStartAction implements PaginatedAction { 'GET', 'stacks' ); - this.paginationKey = createEntityRelationKey(endpointSchemaKey, endpointGuid); + this.paginationKey = createEntityRelationKey(endpointEntityType, endpointGuid); } paginationKey: string; actions = getActions('Stack', 'Fetch all'); diff --git a/src/frontend/packages/cloud-foundry/src/actions/user-provided-service.actions.ts b/src/frontend/packages/cloud-foundry/src/actions/user-provided-service.actions.ts index 7f447bc860..6ef888f96d 100644 --- a/src/frontend/packages/cloud-foundry/src/actions/user-provided-service.actions.ts +++ b/src/frontend/packages/cloud-foundry/src/actions/user-provided-service.actions.ts @@ -2,7 +2,7 @@ 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/stratos-entity-factory'; +import { endpointEntityType } from '../../../store/src/helpers/stratos-entity-factory'; import { PaginatedAction } from '../../../store/src/types/pagination.types'; import { ICFAction } from '../../../store/src/types/request.types'; import { cfEntityFactory } from '../cf-entity-factory'; @@ -39,7 +39,7 @@ export class GetAllUserProvidedServices extends CFStartAction implements Paginat ) { super(); this.paginationKey = paginationKey || (spaceGuid ? createEntityRelationPaginationKey(spaceEntityType, spaceGuid) : - createEntityRelationPaginationKey(endpointSchemaKey, endpointGuid)); + createEntityRelationPaginationKey(endpointEntityType, endpointGuid)); this.options = new HttpRequest( 'GET', `user_provided_service_instances`, diff --git a/src/frontend/packages/cloud-foundry/src/actions/users.actions.ts b/src/frontend/packages/cloud-foundry/src/actions/users.actions.ts index 46e4dee569..73d008753b 100644 --- a/src/frontend/packages/cloud-foundry/src/actions/users.actions.ts +++ b/src/frontend/packages/cloud-foundry/src/actions/users.actions.ts @@ -2,7 +2,7 @@ import { HttpRequest } from '@angular/common/http'; import { getActions } from '../../../store/src/actions/action.helper'; import { EntitySchema } from '../../../store/src/helpers/entity-schema'; -import { endpointSchemaKey } from '../../../store/src/helpers/stratos-entity-factory'; +import { endpointEntityType } from '../../../store/src/helpers/stratos-entity-factory'; import { PaginatedAction } from '../../../store/src/types/pagination.types'; import { EntityRequestAction } from '../../../store/src/types/request.types'; import { cfEntityFactory } from '../cf-entity-factory'; @@ -51,7 +51,7 @@ export class GetAllCfUsersAsAdmin extends CFStartAction implements PaginatedActi paginationKey?: string ) { super(); - this.paginationKey = paginationKey || createEntityRelationPaginationKey(endpointSchemaKey, endpointGuid); + this.paginationKey = paginationKey || createEntityRelationPaginationKey(endpointEntityType, endpointGuid); this.options = new HttpRequest( 'GET', 'users' diff --git a/src/frontend/packages/cloud-foundry/src/cf-entity-factory.ts b/src/frontend/packages/cloud-foundry/src/cf-entity-factory.ts index 40a49404ee..33bbedf4f7 100644 --- a/src/frontend/packages/cloud-foundry/src/cf-entity-factory.ts +++ b/src/frontend/packages/cloud-foundry/src/cf-entity-factory.ts @@ -1,5 +1,5 @@ -import { metricEntityType } from '../../store/src/base-entity-schemas'; import { EntitySchema } from '../../store/src/helpers/entity-schema'; +import { metricEntityType } from '../../store/src/helpers/stratos-entity-factory'; import { APIResource } from '../../store/src/types/api.types'; import { CFApplicationEntitySchema, @@ -200,24 +200,24 @@ const CFUserSchema = new CFUserEntitySchema({ audited_spaces: [createUserOrgSpaceSchema(spaceEntityType, {}, CfUserRoleParams.AUDITED_SPACES)], } }, { - idAttribute: getAPIResourceGuid, - processStrategy: (user: APIResource) => { - if (user.entity.username) { - return user; - } - const entity = { - ...user.entity, - username: user.metadata.guid - }; - - return user.metadata ? { - entity, - metadata: user.metadata - } : { - entity - }; + idAttribute: getAPIResourceGuid, + processStrategy: (user: APIResource) => { + if (user.entity.username) { + return user; } - }); + const entity = { + ...user.entity, + username: user.metadata.guid + }; + + return user.metadata ? { + entity, + metadata: user.metadata + } : { + entity + }; + } +}); entityCache[cfUserEntityType] = CFUserSchema; const coreSpaceSchemaParams = { diff --git a/src/frontend/packages/cloud-foundry/src/cf-entity-generator.ts b/src/frontend/packages/cloud-foundry/src/cf-entity-generator.ts index 6819e1297f..bfa85e3813 100644 --- a/src/frontend/packages/cloud-foundry/src/cf-entity-generator.ts +++ b/src/frontend/packages/cloud-foundry/src/cf-entity-generator.ts @@ -7,7 +7,6 @@ import { EndpointHealthCheck } from '../../core/endpoints-health-checks'; import { urlValidationExpression } from '../../core/src/core/utils.service'; import { BaseEndpointAuth } from '../../core/src/features/endpoints/endpoint-auth'; import { AppState, GeneralEntityAppState } from '../../store/src/app-state'; -import { metricEntityType } from '../../store/src/base-entity-schemas'; import { StratosBaseCatalogEntity, StratosCatalogEndpointEntity, @@ -22,6 +21,7 @@ import { } from '../../store/src/entity-request-pipeline/entity-request-base-handlers/handle-multi-endpoints.pipe'; import { ActionDispatcher, JetstreamResponse } from '../../store/src/entity-request-pipeline/entity-request-pipeline.types'; import { EntitySchema } from '../../store/src/helpers/entity-schema'; +import { metricEntityType } from '../../store/src/helpers/stratos-entity-factory'; import { RequestInfoState } from '../../store/src/reducers/api-request-reducer/types'; import { selectSessionData } from '../../store/src/reducers/auth.reducer'; import { APIResource, EntityInfo } from '../../store/src/types/api.types'; diff --git a/src/frontend/packages/cloud-foundry/src/features/applications/application-delete/delete-app-instances/app-delete-instances-routes-list-config.service.ts b/src/frontend/packages/cloud-foundry/src/features/applications/application-delete/delete-app-instances/app-delete-instances-routes-list-config.service.ts index 59a07fe363..f8b961dfba 100644 --- a/src/frontend/packages/cloud-foundry/src/features/applications/application-delete/delete-app-instances/app-delete-instances-routes-list-config.service.ts +++ b/src/frontend/packages/cloud-foundry/src/features/applications/application-delete/delete-app-instances/app-delete-instances-routes-list-config.service.ts @@ -12,7 +12,7 @@ import { import { CurrentUserPermissionsService } from '../../../../../../core/src/core/permissions/current-user-permissions.service'; import { RowState } from '../../../../../../core/src/shared/components/list/data-sources-controllers/list-data-source-types'; import { ListViewTypes } from '../../../../../../core/src/shared/components/list/list.component.types'; -import { endpointSchemaKey } from '../../../../../../store/src/helpers/stratos-entity-factory'; +import { endpointEntityType } from '../../../../../../store/src/helpers/stratos-entity-factory'; import { PaginationMonitorFactory } from '../../../../../../store/src/monitors/pagination-monitor.factory'; import { APIResource } from '../../../../../../store/src/types/api.types'; import { IServiceBinding } from '../../../../cf-api-svc.types'; @@ -59,7 +59,7 @@ export class AppDeleteServiceInstancesListConfigService extends AppServiceBindin const action = cfEntityCatalog.serviceBinding.actions.getAllForServiceInstance( serviceBinding.entity.service_instance_guid, appService.cfGuid, - createEntityRelationPaginationKey(endpointSchemaKey, serviceBindingEntityType), + createEntityRelationPaginationKey(endpointEntityType, serviceBindingEntityType), { includeRelations: [], } diff --git a/src/frontend/packages/cloud-foundry/src/features/applications/application.service.ts b/src/frontend/packages/cloud-foundry/src/features/applications/application.service.ts index d918209f4f..628b8560a4 100644 --- a/src/frontend/packages/cloud-foundry/src/features/applications/application.service.ts +++ b/src/frontend/packages/cloud-foundry/src/features/applications/application.service.ts @@ -44,13 +44,13 @@ export function createGetApplicationAction(guid: string, endpointGuid: string) { return new GetApplication( guid, endpointGuid, [ - createEntityRelationKey(applicationEntityType, routeEntityType), - createEntityRelationKey(applicationEntityType, spaceEntityType), - createEntityRelationKey(applicationEntityType, stackEntityType), - createEntityRelationKey(applicationEntityType, serviceBindingEntityType), - createEntityRelationKey(routeEntityType, domainEntityType), - createEntityRelationKey(spaceEntityType, organizationEntityType), - ] + createEntityRelationKey(applicationEntityType, routeEntityType), + createEntityRelationKey(applicationEntityType, spaceEntityType), + createEntityRelationKey(applicationEntityType, stackEntityType), + createEntityRelationKey(applicationEntityType, serviceBindingEntityType), + createEntityRelationKey(routeEntityType, domainEntityType), + createEntityRelationKey(spaceEntityType, organizationEntityType), + ] ); } @@ -64,7 +64,7 @@ export interface ApplicationData { @Injectable() export class ApplicationService { - private appEntityService: EntityService>; + public entityService: EntityService>; private appSummaryEntityService: EntityService; constructor( @@ -74,7 +74,7 @@ export class ApplicationService { private appStateService: ApplicationStateService, private appEnvVarsService: ApplicationEnvVarsHelper, ) { - this.appEntityService = cfEntityCatalog.application.store.getEntityService( + this.entityService = cfEntityCatalog.application.store.getEntityService( appGuid, cfGuid, { @@ -138,7 +138,7 @@ export class ApplicationService { private constructCoreObservables() { // First set up all the base observables - this.app$ = this.appEntityService.waitForEntity$; + this.app$ = this.entityService.waitForEntity$; const moreWaiting$ = this.app$.pipe( filter(entityInfo => !!(entityInfo.entity && entityInfo.entity.entity && entityInfo.entity.entity.cfGuid)), map(entityInfo => entityInfo.entity.entity)); @@ -162,9 +162,9 @@ export class ApplicationService { filter(org => !!org) ); - this.isDeletingApp$ = this.appEntityService.isDeletingEntity$.pipe(publishReplay(1), refCount()); + this.isDeletingApp$ = this.entityService.isDeletingEntity$.pipe(publishReplay(1), refCount()); - this.waitForAppEntity$ = this.appEntityService.waitForEntity$.pipe(publishReplay(1), refCount()); + this.waitForAppEntity$ = this.entityService.waitForEntity$.pipe(publishReplay(1), refCount()); this.appSummary$ = this.waitForAppEntity$.pipe( switchMap(() => this.appSummaryEntityService.entityObs$), @@ -231,9 +231,9 @@ export class ApplicationService { } private constructStatusObservables() { - this.isFetchingApp$ = this.appEntityService.isFetchingEntity$; + this.isFetchingApp$ = this.entityService.isFetchingEntity$; - this.isUpdatingApp$ = this.appEntityService.entityObs$.pipe(map(a => { + this.isUpdatingApp$ = this.entityService.entityObs$.pipe(map(a => { const updatingRoot = a.entityRequestInfo.updating[rootUpdatingKey] || { busy: false }; const updatingSection = a.entityRequestInfo.updating[UpdateExistingApplication.updateKey] || { busy: false }; return !!updatingRoot.busy || !!updatingSection.busy; diff --git a/src/frontend/packages/cloud-foundry/src/features/applications/application/application-base.component.ts b/src/frontend/packages/cloud-foundry/src/features/applications/application/application-base.component.ts index a95f69f887..ba7fea321a 100644 --- a/src/frontend/packages/cloud-foundry/src/features/applications/application/application-base.component.ts +++ b/src/frontend/packages/cloud-foundry/src/features/applications/application/application-base.component.ts @@ -3,10 +3,9 @@ import { ActivatedRoute } from '@angular/router'; import { Store } from '@ngrx/store'; import { CFAppState } from '../../../../../cloud-foundry/src/cf-app-state'; -import { APP_GUID, CF_GUID, ENTITY_SERVICE } from '../../../../../core/src/shared/entity.tokens'; -import { EntityServiceFactory } from '../../../../../store/src/entity-service-factory.service'; +import { APP_GUID, CF_GUID } from '../../../../../core/src/shared/entity.tokens'; import { ApplicationStateService } from '../../../shared/services/application-state.service'; -import { ApplicationService, createGetApplicationAction } from '../application.service'; +import { ApplicationService } from '../application.service'; import { ApplicationEnvVarsHelper } from './application-tabs-base/tabs/build-tab/application-env-vars.service'; export function applicationServiceFactory( @@ -25,17 +24,6 @@ export function applicationServiceFactory( ); } -export function cfApplicationEntityServiceFactory( - cfId: string, - id: string, - esf: EntityServiceFactory -) { - return esf.create( - id, - createGetApplicationAction(id, cfId) - ); -} - export function getGuids(type?: string) { return (activatedRoute: ActivatedRoute) => { const { id, endpointId } = activatedRoute.snapshot.params; @@ -72,13 +60,7 @@ export function getGuids(type?: string) { ApplicationStateService, ApplicationEnvVarsHelper, ] - }, - { - provide: ENTITY_SERVICE, - useFactory: cfApplicationEntityServiceFactory, - deps: [CF_GUID, APP_GUID, EntityServiceFactory] - }, - + } ] }) export class ApplicationBaseComponent { diff --git a/src/frontend/packages/cloud-foundry/src/features/applications/application/application-tabs-base/application-polling.service.ts b/src/frontend/packages/cloud-foundry/src/features/applications/application/application-tabs-base/application-polling.service.ts index 39fd632931..046af5a750 100644 --- a/src/frontend/packages/cloud-foundry/src/features/applications/application/application-tabs-base/application-polling.service.ts +++ b/src/frontend/packages/cloud-foundry/src/features/applications/application/application-tabs-base/application-polling.service.ts @@ -1,15 +1,11 @@ -import { Inject, Injectable, NgZone } from '@angular/core'; +import { Injectable, NgZone } from '@angular/core'; import { Store } from '@ngrx/store'; import { Observable, Subscription } from 'rxjs'; import { first, map, tap } from 'rxjs/operators'; import { safeUnsubscribe } from '../../../../../../core/src/core/utils.service'; -import { ENTITY_SERVICE } from '../../../../../../core/src/shared/entity.tokens'; import { AppState } from '../../../../../../store/src/app-state'; -import { EntityService } from '../../../../../../store/src/entity-service'; import { selectDashboardState } from '../../../../../../store/src/selectors/dashboard.selectors'; -import { APIResource } from '../../../../../../store/src/types/api.types'; -import { IApp } from '../../../../cf-api.types'; import { cfEntityCatalog } from '../../../../cf-entity-catalog'; import { ApplicationService } from '../../application.service'; @@ -19,7 +15,7 @@ export class ApplicationPollingService { private pollingSub: Subscription; private autoRefreshString = 'auto-refresh'; - public isPolling$ = this.entityService.updatingSection$.pipe(map( + public isPolling$ = this.applicationService.entityService.updatingSection$.pipe(map( update => update[this.autoRefreshString] && update[this.autoRefreshString].busy )); @@ -27,7 +23,6 @@ export class ApplicationPollingService { constructor( public applicationService: ApplicationService, - @Inject(ENTITY_SERVICE) private entityService: EntityService>, private store: Store, private ngZone: NgZone, ) { @@ -54,7 +49,7 @@ export class ApplicationPollingService { // Auto refresh this.ngZone.runOutsideAngular(() => { - this.pollingSub = this.entityService + this.pollingSub = this.applicationService.entityService .poll(10000, this.autoRefreshString).pipe( tap(() => this.ngZone.run(() => this.poll(false)))) .subscribe(); @@ -69,12 +64,12 @@ export class ApplicationPollingService { const { cfGuid, appGuid } = this.applicationService; if (withApp) { const updatingApp = { - ...this.entityService.action, + ...this.applicationService.entityService.action, updatingKey: this.autoRefreshString }; this.store.dispatch(updatingApp); } - this.entityService.entityObs$.pipe( + this.applicationService.entityService.entityObs$.pipe( first(), ).subscribe(resource => { cfEntityCatalog.appSummary.api.get(appGuid, cfGuid); diff --git a/src/frontend/packages/cloud-foundry/src/features/applications/application/application-tabs-base/application-tabs-base.component.ts b/src/frontend/packages/cloud-foundry/src/features/applications/application/application-tabs-base/application-tabs-base.component.ts index d6e3c44434..260741e7dd 100644 --- a/src/frontend/packages/cloud-foundry/src/features/applications/application/application-tabs-base/application-tabs-base.component.ts +++ b/src/frontend/packages/cloud-foundry/src/features/applications/application/application-tabs-base/application-tabs-base.component.ts @@ -1,4 +1,4 @@ -import { Component, Inject, NgZone, OnDestroy, OnInit } from '@angular/core'; +import { Component, NgZone, OnDestroy, OnInit } from '@angular/core'; import { Store } from '@ngrx/store'; import { combineLatest as observableCombineLatest, Observable, Subscription } from 'rxjs'; import { filter, first, map, startWith, switchMap, withLatestFrom } from 'rxjs/operators'; @@ -21,10 +21,8 @@ import { FavoritesConfigMapper, } from '../../../../../../core/src/shared/components/favorites-meta-card/favorite-config-mapper'; import { IHeaderBreadcrumb } from '../../../../../../core/src/shared/components/page-header/page-header.types'; -import { ENTITY_SERVICE } from '../../../../../../core/src/shared/entity.tokens'; import { RouterNav } from '../../../../../../store/src/actions/router.actions'; import { entityCatalog } from '../../../../../../store/src/entity-catalog/entity-catalog'; -import { EntityService } from '../../../../../../store/src/entity-service'; import { EntitySchema } from '../../../../../../store/src/helpers/entity-schema'; import { ActionState } from '../../../../../../store/src/reducers/api-request-reducer/types'; import { endpointEntitiesSelector } from '../../../../../../store/src/selectors/endpoint.selectors'; @@ -61,7 +59,6 @@ export class ApplicationTabsBaseComponent implements OnInit, OnDestroy { constructor( public applicationService: ApplicationService, - @Inject(ENTITY_SERVICE) private entityService: EntityService, private store: Store, private endpointsService: EndpointsService, private ngZone: NgZone, @@ -246,7 +243,7 @@ export class ApplicationTabsBaseComponent implements OnInit, OnDestroy { } ngOnInit() { - this.appSub$ = this.entityService.entityMonitor.entityRequest$.subscribe(requestInfo => { + this.appSub$ = this.applicationService.entityService.entityMonitor.entityRequest$.subscribe(requestInfo => { if ( requestInfo.deleting.deleted || requestInfo.error @@ -257,7 +254,7 @@ export class ApplicationTabsBaseComponent implements OnInit, OnDestroy { this.isFetching$ = this.applicationService.isFetchingApp$; - this.isBusyUpdating$ = this.entityService.updatingSection$.pipe( + this.isBusyUpdating$ = this.applicationService.entityService.updatingSection$.pipe( map(updatingSection => { const updating = this.updatingSectionBusy(updatingSection.restaging) || this.updatingSectionBusy(updatingSection[UpdateExistingApplication.updateKey]); diff --git a/src/frontend/packages/cloud-foundry/src/features/applications/application/application-tabs-base/tabs/build-tab/build-tab.component.spec.ts b/src/frontend/packages/cloud-foundry/src/features/applications/application/application-tabs-base/tabs/build-tab/build-tab.component.spec.ts index 71731cb35b..58a38edbe5 100644 --- a/src/frontend/packages/cloud-foundry/src/features/applications/application/application-tabs-base/tabs/build-tab/build-tab.component.spec.ts +++ b/src/frontend/packages/cloud-foundry/src/features/applications/application/application-tabs-base/tabs/build-tab/build-tab.component.spec.ts @@ -6,17 +6,15 @@ import { RouterTestingModule } from '@angular/router/testing'; import { CoreModule } from '../../../../../../../../core/src/core/core.module'; import { GITHUB_API_URL } from '../../../../../../../../core/src/core/github.helpers'; -import { APP_GUID, CF_GUID, ENTITY_SERVICE } from '../../../../../../../../core/src/shared/entity.tokens'; +import { APP_GUID, CF_GUID } from '../../../../../../../../core/src/shared/entity.tokens'; import { SharedModule } from '../../../../../../../../core/src/shared/shared.module'; import { TabNavService } from '../../../../../../../../core/tab-nav.service'; -import { EntityServiceFactory } from '../../../../../../../../store/src/entity-service-factory.service'; import { AppStoreModule } from '../../../../../../../../store/src/store.module'; import { ApplicationServiceMock } from '../../../../../../../test-framework/application-service-helper'; import { generateCfStoreModules } from '../../../../../../../test-framework/cloud-foundry-endpoint-service.helper'; import { CloudFoundrySharedModule } from '../../../../../../shared/cf-shared.module'; import { ApplicationStateService } from '../../../../../../shared/services/application-state.service'; import { ApplicationService } from '../../../../application.service'; -import { cfApplicationEntityServiceFactory } from '../../../application-base.component'; import { ApplicationPollComponent } from '../../application-poll/application-poll.component'; import { ApplicationPollingService } from '../../application-polling.service'; import { ApplicationEnvVarsHelper } from './application-env-vars.service'; @@ -53,11 +51,6 @@ describe('BuildTabComponent', () => { TabNavService, { provide: CF_GUID, useValue: '' }, { provide: APP_GUID, useValue: '' }, - { - provide: ENTITY_SERVICE, - useFactory: cfApplicationEntityServiceFactory, - deps: [CF_GUID, APP_GUID, EntityServiceFactory] - }, ApplicationPollingService ] }) diff --git a/src/frontend/packages/cloud-foundry/src/features/applications/application/application-tabs-base/tabs/build-tab/build-tab.component.ts b/src/frontend/packages/cloud-foundry/src/features/applications/application/application-tabs-base/tabs/build-tab/build-tab.component.ts index 6c07dbb615..e4db41a4ba 100644 --- a/src/frontend/packages/cloud-foundry/src/features/applications/application/application-tabs-base/tabs/build-tab/build-tab.component.ts +++ b/src/frontend/packages/cloud-foundry/src/features/applications/application/application-tabs-base/tabs/build-tab/build-tab.component.ts @@ -1,4 +1,4 @@ -import { Component, Inject, OnInit } from '@angular/core'; +import { Component, OnInit } from '@angular/core'; import { ActivatedRoute, Router } from '@angular/router'; import { Store } from '@ngrx/store'; import { combineLatest as observableCombineLatest, Observable, of as observableOf, of } from 'rxjs'; @@ -13,11 +13,9 @@ import { import { getFullEndpointApiUrl } from '../../../../../../../../core/src/features/endpoints/endpoint-helpers'; import { ConfirmationDialogConfig } from '../../../../../../../../core/src/shared/components/confirmation-dialog.config'; import { ConfirmationDialogService } from '../../../../../../../../core/src/shared/components/confirmation-dialog.service'; -import { ENTITY_SERVICE } from '../../../../../../../../core/src/shared/entity.tokens'; import { ResetPagination } from '../../../../../../../../store/src/actions/pagination.actions'; -import { EntityService } from '../../../../../../../../store/src/entity-service'; import { ActionState } from '../../../../../../../../store/src/reducers/api-request-reducer/types'; -import { APIResource, EntityInfo } from '../../../../../../../../store/src/types/api.types'; +import { EntityInfo } from '../../../../../../../../store/src/types/api.types'; import { IAppSummary } from '../../../../../../cf-api.types'; import { cfEntityCatalog } from '../../../../../../cf-entity-catalog'; import { GitSCMService, GitSCMType } from '../../../../../../shared/data-services/scm/scm.service'; @@ -66,7 +64,6 @@ export class BuildTabComponent implements OnInit { public applicationService: ApplicationService, private scmService: GitSCMService, private store: Store, - @Inject(ENTITY_SERVICE) private entityService: EntityService, private route: ActivatedRoute, private router: Router, private confirmDialog: ConfirmationDialogService, @@ -92,7 +89,7 @@ export class BuildTabComponent implements OnInit { return app.fetching || appSummary.entityRequestInfo.fetching; }), distinct()); - this.isBusyUpdating$ = this.entityService.updatingSection$.pipe( + this.isBusyUpdating$ = this.applicationService.entityService.updatingSection$.pipe( map(updatingSection => { const updating = this.updatingSectionBusy(updatingSection.restaging) || this.updatingSectionBusy(updatingSection[UpdateExistingApplication.updateKey]); @@ -266,7 +263,7 @@ export class BuildTabComponent implements OnInit { } pollEntityService(state, stateString): Observable { - return this.entityService + return this.applicationService.entityService .poll(1000, state).pipe( delay(1), filter(({ resource }) => { diff --git a/src/frontend/packages/cloud-foundry/src/features/applications/cli-info-application/cli-info-application.component.ts b/src/frontend/packages/cloud-foundry/src/features/applications/cli-info-application/cli-info-application.component.ts index 3f260c0155..dcf12f1d17 100644 --- a/src/frontend/packages/cloud-foundry/src/features/applications/cli-info-application/cli-info-application.component.ts +++ b/src/frontend/packages/cloud-foundry/src/features/applications/cli-info-application/cli-info-application.component.ts @@ -28,7 +28,6 @@ export class CliInfoApplicationComponent implements OnInit { constructor( private applicationService: ApplicationService, - // private entityServiceFactory: EntityServiceFactory // TODO: RC Search fo ) { this.breadcrumbs$ = new BehaviorSubject([]); } @@ -42,10 +41,10 @@ export class CliInfoApplicationComponent implements OnInit { private setupObservables(cfGuid: string) { this.cfEndpointEntityService = stratosEntityCatalog.endpoint.store.getEntityService(cfGuid); - // TODO: RC EXAMPLE + // TODO: RC Endpoint: get single, dispatch multiple // this.cfEndpointEntityService = this.entityServiceFactory.create( // cfGuid, - // new GetAllEndpoints() // TODO: RC single/multi actions? + // new GetAllEndpoints() // ); this.context$ = combineLatest( diff --git a/src/frontend/packages/cloud-foundry/src/features/cloud-foundry/add-organization/create-organization-step/create-organization-step.component.ts b/src/frontend/packages/cloud-foundry/src/features/cloud-foundry/add-organization/create-organization-step/create-organization-step.component.ts index 3fc1011631..acc4f55a0c 100644 --- a/src/frontend/packages/cloud-foundry/src/features/cloud-foundry/add-organization/create-organization-step/create-organization-step.component.ts +++ b/src/frontend/packages/cloud-foundry/src/features/cloud-foundry/add-organization/create-organization-step/create-organization-step.component.ts @@ -14,7 +14,7 @@ import { import { selectCfRequestInfo } from '../../../../../../cloud-foundry/src/store/selectors/api.selectors'; import { StepOnNextFunction } from '../../../../../../core/src/shared/components/stepper/step/step.component'; import { entityCatalog } from '../../../../../../store/src/entity-catalog/entity-catalog'; -import { endpointSchemaKey } from '../../../../../../store/src/helpers/stratos-entity-factory'; +import { endpointEntityType } from '../../../../../../store/src/helpers/stratos-entity-factory'; import { PaginationMonitorFactory } from '../../../../../../store/src/monitors/pagination-monitor.factory'; import { getPaginationObservables } from '../../../../../../store/src/reducers/pagination-reducer/pagination-reducer.helper'; import { APIResource } from '../../../../../../store/src/types/api.types'; @@ -75,7 +75,7 @@ export class CreateOrganizationStepComponent implements OnInit, OnDestroy { tap((o) => this.allOrgs = o) ); - const quotaPaginationKey = createEntityRelationPaginationKey(endpointSchemaKey, this.cfGuid); + const quotaPaginationKey = createEntityRelationPaginationKey(endpointEntityType, this.cfGuid); this.quotaDefinitions$ = cfEntityCatalog.quotaDefinition.store.getPaginationService( quotaPaginationKey, this.cfGuid, { includeRelations: [] } ).entities$.pipe( diff --git a/src/frontend/packages/cloud-foundry/src/features/cloud-foundry/edit-organization/edit-organization-step/edit-organization-step.component.ts b/src/frontend/packages/cloud-foundry/src/features/cloud-foundry/edit-organization/edit-organization-step/edit-organization-step.component.ts index 52980790b1..5a91738c56 100644 --- a/src/frontend/packages/cloud-foundry/src/features/cloud-foundry/edit-organization/edit-organization-step/edit-organization-step.component.ts +++ b/src/frontend/packages/cloud-foundry/src/features/cloud-foundry/edit-organization/edit-organization-step/edit-organization-step.component.ts @@ -11,7 +11,7 @@ import { } from '../../../../../../cloud-foundry/src/entity-relations/entity-relations.types'; import { safeUnsubscribe } from '../../../../../../core/src/core/utils.service'; import { StepOnNextFunction } from '../../../../../../core/src/shared/components/stepper/step/step.component'; -import { endpointSchemaKey } from '../../../../../../store/src/helpers/stratos-entity-factory'; +import { endpointEntityType } from '../../../../../../store/src/helpers/stratos-entity-factory'; import { PaginationMonitorFactory } from '../../../../../../store/src/monitors/pagination-monitor.factory'; import { ActionState } from '../../../../../../store/src/reducers/api-request-reducer/types'; import { getPaginationObservables } from '../../../../../../store/src/reducers/pagination-reducer/pagination-reducer.helper'; @@ -114,7 +114,7 @@ export class EditOrganizationStepComponent implements OnInit, OnDestroy { ); this.fetchOrgsSub = this.allOrgsInEndpoint$.subscribe(); - const quotaPaginationKey = createEntityRelationPaginationKey(endpointSchemaKey, this.cfGuid); + const quotaPaginationKey = createEntityRelationPaginationKey(endpointEntityType, this.cfGuid); this.quotaDefinitions$ = cfEntityCatalog.quotaDefinition.store.getPaginationService( quotaPaginationKey, this.cfGuid, { includeRelations: [] } ).entities$.pipe( diff --git a/src/frontend/packages/cloud-foundry/src/features/cloud-foundry/quota-definition-form/quota-definition-form.component.ts b/src/frontend/packages/cloud-foundry/src/features/cloud-foundry/quota-definition-form/quota-definition-form.component.ts index 2f3a0c3df7..d330a31aec 100644 --- a/src/frontend/packages/cloud-foundry/src/features/cloud-foundry/quota-definition-form/quota-definition-form.component.ts +++ b/src/frontend/packages/cloud-foundry/src/features/cloud-foundry/quota-definition-form/quota-definition-form.component.ts @@ -8,7 +8,7 @@ import { createEntityRelationPaginationKey } from '../../../../../cloud-foundry/ import { ActiveRouteCfOrgSpace } from '../../../../../cloud-foundry/src/features/cloud-foundry/cf-page.types'; import { getActiveRouteCfOrgSpaceProvider } from '../../../../../cloud-foundry/src/features/cloud-foundry/cf.helpers'; import { safeUnsubscribe } from '../../../../../core/src/core/utils.service'; -import { endpointSchemaKey } from '../../../../../store/src/helpers/stratos-entity-factory'; +import { endpointEntityType } from '../../../../../store/src/helpers/stratos-entity-factory'; import { IQuotaDefinition } from '../../../cf-api.types'; export interface QuotaFormValues { @@ -71,7 +71,7 @@ export class QuotaDefinitionFormComponent implements OnInit, OnDestroy { } fetchQuotasDefinitions() { - const quotaPaginationKey = createEntityRelationPaginationKey(endpointSchemaKey, this.cfGuid); + const quotaPaginationKey = createEntityRelationPaginationKey(endpointEntityType, this.cfGuid); const quotaDefinitions$ = cfEntityCatalog.quotaDefinition.store.getPaginationService(quotaPaginationKey, this.cfGuid, {}) .entities$.pipe( filter(o => !!o), diff --git a/src/frontend/packages/cloud-foundry/src/features/cloud-foundry/services/cloud-foundry-endpoint.service.ts b/src/frontend/packages/cloud-foundry/src/features/cloud-foundry/services/cloud-foundry-endpoint.service.ts index 04de31f668..eec79aba70 100644 --- a/src/frontend/packages/cloud-foundry/src/features/cloud-foundry/services/cloud-foundry-endpoint.service.ts +++ b/src/frontend/packages/cloud-foundry/src/features/cloud-foundry/services/cloud-foundry-endpoint.service.ts @@ -18,7 +18,7 @@ import { } from '../../../../../cloud-foundry/src/entity-relations/entity-relations.types'; import { CfApplicationState } from '../../../../../cloud-foundry/src/store/types/application.types'; import { EntityService } from '../../../../../store/src/entity-service'; -import { endpointSchemaKey } from '../../../../../store/src/helpers/stratos-entity-factory'; +import { endpointEntityType } from '../../../../../store/src/helpers/stratos-entity-factory'; import { PaginationMonitorFactory } from '../../../../../store/src/monitors/pagination-monitor.factory'; import { getPaginationObservables } from '../../../../../store/src/reducers/pagination-reducer/pagination-reducer.helper'; import { PaginationObservables } from '../../../../../store/src/reducers/pagination-reducer/pagination-reducer.types'; @@ -68,8 +68,8 @@ export class CloudFoundryEndpointService { static createGetAllOrganizations(cfGuid: string) { const paginationKey = cfGuid ? - createEntityRelationPaginationKey(endpointSchemaKey, cfGuid) - : createEntityRelationPaginationKey(endpointSchemaKey); + createEntityRelationPaginationKey(endpointEntityType, cfGuid) + : createEntityRelationPaginationKey(endpointEntityType); const getAllOrganizationsAction = cfEntityCatalog.org.actions.getMultiple(cfGuid, paginationKey, { includeRelations: [ @@ -83,8 +83,8 @@ export class CloudFoundryEndpointService { } static createGetAllOrganizationsLimitedSchema(cfGuid: string) { const paginationKey = cfGuid ? - createEntityRelationPaginationKey(endpointSchemaKey, cfGuid) - : createEntityRelationPaginationKey(endpointSchemaKey); + createEntityRelationPaginationKey(endpointEntityType, cfGuid) + : createEntityRelationPaginationKey(endpointEntityType); const getAllOrganizationsAction = cfEntityCatalog.org.actions.getMultiple(cfGuid, paginationKey, { includeRelations: [ diff --git a/src/frontend/packages/cloud-foundry/src/features/cloud-foundry/space-quota-definition-form/space-quota-definition-form.component.ts b/src/frontend/packages/cloud-foundry/src/features/cloud-foundry/space-quota-definition-form/space-quota-definition-form.component.ts index 4e698b0c77..5e648aba80 100644 --- a/src/frontend/packages/cloud-foundry/src/features/cloud-foundry/space-quota-definition-form/space-quota-definition-form.component.ts +++ b/src/frontend/packages/cloud-foundry/src/features/cloud-foundry/space-quota-definition-form/space-quota-definition-form.component.ts @@ -9,7 +9,7 @@ import { createEntityRelationPaginationKey } from '../../../../../cloud-foundry/ import { ActiveRouteCfOrgSpace } from '../../../../../cloud-foundry/src/features/cloud-foundry/cf-page.types'; import { getActiveRouteCfOrgSpaceProvider } from '../../../../../cloud-foundry/src/features/cloud-foundry/cf.helpers'; import { safeUnsubscribe } from '../../../../../core/src/core/utils.service'; -import { endpointSchemaKey } from '../../../../../store/src/helpers/stratos-entity-factory'; +import { endpointEntityType } from '../../../../../store/src/helpers/stratos-entity-factory'; import { IQuotaDefinition } from '../../../cf-api.types'; @@ -65,7 +65,7 @@ export class SpaceQuotaDefinitionFormComponent implements OnInit, OnDestroy { this.spaceQuotaDefinitions$ = cfEntityCatalog.spaceQuota.store.getAllInOrganization.getPaginationService( this.orgGuid, this.cfGuid, - createEntityRelationPaginationKey(endpointSchemaKey, this.cfGuid) + createEntityRelationPaginationKey(endpointEntityType, this.cfGuid) ).entities$ .pipe( filter(o => !!o), diff --git a/src/frontend/packages/cloud-foundry/src/features/cloud-foundry/tabs/cloud-foundry-cells/cloud-foundry-cell/cloud-foundry-cell-base/cloud-foundry-cell-base.component.ts b/src/frontend/packages/cloud-foundry/src/features/cloud-foundry/tabs/cloud-foundry-cells/cloud-foundry-cell/cloud-foundry-cell-base/cloud-foundry-cell-base.component.ts index 848157a8e1..cd137d502e 100644 --- a/src/frontend/packages/cloud-foundry/src/features/cloud-foundry/tabs/cloud-foundry-cells/cloud-foundry-cell/cloud-foundry-cell-base/cloud-foundry-cell-base.component.ts +++ b/src/frontend/packages/cloud-foundry/src/features/cloud-foundry/tabs/cloud-foundry-cells/cloud-foundry-cell/cloud-foundry-cell-base/cloud-foundry-cell-base.component.ts @@ -4,7 +4,7 @@ import { first, map } from 'rxjs/operators'; import { IPageSideNavTab } from '../../../../../../../../core/src/features/dashboard/page-side-nav/page-side-nav.component'; import { IHeaderBreadcrumb } from '../../../../../../../../core/src/shared/components/page-header/page-header.types'; -import { metricEntityType } from '../../../../../../../../store/src/base-entity-schemas'; +import { metricEntityType } from '../../../../../../../../store/src/helpers/stratos-entity-factory'; import { cfEntityFactory } from '../../../../../../cf-entity-factory'; import { getActiveRouteCfCellProvider } from '../../../../cf.helpers'; import { CloudFoundryEndpointService } from '../../../../services/cloud-foundry-endpoint.service'; diff --git a/src/frontend/packages/cloud-foundry/src/features/cloud-foundry/users/manage-users/cf-roles.service.ts b/src/frontend/packages/cloud-foundry/src/features/cloud-foundry/users/manage-users/cf-roles.service.ts index add83ee686..faa4668b08 100644 --- a/src/frontend/packages/cloud-foundry/src/features/cloud-foundry/users/manage-users/cf-roles.service.ts +++ b/src/frontend/packages/cloud-foundry/src/features/cloud-foundry/users/manage-users/cf-roles.service.ts @@ -18,7 +18,7 @@ import { createEntityRelationPaginationKey, } from '../../../../../../cloud-foundry/src/entity-relations/entity-relations.types'; import { CurrentUserPermissionsService } from '../../../../../../core/src/core/permissions/current-user-permissions.service'; -import { endpointSchemaKey } from '../../../../../../store/src/helpers/stratos-entity-factory'; +import { endpointEntityType } from '../../../../../../store/src/helpers/stratos-entity-factory'; import { APIResource, EntityInfo } from '../../../../../../store/src/types/api.types'; import { UsersRolesSetChanges } from '../../../../actions/users-roles.actions'; import { IOrganization, ISpace } from '../../../../cf-api.types'; @@ -239,7 +239,7 @@ export class CfRolesService { fetchOrgs(cfGuid: string): Observable[]> { if (!this.cfOrgs[cfGuid]) { - const paginationKey = createEntityRelationPaginationKey(endpointSchemaKey, cfGuid); + const paginationKey = createEntityRelationPaginationKey(endpointEntityType, cfGuid); const orgs$ = cfEntityCatalog.org.store.getPaginationService( cfGuid, paginationKey, diff --git a/src/frontend/packages/cloud-foundry/src/features/services/services/services-wall.service.ts b/src/frontend/packages/cloud-foundry/src/features/services/services/services-wall.service.ts index cafebb88e6..eadc97f032 100644 --- a/src/frontend/packages/cloud-foundry/src/features/services/services/services-wall.service.ts +++ b/src/frontend/packages/cloud-foundry/src/features/services/services/services-wall.service.ts @@ -3,7 +3,7 @@ import { Observable } from 'rxjs'; import { filter, map, publishReplay, refCount } from 'rxjs/operators'; import { serviceEntityType } from '../../../../../cloud-foundry/src/cf-entity-types'; -import { endpointSchemaKey } from '../../../../../store/src/helpers/stratos-entity-factory'; +import { endpointEntityType } from '../../../../../store/src/helpers/stratos-entity-factory'; import { APIResource } from '../../../../../store/src/types/api.types'; import { IService } from '../../../cf-api-svc.types'; import { cfEntityCatalog } from '../../../cf-entity-catalog'; @@ -18,7 +18,7 @@ export class ServicesWallService { } initServicesObservable = () => { - const paginationKey = createEntityRelationPaginationKey(endpointSchemaKey); + const paginationKey = createEntityRelationPaginationKey(endpointEntityType); return cfEntityCatalog.service.store.getPaginationService(null, paginationKey, {}).entities$ } diff --git a/src/frontend/packages/cloud-foundry/src/shared/components/list/list-types/app-instance/table-cell-cf-cell/table-cell-cf-cell.component.ts b/src/frontend/packages/cloud-foundry/src/shared/components/list/list-types/app-instance/table-cell-cf-cell/table-cell-cf-cell.component.ts index 345c4ec2da..651c1b90ac 100644 --- a/src/frontend/packages/cloud-foundry/src/shared/components/list/list-types/app-instance/table-cell-cf-cell/table-cell-cf-cell.component.ts +++ b/src/frontend/packages/cloud-foundry/src/shared/components/list/list-types/app-instance/table-cell-cf-cell/table-cell-cf-cell.component.ts @@ -21,7 +21,7 @@ export class TableCellCfCellComponent extends TableCellCustom i @Input('config') set config(config: { - metricEntityService: EntityService>> // TODO: RC search for metricEntityService + metricEntityService: EntityService>> cfGuid: string }) { if (!config) { diff --git a/src/frontend/packages/cloud-foundry/src/shared/components/list/list-types/cf-buildpacks/cf-buildpacks-data-source.ts b/src/frontend/packages/cloud-foundry/src/shared/components/list/list-types/cf-buildpacks/cf-buildpacks-data-source.ts index 7e399f7bda..fbc40398d9 100644 --- a/src/frontend/packages/cloud-foundry/src/shared/components/list/list-types/cf-buildpacks/cf-buildpacks-data-source.ts +++ b/src/frontend/packages/cloud-foundry/src/shared/components/list/list-types/cf-buildpacks/cf-buildpacks-data-source.ts @@ -9,7 +9,7 @@ import { ListDataSource, } from '../../../../../../../core/src/shared/components/list/data-sources-controllers/list-data-source'; import { IListConfig } from '../../../../../../../core/src/shared/components/list/list.component.types'; -import { endpointSchemaKey } from '../../../../../../../store/src/helpers/stratos-entity-factory'; +import { endpointEntityType } from '../../../../../../../store/src/helpers/stratos-entity-factory'; import { getRowMetadata } from '../../../../../../../store/src/public-api'; import { APIResource } from '../../../../../../../store/src/types/api.types'; import { cfEntityCatalog } from '../../../../../cf-entity-catalog'; @@ -17,7 +17,7 @@ import { cfEntityFactory } from '../../../../../cf-entity-factory'; export class CfBuildpacksDataSource extends ListDataSource { constructor(store: Store, cfGuid: string, listConfig?: IListConfig) { - const paginationKey = createEntityRelationPaginationKey(endpointSchemaKey, cfGuid); + const paginationKey = createEntityRelationPaginationKey(endpointEntityType, cfGuid); const action = cfEntityCatalog.buildPack.actions.getMultiple(cfGuid, paginationKey) super({ store, diff --git a/src/frontend/packages/cloud-foundry/src/shared/components/list/list-types/cf-cell-apps/cf-cell-apps-list-config.service.ts b/src/frontend/packages/cloud-foundry/src/shared/components/list/list-types/cf-cell-apps/cf-cell-apps-list-config.service.ts index 6bc5cdfb94..6d4c6d7b02 100644 --- a/src/frontend/packages/cloud-foundry/src/shared/components/list/list-types/cf-cell-apps/cf-cell-apps-list-config.service.ts +++ b/src/frontend/packages/cloud-foundry/src/shared/components/list/list-types/cf-cell-apps/cf-cell-apps-list-config.service.ts @@ -5,7 +5,6 @@ import { CFAppState } from '../../../../../../../cloud-foundry/src/cf-app-state' import { ITableColumn } from '../../../../../../../core/src/shared/components/list/list-table/table.types'; import { ListViewTypes } from '../../../../../../../core/src/shared/components/list/list.component.types'; import { ListView } from '../../../../../../../store/src/actions/list.actions'; -import { EntityServiceFactory } from '../../../../../../../store/src/entity-service-factory.service'; import { APIResource } from '../../../../../../../store/src/types/api.types'; import { IApp, ISpace } from '../../../../../cf-api.types'; import { ActiveRouteCfCell } from '../../../../../features/cloud-foundry/cf-page.types'; @@ -24,9 +23,9 @@ export class CfCellAppsListConfigService extends BaseCfListConfig { noEntries: 'There are no applications' }; - constructor(store: Store, private activeRouteCfCell: ActiveRouteCfCell, entityServiceFactory: EntityServiceFactory) { + constructor(store: Store, private activeRouteCfCell: ActiveRouteCfCell) { super(); - this.dataSource = new CfCellAppsDataSource(store, activeRouteCfCell.cfGuid, activeRouteCfCell.cellId, this, entityServiceFactory); + this.dataSource = new CfCellAppsDataSource(store, activeRouteCfCell.cfGuid, activeRouteCfCell.cellId, this); } getColumns = (): ITableColumn[] => [ diff --git a/src/frontend/packages/cloud-foundry/src/shared/components/list/list-types/cf-cell-apps/cf-cell-apps-source.ts b/src/frontend/packages/cloud-foundry/src/shared/components/list/list-types/cf-cell-apps/cf-cell-apps-source.ts index 6e834f3121..f0478d3f52 100644 --- a/src/frontend/packages/cloud-foundry/src/shared/components/list/list-types/cf-cell-apps/cf-cell-apps-source.ts +++ b/src/frontend/packages/cloud-foundry/src/shared/components/list/list-types/cf-cell-apps/cf-cell-apps-source.ts @@ -2,7 +2,6 @@ import { Store } from '@ngrx/store'; import { Observable } from 'rxjs'; import { map } from 'rxjs/operators'; -import { GetApplication } from '../../../../../../../cloud-foundry/src/actions/application.actions'; import { CFAppState } from '../../../../../../../cloud-foundry/src/cf-app-state'; import { applicationEntityType, @@ -15,12 +14,12 @@ import { import { IListConfig } from '../../../../../../../core/src/shared/components/list/list.component.types'; import { MetricQueryType } from '../../../../../../../core/src/shared/services/metrics-range-selector.types'; import { MetricQueryConfig } from '../../../../../../../store/src/actions/metrics.actions'; -import { EntityServiceFactory } from '../../../../../../../store/src/entity-service-factory.service'; import { APIResource } from '../../../../../../../store/src/types/api.types'; import { IMetrics, IMetricVectorResult } from '../../../../../../../store/src/types/base-metric.types'; import { IMetricApplication } from '../../../../../../../store/src/types/metric.types'; import { FetchCFMetricsPaginatedAction } from '../../../../../actions/cf-metrics.actions'; import { IApp } from '../../../../../cf-api.types'; +import { cfEntityCatalog } from '../../../../../cf-entity-catalog'; import { cfEntityFactory } from '../../../../../cf-entity-factory'; import { createEntityRelationKey } from '../../../../../entity-relations/entity-relations.types'; @@ -41,7 +40,6 @@ export class CfCellAppsDataSource cfGuid: string, cellId: string, listConfig: IListConfig, - entityServiceFactory: EntityServiceFactory ) { const action = new FetchCFMetricsPaginatedAction( cellId, @@ -64,7 +62,7 @@ export class CfCellAppsDataSource return response[0].data.result.map(res => ({ metric: res.metric, appGuid: res.metric.application_id, - appEntityService: this.createAppEntityService(res.metric.application_id, cfGuid, entityServiceFactory) + appEntityService: this.createAppEntityService(res.metric.application_id, cfGuid) })); }), listConfig @@ -74,15 +72,18 @@ export class CfCellAppsDataSource private createAppEntityService( appGuid: string, - cfGuid: string, - entityServiceFactory: EntityServiceFactory): Observable> { + cfGuid: string + ): Observable> { if (!this.appEntityServices[appGuid]) { - this.appEntityServices[appGuid] = entityServiceFactory.create>( + this.appEntityServices[appGuid] = cfEntityCatalog.application.store.getEntityService( appGuid, - new GetApplication(appGuid, cfGuid, [ + cfGuid, { + includeRelations: [ createEntityRelationKey(applicationEntityType, spaceEntityType), createEntityRelationKey(spaceEntityType, organizationEntityType) - ]) + ], + populateMissing: true + } ).waitForEntity$.pipe( map(entityInfo => entityInfo.entity) ); diff --git a/src/frontend/packages/cloud-foundry/src/shared/components/list/list-types/cf-quotas/cf-quotas-data-source.service.ts b/src/frontend/packages/cloud-foundry/src/shared/components/list/list-types/cf-quotas/cf-quotas-data-source.service.ts index e7a620600f..b40ab5555e 100644 --- a/src/frontend/packages/cloud-foundry/src/shared/components/list/list-types/cf-quotas/cf-quotas-data-source.service.ts +++ b/src/frontend/packages/cloud-foundry/src/shared/components/list/list-types/cf-quotas/cf-quotas-data-source.service.ts @@ -11,7 +11,7 @@ import { getDefaultRowState, } from '../../../../../../../core/src/shared/components/list/data-sources-controllers/list-data-source-types'; import { IListConfig } from '../../../../../../../core/src/shared/components/list/list.component.types'; -import { endpointSchemaKey } from '../../../../../../../store/src/helpers/stratos-entity-factory'; +import { endpointEntityType } from '../../../../../../../store/src/helpers/stratos-entity-factory'; import { APIResource } from '../../../../../../../store/src/types/api.types'; import { CFAppState } from '../../../../../cf-app-state'; import { cfEntityCatalog } from '../../../../../cf-entity-catalog'; @@ -22,7 +22,7 @@ import { createEntityRelationPaginationKey } from '../../../../../entity-relatio export class CfQuotasDataSourceService extends ListDataSource { constructor(store: Store, cfGuid: string, listConfig?: IListConfig) { - const quotaPaginationKey = createEntityRelationPaginationKey(endpointSchemaKey, cfGuid); + const quotaPaginationKey = createEntityRelationPaginationKey(endpointEntityType, cfGuid); const action = new GetQuotaDefinitions(quotaPaginationKey, cfGuid); super({ diff --git a/src/frontend/packages/cloud-foundry/src/shared/components/list/list-types/cf-security-groups/cf-security-groups-data-source.ts b/src/frontend/packages/cloud-foundry/src/shared/components/list/list-types/cf-security-groups/cf-security-groups-data-source.ts index 620bdcbb5b..2f0b04583f 100644 --- a/src/frontend/packages/cloud-foundry/src/shared/components/list/list-types/cf-security-groups/cf-security-groups-data-source.ts +++ b/src/frontend/packages/cloud-foundry/src/shared/components/list/list-types/cf-security-groups/cf-security-groups-data-source.ts @@ -10,14 +10,14 @@ import { ListDataSource, } from '../../../../../../../core/src/shared/components/list/data-sources-controllers/list-data-source'; import { IListConfig } from '../../../../../../../core/src/shared/components/list/list.component.types'; -import { endpointSchemaKey } from '../../../../../../../store/src/helpers/stratos-entity-factory'; +import { endpointEntityType } from '../../../../../../../store/src/helpers/stratos-entity-factory'; import { APIResource } from '../../../../../../../store/src/types/api.types'; import { cfEntityCatalog } from '../../../../../cf-entity-catalog'; import { cfEntityFactory } from '../../../../../cf-entity-factory'; export class CfSecurityGroupsDataSource extends ListDataSource { constructor(store: Store, cfGuid: string, listConfig?: IListConfig) { - const paginationKey = createEntityRelationPaginationKey(endpointSchemaKey, cfGuid); + const paginationKey = createEntityRelationPaginationKey(endpointEntityType, cfGuid); const action = cfEntityCatalog.securityGroup.actions.getMultiple(cfGuid, paginationKey, {}); super({ store, diff --git a/src/frontend/packages/cloud-foundry/src/shared/components/list/list-types/cf-services/cf-services-data-source.ts b/src/frontend/packages/cloud-foundry/src/shared/components/list/list-types/cf-services/cf-services-data-source.ts index 018c2d1920..58e54ea397 100644 --- a/src/frontend/packages/cloud-foundry/src/shared/components/list/list-types/cf-services/cf-services-data-source.ts +++ b/src/frontend/packages/cloud-foundry/src/shared/components/list/list-types/cf-services/cf-services-data-source.ts @@ -11,7 +11,7 @@ import { } from '../../../../../../../core/src/shared/components/list/data-sources-controllers/list-data-source'; import { IListConfig } from '../../../../../../../core/src/shared/components/list/list.component.types'; import { entityCatalog } from '../../../../../../../store/src/entity-catalog/entity-catalog'; -import { endpointSchemaKey } from '../../../../../../../store/src/helpers/stratos-entity-factory'; +import { endpointEntityType } from '../../../../../../../store/src/helpers/stratos-entity-factory'; import { APIResource } from '../../../../../../../store/src/types/api.types'; import { PaginationEntityState } from '../../../../../../../store/src/types/pagination.types'; import { cfEntityCatalog } from '../../../../../cf-entity-catalog'; @@ -19,7 +19,7 @@ import { CF_ENDPOINT_TYPE } from '../../../../../cf-types'; export class CfServicesDataSource extends ListDataSource { constructor(store: Store, endpointGuid: string, listConfig?: IListConfig) { - const paginationKey = createEntityRelationPaginationKey(endpointSchemaKey); + const paginationKey = createEntityRelationPaginationKey(endpointEntityType); const getServicesAction = cfEntityCatalog.service.actions.getMultiple(endpointGuid, paginationKey, {}); super({ store, diff --git a/src/frontend/packages/cloud-foundry/src/shared/components/list/list-types/cf-space-quotas/cf-space-quotas-data-source.service.ts b/src/frontend/packages/cloud-foundry/src/shared/components/list/list-types/cf-space-quotas/cf-space-quotas-data-source.service.ts index 0c36d99046..3df5ab34e2 100644 --- a/src/frontend/packages/cloud-foundry/src/shared/components/list/list-types/cf-space-quotas/cf-space-quotas-data-source.service.ts +++ b/src/frontend/packages/cloud-foundry/src/shared/components/list/list-types/cf-space-quotas/cf-space-quotas-data-source.service.ts @@ -10,7 +10,7 @@ import { getDefaultRowState, } from '../../../../../../../core/src/shared/components/list/data-sources-controllers/list-data-source-types'; import { IListConfig } from '../../../../../../../core/src/shared/components/list/list.component.types'; -import { endpointSchemaKey } from '../../../../../../../store/src/helpers/stratos-entity-factory'; +import { endpointEntityType } from '../../../../../../../store/src/helpers/stratos-entity-factory'; import { APIResource } from '../../../../../../../store/src/types/api.types'; import { GetOrganizationSpaceQuotaDefinitions } from '../../../../../actions/quota-definitions.actions'; import { CFAppState } from '../../../../../cf-app-state'; @@ -22,7 +22,7 @@ import { createEntityRelationPaginationKey } from '../../../../../entity-relatio export class CfOrgSpaceQuotasDataSourceService extends ListDataSource { constructor(store: Store, orgGuid: string, cfGuid: string, listConfig?: IListConfig) { - const quotaPaginationKey = createEntityRelationPaginationKey(endpointSchemaKey, cfGuid); + const quotaPaginationKey = createEntityRelationPaginationKey(endpointEntityType, cfGuid); const action = new GetOrganizationSpaceQuotaDefinitions(quotaPaginationKey, orgGuid, cfGuid); super({ diff --git a/src/frontend/packages/cloud-foundry/src/shared/data-services/cloud-foundry.service.ts b/src/frontend/packages/cloud-foundry/src/shared/data-services/cloud-foundry.service.ts index 45ba64f2e0..0817bf9e46 100644 --- a/src/frontend/packages/cloud-foundry/src/shared/data-services/cloud-foundry.service.ts +++ b/src/frontend/packages/cloud-foundry/src/shared/data-services/cloud-foundry.service.ts @@ -1,13 +1,11 @@ import { Injectable } from '@angular/core'; -import { Store } from '@ngrx/store'; import { Observable } from 'rxjs'; import { map } from 'rxjs/operators'; -import { CFAppState } from '../../../../cloud-foundry/src/cf-app-state'; -import { endpointEntitySchema } from '../../../../store/src/base-entity-schemas'; import { PaginationMonitor } from '../../../../store/src/monitors/pagination-monitor'; +import { stratosEntityCatalog } from '../../../../store/src/stratos-entity-catalog'; import { APIResource, EntityInfo } from '../../../../store/src/types/api.types'; -import { endpointListKey, EndpointModel } from '../../../../store/src/types/endpoint.types'; +import { EndpointModel } from '../../../../store/src/types/endpoint.types'; @Injectable() export class CloudFoundryService { @@ -18,12 +16,11 @@ export class CloudFoundryService { cfEndpointsMonitor: PaginationMonitor; waitForAppEntity$: Observable>; - constructor( - store: Store - ) { + constructor() { - this.cfEndpointsMonitor = new PaginationMonitor(store, endpointListKey, endpointEntitySchema, true); + this.cfEndpointsMonitor = stratosEntityCatalog.endpoint.store.getPaginationMonitor(); + // TODO: RC should we now avoid selectors.. selectEntity, selectCfEntity, etc? this.cFEndpoints$ = this.cfEndpointsMonitor.currentPage$.pipe( map(endpoints => endpoints.filter(e => e.cnsi_type === 'cf')) ); diff --git a/src/frontend/packages/cloud-foundry/src/shared/data-services/long-running-cf-op.service.ts b/src/frontend/packages/cloud-foundry/src/shared/data-services/long-running-cf-op.service.ts index 296b87b0d4..acec511ca3 100644 --- a/src/frontend/packages/cloud-foundry/src/shared/data-services/long-running-cf-op.service.ts +++ b/src/frontend/packages/cloud-foundry/src/shared/data-services/long-running-cf-op.service.ts @@ -4,7 +4,7 @@ import { Store } from '@ngrx/store'; import { LongRunningOperationsService } from '../../../../core/src/shared/services/long-running-op.service'; import { SnackBarService } from '../../../../core/src/shared/services/snackbar.service'; import { AppState } from '../../../../store/src/app-state'; -import { GetServiceInstance } from '../../actions/service-instances.actions'; +import { cfEntityCatalog } from '../../cf-entity-catalog'; @Injectable() export class LongRunningCfOperationsService extends LongRunningOperationsService { @@ -28,8 +28,7 @@ export class LongRunningCfOperationsService extends LongRunningOperationsService Please refresh the service instance list to check it's status`; // Also attempt to fetch the service instance, this will update the `last operation` value to `update` and `in progress` this.snackBarService.show(message, 'Dismiss'); - // TODO: RC FIX - this.store.dispatch(new GetServiceInstance(serviceInstanceGuid, cfGuid)); + cfEntityCatalog.serviceInstance.api.get(serviceInstanceGuid, cfGuid); } handleLongRunningDeleteService(serviceInstanceGuid: string, cfGuid: string) { @@ -37,8 +36,7 @@ export class LongRunningCfOperationsService extends LongRunningOperationsService Please refresh the service instance list to check it's status`; this.snackBarService.show(message, 'Dismiss'); // Also attempt to fetch the service instance, this will update the `last operation` value to `delete` and `in progress` - // TODO: RC FIX - this.store.dispatch(new GetServiceInstance(serviceInstanceGuid, cfGuid)); + cfEntityCatalog.serviceInstance.api.get(serviceInstanceGuid, cfGuid); } } diff --git a/src/frontend/packages/cloud-foundry/src/shared/services/cf-org-space-label.service.ts b/src/frontend/packages/cloud-foundry/src/shared/services/cf-org-space-label.service.ts index ff76d39b0c..f99a7f24dc 100644 --- a/src/frontend/packages/cloud-foundry/src/shared/services/cf-org-space-label.service.ts +++ b/src/frontend/packages/cloud-foundry/src/shared/services/cf-org-space-label.service.ts @@ -2,9 +2,8 @@ import { Store } from '@ngrx/store'; import { combineLatest, Observable } from 'rxjs'; import { filter, first, map } from 'rxjs/operators'; -import { STRATOS_ENDPOINT_TYPE } from '../../../../store/src/base-entity-schemas'; import { entityCatalog } from '../../../../store/src/entity-catalog/entity-catalog'; -import { endpointSchemaKey } from '../../../../store/src/helpers/stratos-entity-factory'; +import { endpointEntityType, STRATOS_ENDPOINT_TYPE } from '../../../../store/src/helpers/stratos-entity-factory'; import { selectEntity } from '../../../../store/src/selectors/api.selectors'; import { APIResource } from '../../../../store/src/types/api.types'; import { EndpointModel } from '../../../../store/src/types/endpoint.types'; @@ -33,8 +32,9 @@ export class CfOrgSpaceLabelService { private spaceGuid?: string) { this.multipleConnectedEndpoints$ = haveMultiConnectedCfs(this.store); // FIXME: hide STRATOS_ENDPOINT_TYPE from extensions - STRAT-154 - const endpointEntityKey = entityCatalog.getEntityKey(STRATOS_ENDPOINT_TYPE, endpointSchemaKey); + const endpointEntityKey = entityCatalog.getEntityKey(STRATOS_ENDPOINT_TYPE, endpointEntityType); + // TODO: RC should we now avoid selectors.. selectEntity, selectCfEntity, etc? this.cf$ = this.store.select(selectEntity(endpointEntityKey, this.cfGuid)); this.org$ = this.store.select>(selectCfEntity(organizationEntityType, this.orgGuid)); diff --git a/src/frontend/packages/cloud-foundry/src/shared/services/current-user-permissions.service.spec.ts b/src/frontend/packages/cloud-foundry/src/shared/services/current-user-permissions.service.spec.ts index e6e6809326..ddf7d54350 100644 --- a/src/frontend/packages/cloud-foundry/src/shared/services/current-user-permissions.service.spec.ts +++ b/src/frontend/packages/cloud-foundry/src/shared/services/current-user-permissions.service.spec.ts @@ -19,7 +19,7 @@ import { AppTestModule } from '../../../../core/test-framework/core-test.helper' import { AppState } from '../../../../store/src/app-state'; import { EntityCatalogTestModule, TEST_CATALOGUE_ENTITIES } from '../../../../store/src/entity-catalog-test.module'; import { EntityCatalogEntityConfig } from '../../../../store/src/entity-catalog/entity-catalog.types'; -import { endpointSchemaKey, stratosEntityFactory } from '../../../../store/src/helpers/stratos-entity-factory'; +import { endpointEntityType, stratosEntityFactory } from '../../../../store/src/helpers/stratos-entity-factory'; import { generateStratosEntities } from '../../../../store/src/stratos-entity-generator'; import { APIResource } from '../../../../store/src/types/api.types'; import { EndpointModel } from '../../../../store/src/types/endpoint.types'; @@ -588,7 +588,7 @@ describe('CurrentUserPermissionsService with CF checker', () => { // Create request and requestData sections const entityMap = new Map>([ [ - stratosEntityFactory(endpointSchemaKey), + stratosEntityFactory(endpointEntityType), endpoints.map(endpoint => ({ guid: endpoint.guid, data: endpoint diff --git a/src/frontend/packages/core/src/app.module.ts b/src/frontend/packages/core/src/app.module.ts index 1f618e25b3..32e844377b 100644 --- a/src/frontend/packages/core/src/app.module.ts +++ b/src/frontend/packages/core/src/app.module.ts @@ -9,19 +9,17 @@ import { debounceTime, filter, withLatestFrom } from 'rxjs/operators'; import { CfAutoscalerModule } from '../../cf-autoscaler/src/cf-autoscaler.module'; import { CloudFoundryPackageModule } from '../../cloud-foundry/src/cloud-foundry-package.module'; import { SetRecentlyVisitedEntityAction } from '../../store/src/actions/recently-visited.actions'; -import { - UpdateUserFavoriteMetadataAction, -} from '../../store/src/actions/user-favourites-actions/update-user-favorite-metadata-action'; import { GeneralEntityAppState, GeneralRequestDataState } from '../../store/src/app-state'; import { EntityCatalogModule } from '../../store/src/entity-catalog.module'; import { entityCatalog } from '../../store/src/entity-catalog/entity-catalog'; import { EntityCatalogHelper } from '../../store/src/entity-catalog/entity-catalog-entity/entity-catalog.service'; import { EntityCatalogHelpers } from '../../store/src/entity-catalog/entity-catalog.helper'; -import { endpointSchemaKey, STRATOS_ENDPOINT_TYPE } from '../../store/src/helpers/stratos-entity-factory'; +import { endpointEntityType, STRATOS_ENDPOINT_TYPE } from '../../store/src/helpers/stratos-entity-factory'; import { getAPIRequestDataState, selectEntity } from '../../store/src/selectors/api.selectors'; import { internalEventStateSelector } from '../../store/src/selectors/internal-events.selectors'; import { recentlyVisitedSelector } from '../../store/src/selectors/recently-visitied.selectors'; import { AppStoreModule } from '../../store/src/store.module'; +import { stratosEntityCatalog } from '../../store/src/stratos-entity-catalog'; import { generateStratosEntities } from '../../store/src/stratos-entity-generator'; import { EndpointModel } from '../../store/src/types/endpoint.types'; import { IFavoriteMetadata, UserFavorite } from '../../store/src/types/user-favorites.types'; @@ -158,7 +156,7 @@ export class AppModule { if (!backendErrors.length) { return res; } - const entityConfig = entityCatalog.getEntity(STRATOS_ENDPOINT_TYPE, endpointSchemaKey); + const entityConfig = entityCatalog.getEntity(STRATOS_ENDPOINT_TYPE, endpointEntityType); res.push(new GlobalEventData(true, { endpoint: selectEntity(entityConfig.entityKey, eventId)(state), count: backendErrors.length @@ -247,7 +245,7 @@ export class AppModule { private syncFavorite(favorite: UserFavorite, entities: GeneralRequestDataState) { if (favorite) { - const isEndpoint = (favorite.entityType === endpointSchemaKey); + const isEndpoint = (favorite.entityType === endpointEntityType); // If the favorite is an endpoint ensure we look in the stratosEndpoint part of the store instead of, for example, cfEndpoint const entityKey = isEndpoint ? entityCatalog.getEntityKey({ ...favorite, @@ -257,10 +255,10 @@ export class AppModule { if (entity) { const newMetadata = this.favoritesConfigMapper.getEntityMetadata(favorite, entity); if (this.metadataHasChanged(favorite.metadata, newMetadata)) { - this.store.dispatch(new UpdateUserFavoriteMetadataAction({ + stratosEntityCatalog.userFavorite.api.updateFavorite({ ...favorite, metadata: newMetadata - })); + }); } } } diff --git a/src/frontend/packages/core/src/core/permissions/current-user-permissions.service.spec.ts b/src/frontend/packages/core/src/core/permissions/current-user-permissions.service.spec.ts index 1c30c078f2..90d5401db5 100644 --- a/src/frontend/packages/core/src/core/permissions/current-user-permissions.service.spec.ts +++ b/src/frontend/packages/core/src/core/permissions/current-user-permissions.service.spec.ts @@ -5,7 +5,7 @@ import { first, tap } from 'rxjs/operators'; import { AppState } from '../../../../store/src/app-state'; import { EntityCatalogTestModule, TEST_CATALOGUE_ENTITIES } from '../../../../store/src/entity-catalog-test.module'; import { EntityCatalogEntityConfig } from '../../../../store/src/entity-catalog/entity-catalog.types'; -import { endpointSchemaKey, stratosEntityFactory } from '../../../../store/src/helpers/stratos-entity-factory'; +import { endpointEntityType, stratosEntityFactory } from '../../../../store/src/helpers/stratos-entity-factory'; import { generateStratosEntities } from '../../../../store/src/stratos-entity-generator'; import { EndpointModel } from '../../../../store/src/types/endpoint.types'; import { BaseEntityValues } from '../../../../store/src/types/entity.types'; @@ -138,7 +138,7 @@ describe('CurrentUserPermissionsService', () => { // Create request and requestData sections const entityMap = new Map>([ [ - stratosEntityFactory(endpointSchemaKey), + stratosEntityFactory(endpointEntityType), endpoints.map(endpoint => ({ guid: endpoint.guid, data: endpoint diff --git a/src/frontend/packages/core/src/core/user-profile.service.ts b/src/frontend/packages/core/src/core/user-profile.service.ts index 72924925d9..0a496d3adc 100644 --- a/src/frontend/packages/core/src/core/user-profile.service.ts +++ b/src/frontend/packages/core/src/core/user-profile.service.ts @@ -25,18 +25,9 @@ export class UserProfileService { private userGuid$: Observable; - // private stratosUserConfig = entityCatalog.getEntity(userProfileEntitySchema.endpointType, userProfileEntitySchema.entityType); - constructor( private store: Store, - // esf: EntityServiceFactory // TODO: RC Search ) { - // if (!this.stratosUserConfig) { - // console.error('Can not get user profile entity'); - // this.userProfile$ = of({} as UserProfileInfo); - // return; - // } - this.userGuid$ = this.store.select(s => s.auth).pipe( filter((auth: AuthState) => !!(auth && auth.sessionData)), map((auth: AuthState) => auth.sessionData), diff --git a/src/frontend/packages/core/src/features/dashboard/dashboard-base/dashboard-base.component.ts b/src/frontend/packages/core/src/features/dashboard/dashboard-base/dashboard-base.component.ts index c409c37976..7ba92c93b4 100644 --- a/src/frontend/packages/core/src/features/dashboard/dashboard-base/dashboard-base.component.ts +++ b/src/frontend/packages/core/src/features/dashboard/dashboard-base/dashboard-base.component.ts @@ -9,11 +9,11 @@ import { distinctUntilChanged, filter, map, startWith, withLatestFrom } from 'rx import { CloseSideNav, DisableMobileNav, EnableMobileNav } from '../../../../../store/src/actions/dashboard-actions'; import { GetCurrentUsersRelations } from '../../../../../store/src/actions/permissions.actions'; -import { GetUserFavoritesAction } from '../../../../../store/src/actions/user-favourites-actions/get-user-favorites-action'; import { DashboardOnlyAppState } from '../../../../../store/src/app-state'; import { entityCatalog } from '../../../../../store/src/entity-catalog/entity-catalog'; import { DashboardState } from '../../../../../store/src/reducers/dashboard-reducer'; import { selectDashboardState } from '../../../../../store/src/selectors/dashboard.selectors'; +import { stratosEntityCatalog } from '../../../../../store/src/stratos-entity-catalog'; import { TabNavService } from '../../../../tab-nav.service'; import { CustomizationService } from '../../../core/customizations.types'; import { EndpointsService } from '../../../core/endpoints.service'; @@ -144,7 +144,7 @@ export class DashboardBaseComponent implements OnInit, OnDestroy, AfterViewInit }); this.dispatchRelations(); - this.store.dispatch(new GetUserFavoritesAction()); + stratosEntityCatalog.userFavorite.api.getAll(); } ngOnDestroy() { diff --git a/src/frontend/packages/core/src/features/endpoints/connect-endpoint-dialog/connect-endpoint-dialog.component.ts b/src/frontend/packages/core/src/features/endpoints/connect-endpoint-dialog/connect-endpoint-dialog.component.ts index 75402fd26f..3a56bdbc23 100644 --- a/src/frontend/packages/core/src/features/endpoints/connect-endpoint-dialog/connect-endpoint-dialog.component.ts +++ b/src/frontend/packages/core/src/features/endpoints/connect-endpoint-dialog/connect-endpoint-dialog.component.ts @@ -1,9 +1,7 @@ import { Component, Inject, OnDestroy } from '@angular/core'; import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material/dialog'; -import { Store } from '@ngrx/store'; import { Subscription } from 'rxjs'; -import { EndpointOnlyAppState } from '../../../../../store/src/app-state'; import { EndpointsService } from '../../../core/endpoints.service'; import { MarkdownPreviewComponent } from '../../../shared/components/markdown-preview/markdown-preview.component'; import { SidePanelService } from '../../../shared/services/side-panel.service'; @@ -27,12 +25,11 @@ export class ConnectEndpointDialogComponent implements OnDestroy { constructor( public dialogRef: MatDialogRef, @Inject(MAT_DIALOG_DATA) public data: ConnectEndpointConfig, - private store: Store, endpointsService: EndpointsService, private sidePanelService: SidePanelService, private snackBarService: SnackBarService, ) { - this.connectService = new ConnectEndpointService(store, endpointsService, data); + this.connectService = new ConnectEndpointService(endpointsService, data); this.hasConnected = this.connectService.hasConnected$.subscribe(() => { this.snackBarService.show(`Connected endpoint '${this.data.name}'`); diff --git a/src/frontend/packages/core/src/features/endpoints/create-endpoint/create-endpoint-cf-step-1/create-endpoint-cf-step-1.component.ts b/src/frontend/packages/core/src/features/endpoints/create-endpoint/create-endpoint-cf-step-1/create-endpoint-cf-step-1.component.ts index 12debb9a11..76bffe5826 100644 --- a/src/frontend/packages/core/src/features/endpoints/create-endpoint/create-endpoint-cf-step-1/create-endpoint-cf-step-1.component.ts +++ b/src/frontend/packages/core/src/features/endpoints/create-endpoint/create-endpoint-cf-step-1/create-endpoint-cf-step-1.component.ts @@ -11,7 +11,7 @@ import { entityCatalog } from '../../../../../../store/src/entity-catalog/entity import { StratosCatalogEndpointEntity, } from '../../../../../../store/src/entity-catalog/entity-catalog-entity/entity-catalog-entity'; -import { endpointSchemaKey, stratosEntityFactory } from '../../../../../../store/src/helpers/stratos-entity-factory'; +import { endpointEntityType, stratosEntityFactory } from '../../../../../../store/src/helpers/stratos-entity-factory'; import { ActionState } from '../../../../../../store/src/reducers/api-request-reducer/types'; import { getAPIRequestDataState } from '../../../../../../store/src/selectors/api.selectors'; import { stratosEntityCatalog } from '../../../../../../store/src/stratos-entity-catalog'; @@ -69,7 +69,7 @@ export class CreateEndpointCfStep1Component implements IStepperStep, AfterConten map(([pagination, entities]) => { const pages = Object.values(pagination.ids); const page = [].concat.apply([], pages); - const endpoints = page.length ? denormalize(page, [stratosEntityFactory(endpointSchemaKey)], entities) : []; + const endpoints = page.length ? denormalize(page, [stratosEntityFactory(endpointEntityType)], entities) : []; return { names: endpoints.map(ep => ep.name), urls: endpoints.map(ep => getFullEndpointApiUrl(ep)), diff --git a/src/frontend/packages/core/src/features/endpoints/create-endpoint/create-endpoint-connect/create-endpoint-connect.component.ts b/src/frontend/packages/core/src/features/endpoints/create-endpoint/create-endpoint-connect/create-endpoint-connect.component.ts index 9fc5b74dee..7be71e52aa 100644 --- a/src/frontend/packages/core/src/features/endpoints/create-endpoint/create-endpoint-connect/create-endpoint-connect.component.ts +++ b/src/frontend/packages/core/src/features/endpoints/create-endpoint/create-endpoint-connect/create-endpoint-connect.component.ts @@ -1,9 +1,7 @@ import { Component, OnDestroy } from '@angular/core'; -import { Store } from '@ngrx/store'; import { Observable, of } from 'rxjs'; import { map } from 'rxjs/operators'; -import { EndpointOnlyAppState } from '../../../../../../store/src/app-state'; import { EndpointsService } from '../../../../core/endpoints.service'; import { MarkdownPreviewComponent } from '../../../../shared/components/markdown-preview/markdown-preview.component'; import { IStepperStep, StepOnNextResult } from '../../../../shared/components/stepper/step/step.component'; @@ -26,7 +24,6 @@ export class CreateEndpointConnectComponent implements OnDestroy, IStepperStep { public doConnect = false; constructor( - private store: Store, private endpointsService: EndpointsService, private sidePanelService: SidePanelService, ) { @@ -37,7 +34,7 @@ export class CreateEndpointConnectComponent implements OnDestroy, IStepperStep { } onEnter = (data: ConnectEndpointConfig) => { - this.connectService = new ConnectEndpointService(this.store, this.endpointsService, data); + this.connectService = new ConnectEndpointService(this.endpointsService, data); } onNext = (): Observable => this.doConnect ? this.connectService.submit().pipe( diff --git a/src/frontend/packages/core/src/features/error-page/error-page/error-page.component.ts b/src/frontend/packages/core/src/features/error-page/error-page/error-page.component.ts index f820100541..e1c918d6db 100644 --- a/src/frontend/packages/core/src/features/error-page/error-page/error-page.component.ts +++ b/src/frontend/packages/core/src/features/error-page/error-page/error-page.component.ts @@ -7,7 +7,7 @@ import { first, map, withLatestFrom } from 'rxjs/operators'; import { SendClearEndpointEventsAction } from '../../../../../store/src/actions/internal-events.actions'; import { AppState } from '../../../../../store/src/app-state'; -import { endpointSchemaKey } from '../../../../../store/src/helpers/stratos-entity-factory'; +import { endpointEntityType } from '../../../../../store/src/helpers/stratos-entity-factory'; import { InternalEventMonitorFactory } from '../../../../../store/src/monitors/internal-event-monitor.factory'; import { stratosEntityCatalog } from '../../../../../store/src/stratos-entity-catalog'; import { EndpointModel } from '../../../../../store/src/types/endpoint.types'; @@ -36,7 +36,7 @@ export class ErrorPageComponent implements OnInit { const endpointId = this.activatedRoute.snapshot.params.endpointId; if (endpointId) { const endpointMonitor = stratosEntityCatalog.endpoint.store.getEntityMonitor(endpointId); - const cfEndpointEventMonitor = this.internalEventMonitorFactory.getMonitor(endpointSchemaKey, of([endpointId])); + const cfEndpointEventMonitor = this.internalEventMonitorFactory.getMonitor(endpointEntityType, of([endpointId])); this.errorDetails$ = cfEndpointEventMonitor.hasErroredOverTimeNoPoll(30).pipe( withLatestFrom(endpointMonitor.entity$), map(([errors, endpoint]) => { diff --git a/src/frontend/packages/core/src/features/metrics/services/metrics-service.ts b/src/frontend/packages/core/src/features/metrics/services/metrics-service.ts index 6fca8aaefc..b375e0b475 100644 --- a/src/frontend/packages/core/src/features/metrics/services/metrics-service.ts +++ b/src/frontend/packages/core/src/features/metrics/services/metrics-service.ts @@ -2,11 +2,10 @@ import { Injectable } from '@angular/core'; import { Observable } from 'rxjs'; import { map, publishReplay, refCount } from 'rxjs/operators'; -import { endpointEntitySchema } from '../../../../../store/src/base-entity-schemas'; import { PaginationMonitor } from '../../../../../store/src/monitors/pagination-monitor'; -import { PaginationMonitorFactory } from '../../../../../store/src/monitors/pagination-monitor.factory'; +import { stratosEntityCatalog } from '../../../../../store/src/stratos-entity-catalog'; import { APIResource, EntityInfo } from '../../../../../store/src/types/api.types'; -import { endpointListKey, EndpointModel } from '../../../../../store/src/types/endpoint.types'; +import { EndpointModel } from '../../../../../store/src/types/endpoint.types'; import { getFullEndpointApiUrl } from '../../endpoints/endpoint-helpers'; export interface MetricsEndpointProvider { @@ -22,14 +21,8 @@ export class MetricsService { haveNoMetricsEndpoints$: Observable; haveNoConnectedMetricsEndpoints$: Observable; - constructor( - private paginationMonitorFactory: PaginationMonitorFactory - ) { - this.endpointsMonitor = this.paginationMonitorFactory.create( - endpointListKey, - endpointEntitySchema, - true - ); + constructor() { + this.endpointsMonitor = stratosEntityCatalog.endpoint.store.getPaginationMonitor() this.setupObservables(); } diff --git a/src/frontend/packages/core/src/shared/components/favorites-meta-card/favorites-meta-card.component.ts b/src/frontend/packages/core/src/shared/components/favorites-meta-card/favorites-meta-card.component.ts index a559cedad0..8a31c98459 100644 --- a/src/frontend/packages/core/src/shared/components/favorites-meta-card/favorites-meta-card.component.ts +++ b/src/frontend/packages/core/src/shared/components/favorites-meta-card/favorites-meta-card.component.ts @@ -3,13 +3,11 @@ import { Store } from '@ngrx/store'; import { isObservable, Observable, of as observableOf } from 'rxjs'; import { map } from 'rxjs/operators'; -import { - RemoveUserFavoriteAction, -} from '../../../../../store/src/actions/user-favourites-actions/remove-user-favorite-action'; import { AppState } from '../../../../../store/src/app-state'; -import { userFavoritesEntitySchema } from '../../../../../store/src/base-entity-schemas'; import { entityCatalog } from '../../../../../store/src/entity-catalog/entity-catalog'; +import { stratosEntityFactory, userFavouritesEntityType } from '../../../../../store/src/helpers/stratos-entity-factory'; import { endpointEntitiesSelector } from '../../../../../store/src/selectors/endpoint.selectors'; +import { stratosEntityCatalog } from '../../../../../store/src/stratos-entity-catalog'; import { IFavoriteMetadata, UserFavorite } from '../../../../../store/src/types/user-favorites.types'; import { IFavoriteEntity } from '../../../../../store/src/user-favorite-manager'; import { isEndpointConnected } from '../../../features/endpoints/connect.service'; @@ -72,6 +70,7 @@ export class FavoritesMetaCardComponent { @Input() set favoriteEntity(favoriteEntity: IFavoriteEntity) { if (!this.placeholder && favoriteEntity) { + // TODO: RC selector, and remove store const endpoint$ = this.store.select(endpointEntitiesSelector).pipe( map(endpoints => endpoints[favoriteEntity.favorite.endpointId]) ); @@ -83,7 +82,7 @@ export class FavoritesMetaCardComponent { this.favorite = favorite; this.metaFavorite = !this.endpoint || (this.endpoint && !this.endpointHasEntities) ? favorite : null; this.prettyName = prettyName || 'Unknown'; - this.entityConfig = new ComponentEntityMonitorConfig(favorite.guid, userFavoritesEntitySchema); + this.entityConfig = new ComponentEntityMonitorConfig(favorite.guid, stratosEntityFactory(userFavouritesEntityType)); // If this favorite is an endpoint, lookup the image for it from the entitiy catalog if (this.favorite.entityType === 'endpoint') { @@ -131,7 +130,7 @@ export class FavoritesMetaCardComponent { } private removeFavorite = () => { - this.store.dispatch(new RemoveUserFavoriteAction(this.favorite)); + stratosEntityCatalog.userFavorite.api.delete(this.favorite); } public toggleMoreError() { diff --git a/src/frontend/packages/core/src/shared/components/list/list-types/endpoint/base-endpoints-data-source.ts b/src/frontend/packages/core/src/shared/components/list/list-types/endpoint/base-endpoints-data-source.ts index 5c09125f76..afacea4130 100644 --- a/src/frontend/packages/core/src/shared/components/list/list-types/endpoint/base-endpoints-data-source.ts +++ b/src/frontend/packages/core/src/shared/components/list/list-types/endpoint/base-endpoints-data-source.ts @@ -5,13 +5,14 @@ import { map, pairwise, tap, withLatestFrom } from 'rxjs/operators'; import { GetAllEndpoints } from '../../../../../../../store/src/actions/endpoint.actions'; import { CreatePagination } from '../../../../../../../store/src/actions/pagination.actions'; import { AppState } from '../../../../../../../store/src/app-state'; -import { endpointSchemaKey, stratosEntityFactory } from '../../../../../../../store/src/helpers/stratos-entity-factory'; +import { endpointEntityType } from '../../../../../../../store/src/helpers/stratos-entity-factory'; import { EntityMonitorFactory } from '../../../../../../../store/src/monitors/entity-monitor.factory.service'; import { InternalEventMonitorFactory } from '../../../../../../../store/src/monitors/internal-event-monitor.factory'; import { PaginationMonitorFactory } from '../../../../../../../store/src/monitors/pagination-monitor.factory'; import { endpointEntitiesSelector } from '../../../../../../../store/src/selectors/endpoint.selectors'; import { EndpointModel } from '../../../../../../../store/src/types/endpoint.types'; -import { DataFunctionDefinition, ListDataSource } from '../../data-sources-controllers/list-data-source'; +import { ListDataSource } from '../../data-sources-controllers/list-data-source'; +import { IListDataSourceConfig } from '../../data-sources-controllers/list-data-source-config'; import { RowsState } from '../../data-sources-controllers/list-data-source-types'; import { TableRowStateManager } from '../../list-table/table-row/table-row-state-manager'; import { IListConfig } from '../../list.component.types'; @@ -91,7 +92,6 @@ export class BaseEndpointsDataSource extends ListDataSource { this.dsEndpointType = dsEndpointType; } - // TODO: RC what is this? static getEndpointConfig( store: Store, action: GetAllEndpoints, @@ -99,12 +99,12 @@ export class BaseEndpointsDataSource extends ListDataSource { rowsState: Observable, destroy: () => void, refresh: () => void - ) { + ): IListDataSourceConfig { return { store, action, - schema: stratosEntityFactory(endpointSchemaKey), - getRowUniqueId: object => object.guid, + schema: action.entity[0], + getRowUniqueId: (object) => action.entity[0].getId(object), getEmptyType: () => ({ name: '', system_shared_token: false, @@ -118,7 +118,7 @@ export class BaseEndpointsDataSource extends ListDataSource { type: 'filter', field: 'name' }, - ] as DataFunctionDefinition[], + ], listConfig, rowsState, destroy, @@ -130,7 +130,7 @@ export class BaseEndpointsDataSource extends ListDataSource { rowStateManager: TableRowStateManager, store: Store ) { - const eventMonitor = internalEventMonitorFactory.getMonitor(endpointSchemaKey); + const eventMonitor = internalEventMonitorFactory.getMonitor(endpointEntityType); return eventMonitor.hasErroredOverTime().pipe( withLatestFrom(store.select(endpointEntitiesSelector)), tap(([errored, endpoints]) => Object.keys(errored).forEach(id => { diff --git a/src/frontend/packages/core/src/shared/components/list/list-types/endpoint/endpoint-data-source.helpers.ts b/src/frontend/packages/core/src/shared/components/list/list-types/endpoint/endpoint-data-source.helpers.ts index 3c9cc0c03e..e5862804f9 100644 --- a/src/frontend/packages/core/src/shared/components/list/list-types/endpoint/endpoint-data-source.helpers.ts +++ b/src/frontend/packages/core/src/shared/components/list/list-types/endpoint/endpoint-data-source.helpers.ts @@ -1,12 +1,12 @@ - import { combineLatest } from 'rxjs'; import { distinctUntilChanged, map, mergeMap, switchMap, tap } from 'rxjs/operators'; +import { DisconnectEndpoint } from '../../../../../../../store/src/actions/endpoint.actions'; import { EntityMonitorFactory } from '../../../../../../../store/src/monitors/entity-monitor.factory.service'; import { PaginationMonitor } from '../../../../../../../store/src/monitors/pagination-monitor'; -import { TableRowStateManager } from '../../list-table/table-row/table-row-state-manager'; import { EndpointModel } from '../../../../../../../store/src/types/endpoint.types'; -import { EndpointsEffect } from '../../../../../../../store/src/effects/endpoint.effects'; +import { TableRowStateManager } from '../../list-table/table-row/table-row-state-manager'; + export function EndpointRowStateSetUpManager( paginationMonitor: PaginationMonitor, @@ -21,7 +21,7 @@ export function EndpointRowStateSetUpManager( .create(entity.guid, paginationMonitor.entityConfig); const request$ = entityMonitor.entityRequest$.pipe( map(request => { - const disconnect = request.updating[EndpointsEffect.disconnectingKey] || { busy: false }; + const disconnect = request.updating[DisconnectEndpoint.UpdatingKey] || { busy: false }; const unregister = request.deleting || { busy: false }; const busy = disconnect.busy || unregister.busy; const blocked = unregister.busy; diff --git a/src/frontend/packages/core/src/shared/components/recent-entities/recent-entities.component.ts b/src/frontend/packages/core/src/shared/components/recent-entities/recent-entities.component.ts index c07b99ef1a..86af699f5c 100644 --- a/src/frontend/packages/core/src/shared/components/recent-entities/recent-entities.component.ts +++ b/src/frontend/packages/core/src/shared/components/recent-entities/recent-entities.component.ts @@ -5,7 +5,7 @@ import { Observable, of as observableOf } from 'rxjs'; import { filter, map } from 'rxjs/operators'; import { AppState } from '../../../../../store/src/app-state'; -import { endpointSchemaKey } from '../../../../../store/src/helpers/stratos-entity-factory'; +import { endpointEntityType } from '../../../../../store/src/helpers/stratos-entity-factory'; import { endpointEntitiesSelector } from '../../../../../store/src/selectors/endpoint.selectors'; import { recentlyVisitedSelector } from '../../../../../store/src/selectors/recently-visitied.selectors'; import { @@ -29,7 +29,7 @@ class RenderableRecent { public mostRecentHit: moment.Moment; public subText$: Observable; constructor(readonly entity: IRecentlyVisitedEntity, private store: Store) { - if (entity.entityType === endpointSchemaKey) { + if (entity.entityType === endpointEntityType) { this.subText$ = observableOf(entity.prettyType); } else { this.subText$ = this.store.select(endpointEntitiesSelector).pipe( diff --git a/src/frontend/packages/core/src/shared/entity.tokens.ts b/src/frontend/packages/core/src/shared/entity.tokens.ts index ad4c9476e6..0a4b9da0e9 100644 --- a/src/frontend/packages/core/src/shared/entity.tokens.ts +++ b/src/frontend/packages/core/src/shared/entity.tokens.ts @@ -1,8 +1,4 @@ import { InjectionToken } from '@angular/core'; -import { EntityService } from '../../../store/src/entity-service'; - export const CF_GUID = new InjectionToken('cfGuid'); export const APP_GUID = new InjectionToken('appGuid'); - -export const ENTITY_SERVICE = new InjectionToken(null); diff --git a/src/frontend/packages/core/test-framework/entity-service.helper.ts b/src/frontend/packages/core/test-framework/entity-service.helper.ts deleted file mode 100644 index f01fb32974..0000000000 --- a/src/frontend/packages/core/test-framework/entity-service.helper.ts +++ /dev/null @@ -1,28 +0,0 @@ -import { Store } from '@ngrx/store'; -import { schema as normalizrSchema } from 'normalizr'; -import { EntityRequestAction } from '../../store/src/types/request.types'; -import { EntityServiceFactory } from '../../store/src/entity-service-factory.service'; -import { ENTITY_SERVICE } from '../src/shared/entity.tokens'; -import { AppState } from '../../store/src/app-state'; - -export function generateTestEntityServiceProvider( - guid: string, - schema: normalizrSchema.Entity, - action: EntityRequestAction -) { - function useFactory( - store: Store, - entityServiceFactory: EntityServiceFactory - ) { - return entityServiceFactory.create( - guid, - action - ); - } - - return { - provide: ENTITY_SERVICE, - useFactory, - deps: [Store, EntityServiceFactory] - }; -} diff --git a/src/frontend/packages/store/src/actions/endpoint.actions.ts b/src/frontend/packages/store/src/actions/endpoint.actions.ts index 54fc8cdef5..e7998aeca2 100644 --- a/src/frontend/packages/store/src/actions/endpoint.actions.ts +++ b/src/frontend/packages/store/src/actions/endpoint.actions.ts @@ -1,9 +1,9 @@ import { Action } from '@ngrx/store'; import { EndpointType } from '../extension-types'; -import { endpointSchemaKey, STRATOS_ENDPOINT_TYPE } from '../helpers/stratos-entity-factory'; +import { endpointEntityType, STRATOS_ENDPOINT_TYPE, stratosEntityFactory } from '../helpers/stratos-entity-factory'; import { NormalizedResponse } from '../types/api.types'; -import { endpointListKey, EndpointModel } from '../types/endpoint.types'; +import { endpointListKey, EndpointModel, INewlyConnectedEndpointInfo } from '../types/endpoint.types'; import { PaginatedAction } from '../types/pagination.types'; import { EntityRequestAction } from '../types/request.types'; @@ -13,6 +13,10 @@ export const GET_ENDPOINTS_LOGIN = '[Endpoints] Get all at login'; // TODO: RD H export const GET_ENDPOINTS_SUCCESS = '[Endpoints] Get all success'; export const GET_ENDPOINTS_FAILED = '[Endpoints] Get all failed'; +export const GET_ENDPOINT = '[Endpoints] Get'; +export const GET_ENDPOINT_SUCCESS = '[Endpoints] Get success'; +export const GET_ENDPOINT_FAILED = '[Endpoints] Get failed'; + export const CONNECT_ENDPOINTS = '[Endpoints] Connect'; export const CONNECT_ENDPOINTS_SUCCESS = '[Endpoints] Connect succeed'; export const CONNECT_ENDPOINTS_FAILED = '[Endpoints] Connect failed'; @@ -33,43 +37,30 @@ export const UPDATE_ENDPOINT = '[Endpoints] Update'; export const UPDATE_ENDPOINT_SUCCESS = '[Endpoints] Update succeed'; export const UPDATE_ENDPOINT_FAILED = '[Endpoints] Update failed'; -// TODO: RC delete -// export class EndpointActionComplete implements Action { -// constructor( -// public type: string, -// public guid: string, -// public endpointType: EndpointType, -// public endpoint: EndpointModel | INewlyConnectedEndpointInfo -// ) { } -// } - - -// export class EndpointAction implements Action { -// type: string; -// endpointType: EndpointType; -// } - -export class GetAllEndpointsSuccess implements Action { - constructor(public payload: NormalizedResponse, public login = false) { } - type = GET_ENDPOINTS_SUCCESS; +export class EndpointActionComplete implements Action { + constructor( + public type: string, + public guid: string, + public endpointType: EndpointType, + public endpoint: EndpointModel | INewlyConnectedEndpointInfo + ) { } } -abstract class BaseEndpointAction implements EntityRequestAction { - public entityType = endpointSchemaKey; +export abstract class BaseEndpointAction implements EntityRequestAction { + public entityType = endpointEntityType; public endpointType = STRATOS_ENDPOINT_TYPE; public subType = ''; + public entity = [stratosEntityFactory(endpointEntityType)] constructor(public type: string) { } actions: string[]; - // TODO: RC SCHEMAS everywhere } -abstract class SingleBaseEndpointAction extends BaseEndpointAction { +export abstract class SingleBaseEndpointAction extends BaseEndpointAction { constructor( type: string, public guid: string ) { super(type); - } } @@ -79,7 +70,6 @@ abstract class MultipleBaseEndpointAction extends BaseEndpointAction implements public paginationKey: string ) { super(type); - } } @@ -96,6 +86,22 @@ export interface AuthParamsToken { // All supported auth params types export type AuthParams = AuthParamsUsernamePassword | AuthParamsToken; +export class GetEndpoint extends SingleBaseEndpointAction { + constructor( + guid: string + ) { + super( + GET_ENDPOINT, + guid + ) + } + actions = [ + GET_ENDPOINT, + GET_ENDPOINT_SUCCESS, + GET_ENDPOINT_FAILED + ]; +} + export class GetAllEndpoints extends MultipleBaseEndpointAction { public static storeKey = endpointListKey; constructor( @@ -119,6 +125,14 @@ export class GetAllEndpoints extends MultipleBaseEndpointAction { }; } +export class GetAllEndpointsSuccess extends GetAllEndpoints { + constructor(public payload: NormalizedResponse, public login = false) { + super(login) + console.log(this.type);// TODO: RC test type + } + type = GET_ENDPOINTS_SUCCESS; +} + export class ConnectEndpoint extends SingleBaseEndpointAction { static UpdatingKey = 'connectingKey' constructor( diff --git a/src/frontend/packages/store/src/actions/metrics.actions.ts b/src/frontend/packages/store/src/actions/metrics.actions.ts index ae1bf4b3a9..947b43aba1 100644 --- a/src/frontend/packages/store/src/actions/metrics.actions.ts +++ b/src/frontend/packages/store/src/actions/metrics.actions.ts @@ -1,5 +1,5 @@ import { MetricQueryType } from '../../../core/src/shared/services/metrics-range-selector.types'; -import { metricEntityType } from '../base-entity-schemas'; +import { metricEntityType } from '../helpers/stratos-entity-factory'; import { proxyAPIVersion } from '../jetstream'; import { EntityRequestAction } from '../types/request.types'; diff --git a/src/frontend/packages/store/src/actions/system.actions.ts b/src/frontend/packages/store/src/actions/system.actions.ts index 271c361442..208e19a4de 100644 --- a/src/frontend/packages/store/src/actions/system.actions.ts +++ b/src/frontend/packages/store/src/actions/system.actions.ts @@ -1,10 +1,9 @@ import { Action } from '@ngrx/store'; -import { STRATOS_ENDPOINT_TYPE } from '../../../core/src/base-entity-schemas'; -import { stratosEntityFactory, systemInfoSchemaKey } from '../helpers/stratos-entity-factory'; +import { STRATOS_ENDPOINT_TYPE, stratosEntityFactory, systemInfoEntityType } from '../helpers/stratos-entity-factory'; import { EntityRequestAction } from '../types/request.types'; import { SystemInfo } from '../types/system.types'; -import { GetAllEndpoints } from './endpoint.actions'; +import { BaseEndpointAction, GetAllEndpoints } from './endpoint.actions'; export const GET_SYSTEM_INFO = '[System] Get info'; export const GET_SYSTEM_INFO_SUCCESS = '[System] Get info success'; @@ -12,15 +11,14 @@ export const GET_SYSTEM_INFO_FAILED = '[System] Get info failed'; export class GetSystemInfo implements EntityRequestAction { guid = 'info'; - constructor(public login = false, public associatedAction?: GetAllEndpoints) { + constructor(public login = false, public associatedAction?: BaseEndpointAction) { if (!this.associatedAction) { - this.associatedAction = new GetAllEndpoints(login); // TODO: RC + this.associatedAction = new GetAllEndpoints(login); } } - // TODO: RC WHERE SHOULD THIS BE STORED - schemaKey = systemInfoSchemaKey; - entity = [stratosEntityFactory(systemInfoSchemaKey)] - entityType = systemInfoSchemaKey; + schemaKey = systemInfoEntityType; + entity = [stratosEntityFactory(systemInfoEntityType)] + entityType = systemInfoEntityType; endpointType = STRATOS_ENDPOINT_TYPE; type = GET_SYSTEM_INFO; actions = [ @@ -31,11 +29,6 @@ export class GetSystemInfo implements EntityRequestAction { } export class GetSystemSuccess implements Action { - constructor(public payload: SystemInfo, public login = false, public associatedAction: GetAllEndpoints) { } + constructor(public payload: SystemInfo, public login = false, public associatedAction: BaseEndpointAction) { } type = GET_SYSTEM_INFO_SUCCESS; } - -// export class GetSystemFailed implements Action { -// type = GET_SYSTEM_INFO_FAILED; -// } - diff --git a/src/frontend/packages/store/src/actions/user-favourites-actions/base-user-favorites-action.ts b/src/frontend/packages/store/src/actions/user-favourites-actions/base-user-favorites-action.ts deleted file mode 100644 index b5438b6161..0000000000 --- a/src/frontend/packages/store/src/actions/user-favourites-actions/base-user-favorites-action.ts +++ /dev/null @@ -1,11 +0,0 @@ -// import { Action } from '@ngrx/store'; - -// export class BaseUserFavoritesAction implements Action { -// constructor( -// actionType: string, -// ) { -// this.type = actionType; -// } -// public type: string; -// public url = '/user-favorites'; -// } diff --git a/src/frontend/packages/store/src/actions/user-favourites-actions/get-user-favorites-action.ts b/src/frontend/packages/store/src/actions/user-favourites-actions/get-user-favorites-action.ts deleted file mode 100644 index b0b3eed95b..0000000000 --- a/src/frontend/packages/store/src/actions/user-favourites-actions/get-user-favorites-action.ts +++ /dev/null @@ -1,30 +0,0 @@ -import { BaseUserFavoritesAction } from './base-user-favorites-action'; -import { UserFavorite, IFavoriteMetadata } from '../../types/user-favorites.types'; - -export class GetUserFavoritesAction extends BaseUserFavoritesAction { - static ACTION_TYPE = 'GET_USER_FAVORITES'; - constructor() { - super( - GetUserFavoritesAction.ACTION_TYPE - ); - } -} - -export class GetUserFavoritesSuccessAction extends BaseUserFavoritesAction { - static ACTION_TYPE = 'GET_USER_FAVORITES_SUCCESS'; - constructor(public favorites: UserFavorite[]) { - super( - GetUserFavoritesSuccessAction.ACTION_TYPE - ); - } -} - -export class GetUserFavoritesFailedAction extends BaseUserFavoritesAction { - static ACTION_TYPE = 'GET_USER_FAVORITES_FAILED'; - constructor() { - super( - GetUserFavoritesFailedAction.ACTION_TYPE - ); - } -} - diff --git a/src/frontend/packages/store/src/actions/user-favourites-actions/remove-user-favorite-action.ts b/src/frontend/packages/store/src/actions/user-favourites-actions/remove-user-favorite-action.ts deleted file mode 100644 index 89bcd7d47e..0000000000 --- a/src/frontend/packages/store/src/actions/user-favourites-actions/remove-user-favorite-action.ts +++ /dev/null @@ -1,21 +0,0 @@ -import { BaseUserFavoritesAction } from './base-user-favorites-action'; -import { UserFavorite, IFavoriteMetadata } from '../../types/user-favorites.types'; - -export class RemoveUserFavoriteAction extends BaseUserFavoritesAction { - static ACTION_TYPE = 'REMOVE_USER_FAVORITE'; - constructor(public favorite: UserFavorite) { - super( - RemoveUserFavoriteAction.ACTION_TYPE - ); - } -} - -export class RemoveUserFavoriteSuccessAction extends BaseUserFavoritesAction { - static ACTION_TYPE = 'REMOVE_USER_FAVORITE_SUCCESS'; - constructor(public favorite: UserFavorite) { - super( - RemoveUserFavoriteSuccessAction.ACTION_TYPE - ); - } -} - diff --git a/src/frontend/packages/store/src/actions/user-favourites-actions/save-user-favorite-action.ts b/src/frontend/packages/store/src/actions/user-favourites-actions/save-user-favorite-action.ts deleted file mode 100644 index b38c8199de..0000000000 --- a/src/frontend/packages/store/src/actions/user-favourites-actions/save-user-favorite-action.ts +++ /dev/null @@ -1,25 +0,0 @@ -import { IFavoriteMetadata } from './../../types/user-favorites.types'; -import { BaseUserFavoritesAction } from './base-user-favorites-action'; -import { UserFavorite } from '../../types/user-favorites.types'; - -export class SaveUserFavoriteAction extends BaseUserFavoritesAction { - static ACTION_TYPE = 'SAVE_USER_FAVORITE'; - constructor( - public favorite: UserFavorite - ) { - super( - SaveUserFavoriteAction.ACTION_TYPE - ); - } -} - -export class SaveUserFavoriteSuccessAction extends BaseUserFavoritesAction { - static ACTION_TYPE = 'SAVE_USER_FAVORITE_SUCCESS'; - constructor( - public favorite: UserFavorite - ) { - super( - SaveUserFavoriteSuccessAction.ACTION_TYPE - ); - } -} diff --git a/src/frontend/packages/store/src/actions/user-favourites-actions/toggle-user-favorite-action.ts b/src/frontend/packages/store/src/actions/user-favourites-actions/toggle-user-favorite-action.ts deleted file mode 100644 index 03a6100d31..0000000000 --- a/src/frontend/packages/store/src/actions/user-favourites-actions/toggle-user-favorite-action.ts +++ /dev/null @@ -1,13 +0,0 @@ -import { BaseUserFavoritesAction } from './base-user-favorites-action'; -import { UserFavorite, IFavoriteMetadata } from '../../types/user-favorites.types'; - -export class ToggleUserFavoriteAction extends BaseUserFavoritesAction { - static ACTION_TYPE = 'TOGGLE_USER_FAVORITE'; - constructor( - public favorite: UserFavorite - ) { - super( - ToggleUserFavoriteAction.ACTION_TYPE - ); - } -} diff --git a/src/frontend/packages/store/src/actions/user-favourites-actions/update-user-favorite-metadata-action.ts b/src/frontend/packages/store/src/actions/user-favourites-actions/update-user-favorite-metadata-action.ts deleted file mode 100644 index 3707f615f1..0000000000 --- a/src/frontend/packages/store/src/actions/user-favourites-actions/update-user-favorite-metadata-action.ts +++ /dev/null @@ -1,21 +0,0 @@ -import { UserFavorite, IFavoriteMetadata } from '../../types/user-favorites.types'; -import { BaseUserFavoritesAction } from './base-user-favorites-action'; - -export class UpdateUserFavoriteMetadataAction extends BaseUserFavoritesAction { - static ACTION_TYPE = 'UPDATE_FAVORITE_METADATA'; - constructor(public favorite: UserFavorite) { - super( - UpdateUserFavoriteMetadataAction.ACTION_TYPE - ); - } -} - -export class UpdateUserFavoriteMetadataSuccessAction extends BaseUserFavoritesAction { - static ACTION_TYPE = 'UPDATE_FAVORITE_METADATA_SUCCESS'; - constructor(public favorite: UserFavorite) { - super( - UpdateUserFavoriteMetadataSuccessAction.ACTION_TYPE - ); - } -} - diff --git a/src/frontend/packages/store/src/actions/user-favourites-actions/user-favourites.actions.ts b/src/frontend/packages/store/src/actions/user-favourites-actions/user-favourites.actions.ts deleted file mode 100644 index f24e18fec6..0000000000 --- a/src/frontend/packages/store/src/actions/user-favourites-actions/user-favourites.actions.ts +++ /dev/null @@ -1,16 +0,0 @@ -import { STRATOS_ENDPOINT_TYPE, stratosEntityFactory, userFavouritesSchemaKey } from '../../helpers/stratos-entity-factory'; -import { EntityRequestAction } from '../../types/request.types'; - -export class BaseUserFavoritesAction implements EntityRequestAction { - constructor( - actionType: string, - ) { - this.type = actionType; - } - public type: string; - public url = '/user-favorites'; - - public entity = [stratosEntityFactory(userFavouritesSchemaKey)] - public entityType = userFavouritesSchemaKey; - public endpointType = STRATOS_ENDPOINT_TYPE; -} diff --git a/src/frontend/packages/store/src/actions/user-favourites.actions.ts b/src/frontend/packages/store/src/actions/user-favourites.actions.ts new file mode 100644 index 0000000000..76101f101c --- /dev/null +++ b/src/frontend/packages/store/src/actions/user-favourites.actions.ts @@ -0,0 +1,145 @@ +import { STRATOS_ENDPOINT_TYPE, stratosEntityFactory, userFavouritesEntityType } from '../helpers/stratos-entity-factory'; +import { PaginatedAction } from '../types/pagination.types'; +import { EntityRequestAction } from '../types/request.types'; +import { IFavoriteMetadata, UserFavorite } from '../types/user-favorites.types'; + +abstract class BaseUserFavoritesAction implements EntityRequestAction { + constructor( + actionType: string, + ) { + this.type = actionType; + } + public type: string; + public url = '/user-favorites'; + + public entity = [stratosEntityFactory(userFavouritesEntityType)] + public entityType = userFavouritesEntityType; + public endpointType = STRATOS_ENDPOINT_TYPE; +} + + +abstract class BaseSingleUserFavouritesAction extends BaseUserFavoritesAction { + constructor(actionType: string, public guid: string) { + super(actionType); + } +} + +abstract class BaseMultipleUserFavouritesAction extends BaseUserFavoritesAction implements PaginatedAction { + guid: string; + constructor(actionType: string, public paginationKey: string) { + super(actionType); + } +} + + +abstract class BaseSuccessFavouritesAction extends BaseMultipleUserFavouritesAction { + constructor( + paginationKey: string, + public favorites: UserFavorite[], + type: string + ) { + super(type, paginationKey); + } +} + +abstract class BaseSuccessFavouriteAction extends BaseSingleUserFavouritesAction { + constructor( + public favorite: UserFavorite, + type: string + ) { + super(type, favorite.guid); + } +} + +// --------- + +export class GetUserFavoritesAction extends BaseMultipleUserFavouritesAction { + static PAGINATION_KEY = 'user_favourites'; + static ACTION_TYPE = 'GET_USER_FAVORITES'; + constructor() { + super( + GetUserFavoritesAction.ACTION_TYPE, + GetUserFavoritesAction.PAGINATION_KEY + ); + } +} + +export class GetUserFavoritesSuccessAction extends BaseSuccessFavouritesAction { + static ACTION_TYPE = 'GET_USER_FAVORITES_SUCCESS'; + constructor(favorites: UserFavorite[]) { + super( + GetUserFavoritesAction.PAGINATION_KEY, + favorites, + GetUserFavoritesSuccessAction.ACTION_TYPE + ); + } +} + +export class GetUserFavoritesFailedAction extends BaseMultipleUserFavouritesAction { + static ACTION_TYPE = 'GET_USER_FAVORITES_FAILED'; + constructor() { + super( + GetUserFavoritesFailedAction.ACTION_TYPE, + GetUserFavoritesAction.PAGINATION_KEY + ); + } +} + +// --------- + +export class RemoveUserFavoriteAction extends BaseSingleUserFavouritesAction { + static ACTION_TYPE = 'REMOVE_USER_FAVORITE'; + constructor(public favorite: UserFavorite) { + super( + favorite.guid, + RemoveUserFavoriteAction.ACTION_TYPE + ); + } +} + +export class RemoveUserFavoriteSuccessAction extends BaseSuccessFavouriteAction { + static ACTION_TYPE = 'REMOVE_USER_FAVORITE_SUCCESS'; + constructor(favorite: UserFavorite) { + super(favorite, RemoveUserFavoriteSuccessAction.ACTION_TYPE); + } +} + +// --------- + +export class SaveUserFavoriteAction extends BaseSingleUserFavouritesAction { + static ACTION_TYPE = 'SAVE_USER_FAVORITE'; + constructor(public favorite: UserFavorite) { + super(SaveUserFavoriteAction.ACTION_TYPE, favorite.guid); + } +} + +export class SaveUserFavoriteSuccessAction extends BaseSuccessFavouriteAction { + static ACTION_TYPE = 'SAVE_USER_FAVORITE_SUCCESS'; + constructor(favorite: UserFavorite) { + super(favorite, SaveUserFavoriteSuccessAction.ACTION_TYPE); + } +} + +// --------- + +export class ToggleUserFavoriteAction extends BaseSingleUserFavouritesAction { + static ACTION_TYPE = 'TOGGLE_USER_FAVORITE'; + constructor(public favorite: UserFavorite) { + super(favorite.guid, ToggleUserFavoriteAction.ACTION_TYPE); + } +} + +// --------- +export class UpdateUserFavoriteMetadataAction extends BaseSingleUserFavouritesAction { + static ACTION_TYPE = 'UPDATE_FAVORITE_METADATA'; + constructor(public favorite: UserFavorite) { + super(favorite.guid, UpdateUserFavoriteMetadataAction.ACTION_TYPE); + } +} + +export class UpdateUserFavoriteMetadataSuccessAction extends BaseSuccessFavouriteAction { + static ACTION_TYPE = 'UPDATE_FAVORITE_METADATA_SUCCESS'; + constructor(public favorite: UserFavorite) { + super(favorite, UpdateUserFavoriteMetadataSuccessAction.ACTION_TYPE); + } +} diff --git a/src/frontend/packages/store/src/actions/user-profile.actions.ts b/src/frontend/packages/store/src/actions/user-profile.actions.ts index 6607f2d504..c4e25f1eb6 100644 --- a/src/frontend/packages/store/src/actions/user-profile.actions.ts +++ b/src/frontend/packages/store/src/actions/user-profile.actions.ts @@ -1,5 +1,4 @@ -import { userProfilePasswordUpdatingKey } from '../effects/user-profile.effects'; -import { STRATOS_ENDPOINT_TYPE, stratosEntityFactory, userProfileSchemaKey } from '../helpers/stratos-entity-factory'; +import { STRATOS_ENDPOINT_TYPE, stratosEntityFactory, userProfileEntityType } from '../helpers/stratos-entity-factory'; import { rootUpdatingKey } from '../reducers/api-request-reducer/types'; import { EntityRequestAction } from '../types/request.types'; import { UserProfileInfo, UserProfilePasswordUpdate } from '../types/user-profile.types'; @@ -11,9 +10,9 @@ export const UPDATE_USERPASSWORD = '[UserPassword] Update'; abstract class BaseProfileAction implements EntityRequestAction { static guid = 'userProfile'; guid = BaseProfileAction.guid; - entityType = userProfileSchemaKey; + entityType = userProfileEntityType; endpointType = STRATOS_ENDPOINT_TYPE; - entity = [stratosEntityFactory(userProfileSchemaKey)] + entity = [stratosEntityFactory(userProfileEntityType)] constructor(public type: string) { } } @@ -34,5 +33,5 @@ export class UpdateUserPasswordAction extends BaseProfileAction { constructor(public id: string, public passwordChanges: UserProfilePasswordUpdate) { super(UPDATE_USERPASSWORD); } - updatingKey = userProfilePasswordUpdatingKey + updatingKey = 'password' } diff --git a/src/frontend/packages/store/src/effects/endpoint-api-errors.effects.ts b/src/frontend/packages/store/src/effects/endpoint-api-errors.effects.ts index 8686993327..118abe2282 100644 --- a/src/frontend/packages/store/src/effects/endpoint-api-errors.effects.ts +++ b/src/frontend/packages/store/src/effects/endpoint-api-errors.effects.ts @@ -6,7 +6,7 @@ import { map } from 'rxjs/operators'; import { SendEventAction } from '../actions/internal-events.actions'; import { RequestTypes } from '../actions/request.actions'; import { InternalAppState } from '../app-state'; -import { endpointSchemaKey } from '../helpers/stratos-entity-factory'; +import { endpointEntityType } from '../helpers/stratos-entity-factory'; import { InternalEventSeverity } from '../types/internal-events.types'; import { WrapperRequestActionFailed } from '../types/request.types'; @@ -26,7 +26,7 @@ export class EndpointApiError { const { eventCode, message, error, url } = internalEndpointError; internalEndpointError.endpointIds.forEach(endpoint => this.store.dispatch( - new SendEventAction(endpointSchemaKey, endpoint, { + new SendEventAction(endpointEntityType, endpoint, { eventCode, severity: InternalEventSeverity.ERROR, message, diff --git a/src/frontend/packages/store/src/effects/endpoint.effects.ts b/src/frontend/packages/store/src/effects/endpoint.effects.ts index 9b553fe629..e649646f34 100644 --- a/src/frontend/packages/store/src/effects/endpoint.effects.ts +++ b/src/frontend/packages/store/src/effects/endpoint.effects.ts @@ -10,9 +10,12 @@ import { ConnectEndpoint, DISCONNECT_ENDPOINTS, DisconnectEndpoint, + EndpointActionComplete, + GET_ENDPOINT, GET_ENDPOINTS, GetAllEndpoints, GetAllEndpointsSuccess, + GetEndpoint, REGISTER_ENDPOINTS, RegisterEndpoint, UNREGISTER_ENDPOINTS, @@ -21,7 +24,6 @@ import { import { SendClearEventAction } from '../actions/internal-events.actions'; import { ClearPaginationOfEntity } from '../actions/pagination.actions'; import { GET_SYSTEM_INFO_SUCCESS, GetSystemSuccess } from '../actions/system.actions'; -import { GetUserFavoritesAction } from '../actions/user-favourites-actions/get-user-favorites-action'; import { DispatchOnlyAppState } from '../app-state'; import { entityCatalog } from '../entity-catalog/entity-catalog'; import { EndpointType } from '../extension-types'; @@ -48,6 +50,13 @@ export class EndpointsEffect { private store: Store ) { } + @Effect() getAllEndpoint$ = this.actions$.pipe( + ofType(GET_ENDPOINT), + mergeMap((action: GetEndpoint) => [ + stratosEntityCatalog.systemInfo.actions.getSystemInfo(false, action) + ]) + ); + @Effect() getAllEndpointsBySystemInfo$ = this.actions$.pipe( ofType(GET_ENDPOINTS), mergeMap((action: GetAllEndpoints) => [ @@ -85,7 +94,7 @@ export class EndpointsEffect { // (endpoint success) return [ new WrapperRequestActionSuccess(mappedData, associatedAction, 'fetch'), - new GetAllEndpointsSuccess(mappedData, associatedAction.login), + new GetAllEndpointsSuccess(mappedData, associatedAction['login']), ]; })); @@ -285,7 +294,7 @@ export class EndpointsEffect { if (apiActionType === 'delete') { actions.push(new ClearPaginationOfEntity(apiAction, apiAction.guid)); - actions.push(new GetUserFavoritesAction()); + actions.push(stratosEntityCatalog.userFavorite.actions.getAll()); } if (apiActionType === 'create') { diff --git a/src/frontend/packages/store/src/effects/system.effects.ts b/src/frontend/packages/store/src/effects/system.effects.ts index 04f272ae0e..ac2eaa6174 100644 --- a/src/frontend/packages/store/src/effects/system.effects.ts +++ b/src/frontend/packages/store/src/effects/system.effects.ts @@ -18,7 +18,7 @@ export class SystemEffects { private store: Store ) { } - // // TODO: RC + // // TODO: RC getSystemInfo vs getAllEndpoints. when to do start/finish. which to kick off process // static guid = 'info'; @Effect() getInfo$ = this.actions$.pipe( @@ -37,7 +37,7 @@ export class SystemEffects { return [ // new GetSystemFailed(), { type: action.actions[2] }, - new WrapperRequestActionFailed('Could not get system endpoints', associatedAction), + // new WrapperRequestActionFailed('Could not get system endpoints', associatedAction), new WrapperRequestActionFailed('Could not fetch system info', action) ]; })); diff --git a/src/frontend/packages/store/src/effects/user-favorites-effect.ts b/src/frontend/packages/store/src/effects/user-favorites-effect.ts index be235e1b03..82d4bf44aa 100644 --- a/src/frontend/packages/store/src/effects/user-favorites-effect.ts +++ b/src/frontend/packages/store/src/effects/user-favorites-effect.ts @@ -9,27 +9,19 @@ import { GetUserFavoritesAction, GetUserFavoritesFailedAction, GetUserFavoritesSuccessAction, -} from '../actions/user-favourites-actions/get-user-favorites-action'; -import { RemoveUserFavoriteAction, RemoveUserFavoriteSuccessAction, -} from '../actions/user-favourites-actions/remove-user-favorite-action'; -import { SaveUserFavoriteAction, SaveUserFavoriteSuccessAction, -} from '../actions/user-favourites-actions/save-user-favorite-action'; -import { ToggleUserFavoriteAction } from '../actions/user-favourites-actions/toggle-user-favorite-action'; -import { + ToggleUserFavoriteAction, UpdateUserFavoriteMetadataAction, UpdateUserFavoriteMetadataSuccessAction, -} from '../actions/user-favourites-actions/update-user-favorite-metadata-action'; +} from '../actions/user-favourites.actions'; import { DispatchOnlyAppState } from '../app-state'; -import { userFavoritesEntitySchema } from '../base-entity-schemas'; import { entityCatalog } from '../entity-catalog/entity-catalog'; import { proxyAPIVersion } from '../jetstream'; import { NormalizedResponse } from '../types/api.types'; -import { PaginatedAction } from '../types/pagination.types'; -import { WrapperRequestActionSuccess } from '../types/request.types'; +import { StartRequestAction, WrapperRequestActionFailed, WrapperRequestActionSuccess } from '../types/request.types'; import { IFavoriteMetadata, UserFavorite, userFavoritesPaginationKey } from '../types/user-favorites.types'; import { UserFavoriteManager } from '../user-favorite-manager'; @@ -50,25 +42,26 @@ export class UserFavoritesEffect { @Effect() saveFavorite = this.actions$.pipe( ofType(SaveUserFavoriteAction.ACTION_TYPE), mergeMap(action => { + const actionType = 'update'; + this.store.dispatch(new StartRequestAction(action, actionType)) return this.http.post>(favoriteUrlPath, action.favorite).pipe( - mergeMap(newFavorite => { - return [ - new SaveUserFavoriteSuccessAction(newFavorite) - ]; - }) + mergeMap(newFavorite => [ + new WrapperRequestActionSuccess(null, action, actionType), + new SaveUserFavoriteSuccessAction(newFavorite) + ]), + catchError(() => [ + new WrapperRequestActionFailed('Failed to update user favorite', action, actionType) + ]) ); }) ); @Effect({ dispatch: false }) getFavorite$ = this.actions$.pipe( ofType(GetUserFavoritesAction.ACTION_TYPE), - switchMap((action: GetUserFavoritesAction) => { - const apiAction = { - entityType: userFavoritesEntitySchema.entityType, - endpointType: userFavoritesEntitySchema.endpointType, - type: action.type - } as PaginatedAction; - const favEntityKey = entityCatalog.getEntityKey(apiAction); + mergeMap((action: GetUserFavoritesAction) => { + const favEntityKey = entityCatalog.getEntityKey(action); + const actionType = 'fetch'; + this.store.dispatch(new StartRequestAction(action, actionType)) return this.http.get[]>(favoriteUrlPath).pipe( map(favorites => { const mappedData = favorites.reduce>>((data, favorite) => { @@ -79,13 +72,15 @@ export class UserFavoritesEffect { } return data; }, { entities: { [favEntityKey]: {} }, result: [] }); - this.store.dispatch(new WrapperRequestActionSuccess(mappedData, apiAction)); - this.store.dispatch(new GetUserFavoritesSuccessAction(favorites)); + return [ + new WrapperRequestActionSuccess(mappedData, action), + new GetUserFavoritesSuccessAction(favorites) + ] }), - catchError(e => { - this.store.dispatch(new GetUserFavoritesFailedAction()); - throw e; - }) + catchError(() => [ + new GetUserFavoritesFailedAction(), + new WrapperRequestActionFailed('Failed to fetch user favorites', action, actionType) + ]) ); }) ); @@ -109,21 +104,37 @@ export class UserFavoritesEffect { @Effect({ dispatch: false }) removeFavorite$ = this.actions$.pipe( ofType(RemoveUserFavoriteAction.ACTION_TYPE), switchMap((action: RemoveUserFavoriteAction) => { - const { guid } = action.favorite; - this.store.dispatch(new RemoveUserFavoriteSuccessAction(action.favorite)); - this.store.dispatch(new ClearPaginationOfEntity(userFavoritesEntitySchema, guid, userFavoritesPaginationKey)); - return this.http.delete>(`${favoriteUrlPath}/${guid}`); + const actionType = 'update'; + this.store.dispatch(new StartRequestAction(action, actionType)) + return this.http.delete>(`${favoriteUrlPath}/${action.guid}`).pipe( + map(() => [ + new WrapperRequestActionSuccess(null, action), + new RemoveUserFavoriteSuccessAction(action.favorite), + new ClearPaginationOfEntity(action.entity[0], action.guid, userFavoritesPaginationKey) + ]), + catchError(() => [ + new WrapperRequestActionFailed('Failed to remove user favorite', action, actionType) + ]) + ); }) ); @Effect() updateMetadata$ = this.actions$.pipe( ofType(UpdateUserFavoriteMetadataAction.ACTION_TYPE), - mergeMap((action: UpdateUserFavoriteMetadataAction) => { + switchMap((action: UpdateUserFavoriteMetadataAction) => { + const actionType = 'update'; + this.store.dispatch(new StartRequestAction(action, actionType)) return this.http.post>( `${favoriteUrlPath}/${action.favorite.guid}/metadata`, action.favorite.metadata ).pipe( - map(() => new UpdateUserFavoriteMetadataSuccessAction(action.favorite)) + map(() => [ + new WrapperRequestActionSuccess(null, action), + new UpdateUserFavoriteMetadataSuccessAction(action.favorite) + ]), + catchError(() => [ + new WrapperRequestActionFailed('Failed to update user favorite', action, actionType) + ]) ); }) ); diff --git a/src/frontend/packages/store/src/entity-catalog/entity-catalog-entity/entity-catalog-entity.ts b/src/frontend/packages/store/src/entity-catalog/entity-catalog-entity/entity-catalog-entity.ts index b754067761..3b0d9e7bcf 100644 --- a/src/frontend/packages/store/src/entity-catalog/entity-catalog-entity/entity-catalog-entity.ts +++ b/src/frontend/packages/store/src/entity-catalog/entity-catalog-entity/entity-catalog-entity.ts @@ -3,7 +3,6 @@ import { ActionReducer } from '@ngrx/store'; import { KnownKeys, NonOptionalKeys } from '../../../../core/src/core/utils.service'; import { getFullEndpointApiUrl } from '../../../../core/src/features/endpoints/endpoint-helpers'; import { IRequestEntityTypeState } from '../../app-state'; -import { endpointEntitySchema, STRATOS_ENDPOINT_TYPE } from '../../base-entity-schemas'; import { EntitiesFetchHandler, EntitiesInfoHandler, @@ -15,6 +14,7 @@ import { } from '../../entity-request-pipeline/pagination-request-base-handlers/pagination-iterator.pipe'; import { EntityPipelineEntity, stratosEndpointGuidKey } from '../../entity-request-pipeline/pipeline.types'; import { EntitySchema } from '../../helpers/entity-schema'; +import { endpointEntityType, STRATOS_ENDPOINT_TYPE, stratosEntityFactory } from '../../helpers/stratos-entity-factory'; import { EndpointModel } from '../../types/endpoint.types'; import { APISuccessOrFailedAction, EntityRequestAction } from '../../types/request.types'; import { IEndpointFavMetadata } from '../../types/user-favorites.types'; @@ -134,8 +134,8 @@ export class StratosBaseCatalogEntity< } return newSchema; }, { - default: entitySchemas.default - }); + default: entitySchemas.default + }); } private getEndpointType(definition: IStratosBaseEntityDefinition) { @@ -316,7 +316,7 @@ export class StratosCatalogEntity< } export class StratosCatalogEndpointEntity extends StratosBaseCatalogEntity { - static readonly baseEndpointRender = { + static readonly baseEndpointRender: IStratosEntityBuilder = { getMetadata: endpoint => ({ name: endpoint.name, guid: endpoint.guid, @@ -332,19 +332,19 @@ export class StratosCatalogEndpointEntity extends StratosBaseCatalogEntity metadata.user], ['Admin', (metadata) => metadata.admin] ] - } as IStratosEntityBuilder; + }; // This is needed here for typing public definition: IStratosEndpointDefinition; constructor( entity: StratosEndpointExtensionDefinition | IStratosEndpointDefinition, getLink?: (metadata: IEndpointFavMetadata) => string ) { - const fullEntity = { + const fullEntity: IStratosEndpointDefinition = { ...entity, schema: { - default: endpointEntitySchema + default: stratosEntityFactory(endpointEntityType) } - } as IStratosEndpointDefinition; + }; super(fullEntity, { entityBuilder: { ...StratosCatalogEndpointEntity.baseEndpointRender, diff --git a/src/frontend/packages/store/src/entity-catalog/entity-catalog.ts b/src/frontend/packages/store/src/entity-catalog/entity-catalog.ts index 40665ba7af..5565256852 100644 --- a/src/frontend/packages/store/src/entity-catalog/entity-catalog.ts +++ b/src/frontend/packages/store/src/entity-catalog/entity-catalog.ts @@ -1,7 +1,7 @@ import { Action } from '@ngrx/store'; import { IRequestEntityTypeState } from '../app-state'; -import { STRATOS_ENDPOINT_TYPE } from '../base-entity-schemas'; +import { STRATOS_ENDPOINT_TYPE } from '../helpers/stratos-entity-factory'; import { ExtraApiReducers } from '../reducers/api-request-reducers.generator.helpers'; import { ICurrentUserRolesState } from '../types/current-user-roles.types'; import { OrchestratedActionBuilders } from './action-orchestrator/action-orchestrator'; diff --git a/src/frontend/packages/store/src/entity-request-pipeline/entity-request-base-handlers/endpoint-errors.handler.ts b/src/frontend/packages/store/src/entity-request-pipeline/entity-request-base-handlers/endpoint-errors.handler.ts index 0106903103..3f335ec3c5 100644 --- a/src/frontend/packages/store/src/entity-request-pipeline/entity-request-base-handlers/endpoint-errors.handler.ts +++ b/src/frontend/packages/store/src/entity-request-pipeline/entity-request-base-handlers/endpoint-errors.handler.ts @@ -1,6 +1,6 @@ import { SendEventAction } from '../../actions/internal-events.actions'; import { StratosBaseCatalogEntity } from '../../entity-catalog/entity-catalog-entity/entity-catalog-entity'; -import { endpointSchemaKey } from '../../helpers/stratos-entity-factory'; +import { endpointEntityType } from '../../helpers/stratos-entity-factory'; import { ApiRequestTypes } from '../../reducers/api-request-reducer/request-helpers'; import { InternalEventSeverity, InternalEventStateMetadata } from '../../types/internal-events.types'; import { APISuccessOrFailedAction, EntityRequestAction } from '../../types/request.types'; @@ -28,7 +28,7 @@ export const endpointErrorsHandlerFactory = (actionDispatcher: ActionDispatcher) ) ); actionDispatcher( - new SendEventAction(endpointSchemaKey, error.guid, { + new SendEventAction(endpointEntityType, error.guid, { eventCode: error.errorCode, severity: InternalEventSeverity.ERROR, message: errorMessage, diff --git a/src/frontend/packages/store/src/entity-request-pipeline/entity-request-base-handlers/jetstream-error.handler.ts b/src/frontend/packages/store/src/entity-request-pipeline/entity-request-base-handlers/jetstream-error.handler.ts index f9541342fd..5b504a93fa 100644 --- a/src/frontend/packages/store/src/entity-request-pipeline/entity-request-base-handlers/jetstream-error.handler.ts +++ b/src/frontend/packages/store/src/entity-request-pipeline/entity-request-base-handlers/jetstream-error.handler.ts @@ -1,7 +1,7 @@ import { SendEventAction } from '../../actions/internal-events.actions'; import { RecursiveDeleteFailed } from '../../effects/recursive-entity-delete.effect'; import { StratosBaseCatalogEntity } from '../../entity-catalog/entity-catalog-entity/entity-catalog-entity'; -import { endpointSchemaKey } from '../../helpers/stratos-entity-factory'; +import { endpointEntityType } from '../../helpers/stratos-entity-factory'; import { ApiRequestTypes, getFailApiRequestActions } from '../../reducers/api-request-reducer/request-helpers'; import { GLOBAL_EVENT, InternalEventSeverity, InternalEventStateMetadata } from '../../types/internal-events.types'; import { EntityRequestAction } from '../../types/request.types'; @@ -26,7 +26,7 @@ export function jetstreamErrorHandler( if (endpointString) { endpointIds.forEach(endpoint => actionDispatcher( - new SendEventAction(endpointSchemaKey, endpoint, { + new SendEventAction(endpointEntityType, endpoint, { eventCode: error.status ? error.status + '' : '500', severity: InternalEventSeverity.ERROR, message: 'Jetstream API request error', diff --git a/src/frontend/packages/store/src/entity-service.spec.ts b/src/frontend/packages/store/src/entity-service.spec.ts index 8a754fbaae..9154b5fbb5 100644 --- a/src/frontend/packages/store/src/entity-service.spec.ts +++ b/src/frontend/packages/store/src/entity-service.spec.ts @@ -4,7 +4,6 @@ import { inject, TestBed } from '@angular/core/testing'; import { Action, Store } from '@ngrx/store'; import { filter, first, map, pairwise, tap } from 'rxjs/operators'; -import { ENTITY_SERVICE } from '../../core/src/shared/entity.tokens'; import { generateTestEntityServiceProvider } from '../../core/test-framework/entity-service.helper'; import { createEntityStore, TestStoreEntity } from '../testing/src/store-test-helper'; import { APIResponse } from './actions/request.actions'; @@ -170,20 +169,6 @@ describe('EntityServiceService', () => { }); }); - it('should be created', inject([ENTITY_SERVICE], (service: EntityService) => { - expect(service).toBeTruthy(); - })); - - it('should poll', (done) => { - inject([ENTITY_SERVICE, HttpXhrBackend], (service: EntityService, mockBackend: HttpTestingController) => { - const sub = service.poll(1, '_root_').subscribe(a => { - sub.unsubscribe(); - expect('polled once').toEqual('polled once'); - done(); - }); - })(); - }); - it('should get application', (done) => { inject([Store], (store: Store) => { const guid = 'GUID123456789x'; diff --git a/src/frontend/packages/store/src/helpers/stratos-entity-factory.ts b/src/frontend/packages/store/src/helpers/stratos-entity-factory.ts index e95019a75d..80cdf02957 100644 --- a/src/frontend/packages/store/src/helpers/stratos-entity-factory.ts +++ b/src/frontend/packages/store/src/helpers/stratos-entity-factory.ts @@ -1,9 +1,9 @@ import { EntitySchema } from './entity-schema'; -export const userFavouritesSchemaKey = 'userFavorites'; -export const endpointSchemaKey = 'endpoint'; -export const userProfileSchemaKey = 'userProfile'; -export const systemInfoSchemaKey = 'system'; +export const userFavouritesEntityType = 'userFavorites'; +export const endpointEntityType = 'endpoint'; +export const userProfileEntityType = 'userProfile'; +export const systemInfoEntityType = 'systemInfo'; export const metricEntityType = 'metrics'; @@ -19,19 +19,19 @@ class StratosEntitySchema extends EntitySchema { } } -// Note - The cache entry is added as a secondary step. This helps keep the child entity definition's clear and easier to spot circular -// dependencies which would otherwise be hidden (if we assigned directly to entityCache and references via entityCache in other entities) -const UserFavouritesSchema = new StratosEntitySchema(userFavouritesSchemaKey, 'id'); -entityCache[userFavouritesSchemaKey] = UserFavouritesSchema; +// TODO: RC test auto log out process -const SystemInfoSchema = new StratosEntitySchema(systemInfoSchemaKey, 'id'); -entityCache[systemInfoSchemaKey] = SystemInfoSchema; +const UserFavouritesSchema = new StratosEntitySchema(userFavouritesEntityType, 'id'); +entityCache[userFavouritesEntityType] = UserFavouritesSchema; -const EndpointSchema = new StratosEntitySchema(endpointSchemaKey, 'guid'); -entityCache[endpointSchemaKey] = EndpointSchema; +const SystemInfoSchema = new StratosEntitySchema(systemInfoEntityType, 'id'); +entityCache[systemInfoEntityType] = SystemInfoSchema; -const UserProfileInfoSchema = new StratosEntitySchema(userProfileSchemaKey, 'id'); -entityCache[userProfileSchemaKey] = UserProfileInfoSchema; +const EndpointSchema = new StratosEntitySchema(endpointEntityType, 'guid'); +entityCache[endpointEntityType] = EndpointSchema; + +const UserProfileInfoSchema = new StratosEntitySchema(userProfileEntityType, 'id'); +entityCache[userProfileEntityType] = UserProfileInfoSchema; export function stratosEntityFactory(key: string): EntitySchema { const entity = entityCache[key]; @@ -39,9 +39,5 @@ export function stratosEntityFactory(key: string): EntitySchema { throw new Error(`Unknown entity schema type: ${key}`); } return entity; -} -// export const userFavoritesEntitySchema = new StratosEntitySchema(entityFactory(userFavouritesSchemaKey).entityType); -// export const endpointEntitySchema = new StratosEntitySchema(entityFactory(endpointSchemaKey).entityType); -// export const userProfileEntitySchema = new StratosEntitySchema(entityFactory(userProfileSchemaKey).entityType); -// export const systemInfoEntitySchema = new StratosEntitySchema(entityFactory(systemInfoSchemaKey).entityType); \ No newline at end of file +} \ No newline at end of file diff --git a/src/frontend/packages/store/src/reducers/current-user-roles-reducer/recently-visited.reducer.ts b/src/frontend/packages/store/src/reducers/current-user-roles-reducer/recently-visited.reducer.ts index 57bd991ef2..ead7fd092e 100644 --- a/src/frontend/packages/store/src/reducers/current-user-roles-reducer/recently-visited.reducer.ts +++ b/src/frontend/packages/store/src/reducers/current-user-roles-reducer/recently-visited.reducer.ts @@ -9,7 +9,7 @@ import { } from '../../actions/endpoint.actions'; import { AddRecentlyVisitedEntityAction, SetRecentlyVisitedEntityAction } from '../../actions/recently-visited.actions'; import { entityCatalog } from '../../entity-catalog/entity-catalog'; -import { endpointSchemaKey, STRATOS_ENDPOINT_TYPE } from '../../helpers/stratos-entity-factory'; +import { endpointEntityType, STRATOS_ENDPOINT_TYPE } from '../../helpers/stratos-entity-factory'; import { IRecentlyVisitedState } from '../../types/recently-visited.types'; import { addNewHit, cleanRecentsList, getDefaultRecentState } from './recently-visited.reducer.helpers'; @@ -35,7 +35,7 @@ export function recentlyVisitedReducer( return cleanRecentsList(state, [removeEndpointAction.guid]); case GET_ENDPOINTS_SUCCESS: const getAllAction = action as GetAllEndpointsSuccess; - const endpointKey = entityCatalog.getEntityKey(STRATOS_ENDPOINT_TYPE, endpointSchemaKey); + const endpointKey = entityCatalog.getEntityKey(STRATOS_ENDPOINT_TYPE, endpointEntityType); const connectedIds = Object.values(getAllAction.payload.entities[endpointKey]).reduce((ids, endpoint) => { if (endpoint.user) { ids.push(endpoint.guid); diff --git a/src/frontend/packages/store/src/reducers/current-user-roles-reducer/user-favorites-groups.reducer.ts b/src/frontend/packages/store/src/reducers/current-user-roles-reducer/user-favorites-groups.reducer.ts index 30e33e8c01..463b41c655 100644 --- a/src/frontend/packages/store/src/reducers/current-user-roles-reducer/user-favorites-groups.reducer.ts +++ b/src/frontend/packages/store/src/reducers/current-user-roles-reducer/user-favorites-groups.reducer.ts @@ -4,9 +4,9 @@ import { GetUserFavoritesAction, GetUserFavoritesFailedAction, GetUserFavoritesSuccessAction, -} from '../../actions/user-favourites-actions/get-user-favorites-action'; -import { RemoveUserFavoriteSuccessAction } from '../../actions/user-favourites-actions/remove-user-favorite-action'; -import { SaveUserFavoriteSuccessAction } from '../../actions/user-favourites-actions/save-user-favorite-action'; + RemoveUserFavoriteSuccessAction, + SaveUserFavoriteSuccessAction, +} from '../../actions/user-favourites.actions'; import { getDefaultFavoriteGroup, getDefaultFavoriteGroupsState, diff --git a/src/frontend/packages/store/src/reducers/favorite.reducer.ts b/src/frontend/packages/store/src/reducers/favorite.reducer.ts index 31165eb6bd..04a98983be 100644 --- a/src/frontend/packages/store/src/reducers/favorite.reducer.ts +++ b/src/frontend/packages/store/src/reducers/favorite.reducer.ts @@ -1,8 +1,8 @@ -import { RemoveUserFavoriteSuccessAction } from '../actions/user-favourites-actions/remove-user-favorite-action'; -import { SaveUserFavoriteSuccessAction } from '../actions/user-favourites-actions/save-user-favorite-action'; import { + RemoveUserFavoriteSuccessAction, + SaveUserFavoriteSuccessAction, UpdateUserFavoriteMetadataSuccessAction, -} from '../actions/user-favourites-actions/update-user-favorite-metadata-action'; +} from '../actions/user-favourites.actions'; import { IRequestEntityTypeState } from '../app-state'; import { IFavoriteMetadata, UserFavorite } from '../types/user-favorites.types'; @@ -27,7 +27,7 @@ export function deleteUserFavoriteMetadataReducer( ): IRequestEntityTypeState> { if (action.type === RemoveUserFavoriteSuccessAction.ACTION_TYPE) { const { - [action.favorite.guid]: deletedFavorite, + [action.guid]: deletedFavorite, ...newState } = state; return newState; diff --git a/src/frontend/packages/store/src/reducers/internal-events.reducer.ts b/src/frontend/packages/store/src/reducers/internal-events.reducer.ts index b65b2da873..277e067439 100644 --- a/src/frontend/packages/store/src/reducers/internal-events.reducer.ts +++ b/src/frontend/packages/store/src/reducers/internal-events.reducer.ts @@ -7,7 +7,7 @@ import { UNREGISTER_ENDPOINTS_SUCCESS, } from '../actions/endpoint.actions'; import { SendClearEndpointEventsAction, SendClearEventAction, SendEventAction } from '../actions/internal-events.actions'; -import { endpointSchemaKey } from '../helpers/stratos-entity-factory'; +import { endpointEntityType } from '../helpers/stratos-entity-factory'; import { CLEAR_ENDPOINT_ERROR_EVENTS, CLEAR_EVENTS, @@ -21,7 +21,7 @@ import { UPDATE_ENDPOINT_SUCCESS } from './../actions/endpoint.actions'; const defaultState: InternalEventsState = { types: { [GLOBAL_EVENT]: {}, - [endpointSchemaKey]: {} + [endpointEntityType]: {} } }; diff --git a/src/frontend/packages/store/src/reducers/pagination-reducer/pagination-reducer-clear-pagination-type.ts b/src/frontend/packages/store/src/reducers/pagination-reducer/pagination-reducer-clear-pagination-type.ts index 61cc841a8a..c020c81f29 100644 --- a/src/frontend/packages/store/src/reducers/pagination-reducer/pagination-reducer-clear-pagination-type.ts +++ b/src/frontend/packages/store/src/reducers/pagination-reducer/pagination-reducer-clear-pagination-type.ts @@ -1,4 +1,4 @@ -import { EndpointAction } from '../../actions/endpoint.actions'; +import { SingleBaseEndpointAction } from '../../actions/endpoint.actions'; import { entityCatalog } from '../../entity-catalog/entity-catalog'; import { PaginationState } from '../../types/pagination.types'; import { getDefaultPaginationEntityState } from './pagination-reducer-reset-pagination'; @@ -23,7 +23,8 @@ export function paginationClearAllTypes(state: PaginationState, entityKeys: stri }, state); } -export function clearEndpointEntities(state: PaginationState, action: EndpointAction) { +export function clearEndpointEntities(state: PaginationState, action: SingleBaseEndpointAction) { + // TODO: RC Test const entityKeys = entityCatalog.getAllEntitiesForEndpointType(action.endpointType).map(entity => entity.entityKey); if (entityKeys.length > 0) { return paginationClearAllTypes( diff --git a/src/frontend/packages/store/src/reducers/pagination-reducer/pagination.reducer.spec.ts b/src/frontend/packages/store/src/reducers/pagination-reducer/pagination.reducer.spec.ts index 48788d016c..27456925e1 100644 --- a/src/frontend/packages/store/src/reducers/pagination-reducer/pagination.reducer.spec.ts +++ b/src/frontend/packages/store/src/reducers/pagination-reducer/pagination.reducer.spec.ts @@ -1,11 +1,11 @@ import { HttpRequest } from '@angular/common/http'; import { RequestTypes } from '../../actions/request.actions'; -import { ENDPOINT_TYPE, endpointEntitySchema, STRATOS_ENDPOINT_TYPE } from '../../base-entity-schemas'; +import { STRATOS_ENDPOINT_TYPE } from '../../base-entity-schemas'; import { entityCatalog } from '../../entity-catalog/entity-catalog'; import { EntityCatalogHelpers } from '../../entity-catalog/entity-catalog.helper'; import { EntitySchema } from '../../helpers/entity-schema'; -import { endpointSchemaKey, STRATOS_ENDPOINT_TYPE, stratosEntityFactory } from '../../helpers/stratos-entity-factory'; +import { endpointEntityType, STRATOS_ENDPOINT_TYPE, stratosEntityFactory } from '../../helpers/stratos-entity-factory'; import { PaginatedAction } from '../../types/pagination.types'; import { StartRequestAction, WrapperRequestActionFailed, WrapperRequestActionSuccess } from '../../types/request.types'; import { createPaginationReducer } from './pagination.reducer'; @@ -21,8 +21,8 @@ function getReducer() { class MockPagAction implements PaginatedAction { actions = ['ONE', 'TWO', 'THREE']; options = new HttpRequest('GET', 'fake123'); - entity = stratosEntityFactory(endpointSchemaKey); - entityType = endpointSchemaKey; + entity = stratosEntityFactory(endpointEntityType); + entityType = endpointEntityType; endpointType = STRATOS_ENDPOINT_TYPE; paginationKey = 'PaginationKey'; type = RequestTypes.START; diff --git a/src/frontend/packages/store/src/selectors/endpoint.selectors.ts b/src/frontend/packages/store/src/selectors/endpoint.selectors.ts index 5d255df88b..05cb67c88f 100644 --- a/src/frontend/packages/store/src/selectors/endpoint.selectors.ts +++ b/src/frontend/packages/store/src/selectors/endpoint.selectors.ts @@ -1,9 +1,8 @@ import { compose } from '@ngrx/store'; import { InternalAppState, IRequestEntityTypeState } from '../app-state'; -import { STRATOS_ENDPOINT_TYPE } from '../base-entity-schemas'; import { EntityCatalogHelpers } from '../entity-catalog/entity-catalog.helper'; -import { endpointSchemaKey } from '../helpers/stratos-entity-factory'; +import { endpointEntityType, STRATOS_ENDPOINT_TYPE } from '../helpers/stratos-entity-factory'; import { EndpointModel, EndpointState } from '../types/endpoint.types'; import { selectEntities, selectEntity, selectRequestInfo } from './api.selectors'; @@ -12,8 +11,8 @@ export const endpointStatusSelector = (state: InternalAppState): EndpointState = // All endpoint request data // Note - Replacing `buildEntityKey` with `entityCatalog.getEntityKey` will cause circular dependency -const endpointEntityKey = EntityCatalogHelpers.buildEntityKey(endpointSchemaKey, STRATOS_ENDPOINT_TYPE); -// TODO: RC search for this +const endpointEntityKey = EntityCatalogHelpers.buildEntityKey(endpointEntityType, STRATOS_ENDPOINT_TYPE); +// TODO: RC search for this. should replace almost everywhere with stratosEntityCatalog access export const endpointEntitiesSelector = selectEntities(endpointEntityKey); export const endpointOfType = (type: string) => diff --git a/src/frontend/packages/store/src/selectors/favorite-groups.selectors.ts b/src/frontend/packages/store/src/selectors/favorite-groups.selectors.ts index 25fb934666..12139d6f78 100644 --- a/src/frontend/packages/store/src/selectors/favorite-groups.selectors.ts +++ b/src/frontend/packages/store/src/selectors/favorite-groups.selectors.ts @@ -1,13 +1,13 @@ import { compose } from '@ngrx/store'; import { InternalAppState, IRequestEntityTypeState } from '../app-state'; -import { STRATOS_ENDPOINT_TYPE, userFavoritesEntitySchema } from '../base-entity-schemas'; import { entityCatalog } from '../entity-catalog/entity-catalog'; +import { STRATOS_ENDPOINT_TYPE, userFavouritesEntityType } from '../helpers/stratos-entity-factory'; import { IUserFavoriteGroup, IUserFavoritesGroups, IUserFavoritesGroupsState } from '../types/favorite-groups.types'; import { IFavoriteMetadata, UserFavorite } from '../types/user-favorites.types'; import { deriveEndpointFavoriteFromFavorite } from '../user-favorite-helpers'; -const favoritesEntityKey = entityCatalog.getEntityKey(STRATOS_ENDPOINT_TYPE, userFavoritesEntitySchema.entityType); +const favoritesEntityKey = entityCatalog.getEntityKey(STRATOS_ENDPOINT_TYPE, userFavouritesEntityType); export const favoriteEntitiesSelector = (state: InternalAppState): IRequestEntityTypeState> => state.requestData[favoritesEntityKey]; diff --git a/src/frontend/packages/store/src/stratos-action-builders.ts b/src/frontend/packages/store/src/stratos-action-builders.ts new file mode 100644 index 0000000000..0cc74c9bf9 --- /dev/null +++ b/src/frontend/packages/store/src/stratos-action-builders.ts @@ -0,0 +1,200 @@ +import { + AuthParams, + BaseEndpointAction, + ConnectEndpoint, + DisconnectEndpoint, + GetAllEndpoints, + GetEndpoint, + RegisterEndpoint, + UnregisterEndpoint, + UpdateEndpoint, +} from './actions/endpoint.actions'; +import { GetSystemInfo } from './actions/system.actions'; +import { + GetUserFavoritesAction, + RemoveUserFavoriteAction, + SaveUserFavoriteAction, + ToggleUserFavoriteAction, + UpdateUserFavoriteMetadataAction, +} from './actions/user-favourites.actions'; +import { FetchUserProfileAction, UpdateUserPasswordAction, UpdateUserProfileAction } from './actions/user-profile.actions'; +import { OrchestratedActionBuilders } from './entity-catalog/action-orchestrator/action-orchestrator'; +import { EndpointType } from './extension-types'; +import { IFavoriteMetadata, UserFavorite } from './types/user-favorites.types'; +import { UserProfileInfo, UserProfilePasswordUpdate } from './types/user-profile.types'; + +export interface EndpointActionBuilder extends OrchestratedActionBuilders { + get: ( + guid: string + ) => GetEndpoint, + getAll: ( + login?: boolean + ) => GetAllEndpoints, + getMultiple: ( + endpointGuid?: string, + paginationKey?: string, + args?: { login: boolean } + ) => GetAllEndpoints, + connect: ( + guid: string, + endpointType: EndpointType, + authType: string, + authValues: AuthParams, + systemShared: boolean, + body: string, + ) => ConnectEndpoint, + disconnect: ( + guid: string, + endpointType: EndpointType, + ) => DisconnectEndpoint, + unregister: ( + guid: string, + endpointType: EndpointType, + ) => UnregisterEndpoint, + register: ( + endpointType: EndpointType, + endpointSubType: string, + name: string, + endpoint: string, + skipSslValidation: boolean, + clientID?: string, + clientSecret?: string, + ssoAllowed?: boolean, + ) => RegisterEndpoint, + update: ( + guid: string, + endpointGuid: string, + args: { + endpointType: EndpointType, // TODO: RC test different types + id: string, + name: string, + skipSSL: boolean, + setClientInfo: boolean, + clientID: string, + clientSecret: string, + allowSSO: boolean, + } + ) => UpdateEndpoint, +} +export const endpointActionBuilder: EndpointActionBuilder = { + get: (guid: string) => new GetEndpoint(guid), + getAll: (login: boolean) => new GetAllEndpoints(login), + getMultiple: ( + endpointGuid?: string, + paginationKey?: string, + args?: { login: boolean } + ) => new GetAllEndpoints(args ? args.login : false), + connect: ( + guid: string, + endpointType: EndpointType, + authType: string, + authValues: AuthParams, + systemShared: boolean, + body: string, + ) => new ConnectEndpoint(guid, endpointType, authType, authValues, systemShared, body), + disconnect: (guid: string, endpointType: EndpointType) => new DisconnectEndpoint(guid, endpointType), + // TODO: RC test two places where unregister happens + unregister: (guid: string, endpointType: EndpointType) => new UnregisterEndpoint(guid, endpointType), + register: ( + endpointType: EndpointType, + endpointSubType: string, + name: string, + endpoint: string, + skipSslValidation: boolean, + clientID?: string, + clientSecret?: string, + ssoAllowed?: boolean, + ) => new RegisterEndpoint( + endpointType, + endpointSubType, + name, + endpoint, + skipSslValidation, + clientID, + clientSecret, + ssoAllowed, + ), + update: ( + guid: string, + endpointGuid: string, + args: { + endpointType: EndpointType, // TODO: RC test different types + // id: string, + name: string, + skipSSL: boolean, + setClientInfo: boolean, + clientID: string, + clientSecret: string, + allowSSO: boolean, + } + ) => new UpdateEndpoint( + args.endpointType, + guid, + args.name, + args.skipSSL, + args.setClientInfo, + args.clientID, + args.clientSecret, + args.allowSSO + ), +} + +export interface SystemInfoActionBuilder extends OrchestratedActionBuilders { + getSystemInfo: ( + login?: boolean, + associatedAction?: BaseEndpointAction + ) => GetSystemInfo +} +export const systemInfoActionBuilder: SystemInfoActionBuilder = { + getSystemInfo: ( + login?: false, + associatedAction?: BaseEndpointAction + ) => new GetSystemInfo(login, associatedAction) +} + +export interface UserFavoriteActionBuilder extends OrchestratedActionBuilders { + getMultiple: () => GetUserFavoritesAction, + getAll: () => GetUserFavoritesAction, + delete: ( + favorite: UserFavorite + ) => RemoveUserFavoriteAction, + save: ( + favorite: UserFavorite + ) => SaveUserFavoriteAction, + toggle: ( + favorite: UserFavorite + ) => ToggleUserFavoriteAction + updateFavorite: ( + favorite: UserFavorite + ) => UpdateUserFavoriteMetadataAction +} + +export const userFavoriteActionBuilder: UserFavoriteActionBuilder = { + getMultiple: () => new GetUserFavoritesAction(), + getAll: () => new GetUserFavoritesAction(), + delete: (favorite: UserFavorite) => new RemoveUserFavoriteAction(favorite), + save: (favorite: UserFavorite) => new SaveUserFavoriteAction(favorite), + toggle: (favorite: UserFavorite) => new ToggleUserFavoriteAction(favorite), + updateFavorite: (favorite: UserFavorite) => new UpdateUserFavoriteMetadataAction(favorite) +} + +// TODO: Schemas +export interface UserProfileActionBuilder extends OrchestratedActionBuilders { + // TODO: RC test all + get: ( + userGuid: string + ) => FetchUserProfileAction + updateProfile: ( + profile: UserProfileInfo, + password: string + ) => UpdateUserProfileAction + updatePassword: ( + guid: string, + passwordChanges: UserProfilePasswordUpdate + ) => UpdateUserPasswordAction +} +export const userProfileActionBuilder: UserProfileActionBuilder = { + get: (userGuid: string) => new FetchUserProfileAction(userGuid), + updateProfile: (profile: UserProfileInfo, password: string) => new UpdateUserProfileAction(profile, password), + updatePassword: (guid: string, passwordChanges: UserProfilePasswordUpdate) => new UpdateUserPasswordAction(guid, passwordChanges) +} \ No newline at end of file diff --git a/src/frontend/packages/store/src/stratos-entity-catalog.ts b/src/frontend/packages/store/src/stratos-entity-catalog.ts index 658e44bcb0..b6d48446e4 100644 --- a/src/frontend/packages/store/src/stratos-entity-catalog.ts +++ b/src/frontend/packages/store/src/stratos-entity-catalog.ts @@ -1,181 +1,19 @@ -import { - AuthParams, - ConnectEndpoint, - DisconnectEndpoint, - GetAllEndpoints, - RegisterEndpoint, - UnregisterEndpoint, - UpdateEndpoint, -} from './actions/endpoint.actions'; -import { GetSystemInfo } from './actions/system.actions'; -import { FetchUserProfileAction, UpdateUserPasswordAction, UpdateUserProfileAction } from './actions/user-profile.actions'; -import { OrchestratedActionBuilders } from './entity-catalog/action-orchestrator/action-orchestrator'; import { StratosCatalogEndpointEntity, StratosCatalogEntity, } from './entity-catalog/entity-catalog-entity/entity-catalog-entity'; -import { EndpointType } from './extension-types'; +import { + EndpointActionBuilder, + SystemInfoActionBuilder, + UserFavoriteActionBuilder, + UserProfileActionBuilder, +} from './stratos-action-builders'; import { EndpointModel } from './types/endpoint.types'; -import { UserProfileInfo, UserProfilePasswordUpdate } from './types/user-profile.types'; +import { UserProfileInfo } from './types/user-profile.types'; // TODO: RC Test all of these actions - -export interface EndpointActionBuilder extends OrchestratedActionBuilders { - get: ( - guid: string - ) => null, // TODO: RC - getAll: ( - login?: boolean - ) => GetAllEndpoints, - getMultiple: ( - endpointGuid?: string, - paginationKey?: string, - args?: { login: boolean } - ) => GetAllEndpoints, - connect: ( - guid: string, - endpointType: EndpointType, - authType: string, - authValues: AuthParams, - systemShared: boolean, - body: string, - ) => ConnectEndpoint, - disconnect: ( - guid: string, - endpointType: EndpointType, - ) => DisconnectEndpoint, - unregister: ( - guid: string, - endpointType: EndpointType, - ) => UnregisterEndpoint, - register: ( - endpointType: EndpointType, - endpointSubType: string, - name: string, - endpoint: string, - skipSslValidation: boolean, - clientID?: string, - clientSecret?: string, - ssoAllowed?: boolean, - ) => RegisterEndpoint, - update: ( - guid: string, - endpointGuid: string, - args: { - endpointType: EndpointType, // TODO: RC test different types - id: string, - name: string, - skipSSL: boolean, - setClientInfo: boolean, - clientID: string, - clientSecret: string, - allowSSO: boolean, - } - ) => UpdateEndpoint, -} -export const endpointActionBuilder: EndpointActionBuilder = { - get: (guid: string) => null, - getAll: (login: boolean) => new GetAllEndpoints(login), - getMultiple: ( - endpointGuid?: string, - paginationKey?: string, - args?: { login: boolean } - ) => new GetAllEndpoints(args ? args.login : false), - connect: ( - guid: string, - endpointType: EndpointType, - authType: string, - authValues: AuthParams, - systemShared: boolean, - body: string, - ) => new ConnectEndpoint(guid, endpointType, authType, authValues, systemShared, body), - disconnect: (guid: string, endpointType: EndpointType) => new DisconnectEndpoint(guid, endpointType), - // TODO: RC not used?????? - unregister: (guid: string, endpointType: EndpointType) => new UnregisterEndpoint(guid, endpointType), - register: ( - endpointType: EndpointType, - endpointSubType: string, - name: string, - endpoint: string, - skipSslValidation: boolean, - clientID?: string, - clientSecret?: string, - ssoAllowed?: boolean, - ) => new RegisterEndpoint( - endpointType, - endpointSubType, - name, - endpoint, - skipSslValidation, - clientID, - clientSecret, - ssoAllowed, - ), - update: ( - guid: string, - endpointGuid: string, - args: { - endpointType: EndpointType, // TODO: RC test different types - // id: string, - name: string, - skipSSL: boolean, - setClientInfo: boolean, - clientID: string, - clientSecret: string, - allowSSO: boolean, - } - ) => new UpdateEndpoint( - args.endpointType, - guid, - args.name, - args.skipSSL, - args.setClientInfo, - args.clientID, - args.clientSecret, - args.allowSSO - ), -} - -export interface SystemInfoActionBuilder extends OrchestratedActionBuilders { - getSystemInfo: ( - login?: boolean, - associatedAction?: GetAllEndpoints - ) => GetSystemInfo -} -export const systemInfoActionBuilder: SystemInfoActionBuilder = { - getSystemInfo: ( - login?: false, - associatedAction?: GetAllEndpoints - ) => new GetSystemInfo(login, associatedAction) -} - -export interface UserFavoriteActionBuilder extends OrchestratedActionBuilders { - -} - -// TODO: Schemas -export interface UserProfileActionBuilder extends OrchestratedActionBuilders { - get: ( - userGuid: string - ) => FetchUserProfileAction - updateProfile: ( // TODO: RC - profile: UserProfileInfo, - password: string - ) => UpdateUserProfileAction - updatePassword: ( - guid: string, - passwordChanges: UserProfilePasswordUpdate - ) => UpdateUserPasswordAction -} -export const userProfileActionBuilder: UserProfileActionBuilder = { - get: (userGuid: string) => new FetchUserProfileAction(userGuid), - updateProfile: (profile: UserProfileInfo, password: string) => new UpdateUserProfileAction(profile, password), - updatePassword: (guid: string, passwordChanges: UserProfilePasswordUpdate) => new UpdateUserPasswordAction(guid, passwordChanges) -} - export class StratosEntityCatalog { - // TODO: RC transfer types to base-entity-types endpoint: StratosCatalogEntity< any,//TODO: RC EndpointModel, @@ -195,8 +33,8 @@ export class StratosEntityCatalog { > userProfile: StratosCatalogEntity< - any, - any, //TODO: RC + any,//TODO: RC + UserProfileInfo, UserProfileActionBuilder > diff --git a/src/frontend/packages/store/src/stratos-entity-generator.ts b/src/frontend/packages/store/src/stratos-entity-generator.ts index 1c94af4f33..858eb42588 100644 --- a/src/frontend/packages/store/src/stratos-entity-generator.ts +++ b/src/frontend/packages/store/src/stratos-entity-generator.ts @@ -1,122 +1,145 @@ +import { BaseEndpointAuth } from '../../core/src/features/endpoints/endpoint-auth'; import { + MetricsEndpointDetailsComponent, +} from '../../core/src/features/metrics/metrics-endpoint-details/metrics-endpoint-details.component'; +import { + StratosBaseCatalogEntity, StratosCatalogEndpointEntity, StratosCatalogEntity, } from '../../store/src/entity-catalog/entity-catalog-entity/entity-catalog-entity'; import { - endpointSchemaKey, + endpointEntityType, STRATOS_ENDPOINT_TYPE, stratosEntityFactory, - systemInfoSchemaKey, - userFavouritesSchemaKey, + systemInfoEntityType, + userFavouritesEntityType, + userProfileEntityType, } from '../../store/src/helpers/stratos-entity-factory'; import { addOrUpdateUserFavoriteMetadataReducer, deleteUserFavoriteMetadataReducer, } from '../../store/src/reducers/favorite.reducer'; import { systemEndpointsReducer } from '../../store/src/reducers/system-endpoints.reducer'; +import { EndpointModel } from '../../store/src/types/endpoint.types'; +import { IStratosEntityDefinition } from './entity-catalog/entity-catalog.types'; import { EndpointActionBuilder, endpointActionBuilder, - stratosEntityCatalog, SystemInfoActionBuilder, systemInfoActionBuilder, + UserFavoriteActionBuilder, + userFavoriteActionBuilder, UserProfileActionBuilder, userProfileActionBuilder, -} from '../../store/src/stratos-entity-catalog'; -import { EndpointModel } from '../../store/src/types/endpoint.types'; -import { BaseEndpointAuth } from './features/endpoints/endpoint-auth'; -import { - MetricsEndpointDetailsComponent, -} from './features/metrics/metrics-endpoint-details/metrics-endpoint-details.component'; - -// -// These types are used to represent the base stratos types. -// +} from './stratos-action-builders'; +import { stratosEntityCatalog } from './stratos-entity-catalog'; -/** - * This is used as a fake endpoint type to allow the store to be initiated correctly - */ -const stratosType = { - logoUrl: '', - authTypes: [], - type: STRATOS_ENDPOINT_TYPE, - schema: null -}; +export function generateStratosEntities(): StratosBaseCatalogEntity[] { + /** + * This is used as a fake endpoint type to allow the store to be initiated correctly + */ + const stratosType = { + logoUrl: '', + authTypes: [], + type: STRATOS_ENDPOINT_TYPE, + schema: null + } + return [ + generateEndpoint(stratosType), + generateSystemInfo(stratosType), + generateUserFavorite(stratosType), + generateUserProfile(stratosType), + generateMetricsEndpoint() + ] +} /** * DefaultEndpointEntityType is used to represent a general endpoint * This should not be used to actually attempt to render an endpoint and is instead used as a way to fill the */ -class DefaultEndpointCatalogEntity extends StratosCatalogEntity< - any,//TODO: RC - EndpointModel, - EndpointActionBuilder - > { - constructor() { - super({ - schema: stratosEntityFactory(endpointSchemaKey), - type: endpointSchemaKey, - endpoint: stratosType, - }, { +function generateEndpoint(stratosType) { + const definition: IStratosEntityDefinition = { + schema: stratosEntityFactory(endpointEntityType), + type: endpointEntityType, + endpoint: stratosType, + } + stratosEntityCatalog.endpoint = new StratosCatalogEntity< + any,//TODO: RC + EndpointModel, + EndpointActionBuilder + >( + definition, + { dataReducers: [ systemEndpointsReducer ], actionBuilders: endpointActionBuilder - }); - } + } + ) + return stratosEntityCatalog.endpoint; } -class UserFavoriteCatalogEntity extends StratosCatalogEntity { - constructor() { - super({ - schema: stratosEntityFactory(userFavouritesSchemaKey), - type: userFavouritesSchemaKey, - endpoint: stratosType, - }, { - dataReducers: [ - addOrUpdateUserFavoriteMetadataReducer, - deleteUserFavoriteMetadataReducer, - ] - }); +function generateSystemInfo(stratosType) { + const definition: IStratosEntityDefinition = { + schema: stratosEntityFactory(systemInfoEntityType), + type: systemInfoEntityType, + endpoint: stratosType, } + stratosEntityCatalog.systemInfo = new StratosCatalogEntity< + any, + any, //TODO: RC + SystemInfoActionBuilder + >( + definition, + { + actionBuilders: systemInfoActionBuilder + } + ) + return stratosEntityCatalog.systemInfo; } -class UserProfileCatalogEntity extends StratosCatalogEntity< - any, - any, //TODO: RC - UserProfileActionBuilder> { - constructor() { - super({ - schema: stratosEntityFactory(userFavouritesSchemaKey), - type: userFavouritesSchemaKey, - endpoint: stratosType, - }, { - actionBuilders: userProfileActionBuilder - }); +function generateUserFavorite(stratosType) { + const definition: IStratosEntityDefinition = { + schema: stratosEntityFactory(userFavouritesEntityType), + type: userFavouritesEntityType, + endpoint: stratosType, } + stratosEntityCatalog.userFavorite = new StratosCatalogEntity< + any, + any, //TODO: RC + UserFavoriteActionBuilder + >( + definition, + { + dataReducers: [ + addOrUpdateUserFavoriteMetadataReducer, + deleteUserFavoriteMetadataReducer, + ], + actionBuilders: userFavoriteActionBuilder + } + ) + return stratosEntityCatalog.userFavorite; } -class SystemInfoCatalogEntity extends StratosCatalogEntity< - any, - any, //TODO: RC - SystemInfoActionBuilder - > { - constructor() { - super({ - schema: stratosEntityFactory(systemInfoSchemaKey), - type: systemInfoSchemaKey, - endpoint: stratosType, - }, { - actionBuilders: systemInfoActionBuilder - }); +function generateUserProfile(stratosType) { + const definition: IStratosEntityDefinition = { + schema: stratosEntityFactory(userProfileEntityType), + type: userProfileEntityType, + endpoint: stratosType, } + stratosEntityCatalog.userProfile = new StratosCatalogEntity< + any, + any, //TODO: RC + UserProfileActionBuilder>( + definition, + { + actionBuilders: userProfileActionBuilder + } + ) + return stratosEntityCatalog.userProfile; } -export function generateStratosEntities() { - stratosEntityCatalog.endpoint = new DefaultEndpointCatalogEntity(); - stratosEntityCatalog.systemInfo = new SystemInfoCatalogEntity() - stratosEntityCatalog.userFavorite = new UserFavoriteCatalogEntity() - stratosEntityCatalog.userProfile = new UserProfileCatalogEntity() +function generateMetricsEndpoint() { // TODO: metrics location to be sorted - STRAT-152 stratosEntityCatalog.metricsEndpoint = new StratosCatalogEndpointEntity({ type: 'metrics', @@ -130,7 +153,5 @@ export function generateStratosEntities() { }, metadata => `/endpoints/metrics/${metadata.guid}` ) - - return Object.values(stratosEntityCatalog); + return stratosEntityCatalog.metricsEndpoint; } - diff --git a/src/frontend/packages/store/src/types/endpoint.types.ts b/src/frontend/packages/store/src/types/endpoint.types.ts index 5cf9cd7011..3ef7dd7575 100644 --- a/src/frontend/packages/store/src/types/endpoint.types.ts +++ b/src/frontend/packages/store/src/types/endpoint.types.ts @@ -1,8 +1,6 @@ import { StratosScopeStrings } from '../../../core/src/core/permissions/stratos-user-permissions.checker'; import { MetricsAPITargets, MetricsStratosInfo } from '../actions/metrics-api.actions'; import { EndpointType } from '../extension-types'; -import { endpointSchemaKey } from '../helpers/stratos-entity-factory'; -import { RequestSectionKeys, TRequestTypeKeys } from '../reducers/api-request-reducer/types'; export const endpointListKey = 'endpoint-list'; export interface INewlyConnectedEndpointInfo { @@ -13,15 +11,6 @@ export interface INewlyConnectedEndpointInfo { user: EndpointUser; } -// TODO: RC REMOVE -export const endpointStoreNames: { - section: TRequestTypeKeys, - type: string -} = { - section: RequestSectionKeys.Other, - type: endpointSchemaKey -}; - export interface IApiEndpointInfo { ForceQuery: boolean; Fragment: string; diff --git a/src/frontend/packages/store/src/user-favorite-manager.ts b/src/frontend/packages/store/src/user-favorite-manager.ts index b67f56c0e3..04ef51d9b7 100644 --- a/src/frontend/packages/store/src/user-favorite-manager.ts +++ b/src/frontend/packages/store/src/user-favorite-manager.ts @@ -7,7 +7,6 @@ import { FavoritesConfigMapper, TFavoriteMapperFunction, } from '../../core/src/shared/components/favorites-meta-card/favorite-config-mapper'; -import { ToggleUserFavoriteAction } from './actions/user-favourites-actions/toggle-user-favorite-action'; import { GeneralEntityAppState, IRequestEntityTypeState } from './app-state'; import { entityCatalog } from './entity-catalog/entity-catalog'; import { endpointEntitiesSelector } from './selectors/endpoint.selectors'; @@ -18,6 +17,7 @@ import { fetchingFavoritesSelector, } from './selectors/favorite-groups.selectors'; import { isFavorite } from './selectors/favorite.selectors'; +import { stratosEntityCatalog } from './stratos-entity-catalog'; import { IUserFavoritesGroups } from './types/favorite-groups.types'; import { IEndpointFavMetadata, IFavoriteMetadata, UserFavorite } from './types/user-favorites.types'; @@ -160,6 +160,6 @@ export class UserFavoriteManager { } public toggleFavorite(favorite: UserFavorite) { - this.store.dispatch(new ToggleUserFavoriteAction(favorite)); + stratosEntityCatalog.userFavorite.api.toggle(favorite); } } From 922b88ae1e2334f9dd382ec31a06c9c9d7845cf2 Mon Sep 17 00:00:00 2001 From: Richard Cox Date: Fri, 19 Jun 2020 17:45:19 +0100 Subject: [PATCH 04/12] Endpoint changes --- .../src/actions/service-bindings.actions.ts | 3 ++- .../entity-relations-list.spec.ts | 3 ++- .../entity-relations.tree.spec.ts | 2 +- .../current-cf-user-role-session.reducer.ts | 2 +- .../current-cf-user-roles-clear.reducers.ts | 2 +- .../create-endpoint-cf-step-1.component.ts | 21 +++++-------------- .../store/src/actions/endpoint.actions.ts | 18 ++++++++++------ .../store/src/effects/endpoint.effects.ts | 16 ++++++++------ .../store/src/effects/permissions.effect.ts | 2 +- .../entity-catalog-entity-store-helpers.ts | 8 ++++--- .../entity-catalog-entity.ts | 1 + ...gination-reducer-create-pagination.spec.ts | 2 +- .../store/src/selectors/api.selectors.ts | 2 +- .../store/src/stratos-action-builders.ts | 8 +++++-- 14 files changed, 49 insertions(+), 41 deletions(-) diff --git a/src/frontend/packages/cloud-foundry/src/actions/service-bindings.actions.ts b/src/frontend/packages/cloud-foundry/src/actions/service-bindings.actions.ts index d0a2763cfb..cd7763a255 100644 --- a/src/frontend/packages/cloud-foundry/src/actions/service-bindings.actions.ts +++ b/src/frontend/packages/cloud-foundry/src/actions/service-bindings.actions.ts @@ -1,10 +1,11 @@ +import { HttpParams, HttpRequest } from '@angular/common/http'; + import { getActions } from '../../../store/src/actions/action.helper'; import { PaginatedAction, PaginationParam } from '../../../store/src/types/pagination.types'; import { ICFAction } from '../../../store/src/types/request.types'; import { cfEntityFactory } from '../cf-entity-factory'; import { serviceBindingEntityType } from '../cf-entity-types'; import { CFStartAction } from './cf-action.types'; -import { HttpRequest, HttpParams } from '@angular/common/http'; export const DELETE_SERVICE_BINDING_ACTION = '[ Service Instances ] Delete Service Binding'; export const DELETE_SERVICE_BINDING_ACTION_SUCCESS = '[ Service Instances ] Delete Service Binding success'; diff --git a/src/frontend/packages/cloud-foundry/src/entity-relations/entity-relations-list.spec.ts b/src/frontend/packages/cloud-foundry/src/entity-relations/entity-relations-list.spec.ts index 73851810cc..35679dc510 100644 --- a/src/frontend/packages/cloud-foundry/src/entity-relations/entity-relations-list.spec.ts +++ b/src/frontend/packages/cloud-foundry/src/entity-relations/entity-relations-list.spec.ts @@ -1,6 +1,7 @@ +import { EntitySchema } from '../../../store/src/helpers/entity-schema'; import { listEntityRelations } from './entity-relations'; import { createEntityRelationKey, EntityInlineParentAction } from './entity-relations.types'; -import { EntitySchema } from '../../../store/src/helpers/entity-schema'; + const endpointType = 'endpointtype1'; describe('Entity Relations - List relations', () => { diff --git a/src/frontend/packages/cloud-foundry/src/entity-relations/entity-relations.tree.spec.ts b/src/frontend/packages/cloud-foundry/src/entity-relations/entity-relations.tree.spec.ts index 6ce1b9126a..5383e22fbe 100644 --- a/src/frontend/packages/cloud-foundry/src/entity-relations/entity-relations.tree.spec.ts +++ b/src/frontend/packages/cloud-foundry/src/entity-relations/entity-relations.tree.spec.ts @@ -1,5 +1,5 @@ -import { CF_ENDPOINT_TYPE } from '../cf-types'; import { CFEntitySchema } from '../cf-entity-schema-types'; +import { CF_ENDPOINT_TYPE } from '../cf-types'; import { fetchEntityTree } from './entity-relations.tree'; import { createEntityRelationKey, EntityInlineParentAction } from './entity-relations.types'; diff --git a/src/frontend/packages/cloud-foundry/src/store/reducers/current-cf-user-roles-reducer/current-cf-user-role-session.reducer.ts b/src/frontend/packages/cloud-foundry/src/store/reducers/current-cf-user-roles-reducer/current-cf-user-role-session.reducer.ts index 5778477b89..125258e829 100644 --- a/src/frontend/packages/cloud-foundry/src/store/reducers/current-cf-user-roles-reducer/current-cf-user-role-session.reducer.ts +++ b/src/frontend/packages/cloud-foundry/src/store/reducers/current-cf-user-roles-reducer/current-cf-user-role-session.reducer.ts @@ -24,7 +24,7 @@ export function updateNewlyConnectedCfEndpoint( state: IAllCfRolesState, action: EndpointActionComplete ): IAllCfRolesState { - if (action.endpointType !== CF_ENDPOINT_TYPE) { + if (action.completeEndpointType !== CF_ENDPOINT_TYPE) { return state; } const endpoint = action.endpoint as INewlyConnectedEndpointInfo; diff --git a/src/frontend/packages/cloud-foundry/src/store/reducers/current-cf-user-roles-reducer/current-cf-user-roles-clear.reducers.ts b/src/frontend/packages/cloud-foundry/src/store/reducers/current-cf-user-roles-reducer/current-cf-user-roles-clear.reducers.ts index ade79d48f4..9717cc8ad2 100644 --- a/src/frontend/packages/cloud-foundry/src/store/reducers/current-cf-user-roles-reducer/current-cf-user-roles-clear.reducers.ts +++ b/src/frontend/packages/cloud-foundry/src/store/reducers/current-cf-user-roles-reducer/current-cf-user-roles-clear.reducers.ts @@ -19,7 +19,7 @@ export function removeEndpointCfRoles(state: IAllCfRolesState, action: EndpointA } export function addCfEndpoint(state: IAllCfRolesState, action: EndpointActionComplete) { - if (action.endpointType !== CF_ENDPOINT_TYPE) { + if (action.completeEndpointType !== CF_ENDPOINT_TYPE) { return state; } const endpoint = action.endpoint as EndpointModel; diff --git a/src/frontend/packages/core/src/features/endpoints/create-endpoint/create-endpoint-cf-step-1/create-endpoint-cf-step-1.component.ts b/src/frontend/packages/core/src/features/endpoints/create-endpoint/create-endpoint-cf-step-1/create-endpoint-cf-step-1.component.ts index 76bffe5826..f31d6addfd 100644 --- a/src/frontend/packages/core/src/features/endpoints/create-endpoint/create-endpoint-cf-step-1/create-endpoint-cf-step-1.component.ts +++ b/src/frontend/packages/core/src/features/endpoints/create-endpoint/create-endpoint-cf-step-1/create-endpoint-cf-step-1.component.ts @@ -1,19 +1,14 @@ import { AfterContentInit, Component, Input, ViewChild } from '@angular/core'; import { NgForm, NgModel } from '@angular/forms'; import { ActivatedRoute } from '@angular/router'; -import { Store } from '@ngrx/store'; -import { denormalize } from 'normalizr'; import { Observable } from 'rxjs'; -import { filter, map, pairwise, withLatestFrom } from 'rxjs/operators'; +import { filter, map, pairwise, tap } from 'rxjs/operators'; -import { GeneralEntityAppState } from '../../../../../../store/src/app-state'; import { entityCatalog } from '../../../../../../store/src/entity-catalog/entity-catalog'; import { StratosCatalogEndpointEntity, } from '../../../../../../store/src/entity-catalog/entity-catalog-entity/entity-catalog-entity'; -import { endpointEntityType, stratosEntityFactory } from '../../../../../../store/src/helpers/stratos-entity-factory'; import { ActionState } from '../../../../../../store/src/reducers/api-request-reducer/types'; -import { getAPIRequestDataState } from '../../../../../../store/src/selectors/api.selectors'; import { stratosEntityCatalog } from '../../../../../../store/src/stratos-entity-catalog'; import { getIdFromRoute } from '../../../../core/utils.service'; import { IStepperStep, StepOnNextFunction } from '../../../../shared/components/stepper/step/step.component'; @@ -57,19 +52,12 @@ export class CreateEndpointCfStep1Component implements IStepperStep, AfterConten endpoint: StratosCatalogEndpointEntity; constructor( - store: Store, activatedRoute: ActivatedRoute, private snackBarService: SnackBarService ) { - const paginationState$ = stratosEntityCatalog.endpoint.store.getAll.getPaginationMonitor().pagination$; - - // TODO: RC Fix me, this is madness - this.existingEndpoints = paginationState$.pipe( - withLatestFrom(store.select(getAPIRequestDataState)), - map(([pagination, entities]) => { - const pages = Object.values(pagination.ids); - const page = [].concat.apply([], pages); - const endpoints = page.length ? denormalize(page, [stratosEntityFactory(endpointEntityType)], entities) : []; + // TODO: RC test + this.existingEndpoints = stratosEntityCatalog.endpoint.store.getAll.getPaginationMonitor().currentPage$.pipe( + map(endpoints => { return { names: endpoints.map(ep => ep.name), urls: endpoints.map(ep => getFullEndpointApiUrl(ep)), @@ -98,6 +86,7 @@ export class CreateEndpointCfStep1Component implements IStepperStep, AfterConten this.clientSecretField ? this.clientSecretField.value : '', this.ssoAllowedField ? !!this.ssoAllowedField.value : false, ).pipe( + tap(a => console.log('REGISTER RES: ', a)), pairwise(), filter(([oldVal, newVal]) => (oldVal.busy && !newVal.busy)), map(([oldVal, newVal]) => newVal), diff --git a/src/frontend/packages/store/src/actions/endpoint.actions.ts b/src/frontend/packages/store/src/actions/endpoint.actions.ts index e7998aeca2..04f7ab0a6b 100644 --- a/src/frontend/packages/store/src/actions/endpoint.actions.ts +++ b/src/frontend/packages/store/src/actions/endpoint.actions.ts @@ -41,7 +41,8 @@ export class EndpointActionComplete implements Action { constructor( public type: string, public guid: string, - public endpointType: EndpointType, + // Note - The underlying endpoints type (_cf_Endpoint, not _stratos_Endpoint) + public completeEndpointType: EndpointType, public endpoint: EndpointModel | INewlyConnectedEndpointInfo ) { } } @@ -137,7 +138,8 @@ export class ConnectEndpoint extends SingleBaseEndpointAction { static UpdatingKey = 'connectingKey' constructor( guid: string, - public endpointType: EndpointType, + // Note - should not be called endpointType + public connectEndpointType: EndpointType, public authType: string, public authValues: AuthParams, public systemShared: boolean, @@ -160,7 +162,8 @@ export class DisconnectEndpoint extends SingleBaseEndpointAction { static UpdatingKey = 'disconnecting' constructor( guid: string, - public endpointType: EndpointType, + // Note - should not be called endpointType + public disconnectEndpointType: EndpointType, ) { super( DISCONNECT_ENDPOINTS, @@ -178,7 +181,8 @@ export class DisconnectEndpoint extends SingleBaseEndpointAction { export class UnregisterEndpoint extends SingleBaseEndpointAction { constructor( guid: string, - public endpointType: EndpointType, + // Note - should not be called endpointType + public unregisterEndpointType: EndpointType, ) { super( UNREGISTER_ENDPOINTS, @@ -194,7 +198,8 @@ export class UnregisterEndpoint extends SingleBaseEndpointAction { export class RegisterEndpoint extends SingleBaseEndpointAction { constructor( - public endpointType: EndpointType, + // Note - should not be called endpointType + public registerEndpointType: EndpointType, public endpointSubType: string = null, public name: string, public endpoint: string, @@ -218,7 +223,8 @@ export class RegisterEndpoint extends SingleBaseEndpointAction { export class UpdateEndpoint extends SingleBaseEndpointAction { constructor( - public endpointType: EndpointType, // TODO: RC test different types + // Note - should not be called endpointType + public updateEndpointType: EndpointType, // TODO: RC test different types public id: string, public name: string, public skipSSL: boolean, diff --git a/src/frontend/packages/store/src/effects/endpoint.effects.ts b/src/frontend/packages/store/src/effects/endpoint.effects.ts index e649646f34..9e9b1edca8 100644 --- a/src/frontend/packages/store/src/effects/endpoint.effects.ts +++ b/src/frontend/packages/store/src/effects/endpoint.effects.ts @@ -145,7 +145,7 @@ export class EndpointsEffect { '/pp/v1/auth/login/cnsi', params, null, - action.endpointType, + action.connectEndpointType, body, response => response && response.error && response.error.error ? response.error.error : 'Could not connect, please try again' ); @@ -165,7 +165,7 @@ export class EndpointsEffect { '/pp/v1/auth/logout/cnsi', params, null, - action.endpointType + action.disconnectEndpointType ); })); @@ -183,7 +183,7 @@ export class EndpointsEffect { '/pp/v1/unregister', params, 'delete', - action.endpointType + action.unregisterEndpointType ); })); @@ -212,10 +212,10 @@ export class EndpointsEffect { return this.doEndpointAction( action, - '/pp/v1/register/' + action.endpointType, + '/pp/v1/register/' + action.registerEndpointType, new HttpParams({}), 'create', - action.endpointType, + action.registerEndpointType, body, this.processRegisterError ); @@ -244,7 +244,7 @@ export class EndpointsEffect { '/pp/v1/endpoint/' + action.id, new HttpParams({}), 'update', - action.endpointType, + action.updateEndpointType, body, this.processUpdateError ); @@ -270,11 +270,15 @@ export class EndpointsEffect { return message; } + /** + * @param endpointType The underlying endpoints type (_cf_Endpoint, not _stratos_Endpoint) + */ private doEndpointAction( apiAction: EntityRequestAction | PaginatedAction, url: string, params: HttpParams, apiActionType: ApiRequestTypes = 'update', + endpointType: EndpointType, body?: string, errorMessageHandler?: (e: any) => string, diff --git a/src/frontend/packages/store/src/effects/permissions.effect.ts b/src/frontend/packages/store/src/effects/permissions.effect.ts index b9569d4b2e..5f5fc1dadc 100644 --- a/src/frontend/packages/store/src/effects/permissions.effect.ts +++ b/src/frontend/packages/store/src/effects/permissions.effect.ts @@ -51,7 +51,7 @@ export class PermissionsEffects { @Effect() getPermissionForNewlyConnectedEndpoint$ = this.actions$.pipe( ofType(CONNECT_ENDPOINTS_SUCCESS), switchMap(action => { - const endpointType = entityCatalog.getEndpoint(action.endpointType) + const endpointType = entityCatalog.getEndpoint(action.completeEndpointType) if (!endpointType.definition.userRolesFetch) { return EMPTY; } diff --git a/src/frontend/packages/store/src/entity-catalog/entity-catalog-entity/entity-catalog-entity-store-helpers.ts b/src/frontend/packages/store/src/entity-catalog/entity-catalog-entity/entity-catalog-entity-store-helpers.ts index 2e88c4f518..ddf251581d 100644 --- a/src/frontend/packages/store/src/entity-catalog/entity-catalog-entity/entity-catalog-entity-store-helpers.ts +++ b/src/frontend/packages/store/src/entity-catalog/entity-catalog-entity/entity-catalog-entity-store-helpers.ts @@ -122,6 +122,7 @@ export class EntityCatalogEntityStoreHelpers { if (!rAction.guid) { throw new Error(`\`${actionKey}\` action for entity \`${rAction.entityType}\` has no guid`); } + const entityMonitor = es.getEntityMonitor( rAction.guid, { @@ -147,9 +148,10 @@ export class EntityCatalogEntityStoreHelpers { schemaKey: '', startWithNull: false } - ): EntityMonitor => - new EntityMonitor(EntityCatalogHelpers.GetEntityCatalogHelper().store, entityId, entityKey, getSchema(params.schemaKey), params.startWithNull) - , + ): EntityMonitor => { + + return new EntityMonitor(EntityCatalogHelpers.GetEntityCatalogHelper().store, entityId, entityKey, getSchema(params.schemaKey), params.startWithNull); + }, getEntityService: ( ...args: Parameters ): EntityService => { diff --git a/src/frontend/packages/store/src/entity-catalog/entity-catalog-entity/entity-catalog-entity.ts b/src/frontend/packages/store/src/entity-catalog/entity-catalog-entity/entity-catalog-entity.ts index 3b0d9e7bcf..fedbad3db8 100644 --- a/src/frontend/packages/store/src/entity-catalog/entity-catalog-entity/entity-catalog-entity.ts +++ b/src/frontend/packages/store/src/entity-catalog/entity-catalog-entity/entity-catalog-entity.ts @@ -74,6 +74,7 @@ export class StratosBaseCatalogEntity< this.entityKey = this.isEndpoint ? EntityCatalogHelpers.buildEntityKey(EntityCatalogHelpers.endpointType, baseEntity.type) : EntityCatalogHelpers.buildEntityKey(baseEntity.type, baseEntity.endpoint.type); + console.log(definition, this.entityKey) const actionBuilders = ActionBuilderConfigMapper.getActionBuilders( this.builders.actionBuilders, this.endpointType, diff --git a/src/frontend/packages/store/src/reducers/pagination-reducer/pagination-reducer-create-pagination.spec.ts b/src/frontend/packages/store/src/reducers/pagination-reducer/pagination-reducer-create-pagination.spec.ts index d9c0465284..047f677ad6 100644 --- a/src/frontend/packages/store/src/reducers/pagination-reducer/pagination-reducer-create-pagination.spec.ts +++ b/src/frontend/packages/store/src/reducers/pagination-reducer/pagination-reducer-create-pagination.spec.ts @@ -1,5 +1,5 @@ -import { entityCatalog } from '../../entity-catalog/entity-catalog'; import { CreatePagination } from '../../actions/pagination.actions'; +import { entityCatalog } from '../../entity-catalog/entity-catalog'; import { PaginationState } from '../../types/pagination.types'; import { createNewPaginationSection } from './pagination-reducer-create-pagination'; import { getDefaultPaginationEntityState } from './pagination-reducer-reset-pagination'; diff --git a/src/frontend/packages/store/src/selectors/api.selectors.ts b/src/frontend/packages/store/src/selectors/api.selectors.ts index 4aecb698d7..ed793c7678 100644 --- a/src/frontend/packages/store/src/selectors/api.selectors.ts +++ b/src/frontend/packages/store/src/selectors/api.selectors.ts @@ -1,8 +1,8 @@ import { compose } from '@ngrx/store'; +import { GeneralEntityAppState, IRequestEntityTypeState as IRequestEntityKeyState, IRequestTypeState } from '../app-state'; import { EntityCatalogHelpers } from '../entity-catalog/entity-catalog.helper'; import { EntityCatalogEntityConfig } from '../entity-catalog/entity-catalog.types'; -import { GeneralEntityAppState, IRequestEntityTypeState as IRequestEntityKeyState, IRequestTypeState } from '../app-state'; import { ActionState, RequestInfoState, UpdatingSection } from '../reducers/api-request-reducer/types'; import { APIResource } from '../types/api.types'; diff --git a/src/frontend/packages/store/src/stratos-action-builders.ts b/src/frontend/packages/store/src/stratos-action-builders.ts index 0cc74c9bf9..f9b5004580 100644 --- a/src/frontend/packages/store/src/stratos-action-builders.ts +++ b/src/frontend/packages/store/src/stratos-action-builders.ts @@ -25,10 +25,10 @@ import { UserProfileInfo, UserProfilePasswordUpdate } from './types/user-profile export interface EndpointActionBuilder extends OrchestratedActionBuilders { get: ( - guid: string + guid: string, ) => GetEndpoint, getAll: ( - login?: boolean + login?: boolean, ) => GetAllEndpoints, getMultiple: ( endpointGuid?: string, @@ -76,6 +76,10 @@ export interface EndpointActionBuilder extends OrchestratedActionBuilders { } ) => UpdateEndpoint, } + +// TODO: RC reg sterpper, connect with dodgy creds, no error +// TODO: RC connect endpoint whilst on list. connection status changes... but dialog shows.. error in return currentUserCfRolesRequestStateReducer(state, action as GetCfUserRelations); + export const endpointActionBuilder: EndpointActionBuilder = { get: (guid: string) => new GetEndpoint(guid), getAll: (login: boolean) => new GetAllEndpoints(login), From 5c587055804d1f031abad5b781c7db0e51bf83c6 Mon Sep 17 00:00:00 2001 From: Richard Cox Date: Mon, 22 Jun 2020 11:51:49 +0100 Subject: [PATCH 05/12] Fix failure handling during connect on stepper --- .../cli-info-application.component.ts | 6 ---- .../data-services/cloud-foundry.service.ts | 2 +- .../services/cf-org-space-label.service.ts | 2 +- .../src/features/endpoints/connect.service.ts | 36 ++++++------------- .../favorites-meta-card.component.ts | 9 +---- .../store/src/effects/endpoint.effects.ts | 1 - .../store/src/effects/user-profile.effects.ts | 2 +- .../store/src/selectors/endpoint.selectors.ts | 3 +- .../store/src/stratos-action-builders.ts | 3 -- .../store/src/stratos-entity-catalog.ts | 14 ++++---- .../store/src/stratos-entity-generator.ts | 30 +++++++++------- 11 files changed, 41 insertions(+), 67 deletions(-) diff --git a/src/frontend/packages/cloud-foundry/src/features/applications/cli-info-application/cli-info-application.component.ts b/src/frontend/packages/cloud-foundry/src/features/applications/cli-info-application/cli-info-application.component.ts index dcf12f1d17..c3965ac22b 100644 --- a/src/frontend/packages/cloud-foundry/src/features/applications/cli-info-application/cli-info-application.component.ts +++ b/src/frontend/packages/cloud-foundry/src/features/applications/cli-info-application/cli-info-application.component.ts @@ -41,12 +41,6 @@ export class CliInfoApplicationComponent implements OnInit { private setupObservables(cfGuid: string) { this.cfEndpointEntityService = stratosEntityCatalog.endpoint.store.getEntityService(cfGuid); - // TODO: RC Endpoint: get single, dispatch multiple - // this.cfEndpointEntityService = this.entityServiceFactory.create( - // cfGuid, - // new GetAllEndpoints() - // ); - this.context$ = combineLatest( this.applicationService.application$, this.cfEndpointEntityService.waitForEntity$ diff --git a/src/frontend/packages/cloud-foundry/src/shared/data-services/cloud-foundry.service.ts b/src/frontend/packages/cloud-foundry/src/shared/data-services/cloud-foundry.service.ts index 0817bf9e46..537166039f 100644 --- a/src/frontend/packages/cloud-foundry/src/shared/data-services/cloud-foundry.service.ts +++ b/src/frontend/packages/cloud-foundry/src/shared/data-services/cloud-foundry.service.ts @@ -20,7 +20,7 @@ export class CloudFoundryService { this.cfEndpointsMonitor = stratosEntityCatalog.endpoint.store.getPaginationMonitor(); - // TODO: RC should we now avoid selectors.. selectEntity, selectCfEntity, etc? + // TODO: RC Q should we now avoid selectors.. selectEntity, selectCfEntity, etc? and always access via entity catalog? this.cFEndpoints$ = this.cfEndpointsMonitor.currentPage$.pipe( map(endpoints => endpoints.filter(e => e.cnsi_type === 'cf')) ); diff --git a/src/frontend/packages/cloud-foundry/src/shared/services/cf-org-space-label.service.ts b/src/frontend/packages/cloud-foundry/src/shared/services/cf-org-space-label.service.ts index f99a7f24dc..7c42259f5e 100644 --- a/src/frontend/packages/cloud-foundry/src/shared/services/cf-org-space-label.service.ts +++ b/src/frontend/packages/cloud-foundry/src/shared/services/cf-org-space-label.service.ts @@ -34,7 +34,7 @@ export class CfOrgSpaceLabelService { // FIXME: hide STRATOS_ENDPOINT_TYPE from extensions - STRAT-154 const endpointEntityKey = entityCatalog.getEntityKey(STRATOS_ENDPOINT_TYPE, endpointEntityType); - // TODO: RC should we now avoid selectors.. selectEntity, selectCfEntity, etc? + // TODO: RC Q should we now avoid selectors.. selectEntity, selectCfEntity, etc? and always access via entity catalog? this.cf$ = this.store.select(selectEntity(endpointEntityKey, this.cfGuid)); this.org$ = this.store.select>(selectCfEntity(organizationEntityType, this.orgGuid)); diff --git a/src/frontend/packages/core/src/features/endpoints/connect.service.ts b/src/frontend/packages/core/src/features/endpoints/connect.service.ts index c0f8e0ba07..870f816263 100644 --- a/src/frontend/packages/core/src/features/endpoints/connect.service.ts +++ b/src/frontend/packages/core/src/features/endpoints/connect.service.ts @@ -1,15 +1,5 @@ import { combineLatest, Observable, of, Subject, Subscription } from 'rxjs'; -import { - delay, - distinctUntilChanged, - filter, - map, - pairwise, - startWith, - switchMap, - tap, - withLatestFrom, -} from 'rxjs/operators'; +import { delay, distinctUntilChanged, filter, map, pairwise, startWith, switchMap, tap } from 'rxjs/operators'; import { AuthParams, ConnectEndpoint } from '../../../../store/src/actions/endpoint.actions'; import { entityCatalog } from '../../../../store/src/entity-catalog/entity-catalog'; @@ -82,11 +72,11 @@ export class ConnectEndpointService { })); this.subs.push(this.connected$.pipe( - filter(([connected]) => connected), + filter(([isConnected]) => isConnected), delay(this.connectDelay), tap(() => this.hasConnected.next(true)), - distinctUntilChanged(([connected], [oldConnected]) => connected && oldConnected), - ).subscribe(([connected, endpoint]) => this.endpointsService.checkEndpoint(endpoint)) + distinctUntilChanged(([isConnected], [oldIsConnected]) => isConnected && oldIsConnected), + ).subscribe(([, endpoint]) => this.endpointsService.checkEndpoint(endpoint)) ); } @@ -94,7 +84,7 @@ export class ConnectEndpointService { this.update$ = stratosEntityCatalog.endpoint.store.getEntityMonitor(this.config.guid).getUpdatingSection(ConnectEndpoint.UpdatingKey) .pipe(filter(update => !!update)); - // TODO: RC Endpoint entity vs system endpoint (SystemEffects.guid) + // TODO: RC TEST... is systeminfo updated on connect? should this dispatch system info instead? this.fetchingInfo$ = stratosEntityCatalog.endpoint.store.getEntityMonitor(this.config.guid).entityRequest$.pipe( filter(request => !!request), map(request => request.fetching) @@ -144,25 +134,21 @@ export class ConnectEndpointService { this.hasAttemptedConnect = true; const { authType, authVal, systemShared, bodyContent } = this.pData; - stratosEntityCatalog.endpoint.api.connect( + return stratosEntityCatalog.endpoint.api.connect( this.config.guid, this.config.type, authType, authVal, systemShared, bodyContent, - ); - - return this.isBusy$.pipe( + ).pipe( pairwise(), - filter(([oldBusy, newBusy]) => { - return !(oldBusy === true && newBusy === false); - }), - withLatestFrom(this.update$), - map(([, updateSection]) => ({ + filter(([oldV, newV]) => oldV.busy && !newV.busy), + map(([, newV]) => newV), + map(updateSection => ({ success: !updateSection.error, errorMessage: updateSection.message - })) + })), ); } diff --git a/src/frontend/packages/core/src/shared/components/favorites-meta-card/favorites-meta-card.component.ts b/src/frontend/packages/core/src/shared/components/favorites-meta-card/favorites-meta-card.component.ts index 8a31c98459..bef1402d69 100644 --- a/src/frontend/packages/core/src/shared/components/favorites-meta-card/favorites-meta-card.component.ts +++ b/src/frontend/packages/core/src/shared/components/favorites-meta-card/favorites-meta-card.component.ts @@ -1,12 +1,9 @@ import { Component, Input } from '@angular/core'; -import { Store } from '@ngrx/store'; import { isObservable, Observable, of as observableOf } from 'rxjs'; import { map } from 'rxjs/operators'; -import { AppState } from '../../../../../store/src/app-state'; import { entityCatalog } from '../../../../../store/src/entity-catalog/entity-catalog'; import { stratosEntityFactory, userFavouritesEntityType } from '../../../../../store/src/helpers/stratos-entity-factory'; -import { endpointEntitiesSelector } from '../../../../../store/src/selectors/endpoint.selectors'; import { stratosEntityCatalog } from '../../../../../store/src/stratos-entity-catalog'; import { IFavoriteMetadata, UserFavorite } from '../../../../../store/src/types/user-favorites.types'; import { IFavoriteEntity } from '../../../../../store/src/user-favorite-manager'; @@ -70,10 +67,7 @@ export class FavoritesMetaCardComponent { @Input() set favoriteEntity(favoriteEntity: IFavoriteEntity) { if (!this.placeholder && favoriteEntity) { - // TODO: RC selector, and remove store - const endpoint$ = this.store.select(endpointEntitiesSelector).pipe( - map(endpoints => endpoints[favoriteEntity.favorite.endpointId]) - ); + const endpoint$ = stratosEntityCatalog.endpoint.store.getEntityMonitor(favoriteEntity.favorite.endpointId).entity$; this.endpointConnected$ = endpoint$.pipe(map(endpoint => isEndpointConnected(endpoint))); this.actions$ = this.endpointConnected$.pipe( map(connected => connected ? this.config.menuItems : []) @@ -112,7 +106,6 @@ export class FavoritesMetaCardComponent { } constructor( - private store: Store, private confirmDialog: ConfirmationDialogService ) { } diff --git a/src/frontend/packages/store/src/effects/endpoint.effects.ts b/src/frontend/packages/store/src/effects/endpoint.effects.ts index 9e9b1edca8..9ce8ab96cf 100644 --- a/src/frontend/packages/store/src/effects/endpoint.effects.ts +++ b/src/frontend/packages/store/src/effects/endpoint.effects.ts @@ -278,7 +278,6 @@ export class EndpointsEffect { url: string, params: HttpParams, apiActionType: ApiRequestTypes = 'update', - endpointType: EndpointType, body?: string, errorMessageHandler?: (e: any) => string, diff --git a/src/frontend/packages/store/src/effects/user-profile.effects.ts b/src/frontend/packages/store/src/effects/user-profile.effects.ts index 26e12c0401..81c0816a0c 100644 --- a/src/frontend/packages/store/src/effects/user-profile.effects.ts +++ b/src/frontend/packages/store/src/effects/user-profile.effects.ts @@ -81,7 +81,7 @@ export class UserProfileEffect { 'x-stratos-password-new': action.passwordChanges.password }; return this.httpClient.put(`/pp/${proxyAPIVersion}/users/${userGuid}/password`, action.passwordChanges, { headers }).pipe( - switchMap((info: UserProfileInfo) => {// TODO: RC push result back into store?? + switchMap((info: UserProfileInfo) => {// TODO: RC TEST & push result back into store?? return [ new WrapperRequestActionSuccess({ entities: {}, diff --git a/src/frontend/packages/store/src/selectors/endpoint.selectors.ts b/src/frontend/packages/store/src/selectors/endpoint.selectors.ts index 05cb67c88f..a77a92e217 100644 --- a/src/frontend/packages/store/src/selectors/endpoint.selectors.ts +++ b/src/frontend/packages/store/src/selectors/endpoint.selectors.ts @@ -12,10 +12,9 @@ export const endpointStatusSelector = (state: InternalAppState): EndpointState = // All endpoint request data // Note - Replacing `buildEntityKey` with `entityCatalog.getEntityKey` will cause circular dependency const endpointEntityKey = EntityCatalogHelpers.buildEntityKey(endpointEntityType, STRATOS_ENDPOINT_TYPE); -// TODO: RC search for this. should replace almost everywhere with stratosEntityCatalog access export const endpointEntitiesSelector = selectEntities(endpointEntityKey); -export const endpointOfType = (type: string) => +const endpointOfType = (type: string) => (endpoints: IRequestEntityTypeState): IRequestEntityTypeState => { return Object.values(endpoints || {}).reduce((endpointsOfType, endpoint) => { if (endpoint.cnsi_type === type) { diff --git a/src/frontend/packages/store/src/stratos-action-builders.ts b/src/frontend/packages/store/src/stratos-action-builders.ts index f9b5004580..2855407bbe 100644 --- a/src/frontend/packages/store/src/stratos-action-builders.ts +++ b/src/frontend/packages/store/src/stratos-action-builders.ts @@ -77,9 +77,6 @@ export interface EndpointActionBuilder extends OrchestratedActionBuilders { ) => UpdateEndpoint, } -// TODO: RC reg sterpper, connect with dodgy creds, no error -// TODO: RC connect endpoint whilst on list. connection status changes... but dialog shows.. error in return currentUserCfRolesRequestStateReducer(state, action as GetCfUserRelations); - export const endpointActionBuilder: EndpointActionBuilder = { get: (guid: string) => new GetEndpoint(guid), getAll: (login: boolean) => new GetAllEndpoints(login), diff --git a/src/frontend/packages/store/src/stratos-entity-catalog.ts b/src/frontend/packages/store/src/stratos-entity-catalog.ts index b6d48446e4..ae0816e1e6 100644 --- a/src/frontend/packages/store/src/stratos-entity-catalog.ts +++ b/src/frontend/packages/store/src/stratos-entity-catalog.ts @@ -9,31 +9,33 @@ import { UserProfileActionBuilder, } from './stratos-action-builders'; import { EndpointModel } from './types/endpoint.types'; +import { SystemInfo } from './types/system.types'; +import { UserFavorite } from './types/user-favorites.types'; import { UserProfileInfo } from './types/user-profile.types'; // TODO: RC Test all of these actions export class StratosEntityCatalog { endpoint: StratosCatalogEntity< - any,//TODO: RC + undefined, EndpointModel, EndpointActionBuilder > systemInfo: StratosCatalogEntity< - any, - any, //TODO: RC + undefined, + SystemInfo, SystemInfoActionBuilder > userFavorite: StratosCatalogEntity< - any, - any, //TODO: RC + undefined, + UserFavorite, UserFavoriteActionBuilder > userProfile: StratosCatalogEntity< - any,//TODO: RC + undefined, UserProfileInfo, UserProfileActionBuilder > diff --git a/src/frontend/packages/store/src/stratos-entity-generator.ts b/src/frontend/packages/store/src/stratos-entity-generator.ts index 858eb42588..078ecad5ad 100644 --- a/src/frontend/packages/store/src/stratos-entity-generator.ts +++ b/src/frontend/packages/store/src/stratos-entity-generator.ts @@ -33,6 +33,9 @@ import { userProfileActionBuilder, } from './stratos-action-builders'; import { stratosEntityCatalog } from './stratos-entity-catalog'; +import { SystemInfo } from './types/system.types'; +import { UserFavorite } from './types/user-favorites.types'; +import { UserProfileInfo } from './types/user-profile.types'; export function generateStratosEntities(): StratosBaseCatalogEntity[] { /** @@ -64,7 +67,7 @@ function generateEndpoint(stratosType) { endpoint: stratosType, } stratosEntityCatalog.endpoint = new StratosCatalogEntity< - any,//TODO: RC + undefined, EndpointModel, EndpointActionBuilder >( @@ -86,8 +89,8 @@ function generateSystemInfo(stratosType) { endpoint: stratosType, } stratosEntityCatalog.systemInfo = new StratosCatalogEntity< - any, - any, //TODO: RC + undefined, + SystemInfo, SystemInfoActionBuilder >( definition, @@ -105,8 +108,8 @@ function generateUserFavorite(stratosType) { endpoint: stratosType, } stratosEntityCatalog.userFavorite = new StratosCatalogEntity< - any, - any, //TODO: RC + undefined, + UserFavorite, UserFavoriteActionBuilder >( definition, @@ -128,14 +131,15 @@ function generateUserProfile(stratosType) { endpoint: stratosType, } stratosEntityCatalog.userProfile = new StratosCatalogEntity< - any, - any, //TODO: RC - UserProfileActionBuilder>( - definition, - { - actionBuilders: userProfileActionBuilder - } - ) + undefined, + UserProfileInfo, + UserProfileActionBuilder + >( + definition, + { + actionBuilders: userProfileActionBuilder + } + ) return stratosEntityCatalog.userProfile; } From f7a0d9e84fa7a9b322124c71e85ff708ed71b664 Mon Sep 17 00:00:00 2001 From: Richard Cox Date: Mon, 22 Jun 2020 15:01:10 +0100 Subject: [PATCH 06/12] Fix favourites --- .../create-endpoint-cf-step-1.component.ts | 3 +- .../favorite-config-mapper.ts | 4 +- .../endpoint-card/endpoint-card.component.ts | 2 - .../src/actions/user-favourites.actions.ts | 42 +++++----- .../src/effects/user-favorites-effect.ts | 82 ++++++++++--------- .../entity-catalog-entity.ts | 1 - .../plugins/userfavorites/favorites.go | 8 +- 7 files changed, 74 insertions(+), 68 deletions(-) diff --git a/src/frontend/packages/core/src/features/endpoints/create-endpoint/create-endpoint-cf-step-1/create-endpoint-cf-step-1.component.ts b/src/frontend/packages/core/src/features/endpoints/create-endpoint/create-endpoint-cf-step-1/create-endpoint-cf-step-1.component.ts index f31d6addfd..56f784e3ea 100644 --- a/src/frontend/packages/core/src/features/endpoints/create-endpoint/create-endpoint-cf-step-1/create-endpoint-cf-step-1.component.ts +++ b/src/frontend/packages/core/src/features/endpoints/create-endpoint/create-endpoint-cf-step-1/create-endpoint-cf-step-1.component.ts @@ -2,7 +2,7 @@ import { AfterContentInit, Component, Input, ViewChild } from '@angular/core'; import { NgForm, NgModel } from '@angular/forms'; import { ActivatedRoute } from '@angular/router'; import { Observable } from 'rxjs'; -import { filter, map, pairwise, tap } from 'rxjs/operators'; +import { filter, map, pairwise } from 'rxjs/operators'; import { entityCatalog } from '../../../../../../store/src/entity-catalog/entity-catalog'; import { @@ -86,7 +86,6 @@ export class CreateEndpointCfStep1Component implements IStepperStep, AfterConten this.clientSecretField ? this.clientSecretField.value : '', this.ssoAllowedField ? !!this.ssoAllowedField.value : false, ).pipe( - tap(a => console.log('REGISTER RES: ', a)), pairwise(), filter(([oldVal, newVal]) => (oldVal.busy && !newVal.busy)), map(([oldVal, newVal]) => newVal), diff --git a/src/frontend/packages/core/src/shared/components/favorites-meta-card/favorite-config-mapper.ts b/src/frontend/packages/core/src/shared/components/favorites-meta-card/favorite-config-mapper.ts index 94e4d2bbd6..be98c292e7 100644 --- a/src/frontend/packages/core/src/shared/components/favorites-meta-card/favorite-config-mapper.ts +++ b/src/frontend/packages/core/src/shared/components/favorites-meta-card/favorite-config-mapper.ts @@ -167,13 +167,13 @@ export class FavoritesConfigMapper { public getFavoriteEndpointFromEntity( endpoint: EndpointModel - ) { + ): UserFavoriteEndpoint { return this.getFavoriteFromEntity( EntityCatalogHelpers.endpointType, endpoint.cnsi_type, endpoint.guid, endpoint - ) as UserFavoriteEndpoint; + ); } } diff --git a/src/frontend/packages/core/src/shared/components/list/list-types/endpoint/endpoint-card/endpoint-card.component.ts b/src/frontend/packages/core/src/shared/components/list/list-types/endpoint/endpoint-card/endpoint-card.component.ts index 581680cd4f..68ab2b688a 100644 --- a/src/frontend/packages/core/src/shared/components/list/list-types/endpoint/endpoint-card/endpoint-card.component.ts +++ b/src/frontend/packages/core/src/shared/components/list/list-types/endpoint/endpoint-card/endpoint-card.component.ts @@ -9,7 +9,6 @@ import { ViewContainerRef, } from '@angular/core'; import { Store } from '@ngrx/store'; -import { CurrentUserPermissionsService } from 'frontend/packages/core/src/core/permissions/current-user-permissions.service'; import { AppState } from 'frontend/packages/store/src/app-state'; import { Observable, of, ReplaySubject, Subscription } from 'rxjs'; import { map, startWith } from 'rxjs/operators'; @@ -126,7 +125,6 @@ export class EndpointCardComponent extends CardCell implements On private endpointListHelper: EndpointListHelper, private componentFactoryResolver: ComponentFactoryResolver, private favoritesConfigMapper: FavoritesConfigMapper, - private currentUserPermissionsService: CurrentUserPermissionsService, ) { super(); this.endpointIds$ = this.endpointIds.asObservable(); diff --git a/src/frontend/packages/store/src/actions/user-favourites.actions.ts b/src/frontend/packages/store/src/actions/user-favourites.actions.ts index 76101f101c..c4fcfdf744 100644 --- a/src/frontend/packages/store/src/actions/user-favourites.actions.ts +++ b/src/frontend/packages/store/src/actions/user-favourites.actions.ts @@ -34,9 +34,9 @@ abstract class BaseMultipleUserFavouritesAction extends BaseUserFavoritesAction abstract class BaseSuccessFavouritesAction extends BaseMultipleUserFavouritesAction { constructor( - paginationKey: string, + type: string, public favorites: UserFavorite[], - type: string + paginationKey: string, ) { super(type, paginationKey); } @@ -44,8 +44,8 @@ abstract class BaseSuccessFavouritesAction extends BaseMultipleUserFavouritesAct abstract class BaseSuccessFavouriteAction extends BaseSingleUserFavouritesAction { constructor( + type: string, public favorite: UserFavorite, - type: string ) { super(type, favorite.guid); } @@ -55,7 +55,7 @@ abstract class BaseSuccessFavouriteAction extends BaseSingleUserFavouritesAction export class GetUserFavoritesAction extends BaseMultipleUserFavouritesAction { static PAGINATION_KEY = 'user_favourites'; - static ACTION_TYPE = 'GET_USER_FAVORITES'; + static ACTION_TYPE = '[Favorite] Get Favorites'; constructor() { super( GetUserFavoritesAction.ACTION_TYPE, @@ -65,18 +65,18 @@ export class GetUserFavoritesAction extends BaseMultipleUserFavouritesAction { } export class GetUserFavoritesSuccessAction extends BaseSuccessFavouritesAction { - static ACTION_TYPE = 'GET_USER_FAVORITES_SUCCESS'; + static ACTION_TYPE = '[Favorite] Get Favorites Success'; constructor(favorites: UserFavorite[]) { super( - GetUserFavoritesAction.PAGINATION_KEY, + GetUserFavoritesSuccessAction.ACTION_TYPE, favorites, - GetUserFavoritesSuccessAction.ACTION_TYPE + GetUserFavoritesAction.PAGINATION_KEY, ); } } export class GetUserFavoritesFailedAction extends BaseMultipleUserFavouritesAction { - static ACTION_TYPE = 'GET_USER_FAVORITES_FAILED'; + static ACTION_TYPE = '[Favorite] Get Favorites Failed'; constructor() { super( GetUserFavoritesFailedAction.ACTION_TYPE, @@ -88,58 +88,58 @@ export class GetUserFavoritesFailedAction extends BaseMultipleUserFavouritesActi // --------- export class RemoveUserFavoriteAction extends BaseSingleUserFavouritesAction { - static ACTION_TYPE = 'REMOVE_USER_FAVORITE'; + static ACTION_TYPE = '[Favorite] Remove Favorite'; constructor(public favorite: UserFavorite) { super( + RemoveUserFavoriteAction.ACTION_TYPE, favorite.guid, - RemoveUserFavoriteAction.ACTION_TYPE ); } } export class RemoveUserFavoriteSuccessAction extends BaseSuccessFavouriteAction { - static ACTION_TYPE = 'REMOVE_USER_FAVORITE_SUCCESS'; + static ACTION_TYPE = '[Favorite] Remove Favorite Success'; constructor(favorite: UserFavorite) { - super(favorite, RemoveUserFavoriteSuccessAction.ACTION_TYPE); + super(RemoveUserFavoriteSuccessAction.ACTION_TYPE, favorite) } } // --------- export class SaveUserFavoriteAction extends BaseSingleUserFavouritesAction { - static ACTION_TYPE = 'SAVE_USER_FAVORITE'; + static ACTION_TYPE = '[Favorite] Save Favorite'; constructor(public favorite: UserFavorite) { super(SaveUserFavoriteAction.ACTION_TYPE, favorite.guid); } } export class SaveUserFavoriteSuccessAction extends BaseSuccessFavouriteAction { - static ACTION_TYPE = 'SAVE_USER_FAVORITE_SUCCESS'; + static ACTION_TYPE = '[Favorite] Save Favorite Success'; constructor(favorite: UserFavorite) { - super(favorite, SaveUserFavoriteSuccessAction.ACTION_TYPE); + super(SaveUserFavoriteSuccessAction.ACTION_TYPE, favorite); } } // --------- export class ToggleUserFavoriteAction extends BaseSingleUserFavouritesAction { - static ACTION_TYPE = 'TOGGLE_USER_FAVORITE'; + static ACTION_TYPE = '[Favorite] Toggle Favorite'; constructor(public favorite: UserFavorite) { - super(favorite.guid, ToggleUserFavoriteAction.ACTION_TYPE); + super(ToggleUserFavoriteAction.ACTION_TYPE, favorite.guid); } } // --------- export class UpdateUserFavoriteMetadataAction extends BaseSingleUserFavouritesAction { - static ACTION_TYPE = 'UPDATE_FAVORITE_METADATA'; + static ACTION_TYPE = '[Favorite] Update Favorite Metadata'; constructor(public favorite: UserFavorite) { - super(favorite.guid, UpdateUserFavoriteMetadataAction.ACTION_TYPE); + super(UpdateUserFavoriteMetadataAction.ACTION_TYPE, favorite.guid); } } export class UpdateUserFavoriteMetadataSuccessAction extends BaseSuccessFavouriteAction { - static ACTION_TYPE = 'UPDATE_FAVORITE_METADATA_SUCCESS'; + static ACTION_TYPE = '[Favorite] Update Favorite Metadata Success'; constructor(public favorite: UserFavorite) { - super(favorite, UpdateUserFavoriteMetadataSuccessAction.ACTION_TYPE); + super(UpdateUserFavoriteMetadataSuccessAction.ACTION_TYPE, favorite); } } diff --git a/src/frontend/packages/store/src/effects/user-favorites-effect.ts b/src/frontend/packages/store/src/effects/user-favorites-effect.ts index 82d4bf44aa..02240e52af 100644 --- a/src/frontend/packages/store/src/effects/user-favorites-effect.ts +++ b/src/frontend/packages/store/src/effects/user-favorites-effect.ts @@ -2,7 +2,7 @@ import { HttpClient } from '@angular/common/http'; import { Injectable } from '@angular/core'; import { Actions, Effect, ofType } from '@ngrx/effects'; import { Store } from '@ngrx/store'; -import { catchError, first, map, mergeMap, switchMap } from 'rxjs/operators'; +import { catchError, first, mergeMap, switchMap } from 'rxjs/operators'; import { ClearPaginationOfEntity } from '../actions/pagination.actions'; import { @@ -45,25 +45,27 @@ export class UserFavoritesEffect { const actionType = 'update'; this.store.dispatch(new StartRequestAction(action, actionType)) return this.http.post>(favoriteUrlPath, action.favorite).pipe( - mergeMap(newFavorite => [ - new WrapperRequestActionSuccess(null, action, actionType), - new SaveUserFavoriteSuccessAction(newFavorite) - ]), - catchError(() => [ - new WrapperRequestActionFailed('Failed to update user favorite', action, actionType) - ]) + switchMap(newFavorite => { + this.store.dispatch(new WrapperRequestActionSuccess(null, action, actionType)); + this.store.dispatch(new SaveUserFavoriteSuccessAction(newFavorite)); + return []; + }), + catchError(() => { + this.store.dispatch(new WrapperRequestActionFailed('Failed to update user favorite', action, actionType)); + return []; + }) ); }) ); @Effect({ dispatch: false }) getFavorite$ = this.actions$.pipe( ofType(GetUserFavoritesAction.ACTION_TYPE), - mergeMap((action: GetUserFavoritesAction) => { + switchMap((action: GetUserFavoritesAction) => { const favEntityKey = entityCatalog.getEntityKey(action); const actionType = 'fetch'; this.store.dispatch(new StartRequestAction(action, actionType)) return this.http.get[]>(favoriteUrlPath).pipe( - map(favorites => { + switchMap(favorites => { const mappedData = favorites.reduce>>((data, favorite) => { const { guid } = favorite; if (guid) { @@ -72,15 +74,15 @@ export class UserFavoritesEffect { } return data; }, { entities: { [favEntityKey]: {} }, result: [] }); - return [ - new WrapperRequestActionSuccess(mappedData, action), - new GetUserFavoritesSuccessAction(favorites) - ] + this.store.dispatch(new WrapperRequestActionSuccess(mappedData, action, actionType, mappedData.result.length, 1)); + this.store.dispatch(new GetUserFavoritesSuccessAction(favorites)); + return []; }), - catchError(() => [ - new GetUserFavoritesFailedAction(), - new WrapperRequestActionFailed('Failed to fetch user favorites', action, actionType) - ]) + catchError(() => { + this.store.dispatch(new GetUserFavoritesFailedAction()) + this.store.dispatch(new WrapperRequestActionFailed('Failed to fetch user favorites', action, actionType)) + return []; + }) ); }) ); @@ -90,11 +92,11 @@ export class UserFavoritesEffect { mergeMap(action => this.userFavoriteManager.getIsFavoriteObservable(action.favorite).pipe( first(), - map(isFav => { + switchMap(isFav => { if (isFav) { - return new RemoveUserFavoriteAction(action.favorite); + return [new RemoveUserFavoriteAction(action.favorite)]; } else { - return new SaveUserFavoriteAction(action.favorite); + return [new SaveUserFavoriteAction(action.favorite)]; } }) ) @@ -103,38 +105,42 @@ export class UserFavoritesEffect { @Effect({ dispatch: false }) removeFavorite$ = this.actions$.pipe( ofType(RemoveUserFavoriteAction.ACTION_TYPE), - switchMap((action: RemoveUserFavoriteAction) => { + mergeMap((action: RemoveUserFavoriteAction) => { const actionType = 'update'; this.store.dispatch(new StartRequestAction(action, actionType)) return this.http.delete>(`${favoriteUrlPath}/${action.guid}`).pipe( - map(() => [ - new WrapperRequestActionSuccess(null, action), - new RemoveUserFavoriteSuccessAction(action.favorite), - new ClearPaginationOfEntity(action.entity[0], action.guid, userFavoritesPaginationKey) - ]), - catchError(() => [ - new WrapperRequestActionFailed('Failed to remove user favorite', action, actionType) - ]) + switchMap(() => { + this.store.dispatch(new WrapperRequestActionSuccess(null, action)); + this.store.dispatch(new RemoveUserFavoriteSuccessAction(action.favorite)); + this.store.dispatch(new ClearPaginationOfEntity(action.entity[0], action.guid, userFavoritesPaginationKey)); + return []; + }), + catchError(() => { + this.store.dispatch(new WrapperRequestActionFailed('Failed to remove user favorite', action, actionType)); + return []; + }) ); }) ); @Effect() updateMetadata$ = this.actions$.pipe( ofType(UpdateUserFavoriteMetadataAction.ACTION_TYPE), - switchMap((action: UpdateUserFavoriteMetadataAction) => { + mergeMap((action: UpdateUserFavoriteMetadataAction) => { const actionType = 'update'; this.store.dispatch(new StartRequestAction(action, actionType)) return this.http.post>( `${favoriteUrlPath}/${action.favorite.guid}/metadata`, action.favorite.metadata ).pipe( - map(() => [ - new WrapperRequestActionSuccess(null, action), - new UpdateUserFavoriteMetadataSuccessAction(action.favorite) - ]), - catchError(() => [ - new WrapperRequestActionFailed('Failed to update user favorite', action, actionType) - ]) + switchMap(() => { + this.store.dispatch(new WrapperRequestActionSuccess(null, action)); + this.store.dispatch(new UpdateUserFavoriteMetadataSuccessAction(action.favorite)); + return []; + }), + catchError(() => { + this.store.dispatch(new WrapperRequestActionFailed('Failed to update user favorite', action, actionType)); + return []; + }) ); }) ); diff --git a/src/frontend/packages/store/src/entity-catalog/entity-catalog-entity/entity-catalog-entity.ts b/src/frontend/packages/store/src/entity-catalog/entity-catalog-entity/entity-catalog-entity.ts index fedbad3db8..3b0d9e7bcf 100644 --- a/src/frontend/packages/store/src/entity-catalog/entity-catalog-entity/entity-catalog-entity.ts +++ b/src/frontend/packages/store/src/entity-catalog/entity-catalog-entity/entity-catalog-entity.ts @@ -74,7 +74,6 @@ export class StratosBaseCatalogEntity< this.entityKey = this.isEndpoint ? EntityCatalogHelpers.buildEntityKey(EntityCatalogHelpers.endpointType, baseEntity.type) : EntityCatalogHelpers.buildEntityKey(baseEntity.type, baseEntity.endpoint.type); - console.log(definition, this.entityKey) const actionBuilders = ActionBuilderConfigMapper.getActionBuilders( this.builders.actionBuilders, this.endpointType, diff --git a/src/jetstream/plugins/userfavorites/favorites.go b/src/jetstream/plugins/userfavorites/favorites.go index 7d87db1146..878a95d25a 100644 --- a/src/jetstream/plugins/userfavorites/favorites.go +++ b/src/jetstream/plugins/userfavorites/favorites.go @@ -139,7 +139,9 @@ func (uf *UserFavorites) create(c echo.Context) error { return interfaces.NewHTTPShadowError( http.StatusBadRequest, "Failed to save favorite to db", - "Failed to save favorite to db") + "Failed to save favorite to db %+v", + err, + ) } jsonString, err := json.Marshal(updatedFavorite) @@ -147,7 +149,9 @@ func (uf *UserFavorites) create(c echo.Context) error { return interfaces.NewHTTPShadowError( http.StatusBadRequest, "Failed to Marshal favorite from db", - "Failed to Marshal favorite from db") + "Failed to Marshal favorite from db %+v", + err, + ) } c.Response().Header().Set("Content-Type", "application/json") From 4395186bfcda03e673b9a0e8f6d76554d2601e91 Mon Sep 17 00:00:00 2001 From: Richard Cox Date: Mon, 22 Jun 2020 15:05:11 +0100 Subject: [PATCH 07/12] Removed some TODOs --- .../cf-quotas/cf-quotas-data-source.service.ts | 1 - .../cf-space-quotas-data-source.service.ts | 1 - .../permissions/current-user-permissions.service.ts | 1 - .../meta-card/meta-card-base/meta-card.component.ts | 10 +++++++++- 4 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/frontend/packages/cloud-foundry/src/shared/components/list/list-types/cf-quotas/cf-quotas-data-source.service.ts b/src/frontend/packages/cloud-foundry/src/shared/components/list/list-types/cf-quotas/cf-quotas-data-source.service.ts index b40ab5555e..1771755cb0 100644 --- a/src/frontend/packages/cloud-foundry/src/shared/components/list/list-types/cf-quotas/cf-quotas-data-source.service.ts +++ b/src/frontend/packages/cloud-foundry/src/shared/components/list/list-types/cf-quotas/cf-quotas-data-source.service.ts @@ -44,7 +44,6 @@ export class CfQuotasDataSourceService extends ListDataSource { if (!this.sourceScheme || !row) { return of(getDefaultRowState()); } - // TODO: RC test return cfEntityCatalog.quotaDefinition.store.getEntityMonitor(this.getRowUniqueId(row)).entityRequest$.pipe( distinctUntilChanged(), map(requestInfo => ({ diff --git a/src/frontend/packages/cloud-foundry/src/shared/components/list/list-types/cf-space-quotas/cf-space-quotas-data-source.service.ts b/src/frontend/packages/cloud-foundry/src/shared/components/list/list-types/cf-space-quotas/cf-space-quotas-data-source.service.ts index 3df5ab34e2..cd9e0e00c1 100644 --- a/src/frontend/packages/cloud-foundry/src/shared/components/list/list-types/cf-space-quotas/cf-space-quotas-data-source.service.ts +++ b/src/frontend/packages/cloud-foundry/src/shared/components/list/list-types/cf-space-quotas/cf-space-quotas-data-source.service.ts @@ -45,7 +45,6 @@ export class CfOrgSpaceQuotasDataSourceService extends ListDataSource ({ diff --git a/src/frontend/packages/core/src/core/permissions/current-user-permissions.service.ts b/src/frontend/packages/core/src/core/permissions/current-user-permissions.service.ts index 9d2b92d263..4ad096b7c5 100644 --- a/src/frontend/packages/core/src/core/permissions/current-user-permissions.service.ts +++ b/src/frontend/packages/core/src/core/permissions/current-user-permissions.service.ts @@ -76,7 +76,6 @@ export class CurrentUserPermissionsService { } else if (actionConfig) { return this.getSimplePermission(actionConfig, endpointGuid, ...args); } else if (endpointGuid) { - // TODO: RC test return stratosEntityCatalog.endpoint.store.getEntityMonitor(endpointGuid).entity$.pipe( switchMap(endpoint => endpoint ? this.getFallbackPermission(endpointGuid, endpoint.cnsi_type) : diff --git a/src/frontend/packages/core/src/shared/components/list/list-cards/meta-card/meta-card-base/meta-card.component.ts b/src/frontend/packages/core/src/shared/components/list/list-cards/meta-card/meta-card-base/meta-card.component.ts index ced89b65c0..8c086bf3bb 100644 --- a/src/frontend/packages/core/src/shared/components/list/list-cards/meta-card/meta-card-base/meta-card.component.ts +++ b/src/frontend/packages/core/src/shared/components/list/list-cards/meta-card/meta-card-base/meta-card.component.ts @@ -45,8 +45,16 @@ export class MetaCardComponent implements OnDestroy { @Input() status$: Observable; + // @Input() + // public favorite: UserFavorite; + private _favorite: UserFavorite; @Input() - public favorite: UserFavorite; + set favorite(favorite: UserFavorite) { + this._favorite = favorite; + } + get favorite(): UserFavorite { + return this._favorite; + } @Input() public confirmFavoriteRemoval = false; From 5ea088cc67b7ae97b486fce2ddbd6e7c73c3d9f2 Mon Sep 17 00:00:00 2001 From: Richard Cox Date: Mon, 22 Jun 2020 17:01:38 +0100 Subject: [PATCH 08/12] Fixes & todos --- .../cloud-foundry/src/cf-entity-generator.ts | 16 ++++-- .../current-cf-user-role-session.reducer.ts | 2 +- .../current-cf-user-roles-clear.reducers.ts | 2 +- .../src/features/endpoints/connect.service.ts | 4 +- .../create-endpoint-cf-step-1.component.ts | 11 ++-- .../edit-profile-info.component.ts | 6 +-- .../app-action-monitor-icon.component.spec.ts | 4 +- .../favorites-entity-list.component.ts | 3 ++ .../favorite-config-mapper.ts | 13 +++-- ...ell-request-monitor-icon.component.spec.ts | 4 +- .../store/src/actions/endpoint.actions.ts | 50 +++++++++++-------- .../store/src/effects/endpoint.effects.ts | 17 +++---- .../store/src/effects/permissions.effect.ts | 2 +- .../store/src/effects/system.effects.ts | 6 +-- .../store/src/effects/user-profile.effects.ts | 4 +- ...agination-reducer-clear-pagination-type.ts | 5 +- .../src/reducers/system-endpoints.reducer.ts | 1 - .../store/src/stratos-action-builders.ts | 7 +-- .../store/testing/src/store-test-helper.ts | 4 +- 19 files changed, 89 insertions(+), 72 deletions(-) diff --git a/src/frontend/packages/cloud-foundry/src/cf-entity-generator.ts b/src/frontend/packages/cloud-foundry/src/cf-entity-generator.ts index bfa85e3813..3c3a56a899 100644 --- a/src/frontend/packages/cloud-foundry/src/cf-entity-generator.ts +++ b/src/frontend/packages/cloud-foundry/src/cf-entity-generator.ts @@ -409,7 +409,9 @@ function generateCFQuotaDefinitionEntity(endpointDefinition: StratosEndpointExte const definition: IStratosEntityDefinition = { type: quotaDefinitionEntityType, schema: cfEntityFactory(quotaDefinitionEntityType), - endpoint: endpointDefinition + endpoint: endpointDefinition, + label: 'Organization Quota', + labelPlural: 'Organization Quotas', }; cfEntityCatalog.quotaDefinition = new StratosCatalogEntity< IBasicCFMetaData, @@ -451,6 +453,8 @@ function generateCFAppEnvVarEntity(endpointDefinition: StratosEndpointExtensionD } }; }, + label: 'App Env Var', + labelPlural: 'App Env Vars', }; cfEntityCatalog.appEnvVar = new StratosCatalogEntity< IBasicCFMetaData, @@ -478,6 +482,8 @@ function generateCFAppSummaryEntity(endpointDefinition: StratosEndpointExtension type: appSummaryEntityType, schema: cfEntityFactory(appSummaryEntityType), endpoint: endpointDefinition, + label: 'App Summary', + labelPlural: 'App Summaries', }; cfEntityCatalog.appSummary = new StratosCatalogEntity(definition, { dataReducers: [ @@ -500,7 +506,9 @@ function generateCFSpaceQuotaEntity(endpointDefinition: StratosEndpointExtension const definition: IStratosEntityDefinition = { type: spaceQuotaEntityType, schema: cfEntityFactory(spaceQuotaEntityType), - endpoint: endpointDefinition + endpoint: endpointDefinition, + label: 'Space Quota', + labelPlural: 'Space Quotas', }; cfEntityCatalog.spaceQuota = new StratosCatalogEntity< IBasicCFMetaData, @@ -518,7 +526,9 @@ function generateCFPrivateDomainEntity(endpointDefinition: StratosEndpointExtens const definition: IStratosEntityDefinition = { type: privateDomainsEntityType, schema: cfEntityFactory(privateDomainsEntityType), - endpoint: endpointDefinition + endpoint: endpointDefinition, + label: 'Private Domain', + labelPlural: 'Private Domains', }; cfEntityCatalog.privateDomain = new StratosCatalogEntity>(definition, { dataReducers: [ diff --git a/src/frontend/packages/cloud-foundry/src/store/reducers/current-cf-user-roles-reducer/current-cf-user-role-session.reducer.ts b/src/frontend/packages/cloud-foundry/src/store/reducers/current-cf-user-roles-reducer/current-cf-user-role-session.reducer.ts index 125258e829..5778477b89 100644 --- a/src/frontend/packages/cloud-foundry/src/store/reducers/current-cf-user-roles-reducer/current-cf-user-role-session.reducer.ts +++ b/src/frontend/packages/cloud-foundry/src/store/reducers/current-cf-user-roles-reducer/current-cf-user-role-session.reducer.ts @@ -24,7 +24,7 @@ export function updateNewlyConnectedCfEndpoint( state: IAllCfRolesState, action: EndpointActionComplete ): IAllCfRolesState { - if (action.completeEndpointType !== CF_ENDPOINT_TYPE) { + if (action.endpointType !== CF_ENDPOINT_TYPE) { return state; } const endpoint = action.endpoint as INewlyConnectedEndpointInfo; diff --git a/src/frontend/packages/cloud-foundry/src/store/reducers/current-cf-user-roles-reducer/current-cf-user-roles-clear.reducers.ts b/src/frontend/packages/cloud-foundry/src/store/reducers/current-cf-user-roles-reducer/current-cf-user-roles-clear.reducers.ts index 9717cc8ad2..ade79d48f4 100644 --- a/src/frontend/packages/cloud-foundry/src/store/reducers/current-cf-user-roles-reducer/current-cf-user-roles-clear.reducers.ts +++ b/src/frontend/packages/cloud-foundry/src/store/reducers/current-cf-user-roles-reducer/current-cf-user-roles-clear.reducers.ts @@ -19,7 +19,7 @@ export function removeEndpointCfRoles(state: IAllCfRolesState, action: EndpointA } export function addCfEndpoint(state: IAllCfRolesState, action: EndpointActionComplete) { - if (action.completeEndpointType !== CF_ENDPOINT_TYPE) { + if (action.endpointType !== CF_ENDPOINT_TYPE) { return state; } const endpoint = action.endpoint as EndpointModel; diff --git a/src/frontend/packages/core/src/features/endpoints/connect.service.ts b/src/frontend/packages/core/src/features/endpoints/connect.service.ts index 870f816263..9272b408b9 100644 --- a/src/frontend/packages/core/src/features/endpoints/connect.service.ts +++ b/src/frontend/packages/core/src/features/endpoints/connect.service.ts @@ -66,8 +66,9 @@ export class ConnectEndpointService { pairwise() ).subscribe(([oldVal, newVal]) => { if (!newVal.error && (oldVal.busy && !newVal.busy)) { + // TODO: RC Q Shouldn't this be in `next`? // Has finished fetching - stratosEntityCatalog.endpoint.api.get(this.config.guid); // TODO: RC Test + stratosEntityCatalog.endpoint.api.get(this.config.guid); } })); @@ -84,7 +85,6 @@ export class ConnectEndpointService { this.update$ = stratosEntityCatalog.endpoint.store.getEntityMonitor(this.config.guid).getUpdatingSection(ConnectEndpoint.UpdatingKey) .pipe(filter(update => !!update)); - // TODO: RC TEST... is systeminfo updated on connect? should this dispatch system info instead? this.fetchingInfo$ = stratosEntityCatalog.endpoint.store.getEntityMonitor(this.config.guid).entityRequest$.pipe( filter(request => !!request), map(request => request.fetching) diff --git a/src/frontend/packages/core/src/features/endpoints/create-endpoint/create-endpoint-cf-step-1/create-endpoint-cf-step-1.component.ts b/src/frontend/packages/core/src/features/endpoints/create-endpoint/create-endpoint-cf-step-1/create-endpoint-cf-step-1.component.ts index 56f784e3ea..97de4217b6 100644 --- a/src/frontend/packages/core/src/features/endpoints/create-endpoint/create-endpoint-cf-step-1/create-endpoint-cf-step-1.component.ts +++ b/src/frontend/packages/core/src/features/endpoints/create-endpoint/create-endpoint-cf-step-1/create-endpoint-cf-step-1.component.ts @@ -55,14 +55,11 @@ export class CreateEndpointCfStep1Component implements IStepperStep, AfterConten activatedRoute: ActivatedRoute, private snackBarService: SnackBarService ) { - // TODO: RC test this.existingEndpoints = stratosEntityCatalog.endpoint.store.getAll.getPaginationMonitor().currentPage$.pipe( - map(endpoints => { - return { - names: endpoints.map(ep => ep.name), - urls: endpoints.map(ep => getFullEndpointApiUrl(ep)), - }; - }) + map(endpoints => ({ + names: endpoints.map(ep => ep.name), + urls: endpoints.map(ep => getFullEndpointApiUrl(ep)), + })) ); const epType = getIdFromRoute(activatedRoute, 'type'); diff --git a/src/frontend/packages/core/src/features/user-profile/edit-profile-info/edit-profile-info.component.ts b/src/frontend/packages/core/src/features/user-profile/edit-profile-info/edit-profile-info.component.ts index 54194241ee..75aa2b69bf 100644 --- a/src/frontend/packages/core/src/features/user-profile/edit-profile-info/edit-profile-info.component.ts +++ b/src/frontend/packages/core/src/features/user-profile/edit-profile-info/edit-profile-info.component.ts @@ -2,7 +2,7 @@ import { Component, OnDestroy, OnInit } from '@angular/core'; import { AbstractControl, FormBuilder, FormGroup, ValidatorFn, Validators } from '@angular/forms'; import { ErrorStateMatcher, ShowOnDirtyErrorStateMatcher } from '@angular/material/core'; import { Subscription } from 'rxjs'; -import { first, map, take, tap } from 'rxjs/operators'; +import { delay, first, map, take, tap } from 'rxjs/operators'; import { UserProfileInfo, UserProfileInfoUpdates } from '../../../../../store/src/types/user-profile.types'; import { CurrentUserPermissionsService } from '../../../core/permissions/current-user-permissions.service'; @@ -119,8 +119,7 @@ export class EditProfileInfoComponent implements OnInit, OnDestroy { updates[key] = this.editProfileForm.value[key]; } } - const obs$ = this.userProfileService.updateProfile(this.profile, updates); - return obs$.pipe( + return this.userProfileService.updateProfile(this.profile, updates).pipe( take(1), map(([profileResult, passwordResult]) => { const okay = !profileResult.error && !passwordResult.error; @@ -131,6 +130,7 @@ export class EditProfileInfoComponent implements OnInit, OnDestroy { message: okay ? '' : `An error occurred whilst updating your profile: ${message}` }; }), + delay(300), // Ensure that the profile is updated before fetching to refresh local copy tap(() => this.userProfileService.fetchUserProfile()) ); } diff --git a/src/frontend/packages/core/src/shared/components/app-action-monitor-icon/app-action-monitor-icon.component.spec.ts b/src/frontend/packages/core/src/shared/components/app-action-monitor-icon/app-action-monitor-icon.component.spec.ts index 06860cf718..571f14e1ee 100644 --- a/src/frontend/packages/core/src/shared/components/app-action-monitor-icon/app-action-monitor-icon.component.spec.ts +++ b/src/frontend/packages/core/src/shared/components/app-action-monitor-icon/app-action-monitor-icon.component.spec.ts @@ -1,6 +1,6 @@ import { async, ComponentFixture, TestBed } from '@angular/core/testing'; -import { endpointEntitySchema } from '../../../../../store/src/base-entity-schemas'; +import { endpointEntityType, stratosEntityFactory } from '../../../../../store/src/helpers/stratos-entity-factory'; import { BaseTestModules } from '../../../../test-framework/core-test.helper'; import { AppActionMonitorIconComponent } from './app-action-monitor-icon.component'; @@ -21,7 +21,7 @@ describe('AppActionMonitorIconComponent', () => { fixture = TestBed.createComponent(AppActionMonitorIconComponent); component = fixture.componentInstance; component.id = '1'; - component.schema = endpointEntitySchema; + component.schema = stratosEntityFactory(endpointEntityType); fixture.detectChanges(); }); diff --git a/src/frontend/packages/core/src/shared/components/favorites-entity-list/favorites-entity-list.component.ts b/src/frontend/packages/core/src/shared/components/favorites-entity-list/favorites-entity-list.component.ts index 31171980d5..807324ed19 100644 --- a/src/frontend/packages/core/src/shared/components/favorites-entity-list/favorites-entity-list.component.ts +++ b/src/frontend/packages/core/src/shared/components/favorites-entity-list/favorites-entity-list.component.ts @@ -33,6 +33,9 @@ export class FavoritesEntityListComponent implements OnInit { @Input() set endpointTypes(types: string[] | string) { if (!this.favoriteTypes) { + // return [ + + // ] if (Array.isArray(types)) { this.favoriteTypes = types.reduce((allTypes, endpointType) => { return [ diff --git a/src/frontend/packages/core/src/shared/components/favorites-meta-card/favorite-config-mapper.ts b/src/frontend/packages/core/src/shared/components/favorites-meta-card/favorite-config-mapper.ts index be98c292e7..5f3091feb7 100644 --- a/src/frontend/packages/core/src/shared/components/favorites-meta-card/favorite-config-mapper.ts +++ b/src/frontend/packages/core/src/shared/components/favorites-meta-card/favorite-config-mapper.ts @@ -129,10 +129,15 @@ export class FavoritesConfigMapper { * For a given endpoint type, return the list of possible favorite types */ public getAllTypesForEndpoint(endpointType: string): IFavoriteTypes[] { - return entityCatalog.getAllEntitiesForEndpointType(endpointType).map(catalogEntity => ({ - type: catalogEntity.definition.type, - prettyName: catalogEntity.definition.label - })); + return entityCatalog.getAllEntitiesForEndpointType(endpointType) + .filter(fav => { + console.log(fav); + return true; + }) + .map(catalogEntity => ({ + type: catalogEntity.definition.type, + prettyName: catalogEntity.definition.label + })); } private buildFavoriteFromCatalogEntity( diff --git a/src/frontend/packages/core/src/shared/components/list/list-table/table-cell-request-monitor-icon/table-cell-request-monitor-icon.component.spec.ts b/src/frontend/packages/core/src/shared/components/list/list-table/table-cell-request-monitor-icon/table-cell-request-monitor-icon.component.spec.ts index 8a69e57ded..8dac64962b 100644 --- a/src/frontend/packages/core/src/shared/components/list/list-table/table-cell-request-monitor-icon/table-cell-request-monitor-icon.component.spec.ts +++ b/src/frontend/packages/core/src/shared/components/list/list-table/table-cell-request-monitor-icon/table-cell-request-monitor-icon.component.spec.ts @@ -1,6 +1,6 @@ import { async, ComponentFixture, TestBed } from '@angular/core/testing'; -import { endpointEntitySchema } from '../../../../../../../store/src/base-entity-schemas'; +import { endpointEntityType, stratosEntityFactory } from '../../../../../../../store/src/helpers/stratos-entity-factory'; import { BaseTestModules } from '../../../../../../test-framework/core-test.helper'; import { AppMonitorComponentTypes } from '../../../app-action-monitor-icon/app-action-monitor-icon.component'; import { TableCellRequestMonitorIconComponent } from './table-cell-request-monitor-icon.component'; @@ -24,7 +24,7 @@ describe('TableCellRequestMonitorIconComponent', () => { component.id = '1'; component.config = () => ({ entityKey: '', - schema: endpointEntitySchema, + schema: stratosEntityFactory(endpointEntityType), monitorState: AppMonitorComponentTypes.DELETE }); component.row = { diff --git a/src/frontend/packages/store/src/actions/endpoint.actions.ts b/src/frontend/packages/store/src/actions/endpoint.actions.ts index 04f7ab0a6b..6581b0b3a5 100644 --- a/src/frontend/packages/store/src/actions/endpoint.actions.ts +++ b/src/frontend/packages/store/src/actions/endpoint.actions.ts @@ -8,8 +8,6 @@ import { PaginatedAction } from '../types/pagination.types'; import { EntityRequestAction } from '../types/request.types'; export const GET_ENDPOINTS = '[Endpoints] Get all'; -export const GET_ENDPOINTS_START = '[Endpoints] Get all start'; // TODO: RD HUH -export const GET_ENDPOINTS_LOGIN = '[Endpoints] Get all at login'; // TODO: RD HUH export const GET_ENDPOINTS_SUCCESS = '[Endpoints] Get all success'; export const GET_ENDPOINTS_FAILED = '[Endpoints] Get all failed'; @@ -42,7 +40,7 @@ export class EndpointActionComplete implements Action { public type: string, public guid: string, // Note - The underlying endpoints type (_cf_Endpoint, not _stratos_Endpoint) - public completeEndpointType: EndpointType, + public endpointType: EndpointType, public endpoint: EndpointModel | INewlyConnectedEndpointInfo ) { } } @@ -58,19 +56,25 @@ export abstract class BaseEndpointAction implements EntityRequestAction { export abstract class SingleBaseEndpointAction extends BaseEndpointAction { constructor( - type: string, - public guid: string + actionType: string, + public guid: string, + /** + * The endpoint type of the endpoint + * endpointType = stratos endpoint type... where it will be stored + * endpointsType = specific type of the endpoint type... for instance 'metrics' + */ + public endpointsType?: string ) { - super(type); + super(actionType); } } abstract class MultipleBaseEndpointAction extends BaseEndpointAction implements PaginatedAction { constructor( - type: string, + actionType: string, public paginationKey: string ) { - super(type); + super(actionType); } } @@ -89,7 +93,7 @@ export type AuthParams = AuthParamsUsernamePassword | AuthParamsToken; export class GetEndpoint extends SingleBaseEndpointAction { constructor( - guid: string + guid: string, ) { super( GET_ENDPOINT, @@ -114,7 +118,7 @@ export class GetAllEndpoints extends MultipleBaseEndpointAction { ) } actions = [ - GET_ENDPOINTS_START, + GET_ENDPOINTS, GET_ENDPOINTS_SUCCESS, GET_ENDPOINTS_FAILED ]; @@ -129,7 +133,6 @@ export class GetAllEndpoints extends MultipleBaseEndpointAction { export class GetAllEndpointsSuccess extends GetAllEndpoints { constructor(public payload: NormalizedResponse, public login = false) { super(login) - console.log(this.type);// TODO: RC test type } type = GET_ENDPOINTS_SUCCESS; } @@ -139,7 +142,7 @@ export class ConnectEndpoint extends SingleBaseEndpointAction { constructor( guid: string, // Note - should not be called endpointType - public connectEndpointType: EndpointType, + connectEndpointType: EndpointType, public authType: string, public authValues: AuthParams, public systemShared: boolean, @@ -147,7 +150,8 @@ export class ConnectEndpoint extends SingleBaseEndpointAction { ) { super( CONNECT_ENDPOINTS, - guid + guid, + connectEndpointType ); } updatingKey = ConnectEndpoint.UpdatingKey; @@ -163,11 +167,12 @@ export class DisconnectEndpoint extends SingleBaseEndpointAction { constructor( guid: string, // Note - should not be called endpointType - public disconnectEndpointType: EndpointType, + disconnectEndpointType: EndpointType, ) { super( DISCONNECT_ENDPOINTS, - guid + guid, + disconnectEndpointType ); } updatingKey = DisconnectEndpoint.UpdatingKey; @@ -182,11 +187,12 @@ export class UnregisterEndpoint extends SingleBaseEndpointAction { constructor( guid: string, // Note - should not be called endpointType - public unregisterEndpointType: EndpointType, + unregisterEndpointType: EndpointType, ) { super( UNREGISTER_ENDPOINTS, - guid + guid, + unregisterEndpointType ); } actions = [ @@ -199,7 +205,7 @@ export class UnregisterEndpoint extends SingleBaseEndpointAction { export class RegisterEndpoint extends SingleBaseEndpointAction { constructor( // Note - should not be called endpointType - public registerEndpointType: EndpointType, + registerEndpointType: EndpointType, public endpointSubType: string = null, public name: string, public endpoint: string, @@ -210,7 +216,8 @@ export class RegisterEndpoint extends SingleBaseEndpointAction { ) { super( REGISTER_ENDPOINTS, - '' + name + '' + name, + registerEndpointType ); } updatingKey = 'registering' @@ -224,7 +231,7 @@ export class RegisterEndpoint extends SingleBaseEndpointAction { export class UpdateEndpoint extends SingleBaseEndpointAction { constructor( // Note - should not be called endpointType - public updateEndpointType: EndpointType, // TODO: RC test different types + updateEndpointType: EndpointType, public id: string, public name: string, public skipSSL: boolean, @@ -235,7 +242,8 @@ export class UpdateEndpoint extends SingleBaseEndpointAction { ) { super( UPDATE_ENDPOINT, - id + id, + updateEndpointType ); } updatingKey = 'updating' diff --git a/src/frontend/packages/store/src/effects/endpoint.effects.ts b/src/frontend/packages/store/src/effects/endpoint.effects.ts index 9ce8ab96cf..2e796553f9 100644 --- a/src/frontend/packages/store/src/effects/endpoint.effects.ts +++ b/src/frontend/packages/store/src/effects/endpoint.effects.ts @@ -68,16 +68,15 @@ export class EndpointsEffect { ofType(GET_SYSTEM_INFO_SUCCESS), mergeMap(action => { const { associatedAction } = action; - // TODO: RC test service instance wall const entityKey = entityCatalog.getEntityKey(associatedAction); const endpoints = action.payload.endpoints; // Data is an array of endpoints - const mappedData = { + const mappedData: NormalizedResponse = { entities: { [entityKey]: {} }, result: [] - } as NormalizedResponse; + }; Object.keys(endpoints).forEach((type: string) => { const endpointsForType = endpoints[type]; @@ -145,7 +144,7 @@ export class EndpointsEffect { '/pp/v1/auth/login/cnsi', params, null, - action.connectEndpointType, + action.endpointsType, body, response => response && response.error && response.error.error ? response.error.error : 'Could not connect, please try again' ); @@ -165,7 +164,7 @@ export class EndpointsEffect { '/pp/v1/auth/logout/cnsi', params, null, - action.disconnectEndpointType + action.endpointsType ); })); @@ -183,7 +182,7 @@ export class EndpointsEffect { '/pp/v1/unregister', params, 'delete', - action.unregisterEndpointType + action.endpointsType ); })); @@ -212,10 +211,10 @@ export class EndpointsEffect { return this.doEndpointAction( action, - '/pp/v1/register/' + action.registerEndpointType, + '/pp/v1/register/' + action.endpointsType, new HttpParams({}), 'create', - action.registerEndpointType, + action.endpointsType, body, this.processRegisterError ); @@ -244,7 +243,7 @@ export class EndpointsEffect { '/pp/v1/endpoint/' + action.id, new HttpParams({}), 'update', - action.updateEndpointType, + action.endpointsType, body, this.processUpdateError ); diff --git a/src/frontend/packages/store/src/effects/permissions.effect.ts b/src/frontend/packages/store/src/effects/permissions.effect.ts index 5f5fc1dadc..b9569d4b2e 100644 --- a/src/frontend/packages/store/src/effects/permissions.effect.ts +++ b/src/frontend/packages/store/src/effects/permissions.effect.ts @@ -51,7 +51,7 @@ export class PermissionsEffects { @Effect() getPermissionForNewlyConnectedEndpoint$ = this.actions$.pipe( ofType(CONNECT_ENDPOINTS_SUCCESS), switchMap(action => { - const endpointType = entityCatalog.getEndpoint(action.completeEndpointType) + const endpointType = entityCatalog.getEndpoint(action.endpointType) if (!endpointType.definition.userRolesFetch) { return EMPTY; } diff --git a/src/frontend/packages/store/src/effects/system.effects.ts b/src/frontend/packages/store/src/effects/system.effects.ts index ac2eaa6174..f456faabaf 100644 --- a/src/frontend/packages/store/src/effects/system.effects.ts +++ b/src/frontend/packages/store/src/effects/system.effects.ts @@ -18,12 +18,12 @@ export class SystemEffects { private store: Store ) { } - // // TODO: RC getSystemInfo vs getAllEndpoints. when to do start/finish. which to kick off process - // static guid = 'info'; - @Effect() getInfo$ = this.actions$.pipe( ofType(GET_SYSTEM_INFO), mergeMap(action => { + // Associated action with be either get endpoint or get all endpoints/ + // Start action for those two are dispatched here, as well as error handling + // Success actions are handling in the effect associated with GetSystemSuccess this.store.dispatch(new StartRequestAction(action)); const { associatedAction } = action; this.store.dispatch(new StartRequestAction(associatedAction, 'fetch')); diff --git a/src/frontend/packages/store/src/effects/user-profile.effects.ts b/src/frontend/packages/store/src/effects/user-profile.effects.ts index 81c0816a0c..9c010fee57 100644 --- a/src/frontend/packages/store/src/effects/user-profile.effects.ts +++ b/src/frontend/packages/store/src/effects/user-profile.effects.ts @@ -58,7 +58,7 @@ export class UserProfileEffect { } return this.httpClient.put(`/pp/${proxyAPIVersion}/users/${userGuid}`, action.profile, { headers }).pipe( - mergeMap((info: UserProfileInfo) => {// TODO: RC push result back into store?? + mergeMap((info: UserProfileInfo) => { return [ new WrapperRequestActionSuccess({ entities: {}, @@ -81,7 +81,7 @@ export class UserProfileEffect { 'x-stratos-password-new': action.passwordChanges.password }; return this.httpClient.put(`/pp/${proxyAPIVersion}/users/${userGuid}/password`, action.passwordChanges, { headers }).pipe( - switchMap((info: UserProfileInfo) => {// TODO: RC TEST & push result back into store?? + switchMap((info: UserProfileInfo) => { return [ new WrapperRequestActionSuccess({ entities: {}, diff --git a/src/frontend/packages/store/src/reducers/pagination-reducer/pagination-reducer-clear-pagination-type.ts b/src/frontend/packages/store/src/reducers/pagination-reducer/pagination-reducer-clear-pagination-type.ts index c020c81f29..aaf5dafbaf 100644 --- a/src/frontend/packages/store/src/reducers/pagination-reducer/pagination-reducer-clear-pagination-type.ts +++ b/src/frontend/packages/store/src/reducers/pagination-reducer/pagination-reducer-clear-pagination-type.ts @@ -1,4 +1,4 @@ -import { SingleBaseEndpointAction } from '../../actions/endpoint.actions'; +import { EndpointActionComplete } from '../../actions/endpoint.actions'; import { entityCatalog } from '../../entity-catalog/entity-catalog'; import { PaginationState } from '../../types/pagination.types'; import { getDefaultPaginationEntityState } from './pagination-reducer-reset-pagination'; @@ -23,8 +23,7 @@ export function paginationClearAllTypes(state: PaginationState, entityKeys: stri }, state); } -export function clearEndpointEntities(state: PaginationState, action: SingleBaseEndpointAction) { - // TODO: RC Test +export function clearEndpointEntities(state: PaginationState, action: EndpointActionComplete) { const entityKeys = entityCatalog.getAllEntitiesForEndpointType(action.endpointType).map(entity => entity.entityKey); if (entityKeys.length > 0) { return paginationClearAllTypes( diff --git a/src/frontend/packages/store/src/reducers/system-endpoints.reducer.ts b/src/frontend/packages/store/src/reducers/system-endpoints.reducer.ts index 5a6d41894d..40fdc63271 100644 --- a/src/frontend/packages/store/src/reducers/system-endpoints.reducer.ts +++ b/src/frontend/packages/store/src/reducers/system-endpoints.reducer.ts @@ -28,7 +28,6 @@ export function systemEndpointsReducer(state: IRequestEntityTypeState new ConnectEndpoint(guid, endpointType, authType, authValues, systemShared, body), disconnect: (guid: string, endpointType: EndpointType) => new DisconnectEndpoint(guid, endpointType), - // TODO: RC test two places where unregister happens unregister: (guid: string, endpointType: EndpointType) => new UnregisterEndpoint(guid, endpointType), register: ( endpointType: EndpointType, @@ -119,7 +118,7 @@ export const endpointActionBuilder: EndpointActionBuilder = { guid: string, endpointGuid: string, args: { - endpointType: EndpointType, // TODO: RC test different types + endpointType: EndpointType, // id: string, name: string, skipSSL: boolean, @@ -179,9 +178,7 @@ export const userFavoriteActionBuilder: UserFavoriteActionBuilder = { updateFavorite: (favorite: UserFavorite) => new UpdateUserFavoriteMetadataAction(favorite) } -// TODO: Schemas export interface UserProfileActionBuilder extends OrchestratedActionBuilders { - // TODO: RC test all get: ( userGuid: string ) => FetchUserProfileAction diff --git a/src/frontend/packages/store/testing/src/store-test-helper.ts b/src/frontend/packages/store/testing/src/store-test-helper.ts index 44b01d7eb7..98731e61fe 100644 --- a/src/frontend/packages/store/testing/src/store-test-helper.ts +++ b/src/frontend/packages/store/testing/src/store-test-helper.ts @@ -3,9 +3,9 @@ import { TestBed } from '@angular/core/testing'; import { Store, StoreModule } from '@ngrx/store'; import { AppState } from '../../src/app-state'; -import { endpointEntitySchema } from '../../src/base-entity-schemas'; import { entityCatalog } from '../../src/entity-catalog/entity-catalog'; import { EntityCatalogEntityConfig } from '../../src/entity-catalog/entity-catalog.types'; +import { endpointEntityType, stratosEntityFactory } from '../../src/helpers/stratos-entity-factory'; import { appReducers } from '../../src/reducers.module'; import { getDefaultRequestState, rootUpdatingKey } from '../../src/reducers/api-request-reducer/types'; import { getDefaultPaginationEntityState } from '../../src/reducers/pagination-reducer/pagination-reducer-reset-pagination'; @@ -396,7 +396,7 @@ export function createEntityStore(entityMap: Map Date: Mon, 22 Jun 2020 17:36:46 +0100 Subject: [PATCH 09/12] Unit test fixes --- ...p-autoscaler-events-config.service.spec.ts | 9 ------- .../application-delete.component.spec.ts | 9 ------- .../delete-app-instances.component.spec.ts | 9 ------- .../delete-app-routes.component.spec.ts | 9 ------- .../applications/application.service.spec.ts | 9 ------- .../application-poll.component.spec.ts | 9 ------- .../application-tabs-base.component.spec.ts | 9 ------- .../log-stream-tab.component.spec.ts | 9 ------- .../metrics-tab/metrics-tab.component.spec.ts | 9 ------- .../cli-info-application.component.spec.ts | 9 ------- .../edit-application.component.spec.ts | 9 ------- .../space-quota-definition.component.spec.ts | 4 ++-- .../cf-app-instances-config.service.spec.ts | 9 ------- ...-app-variables-list-config.service.spec.ts | 9 ------- .../application-service-helper.ts | 7 +++++- .../cloud-foundry-endpoint-service.helper.ts | 2 +- ...table-cell-endpoint-name.component.spec.ts | 4 +++- .../table-cell-endpoint-name.component.ts | 15 +++++++----- .../packages/store/src/base-entity-schemas.ts | 24 ------------------- .../src/entity-catalog/entity-catalog.spec.ts | 6 ++--- .../packages/store/src/entity-service.spec.ts | 8 +------ .../user-favorites-groups.reducer.spec.ts | 6 ++--- .../pagination.reducer.spec.ts | 1 - .../store/src/stratos-entity-catalog.ts | 2 -- 24 files changed, 28 insertions(+), 168 deletions(-) delete mode 100644 src/frontend/packages/store/src/base-entity-schemas.ts diff --git a/src/frontend/packages/cf-autoscaler/src/shared/list-types/app-autoscaler-event/cf-app-autoscaler-events-config.service.spec.ts b/src/frontend/packages/cf-autoscaler/src/shared/list-types/app-autoscaler-event/cf-app-autoscaler-events-config.service.spec.ts index 56fe3b5865..fcfbc0bf81 100644 --- a/src/frontend/packages/cf-autoscaler/src/shared/list-types/app-autoscaler-event/cf-app-autoscaler-events-config.service.spec.ts +++ b/src/frontend/packages/cf-autoscaler/src/shared/list-types/app-autoscaler-event/cf-app-autoscaler-events-config.service.spec.ts @@ -5,9 +5,6 @@ import { inject, TestBed } from '@angular/core/testing'; import { RouterTestingModule } from '@angular/router/testing'; import { createEmptyStoreModule } from '@stratosui/store/testing'; -import { GetApplication } from '../../../../../cloud-foundry/src/actions/application.actions'; -import { cfEntityFactory } from '../../../../../cloud-foundry/src/cf-entity-factory'; -import { applicationEntityType } from '../../../../../cloud-foundry/src/cf-entity-types'; import { ApplicationsModule } from '../../../../../cloud-foundry/src/features/applications/applications.module'; import { generateTestApplicationServiceProvider, @@ -15,7 +12,6 @@ import { import { CoreModule } from '../../../../../core/src/core/core.module'; import { SharedModule } from '../../../../../core/src/shared/shared.module'; import { AppTestModule } from '../../../../../core/test-framework/core-test.helper'; -import { generateTestEntityServiceProvider } from '../../../../../core/test-framework/entity-service.helper'; import { EntityCatalogHelper } from '../../../../../store/src/entity-catalog/entity-catalog-entity/entity-catalog.service'; import { EntityServiceFactory } from '../../../../../store/src/entity-service-factory.service'; import { EntityMonitorFactory } from '../../../../../store/src/monitors/entity-monitor.factory.service'; @@ -35,11 +31,6 @@ describe('CfAppAutoscalerEventsConfigService', () => { EntityServiceFactory, EntityMonitorFactory, EntityCatalogHelper, - generateTestEntityServiceProvider( - appGuid, - cfEntityFactory(applicationEntityType), - new GetApplication(appGuid, cfGuid) - ), generateTestApplicationServiceProvider(appGuid, cfGuid), HttpClient, ], diff --git a/src/frontend/packages/cloud-foundry/src/features/applications/application-delete/application-delete.component.spec.ts b/src/frontend/packages/cloud-foundry/src/features/applications/application-delete/application-delete.component.spec.ts index 7e8ac98783..52aa6ff434 100644 --- a/src/frontend/packages/cloud-foundry/src/features/applications/application-delete/application-delete.component.spec.ts +++ b/src/frontend/packages/cloud-foundry/src/features/applications/application-delete/application-delete.component.spec.ts @@ -1,12 +1,8 @@ import { async, ComponentFixture, TestBed } from '@angular/core/testing'; -import { GetApplication } from '../../../../../cloud-foundry/src/actions/application.actions'; -import { cfEntityFactory } from '../../../../../cloud-foundry/src/cf-entity-factory'; import { TabNavService } from '../../../../../core/tab-nav.service'; -import { generateTestEntityServiceProvider } from '../../../../../core/test-framework/entity-service.helper'; import { generateTestApplicationServiceProvider } from '../../../../test-framework/application-service-helper'; import { generateCfBaseTestModules } from '../../../../test-framework/cloud-foundry-endpoint-service.helper'; -import { applicationEntityType } from '../../../cf-entity-types'; import { ApplicationsModule } from '../applications.module'; import { ApplicationDeleteComponent } from './application-delete.component'; @@ -22,11 +18,6 @@ describe('ApplicationDeleteComponent', () => { ApplicationsModule ], providers: [ - generateTestEntityServiceProvider( - appId, - cfEntityFactory(applicationEntityType), - new GetApplication(appId, cfId) - ), generateTestApplicationServiceProvider(cfId, appId), TabNavService ] diff --git a/src/frontend/packages/cloud-foundry/src/features/applications/application-delete/delete-app-instances/delete-app-instances.component.spec.ts b/src/frontend/packages/cloud-foundry/src/features/applications/application-delete/delete-app-instances/delete-app-instances.component.spec.ts index cc133e9d3b..184b50070a 100644 --- a/src/frontend/packages/cloud-foundry/src/features/applications/application-delete/delete-app-instances/delete-app-instances.component.spec.ts +++ b/src/frontend/packages/cloud-foundry/src/features/applications/application-delete/delete-app-instances/delete-app-instances.component.spec.ts @@ -1,12 +1,8 @@ import { DatePipe } from '@angular/common'; import { async, ComponentFixture, TestBed } from '@angular/core/testing'; -import { GetApplication } from '../../../../../../cloud-foundry/src/actions/application.actions'; -import { cfEntityFactory } from '../../../../../../cloud-foundry/src/cf-entity-factory'; -import { generateTestEntityServiceProvider } from '../../../../../../core/test-framework/entity-service.helper'; import { generateTestApplicationServiceProvider } from '../../../../../test-framework/application-service-helper'; import { generateCfBaseTestModules } from '../../../../../test-framework/cloud-foundry-endpoint-service.helper'; -import { applicationEntityType } from '../../../../cf-entity-types'; import { ServiceActionHelperService } from '../../../../shared/data-services/service-action-helper.service'; import { ApplicationEnvVarsHelper, @@ -24,11 +20,6 @@ describe('DeleteAppInstancesComponent', () => { declarations: [DeleteAppServiceInstancesComponent], imports: generateCfBaseTestModules(), providers: [ - generateTestEntityServiceProvider( - appId, - cfEntityFactory(applicationEntityType), - new GetApplication(appId, cfId) - ), generateTestApplicationServiceProvider(cfId, appId), ApplicationEnvVarsHelper, DatePipe, diff --git a/src/frontend/packages/cloud-foundry/src/features/applications/application-delete/delete-app-routes/delete-app-routes.component.spec.ts b/src/frontend/packages/cloud-foundry/src/features/applications/application-delete/delete-app-routes/delete-app-routes.component.spec.ts index 28b04b412d..7e6b4e0ff6 100644 --- a/src/frontend/packages/cloud-foundry/src/features/applications/application-delete/delete-app-routes/delete-app-routes.component.spec.ts +++ b/src/frontend/packages/cloud-foundry/src/features/applications/application-delete/delete-app-routes/delete-app-routes.component.spec.ts @@ -1,12 +1,8 @@ import { DatePipe } from '@angular/common'; import { async, ComponentFixture, TestBed } from '@angular/core/testing'; -import { GetApplication } from '../../../../../../cloud-foundry/src/actions/application.actions'; -import { cfEntityFactory } from '../../../../../../cloud-foundry/src/cf-entity-factory'; -import { generateTestEntityServiceProvider } from '../../../../../../core/test-framework/entity-service.helper'; import { generateTestApplicationServiceProvider } from '../../../../../test-framework/application-service-helper'; import { generateCfBaseTestModules } from '../../../../../test-framework/cloud-foundry-endpoint-service.helper'; -import { applicationEntityType } from '../../../../cf-entity-types'; import { ApplicationEnvVarsHelper, } from '../../application/application-tabs-base/tabs/build-tab/application-env-vars.service'; @@ -23,11 +19,6 @@ describe('DeleteAppRoutesComponent', () => { declarations: [DeleteAppRoutesComponent], imports: generateCfBaseTestModules(), providers: [ - generateTestEntityServiceProvider( - appId, - cfEntityFactory(applicationEntityType), - new GetApplication(appId, cfId) - ), generateTestApplicationServiceProvider(cfId, appId), ApplicationEnvVarsHelper, DatePipe, diff --git a/src/frontend/packages/cloud-foundry/src/features/applications/application.service.spec.ts b/src/frontend/packages/cloud-foundry/src/features/applications/application.service.spec.ts index aba0ea3567..23282a262b 100644 --- a/src/frontend/packages/cloud-foundry/src/features/applications/application.service.spec.ts +++ b/src/frontend/packages/cloud-foundry/src/features/applications/application.service.spec.ts @@ -1,18 +1,14 @@ import { inject, TestBed } from '@angular/core/testing'; import { RouterTestingModule } from '@angular/router/testing'; -import { GetApplication } from '../../../../cloud-foundry/src/actions/application.actions'; -import { cfEntityFactory } from '../../../../cloud-foundry/src/cf-entity-factory'; import { CoreModule } from '../../../../core/src/core/core.module'; import { ExtensionService } from '../../../../core/src/core/extension/extension-service'; import { getGitHubAPIURL, GITHUB_API_URL } from '../../../../core/src/core/github.helpers'; -import { generateTestEntityServiceProvider } from '../../../../core/test-framework/entity-service.helper'; import { EntityMonitorFactory } from '../../../../store/src/monitors/entity-monitor.factory.service'; import { PaginationMonitorFactory } from '../../../../store/src/monitors/pagination-monitor.factory'; import { AppStoreModule } from '../../../../store/src/store.module'; import { generateTestApplicationServiceProvider } from '../../../test-framework/application-service-helper'; import { generateCfStoreModules } from '../../../test-framework/cloud-foundry-endpoint-service.helper'; -import { applicationEntityType } from '../../cf-entity-types'; import { LongRunningCfOperationsService } from '../../shared/data-services/long-running-cf-op.service'; import { GitSCMService } from '../../shared/data-services/scm/scm.service'; import { ApplicationStateService } from '../../shared/services/application-state.service'; @@ -33,11 +29,6 @@ describe('ApplicationService', () => { generateCfStoreModules() ], providers: [ - generateTestEntityServiceProvider( - appId, - cfEntityFactory(applicationEntityType), - new GetApplication(appId, cfId) - ), generateTestApplicationServiceProvider(cfId, appId), ApplicationStateService, ApplicationEnvVarsHelper, diff --git a/src/frontend/packages/cloud-foundry/src/features/applications/application/application-tabs-base/application-poll/application-poll.component.spec.ts b/src/frontend/packages/cloud-foundry/src/features/applications/application/application-tabs-base/application-poll/application-poll.component.spec.ts index 096eebe3f7..d20348cc9f 100644 --- a/src/frontend/packages/cloud-foundry/src/features/applications/application/application-tabs-base/application-poll/application-poll.component.spec.ts +++ b/src/frontend/packages/cloud-foundry/src/features/applications/application/application-tabs-base/application-poll/application-poll.component.spec.ts @@ -1,11 +1,7 @@ import { async, ComponentFixture, TestBed } from '@angular/core/testing'; -import { generateTestEntityServiceProvider } from '../../../../../../../core/test-framework/entity-service.helper'; import { generateTestApplicationServiceProvider } from '../../../../../../test-framework/application-service-helper'; import { generateCfBaseTestModules } from '../../../../../../test-framework/cloud-foundry-endpoint-service.helper'; -import { GetApplication } from '../../../../../actions/application.actions'; -import { cfEntityFactory } from '../../../../../cf-entity-factory'; -import { applicationEntityType } from '../../../../../cf-entity-types'; import { ApplicationPollingService } from '../application-polling.service'; import { ApplicationEnvVarsHelper } from '../tabs/build-tab/application-env-vars.service'; import { ApplicationStateService } from './../../../../../shared/services/application-state.service'; @@ -23,11 +19,6 @@ describe('ApplicationPollComponent', () => { declarations: [ApplicationPollComponent], providers: [ ApplicationPollingService, - generateTestEntityServiceProvider( - appId, - cfEntityFactory(applicationEntityType), - new GetApplication(appId, cfId) - ), generateTestApplicationServiceProvider(cfId, appId), ApplicationEnvVarsHelper, ApplicationStateService, diff --git a/src/frontend/packages/cloud-foundry/src/features/applications/application/application-tabs-base/application-tabs-base.component.spec.ts b/src/frontend/packages/cloud-foundry/src/features/applications/application/application-tabs-base/application-tabs-base.component.spec.ts index 55f591b111..19c49370d4 100644 --- a/src/frontend/packages/cloud-foundry/src/features/applications/application/application-tabs-base/application-tabs-base.component.spec.ts +++ b/src/frontend/packages/cloud-foundry/src/features/applications/application/application-tabs-base/application-tabs-base.component.spec.ts @@ -5,17 +5,13 @@ import { NoopAnimationsModule } from '@angular/platform-browser/animations'; import { RouterTestingModule } from '@angular/router/testing'; import { StoreModule } from '@ngrx/store'; -import { GetApplication } from '../../../../../../cloud-foundry/src/actions/application.actions'; -import { cfEntityFactory } from '../../../../../../cloud-foundry/src/cf-entity-factory'; import { CoreModule } from '../../../../../../core/src/core/core.module'; import { getGitHubAPIURL, GITHUB_API_URL } from '../../../../../../core/src/core/github.helpers'; import { MDAppModule } from '../../../../../../core/src/core/md.module'; import { SharedModule } from '../../../../../../core/src/shared/shared.module'; import { TabNavService } from '../../../../../../core/tab-nav.service'; -import { generateTestEntityServiceProvider } from '../../../../../../core/test-framework/entity-service.helper'; import { generateTestApplicationServiceProvider } from '../../../../../test-framework/application-service-helper'; import { generateCfStoreModules } from '../../../../../test-framework/cloud-foundry-endpoint-service.helper'; -import { applicationEntityType } from '../../../../cf-entity-types'; import { ApplicationStateService } from '../../../../shared/services/application-state.service'; import { ApplicationTabsBaseComponent } from './application-tabs-base.component'; import { ApplicationEnvVarsHelper } from './tabs/build-tab/application-env-vars.service'; @@ -44,11 +40,6 @@ describe('ApplicationTabsBaseComponent', () => { HttpClientTestingModule ], providers: [ - generateTestEntityServiceProvider( - appId, - cfEntityFactory(applicationEntityType), - new GetApplication(appId, cfId) - ), generateTestApplicationServiceProvider(cfId, appId), ApplicationStateService, ApplicationEnvVarsHelper, diff --git a/src/frontend/packages/cloud-foundry/src/features/applications/application/application-tabs-base/tabs/log-stream-tab/log-stream-tab.component.spec.ts b/src/frontend/packages/cloud-foundry/src/features/applications/application/application-tabs-base/tabs/log-stream-tab/log-stream-tab.component.spec.ts index b300ad4f84..03b62309d1 100644 --- a/src/frontend/packages/cloud-foundry/src/features/applications/application/application-tabs-base/tabs/log-stream-tab/log-stream-tab.component.spec.ts +++ b/src/frontend/packages/cloud-foundry/src/features/applications/application/application-tabs-base/tabs/log-stream-tab/log-stream-tab.component.spec.ts @@ -3,18 +3,14 @@ import { NoopAnimationsModule } from '@angular/platform-browser/animations'; import { RouterTestingModule } from '@angular/router/testing'; import { StoreModule } from '@ngrx/store'; -import { GetApplication } from '../../../../../../../../cloud-foundry/src/actions/application.actions'; -import { cfEntityFactory } from '../../../../../../../../cloud-foundry/src/cf-entity-factory'; import { CoreModule } from '../../../../../../../../core/src/core/core.module'; import { MDAppModule } from '../../../../../../../../core/src/core/md.module'; import { LogViewerComponent } from '../../../../../../../../core/src/shared/components/log-viewer/log-viewer.component'; -import { generateTestEntityServiceProvider } from '../../../../../../../../core/test-framework/entity-service.helper'; import { EntityMonitorFactory } from '../../../../../../../../store/src/monitors/entity-monitor.factory.service'; import { PaginationMonitorFactory } from '../../../../../../../../store/src/monitors/pagination-monitor.factory'; import { AppStoreModule } from '../../../../../../../../store/src/store.module'; import { generateTestApplicationServiceProvider } from '../../../../../../../test-framework/application-service-helper'; import { generateCfStoreModules } from '../../../../../../../test-framework/cloud-foundry-endpoint-service.helper'; -import { applicationEntityType } from '../../../../../../cf-entity-types'; import { ApplicationStateService } from '../../../../../../shared/services/application-state.service'; import { ApplicationEnvVarsHelper } from '../build-tab/application-env-vars.service'; import { LogStreamTabComponent } from './log-stream-tab.component'; @@ -41,11 +37,6 @@ describe('LogStreamTabComponent', () => { LogStreamTabComponent ], providers: [ - generateTestEntityServiceProvider( - appId, - cfEntityFactory(applicationEntityType), - new GetApplication(appId, cfId) - ), generateTestApplicationServiceProvider(cfId, appId), AppStoreModule, ApplicationStateService, diff --git a/src/frontend/packages/cloud-foundry/src/features/applications/application/application-tabs-base/tabs/metrics-tab/metrics-tab.component.spec.ts b/src/frontend/packages/cloud-foundry/src/features/applications/application/application-tabs-base/tabs/metrics-tab/metrics-tab.component.spec.ts index 6bb64cb28b..42bf58fa38 100644 --- a/src/frontend/packages/cloud-foundry/src/features/applications/application/application-tabs-base/tabs/metrics-tab/metrics-tab.component.spec.ts +++ b/src/frontend/packages/cloud-foundry/src/features/applications/application/application-tabs-base/tabs/metrics-tab/metrics-tab.component.spec.ts @@ -1,14 +1,10 @@ import { async, ComponentFixture, TestBed } from '@angular/core/testing'; import { NoopAnimationsModule } from '@angular/platform-browser/animations'; -import { GetApplication } from '../../../../../../../../cloud-foundry/src/actions/application.actions'; -import { cfEntityFactory } from '../../../../../../../../cloud-foundry/src/cf-entity-factory'; import { MDAppModule } from '../../../../../../../../core/src/core/md.module'; import { SharedModule } from '../../../../../../../../core/src/shared/shared.module'; -import { generateTestEntityServiceProvider } from '../../../../../../../../core/test-framework/entity-service.helper'; import { generateTestApplicationServiceProvider } from '../../../../../../../test-framework/application-service-helper'; import { generateCfStoreModules } from '../../../../../../../test-framework/cloud-foundry-endpoint-service.helper'; -import { applicationEntityType } from '../../../../../../cf-entity-types'; import { ApplicationStateService } from '../../../../../../shared/services/application-state.service'; import { ApplicationEnvVarsHelper } from '../build-tab/application-env-vars.service'; import { MetricsTabComponent } from './metrics-tab.component'; @@ -30,11 +26,6 @@ describe('MetricsTabComponent', () => { providers: [ ApplicationStateService, ApplicationEnvVarsHelper, - generateTestEntityServiceProvider( - appId, - cfEntityFactory(applicationEntityType), - new GetApplication(appId, cfId) - ), generateTestApplicationServiceProvider(cfId, appId), ] }) diff --git a/src/frontend/packages/cloud-foundry/src/features/applications/cli-info-application/cli-info-application.component.spec.ts b/src/frontend/packages/cloud-foundry/src/features/applications/cli-info-application/cli-info-application.component.spec.ts index c3ead1317a..ff36e161d2 100644 --- a/src/frontend/packages/cloud-foundry/src/features/applications/cli-info-application/cli-info-application.component.spec.ts +++ b/src/frontend/packages/cloud-foundry/src/features/applications/cli-info-application/cli-info-application.component.spec.ts @@ -1,16 +1,12 @@ import { async, ComponentFixture, TestBed } from '@angular/core/testing'; import { RouterTestingModule } from '@angular/router/testing'; -import { GetApplication } from '../../../../../cloud-foundry/src/actions/application.actions'; -import { cfEntityFactory } from '../../../../../cloud-foundry/src/cf-entity-factory'; import { CoreModule } from '../../../../../core/src/core/core.module'; import { MDAppModule } from '../../../../../core/src/core/md.module'; import { SharedModule } from '../../../../../core/src/shared/shared.module'; import { TabNavService } from '../../../../../core/tab-nav.service'; -import { generateTestEntityServiceProvider } from '../../../../../core/test-framework/entity-service.helper'; import { generateTestApplicationServiceProvider } from '../../../../test-framework/application-service-helper'; import { generateCfStoreModules } from '../../../../test-framework/cloud-foundry-endpoint-service.helper'; -import { applicationEntityType } from '../../../cf-entity-types'; import { CloudFoundrySharedModule } from '../../../shared/cf-shared.module'; import { ApplicationStateService } from '../../../shared/services/application-state.service'; import { ApplicationEnvVarsHelper } from '../application/application-tabs-base/tabs/build-tab/application-env-vars.service'; @@ -35,11 +31,6 @@ describe('CliInfoApplicationComponent', () => { CloudFoundrySharedModule ], providers: [ - generateTestEntityServiceProvider( - appId, - cfEntityFactory(applicationEntityType), - new GetApplication(appId, cfId) - ), generateTestApplicationServiceProvider(cfId, appId), ApplicationStateService, ApplicationEnvVarsHelper, diff --git a/src/frontend/packages/cloud-foundry/src/features/applications/edit-application/edit-application.component.spec.ts b/src/frontend/packages/cloud-foundry/src/features/applications/edit-application/edit-application.component.spec.ts index f25b7fa87f..e5de781a2a 100644 --- a/src/frontend/packages/cloud-foundry/src/features/applications/edit-application/edit-application.component.spec.ts +++ b/src/frontend/packages/cloud-foundry/src/features/applications/edit-application/edit-application.component.spec.ts @@ -4,18 +4,14 @@ import { async, ComponentFixture, TestBed } from '@angular/core/testing'; import { NoopAnimationsModule } from '@angular/platform-browser/animations'; import { RouterTestingModule } from '@angular/router/testing'; -import { GetApplication } from '../../../../../cloud-foundry/src/actions/application.actions'; -import { cfEntityFactory } from '../../../../../cloud-foundry/src/cf-entity-factory'; import { CoreModule } from '../../../../../core/src/core/core.module'; import { SharedModule } from '../../../../../core/src/shared/shared.module'; import { TabNavService } from '../../../../../core/tab-nav.service'; -import { generateTestEntityServiceProvider } from '../../../../../core/test-framework/entity-service.helper'; import { ApplicationServiceMock, generateTestApplicationServiceProvider, } from '../../../../test-framework/application-service-helper'; import { generateCfStoreModules } from '../../../../test-framework/cloud-foundry-endpoint-service.helper'; -import { applicationEntityType } from '../../../cf-entity-types'; import { ApplicationStateService } from '../../../shared/services/application-state.service'; import { ApplicationService } from '../application.service'; import { ApplicationEnvVarsHelper } from '../application/application-tabs-base/tabs/build-tab/application-env-vars.service'; @@ -42,11 +38,6 @@ describe('EditApplicationComponent', () => { ], providers: [ { provide: ApplicationService, useClass: ApplicationServiceMock }, - generateTestEntityServiceProvider( - appId, - cfEntityFactory(applicationEntityType), - new GetApplication(appId, cfId) - ), generateTestApplicationServiceProvider(cfId, appId), ApplicationStateService, ApplicationEnvVarsHelper, diff --git a/src/frontend/packages/cloud-foundry/src/features/cloud-foundry/space-quota-definition/space-quota-definition.component.spec.ts b/src/frontend/packages/cloud-foundry/src/features/cloud-foundry/space-quota-definition/space-quota-definition.component.spec.ts index f4cf1f0ad5..ee79e073f2 100644 --- a/src/frontend/packages/cloud-foundry/src/features/cloud-foundry/space-quota-definition/space-quota-definition.component.spec.ts +++ b/src/frontend/packages/cloud-foundry/src/features/cloud-foundry/space-quota-definition/space-quota-definition.component.spec.ts @@ -4,9 +4,9 @@ import { Store } from '@ngrx/store'; import { testSCFEndpoint, testSCFEndpointGuid } from '@stratosui/store/testing'; import { TabNavService } from '../../../../../core/tab-nav.service'; -import { endpointEntitySchema } from '../../../../../store/src/base-entity-schemas'; import { EntityCatalogHelpers } from '../../../../../store/src/entity-catalog/entity-catalog.helper'; import { EntityCatalogEntityConfig } from '../../../../../store/src/entity-catalog/entity-catalog.types'; +import { endpointEntityType, stratosEntityFactory } from '../../../../../store/src/helpers/stratos-entity-factory'; import { NormalizedResponse } from '../../../../../store/src/types/api.types'; import { WrapperRequestActionSuccess } from '../../../../../store/src/types/request.types'; import { @@ -51,7 +51,7 @@ describe('SpaceQuotaDefinitionComponent', () => { .compileComponents(); - const stratosEndpointEntityConfig: EntityCatalogEntityConfig = endpointEntitySchema; + const stratosEndpointEntityConfig: EntityCatalogEntityConfig = stratosEntityFactory(endpointEntityType); const stratosEndpointEntityKey = EntityCatalogHelpers.buildEntityKey( stratosEndpointEntityConfig.entityType, stratosEndpointEntityConfig.endpointType diff --git a/src/frontend/packages/cloud-foundry/src/shared/components/list/list-types/app-instance/cf-app-instances-config.service.spec.ts b/src/frontend/packages/cloud-foundry/src/shared/components/list/list-types/app-instance/cf-app-instances-config.service.spec.ts index dd2d9a08a4..3966e4880a 100644 --- a/src/frontend/packages/cloud-foundry/src/shared/components/list/list-types/app-instance/cf-app-instances-config.service.spec.ts +++ b/src/frontend/packages/cloud-foundry/src/shared/components/list/list-types/app-instance/cf-app-instances-config.service.spec.ts @@ -6,15 +6,11 @@ import { testSCFEndpointGuid } from '@stratosui/store/testing'; import { CoreModule } from '../../../../../../../core/src/core/core.module'; import { CF_GUID } from '../../../../../../../core/src/shared/entity.tokens'; import { SharedModule } from '../../../../../../../core/src/shared/shared.module'; -import { generateTestEntityServiceProvider } from '../../../../../../../core/test-framework/entity-service.helper'; import { generateTestApplicationServiceProvider } from '../../../../../../test-framework/application-service-helper'; import { generateCfStoreModules, generateTestCfEndpointServiceProvider, } from '../../../../../../test-framework/cloud-foundry-endpoint-service.helper'; -import { GetApplication } from '../../../../../actions/application.actions'; -import { cfEntityFactory } from '../../../../../cf-entity-factory'; -import { applicationEntityType } from '../../../../../cf-entity-types'; import { ApplicationsModule } from '../../../../../features/applications/applications.module'; import { CfAppInstancesConfigService } from './cf-app-instances-config.service'; @@ -27,11 +23,6 @@ describe('CfAppInstancesConfigService', () => { TestBed.configureTestingModule({ providers: [ CfAppInstancesConfigService, - generateTestEntityServiceProvider( - appGuid, - cfEntityFactory(applicationEntityType), - new GetApplication(appGuid, cfGuid) - ), generateTestApplicationServiceProvider(appGuid, cfGuid), generateTestCfEndpointServiceProvider(), { diff --git a/src/frontend/packages/cloud-foundry/src/shared/components/list/list-types/app-variables/cf-app-variables-list-config.service.spec.ts b/src/frontend/packages/cloud-foundry/src/shared/components/list/list-types/app-variables/cf-app-variables-list-config.service.spec.ts index 4eea9c86fc..b2a3d64486 100644 --- a/src/frontend/packages/cloud-foundry/src/shared/components/list/list-types/app-variables/cf-app-variables-list-config.service.spec.ts +++ b/src/frontend/packages/cloud-foundry/src/shared/components/list/list-types/app-variables/cf-app-variables-list-config.service.spec.ts @@ -4,12 +4,8 @@ import { RouterTestingModule } from '@angular/router/testing'; import { CoreModule } from '../../../../../../../core/src/core/core.module'; import { SharedModule } from '../../../../../../../core/src/shared/shared.module'; -import { generateTestEntityServiceProvider } from '../../../../../../../core/test-framework/entity-service.helper'; import { generateTestApplicationServiceProvider } from '../../../../../../test-framework/application-service-helper'; import { generateCfStoreModules } from '../../../../../../test-framework/cloud-foundry-endpoint-service.helper'; -import { GetApplication } from '../../../../../actions/application.actions'; -import { cfEntityFactory } from '../../../../../cf-entity-factory'; -import { applicationEntityType } from '../../../../../cf-entity-types'; import { ApplicationsModule } from '../../../../../features/applications/applications.module'; import { CfAppVariablesListConfigService } from './cf-app-variables-list-config.service'; @@ -22,11 +18,6 @@ describe('CfAppVariablesListConfigService', () => { TestBed.configureTestingModule({ providers: [ CfAppVariablesListConfigService, - generateTestEntityServiceProvider( - appGuid, - cfEntityFactory(applicationEntityType), - new GetApplication(appGuid, cfGuid) - ), generateTestApplicationServiceProvider(appGuid, cfGuid) ], imports: [ diff --git a/src/frontend/packages/cloud-foundry/test-framework/application-service-helper.ts b/src/frontend/packages/cloud-foundry/test-framework/application-service-helper.ts index 6c07e9ba8f..18ed991825 100644 --- a/src/frontend/packages/cloud-foundry/test-framework/application-service-helper.ts +++ b/src/frontend/packages/cloud-foundry/test-framework/application-service-helper.ts @@ -1,7 +1,8 @@ import { Store } from '@ngrx/store'; -import { Observable, of as observableOf } from 'rxjs'; +import { Observable, of as observableOf, of } from 'rxjs'; import { map } from 'rxjs/internal/operators/map'; +import { EntityService } from '../../store/src/entity-service'; import { RequestInfoState } from '../../store/src/reducers/api-request-reducer/types'; import { APIResource, EntityInfo } from '../../store/src/types/api.types'; import { IApp, IAppSummary, IDomain, ISpace } from '../src/cf-api.types'; @@ -81,6 +82,10 @@ export class ApplicationServiceMock { appSpace$: Observable> = observableOf(createEntity({} as ISpace)); applicationRunning$: Observable = observableOf(false); orgDomains$: Observable[]> = observableOf([]); + entityService: EntityService>> = { + waitForEntity$: of({}), + updatingSection$: of({}) + } as EntityService>> } export function generateTestApplicationServiceProvider(appGuid: string, cfGuid: string) { diff --git a/src/frontend/packages/cloud-foundry/test-framework/cloud-foundry-endpoint-service.helper.ts b/src/frontend/packages/cloud-foundry/test-framework/cloud-foundry-endpoint-service.helper.ts index 2174658903..3fc7ed40e9 100644 --- a/src/frontend/packages/cloud-foundry/test-framework/cloud-foundry-endpoint-service.helper.ts +++ b/src/frontend/packages/cloud-foundry/test-framework/cloud-foundry-endpoint-service.helper.ts @@ -114,7 +114,7 @@ export function generateTestCfServiceProvider() { useFactory: ( store: Store, ) => { - const appService = new CloudFoundryService(store); + const appService = new CloudFoundryService(); return appService; }, deps: [Store] diff --git a/src/frontend/packages/core/src/shared/components/list/list-types/endpoint/table-cell-endpoint-name/table-cell-endpoint-name.component.spec.ts b/src/frontend/packages/core/src/shared/components/list/list-types/endpoint/table-cell-endpoint-name/table-cell-endpoint-name.component.spec.ts index 02c3cb866a..6813bb19d8 100644 --- a/src/frontend/packages/core/src/shared/components/list/list-types/endpoint/table-cell-endpoint-name/table-cell-endpoint-name.component.spec.ts +++ b/src/frontend/packages/core/src/shared/components/list/list-types/endpoint/table-cell-endpoint-name/table-cell-endpoint-name.component.spec.ts @@ -26,7 +26,9 @@ describe('TableCellEndpointNameComponent', () => { beforeEach(() => { fixture = TestBed.createComponent(TableCellEndpointNameComponent); component = fixture.componentInstance; - component.row = {} as EndpointModel; + component.row = { + guid: '' + } as EndpointModel; fixture.detectChanges(); }); diff --git a/src/frontend/packages/core/src/shared/components/list/list-types/endpoint/table-cell-endpoint-name/table-cell-endpoint-name.component.ts b/src/frontend/packages/core/src/shared/components/list/list-types/endpoint/table-cell-endpoint-name/table-cell-endpoint-name.component.ts index 98224d0f18..d3c9c5940a 100644 --- a/src/frontend/packages/core/src/shared/components/list/list-types/endpoint/table-cell-endpoint-name/table-cell-endpoint-name.component.ts +++ b/src/frontend/packages/core/src/shared/components/list/list-types/endpoint/table-cell-endpoint-name/table-cell-endpoint-name.component.ts @@ -1,6 +1,7 @@ import { Component, Input } from '@angular/core'; import { Observable } from 'rxjs'; import { map } from 'rxjs/internal/operators/map'; +import { filter } from 'rxjs/operators'; import { entityCatalog } from '../../../../../../../../store/src/entity-catalog/entity-catalog'; import { stratosEntityCatalog } from '../../../../../../../../store/src/stratos-entity-catalog'; @@ -25,13 +26,15 @@ export class TableCellEndpointNameComponent extends TableCellCustom data.entity), - map((data: any) => { + this.endpoint$ = stratosEntityCatalog.endpoint.store.getEntityMonitor(id).entity$.pipe( + filter(data => !!data), + map(data => { const ep = entityCatalog.getEndpoint(data.cnsi_type, data.sub_type).definition; - data.canShowLink = data.connectionStatus === 'connected' || ep.unConnectable; - data.link = EndpointsService.getLinkForEndpoint(data); - return data; + return { + ...data, + canShowLink: data.connectionStatus === 'connected' || ep.unConnectable, + link: EndpointsService.getLinkForEndpoint(data) + }; }) ); } diff --git a/src/frontend/packages/store/src/base-entity-schemas.ts b/src/frontend/packages/store/src/base-entity-schemas.ts deleted file mode 100644 index 193079eecf..0000000000 --- a/src/frontend/packages/store/src/base-entity-schemas.ts +++ /dev/null @@ -1,24 +0,0 @@ -// import { -// endpointSchemaKey, -// entityFactory, -// systemInfoSchemaKey, -// userFavouritesSchemaKey, -// userProfileSchemaKey, -// } from '../../store/src/helpers/entity-factory'; -// import { EntitySchema } from '../../store/src/helpers/entity-schema'; - -// export const metricEntityType = 'metrics'; - -// export const STRATOS_ENDPOINT_TYPE = 'stratos'; -// export const ENDPOINT_TYPE = 'endpoint'; - -// class StratosEntitySchema extends EntitySchema { -// constructor(entityType: string) { -// super(entityType, STRATOS_ENDPOINT_TYPE); -// } -// } - -// export const userFavoritesEntitySchema = new StratosEntitySchema(entityFactory(userFavouritesSchemaKey).entityType); -// export const endpointEntitySchema = new StratosEntitySchema(entityFactory(endpointSchemaKey).entityType); -// export const userProfileEntitySchema = new StratosEntitySchema(entityFactory(userProfileSchemaKey).entityType); -// export const systemInfoEntitySchema = new StratosEntitySchema(entityFactory(systemInfoSchemaKey).entityType); diff --git a/src/frontend/packages/store/src/entity-catalog/entity-catalog.spec.ts b/src/frontend/packages/store/src/entity-catalog/entity-catalog.spec.ts index ce4979a9fc..e0edb27a55 100644 --- a/src/frontend/packages/store/src/entity-catalog/entity-catalog.spec.ts +++ b/src/frontend/packages/store/src/entity-catalog/entity-catalog.spec.ts @@ -2,8 +2,8 @@ import { BaseEndpointAuth } from '../../../core/src/features/endpoints/endpoint- import { EndpointListDetailsComponent, } from '../../../core/src/shared/components/list/list-types/endpoint/endpoint-list.helpers'; -import { endpointEntitySchema } from '../base-entity-schemas'; import { EntitySchema } from '../helpers/entity-schema'; +import { endpointEntityType, stratosEntityFactory } from '../helpers/stratos-entity-factory'; import { TestEntityCatalog } from './entity-catalog'; import { StratosCatalogEndpointEntity, StratosCatalogEntity } from './entity-catalog-entity/entity-catalog-entity'; import { EntityCatalogSchemas, IStratosEndpointDefinition } from './entity-catalog.types'; @@ -107,7 +107,7 @@ describe('EntityCatalogService', () => { expect(catalogEntity.definition).toEqual({ ...endpoint, schema: { - default: endpointEntitySchema + default: stratosEntityFactory(endpointEntityType) } }); }); @@ -141,7 +141,7 @@ describe('EntityCatalogService', () => { iconFont: 'stratos-icons', listDetailsComponent: EndpointListDetailsComponent, schema: { - default: endpointEntitySchema + default: stratosEntityFactory(endpointEntityType) }, parentType: endpoint.type }; diff --git a/src/frontend/packages/store/src/entity-service.spec.ts b/src/frontend/packages/store/src/entity-service.spec.ts index 9154b5fbb5..ad52aab1fb 100644 --- a/src/frontend/packages/store/src/entity-service.spec.ts +++ b/src/frontend/packages/store/src/entity-service.spec.ts @@ -4,11 +4,9 @@ import { inject, TestBed } from '@angular/core/testing'; import { Action, Store } from '@ngrx/store'; import { filter, first, map, pairwise, tap } from 'rxjs/operators'; -import { generateTestEntityServiceProvider } from '../../core/test-framework/entity-service.helper'; import { createEntityStore, TestStoreEntity } from '../testing/src/store-test-helper'; import { APIResponse } from './actions/request.actions'; import { GeneralAppState } from './app-state'; -import { STRATOS_ENDPOINT_TYPE } from './base-entity-schemas'; import { EntityCatalogTestModule, TEST_CATALOGUE_ENTITIES } from './entity-catalog-test.module'; import { StratosBaseCatalogEntity } from './entity-catalog/entity-catalog-entity/entity-catalog-entity'; import { EntityCatalogEntityConfig, IStratosEndpointDefinition } from './entity-catalog/entity-catalog.types'; @@ -17,6 +15,7 @@ import { PipelineResult } from './entity-request-pipeline/entity-request-pipelin import { EntityService } from './entity-service'; import { EntityServiceFactory } from './entity-service-factory.service'; import { EntitySchema } from './helpers/entity-schema'; +import { STRATOS_ENDPOINT_TYPE } from './helpers/stratos-entity-factory'; import { EntityMonitor } from './monitors/entity-monitor'; import { EntityMonitorFactory } from './monitors/entity-monitor.factory.service'; import { completeApiRequest, startApiRequest } from './reducers/api-request-reducer/request-helpers'; @@ -142,11 +141,6 @@ describe('EntityServiceService', () => { providers: [ EntityServiceFactory, EntityMonitorFactory, - generateTestEntityServiceProvider( - action.guid, - entitySchema, - action - ), { provide: HttpXhrBackend, useClass: HttpTestingController diff --git a/src/frontend/packages/store/src/reducers/current-user-roles-reducer/user-favorites-groups.reducer.spec.ts b/src/frontend/packages/store/src/reducers/current-user-roles-reducer/user-favorites-groups.reducer.spec.ts index 2d64c4610c..3afec96484 100644 --- a/src/frontend/packages/store/src/reducers/current-user-roles-reducer/user-favorites-groups.reducer.spec.ts +++ b/src/frontend/packages/store/src/reducers/current-user-roles-reducer/user-favorites-groups.reducer.spec.ts @@ -2,9 +2,9 @@ import { GetUserFavoritesAction, GetUserFavoritesFailedAction, GetUserFavoritesSuccessAction, -} from '../../actions/user-favourites-actions/get-user-favorites-action'; -import { RemoveUserFavoriteSuccessAction } from '../../actions/user-favourites-actions/remove-user-favorite-action'; -import { SaveUserFavoriteSuccessAction } from '../../actions/user-favourites-actions/save-user-favorite-action'; + RemoveUserFavoriteSuccessAction, + SaveUserFavoriteSuccessAction, +} from '../../actions/user-favourites.actions'; import { getDefaultFavoriteGroupsState, IUserFavoritesGroupsState } from '../../types/favorite-groups.types'; import { IEndpointFavMetadata, UserFavorite } from '../../types/user-favorites.types'; import { deriveEndpointFavoriteFromFavorite } from '../../user-favorite-helpers'; diff --git a/src/frontend/packages/store/src/reducers/pagination-reducer/pagination.reducer.spec.ts b/src/frontend/packages/store/src/reducers/pagination-reducer/pagination.reducer.spec.ts index 27456925e1..cd0fe5bc3b 100644 --- a/src/frontend/packages/store/src/reducers/pagination-reducer/pagination.reducer.spec.ts +++ b/src/frontend/packages/store/src/reducers/pagination-reducer/pagination.reducer.spec.ts @@ -1,7 +1,6 @@ import { HttpRequest } from '@angular/common/http'; import { RequestTypes } from '../../actions/request.actions'; -import { STRATOS_ENDPOINT_TYPE } from '../../base-entity-schemas'; import { entityCatalog } from '../../entity-catalog/entity-catalog'; import { EntityCatalogHelpers } from '../../entity-catalog/entity-catalog.helper'; import { EntitySchema } from '../../helpers/entity-schema'; diff --git a/src/frontend/packages/store/src/stratos-entity-catalog.ts b/src/frontend/packages/store/src/stratos-entity-catalog.ts index ae0816e1e6..9237a16978 100644 --- a/src/frontend/packages/store/src/stratos-entity-catalog.ts +++ b/src/frontend/packages/store/src/stratos-entity-catalog.ts @@ -13,8 +13,6 @@ import { SystemInfo } from './types/system.types'; import { UserFavorite } from './types/user-favorites.types'; import { UserProfileInfo } from './types/user-profile.types'; -// TODO: RC Test all of these actions - export class StratosEntityCatalog { endpoint: StratosCatalogEntity< undefined, From 4c0b631f787969406c853db7b14a867c4c27f8bd Mon Sep 17 00:00:00 2001 From: Richard Cox Date: Tue, 23 Jun 2020 11:05:38 +0100 Subject: [PATCH 10/12] Fixes following merge --- .../packages/core/src/stratos-entities.ts | 33 ------------------- .../store/src/stratos-entity-generator.ts | 2 +- .../store/src/user-favorite-manager.ts | 1 - 3 files changed, 1 insertion(+), 35 deletions(-) delete mode 100644 src/frontend/packages/core/src/stratos-entities.ts diff --git a/src/frontend/packages/core/src/stratos-entities.ts b/src/frontend/packages/core/src/stratos-entities.ts deleted file mode 100644 index 539aec7e4c..0000000000 --- a/src/frontend/packages/core/src/stratos-entities.ts +++ /dev/null @@ -1,33 +0,0 @@ -import { - DefaultEndpointCatalogEntity, - SystemInfoCatalogEntity, - UserFavoriteCatalogEntity, - UserProfileCatalogEntity, -} from '../../store/src/base-entity-types'; -import { StratosCatalogEndpointEntity } from '../../store/src/entity-catalog/entity-catalog-entity/entity-catalog-entity'; -import { BaseEndpointAuth } from './core/endpoint-auth'; -import { - MetricsEndpointDetailsComponent, -} from './features/metrics/metrics-endpoint-details/metrics-endpoint-details.component'; - -export function generateStratosEntities() { - return [ - new DefaultEndpointCatalogEntity(), - new SystemInfoCatalogEntity(), - new UserFavoriteCatalogEntity(), - new UserProfileCatalogEntity(), - // TODO: metrics location to be sorted - STRAT-152 - new StratosCatalogEndpointEntity({ - type: 'metrics', - label: 'Metrics', - labelPlural: 'Metrics', - tokenSharing: true, - logoUrl: '/core/assets/endpoint-icons/metrics.svg', - authTypes: [BaseEndpointAuth.UsernamePassword, BaseEndpointAuth.None], - renderPriority: 1, - listDetailsComponent: MetricsEndpointDetailsComponent, - }, - metadata => `/endpoints/metrics/${metadata.guid}` - ) - ]; -} diff --git a/src/frontend/packages/store/src/stratos-entity-generator.ts b/src/frontend/packages/store/src/stratos-entity-generator.ts index 078ecad5ad..0062f4fc4a 100644 --- a/src/frontend/packages/store/src/stratos-entity-generator.ts +++ b/src/frontend/packages/store/src/stratos-entity-generator.ts @@ -1,4 +1,4 @@ -import { BaseEndpointAuth } from '../../core/src/features/endpoints/endpoint-auth'; +import { BaseEndpointAuth } from '../../core/src/core/endpoint-auth'; import { MetricsEndpointDetailsComponent, } from '../../core/src/features/metrics/metrics-endpoint-details/metrics-endpoint-details.component'; diff --git a/src/frontend/packages/store/src/user-favorite-manager.ts b/src/frontend/packages/store/src/user-favorite-manager.ts index 9b9b4f8e04..a1e0d211e6 100644 --- a/src/frontend/packages/store/src/user-favorite-manager.ts +++ b/src/frontend/packages/store/src/user-favorite-manager.ts @@ -3,7 +3,6 @@ import { Store } from '@ngrx/store'; import { combineLatest, Observable, of } from 'rxjs'; import { filter, map, switchMap, tap } from 'rxjs/operators'; -import { FavoritesConfigMapper } from '../../core/src/shared/components/favorites-meta-card/favorite-config-mapper'; import { GeneralEntityAppState, IRequestEntityTypeState } from './app-state'; import { entityCatalog } from './entity-catalog/entity-catalog'; import { FavoritesConfigMapper } from './favorite-config-mapper'; From f07a8faa62c7d7bec76e187e622000e1843920b2 Mon Sep 17 00:00:00 2001 From: Richard Cox Date: Tue, 23 Jun 2020 16:27:06 +0100 Subject: [PATCH 11/12] Fix cf unit tests --- .../packages/cloud-foundry/src/cloud-foundry-test.module.ts | 1 + .../packages/cloud-foundry/test-framework/cf-test-helper.ts | 1 - 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/src/frontend/packages/cloud-foundry/src/cloud-foundry-test.module.ts b/src/frontend/packages/cloud-foundry/src/cloud-foundry-test.module.ts index 5d9bacb094..99bfc37bbd 100644 --- a/src/frontend/packages/cloud-foundry/src/cloud-foundry-test.module.ts +++ b/src/frontend/packages/cloud-foundry/src/cloud-foundry-test.module.ts @@ -7,6 +7,7 @@ import { getGitHubAPIURL, GITHUB_API_URL } from '../../core/src/core/github.help import { LoggerService } from '../../core/src/core/logger.service'; import { CATALOGUE_ENTITIES, EntityCatalogFeatureModule } from '../../store/src/entity-catalog.module'; import { entityCatalog, TestEntityCatalog } from '../../store/src/entity-catalog/entity-catalog'; +import { generateStratosEntities } from '../../store/src/stratos-entity-generator'; import { testSCFEndpointGuid } from '../../store/testing/public-api'; import { BaseCfOrgSpaceRouteMock } from '../test-framework/cloud-foundry-endpoint-service.helper'; import { generateCFEntities } from './cf-entity-generator'; diff --git a/src/frontend/packages/cloud-foundry/test-framework/cf-test-helper.ts b/src/frontend/packages/cloud-foundry/test-framework/cf-test-helper.ts index 55264b2447..c22514e227 100644 --- a/src/frontend/packages/cloud-foundry/test-framework/cf-test-helper.ts +++ b/src/frontend/packages/cloud-foundry/test-framework/cf-test-helper.ts @@ -1,4 +1,3 @@ -import { generateStratosEntities } from '../../core/src/stratos-entities'; import { BaseTestModules } from '../../core/test-framework/core-test.helper'; import { EntityCatalogTestModule, TEST_CATALOGUE_ENTITIES } from '../../store/src/entity-catalog-test.module'; import { generateStratosEntities } from '../../store/src/stratos-entity-generator'; From 26a3610247d2da171208590f5d5178dae8941abf Mon Sep 17 00:00:00 2001 From: Richard Cox Date: Wed, 24 Jun 2020 13:27:19 +0100 Subject: [PATCH 12/12] Changes following review --- .../shared/data-services/cloud-foundry.service.ts | 1 - .../shared/services/cf-org-space-label.service.ts | 1 - .../core/src/features/endpoints/connect.service.ts | 1 - .../favorites-entity-list.component.ts | 3 --- .../meta-card/meta-card-base/meta-card.component.ts | 10 +--------- .../packages/store/src/actions/endpoint.actions.ts | 4 +++- .../packages/store/src/actions/system.actions.ts | 3 ++- .../packages/store/src/effects/endpoint.effects.ts | 2 +- .../packages/store/src/effects/system.effects.ts | 2 -- .../entity-catalog-entity-store-helpers.ts | 7 +++---- .../packages/store/src/favorite-config-mapper.ts | 13 ++++--------- .../store/src/helpers/stratos-entity-factory.ts | 7 ++----- .../packages/store/src/types/system.types.ts | 8 -------- 13 files changed, 16 insertions(+), 46 deletions(-) diff --git a/src/frontend/packages/cloud-foundry/src/shared/data-services/cloud-foundry.service.ts b/src/frontend/packages/cloud-foundry/src/shared/data-services/cloud-foundry.service.ts index 537166039f..2482601268 100644 --- a/src/frontend/packages/cloud-foundry/src/shared/data-services/cloud-foundry.service.ts +++ b/src/frontend/packages/cloud-foundry/src/shared/data-services/cloud-foundry.service.ts @@ -20,7 +20,6 @@ export class CloudFoundryService { this.cfEndpointsMonitor = stratosEntityCatalog.endpoint.store.getPaginationMonitor(); - // TODO: RC Q should we now avoid selectors.. selectEntity, selectCfEntity, etc? and always access via entity catalog? this.cFEndpoints$ = this.cfEndpointsMonitor.currentPage$.pipe( map(endpoints => endpoints.filter(e => e.cnsi_type === 'cf')) ); diff --git a/src/frontend/packages/cloud-foundry/src/shared/services/cf-org-space-label.service.ts b/src/frontend/packages/cloud-foundry/src/shared/services/cf-org-space-label.service.ts index 7c42259f5e..36c9cb2e38 100644 --- a/src/frontend/packages/cloud-foundry/src/shared/services/cf-org-space-label.service.ts +++ b/src/frontend/packages/cloud-foundry/src/shared/services/cf-org-space-label.service.ts @@ -34,7 +34,6 @@ export class CfOrgSpaceLabelService { // FIXME: hide STRATOS_ENDPOINT_TYPE from extensions - STRAT-154 const endpointEntityKey = entityCatalog.getEntityKey(STRATOS_ENDPOINT_TYPE, endpointEntityType); - // TODO: RC Q should we now avoid selectors.. selectEntity, selectCfEntity, etc? and always access via entity catalog? this.cf$ = this.store.select(selectEntity(endpointEntityKey, this.cfGuid)); this.org$ = this.store.select>(selectCfEntity(organizationEntityType, this.orgGuid)); diff --git a/src/frontend/packages/core/src/features/endpoints/connect.service.ts b/src/frontend/packages/core/src/features/endpoints/connect.service.ts index 9272b408b9..76504957f7 100644 --- a/src/frontend/packages/core/src/features/endpoints/connect.service.ts +++ b/src/frontend/packages/core/src/features/endpoints/connect.service.ts @@ -66,7 +66,6 @@ export class ConnectEndpointService { pairwise() ).subscribe(([oldVal, newVal]) => { if (!newVal.error && (oldVal.busy && !newVal.busy)) { - // TODO: RC Q Shouldn't this be in `next`? // Has finished fetching stratosEntityCatalog.endpoint.api.get(this.config.guid); } diff --git a/src/frontend/packages/core/src/shared/components/favorites-entity-list/favorites-entity-list.component.ts b/src/frontend/packages/core/src/shared/components/favorites-entity-list/favorites-entity-list.component.ts index 35f2f7eca0..06800db5f3 100644 --- a/src/frontend/packages/core/src/shared/components/favorites-entity-list/favorites-entity-list.component.ts +++ b/src/frontend/packages/core/src/shared/components/favorites-entity-list/favorites-entity-list.component.ts @@ -33,9 +33,6 @@ export class FavoritesEntityListComponent implements OnInit { @Input() set endpointTypes(types: string[] | string) { if (!this.favoriteTypes) { - // return [ - - // ] if (Array.isArray(types)) { this.favoriteTypes = types.reduce((allTypes, endpointType) => { return [ diff --git a/src/frontend/packages/core/src/shared/components/list/list-cards/meta-card/meta-card-base/meta-card.component.ts b/src/frontend/packages/core/src/shared/components/list/list-cards/meta-card/meta-card-base/meta-card.component.ts index 3ffb7c4287..59a95244d6 100644 --- a/src/frontend/packages/core/src/shared/components/list/list-cards/meta-card/meta-card-base/meta-card.component.ts +++ b/src/frontend/packages/core/src/shared/components/list/list-cards/meta-card/meta-card-base/meta-card.component.ts @@ -37,16 +37,8 @@ export class MetaCardComponent implements OnDestroy { @Input() status$: Observable; - // @Input() - // public favorite: UserFavorite; - private _favorite: UserFavorite; @Input() - set favorite(favorite: UserFavorite) { - this._favorite = favorite; - } - get favorite(): UserFavorite { - return this._favorite; - } + public favorite: UserFavorite; @Input() public confirmFavoriteRemoval = false; diff --git a/src/frontend/packages/store/src/actions/endpoint.actions.ts b/src/frontend/packages/store/src/actions/endpoint.actions.ts index 6581b0b3a5..2e4b8404ed 100644 --- a/src/frontend/packages/store/src/actions/endpoint.actions.ts +++ b/src/frontend/packages/store/src/actions/endpoint.actions.ts @@ -39,7 +39,9 @@ export class EndpointActionComplete implements Action { constructor( public type: string, public guid: string, - // Note - The underlying endpoints type (_cf_Endpoint, not _stratos_Endpoint) + /** + * Note - The underlying endpoints type (_cf_Endpoint, not _stratos_Endpoint) + */ public endpointType: EndpointType, public endpoint: EndpointModel | INewlyConnectedEndpointInfo ) { } diff --git a/src/frontend/packages/store/src/actions/system.actions.ts b/src/frontend/packages/store/src/actions/system.actions.ts index 208e19a4de..29c9f9410d 100644 --- a/src/frontend/packages/store/src/actions/system.actions.ts +++ b/src/frontend/packages/store/src/actions/system.actions.ts @@ -10,7 +10,8 @@ export const GET_SYSTEM_INFO_SUCCESS = '[System] Get info success'; export const GET_SYSTEM_INFO_FAILED = '[System] Get info failed'; export class GetSystemInfo implements EntityRequestAction { - guid = 'info'; + static guid = 'info'; + guid = GetSystemInfo.guid; constructor(public login = false, public associatedAction?: BaseEndpointAction) { if (!this.associatedAction) { this.associatedAction = new GetAllEndpoints(login); diff --git a/src/frontend/packages/store/src/effects/endpoint.effects.ts b/src/frontend/packages/store/src/effects/endpoint.effects.ts index 3910e945d1..6925c05e5c 100644 --- a/src/frontend/packages/store/src/effects/endpoint.effects.ts +++ b/src/frontend/packages/store/src/effects/endpoint.effects.ts @@ -50,7 +50,7 @@ export class EndpointsEffect { private store: Store ) { } - @Effect() getAllEndpoint$ = this.actions$.pipe( + @Effect() getEndpoint$ = this.actions$.pipe( ofType(GET_ENDPOINT), mergeMap((action: GetEndpoint) => [ stratosEntityCatalog.systemInfo.actions.getSystemInfo(false, action) diff --git a/src/frontend/packages/store/src/effects/system.effects.ts b/src/frontend/packages/store/src/effects/system.effects.ts index f456faabaf..07eb09bdf5 100644 --- a/src/frontend/packages/store/src/effects/system.effects.ts +++ b/src/frontend/packages/store/src/effects/system.effects.ts @@ -35,9 +35,7 @@ export class SystemEffects { ]; }), catchError((e) => { return [ - // new GetSystemFailed(), { type: action.actions[2] }, - // new WrapperRequestActionFailed('Could not get system endpoints', associatedAction), new WrapperRequestActionFailed('Could not fetch system info', action) ]; })); diff --git a/src/frontend/packages/store/src/entity-catalog/entity-catalog-entity/entity-catalog-entity-store-helpers.ts b/src/frontend/packages/store/src/entity-catalog/entity-catalog-entity/entity-catalog-entity-store-helpers.ts index ddf251581d..0ad7cc9d67 100644 --- a/src/frontend/packages/store/src/entity-catalog/entity-catalog-entity/entity-catalog-entity-store-helpers.ts +++ b/src/frontend/packages/store/src/entity-catalog/entity-catalog-entity/entity-catalog-entity-store-helpers.ts @@ -148,10 +148,9 @@ export class EntityCatalogEntityStoreHelpers { schemaKey: '', startWithNull: false } - ): EntityMonitor => { - - return new EntityMonitor(EntityCatalogHelpers.GetEntityCatalogHelper().store, entityId, entityKey, getSchema(params.schemaKey), params.startWithNull); - }, + ): EntityMonitor => new EntityMonitor( + EntityCatalogHelpers.GetEntityCatalogHelper().store, entityId, entityKey, getSchema(params.schemaKey), params.startWithNull + ), getEntityService: ( ...args: Parameters ): EntityService => { diff --git a/src/frontend/packages/store/src/favorite-config-mapper.ts b/src/frontend/packages/store/src/favorite-config-mapper.ts index 8009dfe116..8fa3cd6890 100644 --- a/src/frontend/packages/store/src/favorite-config-mapper.ts +++ b/src/frontend/packages/store/src/favorite-config-mapper.ts @@ -122,15 +122,10 @@ export class FavoritesConfigMapper { * For a given endpoint type, return the list of possible favorite types */ public getAllTypesForEndpoint(endpointType: string): IFavoriteTypes[] { - return entityCatalog.getAllEntitiesForEndpointType(endpointType) - .filter(fav => { - console.log(fav); - return true; - }) - .map(catalogEntity => ({ - type: catalogEntity.definition.type, - prettyName: catalogEntity.definition.label - })); + return entityCatalog.getAllEntitiesForEndpointType(endpointType).map(catalogEntity => ({ + type: catalogEntity.definition.type, + prettyName: catalogEntity.definition.label + })); } private buildFavoriteFromCatalogEntity( diff --git a/src/frontend/packages/store/src/helpers/stratos-entity-factory.ts b/src/frontend/packages/store/src/helpers/stratos-entity-factory.ts index 80cdf02957..1182c576a3 100644 --- a/src/frontend/packages/store/src/helpers/stratos-entity-factory.ts +++ b/src/frontend/packages/store/src/helpers/stratos-entity-factory.ts @@ -19,12 +19,10 @@ class StratosEntitySchema extends EntitySchema { } } -// TODO: RC test auto log out process - -const UserFavouritesSchema = new StratosEntitySchema(userFavouritesEntityType, 'id'); +const UserFavouritesSchema = new StratosEntitySchema(userFavouritesEntityType, 'guid'); entityCache[userFavouritesEntityType] = UserFavouritesSchema; -const SystemInfoSchema = new StratosEntitySchema(systemInfoEntityType, 'id'); +const SystemInfoSchema = new StratosEntitySchema(systemInfoEntityType, 'guid'); entityCache[systemInfoEntityType] = SystemInfoSchema; const EndpointSchema = new StratosEntitySchema(endpointEntityType, 'guid'); @@ -39,5 +37,4 @@ export function stratosEntityFactory(key: string): EntitySchema { throw new Error(`Unknown entity schema type: ${key}`); } return entity; - } \ No newline at end of file diff --git a/src/frontend/packages/store/src/types/system.types.ts b/src/frontend/packages/store/src/types/system.types.ts index 29c0aa32bf..a369b88217 100644 --- a/src/frontend/packages/store/src/types/system.types.ts +++ b/src/frontend/packages/store/src/types/system.types.ts @@ -12,11 +12,3 @@ export interface SystemInfo { } }; } - -// export const systemStoreNames: { -// section: TRequestTypeKeys, -// type: string -// } = { -// section: RequestSectionKeys.Other, -// type: entityFactory(systemInfoSchemaKey).entityType -// };