diff --git a/src/frontend/packages/core/src/features/cloud-foundry/cli-info-cloud-foundry/cli-info-cloud-foundry.component.ts b/src/frontend/packages/core/src/features/cloud-foundry/cli-info-cloud-foundry/cli-info-cloud-foundry.component.ts index 70f6f57dea..21609f0974 100644 --- a/src/frontend/packages/core/src/features/cloud-foundry/cli-info-cloud-foundry/cli-info-cloud-foundry.component.ts +++ b/src/frontend/packages/core/src/features/cloud-foundry/cli-info-cloud-foundry/cli-info-cloud-foundry.component.ts @@ -1,9 +1,13 @@ - -import { of as observableOf, BehaviorSubject, Observable, combineLatest } from 'rxjs'; import { Component, OnInit, Optional } from '@angular/core'; import { Store } from '@ngrx/store'; +import { BehaviorSubject, combineLatest, Observable, of as observableOf } from 'rxjs'; import { first, map } from 'rxjs/operators'; +import { RouterNav } from '../../../../../store/src/actions/router.actions'; +import { AppState } from '../../../../../store/src/app-state'; +import { APIResource, EntityInfo } from '../../../../../store/src/types/api.types'; +import { EndpointModel } from '../../../../../store/src/types/endpoint.types'; +import { getPreviousRoutingState } from '../../../../../store/src/types/routing.type'; import { IOrganization, ISpace } from '../../../core/cf-api.types'; import { CurrentUserPermissionsChecker } from '../../../core/current-user-permissions.checker'; import { CurrentUserPermissions } from '../../../core/current-user-permissions.config'; @@ -15,11 +19,7 @@ import { getActiveRouteCfOrgSpaceProvider } from '../cf.helpers'; import { CloudFoundryEndpointService } from '../services/cloud-foundry-endpoint.service'; import { CloudFoundryOrganizationService } from '../services/cloud-foundry-organization.service'; import { CloudFoundrySpaceService } from '../services/cloud-foundry-space.service'; -import { EntityInfo, APIResource } from '../../../../../store/src/types/api.types'; -import { EndpointModel } from '../../../../../store/src/types/endpoint.types'; -import { AppState } from '../../../../../store/src/app-state'; -import { getPreviousRoutingState } from '../../../../../store/src/types/routing.type'; -import { RouterNav } from '../../../../../store/src/actions/router.actions'; + @Component({ selector: 'app-cli-info-cloud-foundry', @@ -71,7 +71,6 @@ export class CliInfoCloudFoundryComponent implements OnInit { } ngOnInit() { - const { cfGuid, orgGuid, spaceGuid } = this.activeRouteCfOrgSpace; this.setupRouteObservable(this.getDefaultBackLink()); // Will auto unsubscribe as we are using 'first' this.route$.pipe(first()).subscribe(route => { @@ -107,7 +106,7 @@ export class CliInfoCloudFoundryComponent implements OnInit { } private setupObservables() { - const { cfGuid, orgGuid, spaceGuid } = this.activeRouteCfOrgSpace; + const { orgGuid, spaceGuid } = this.activeRouteCfOrgSpace; const org$ = orgGuid ? this.cfOrgService.org$ : observableOf(null); const space$ = spaceGuid ? this.cfSpaceService.space$ : observableOf(null); this.endpointOrgSpace$ = combineLatest( @@ -130,7 +129,6 @@ export class CliInfoCloudFoundryComponent implements OnInit { } private setupBreadcrumbs() { - const { cfGuid, orgGuid, spaceGuid } = this.activeRouteCfOrgSpace; this.breadcrumbs$ = this.endpointOrgSpace$.pipe( map(([cf, org, space]) => { const breadcrumbs = [{ diff --git a/src/frontend/packages/core/src/features/cloud-foundry/services/cloud-foundry-endpoint.service.ts b/src/frontend/packages/core/src/features/cloud-foundry/services/cloud-foundry-endpoint.service.ts index 1d4589ca55..87dd37fc4b 100644 --- a/src/frontend/packages/core/src/features/cloud-foundry/services/cloud-foundry-endpoint.service.ts +++ b/src/frontend/packages/core/src/features/cloud-foundry/services/cloud-foundry-endpoint.service.ts @@ -18,7 +18,6 @@ import { privateDomainsSchemaKey, quotaDefinitionSchemaKey, routeSchemaKey, - serviceInstancesSchemaKey, spaceSchemaKey, } from '../../../../../store/src/helpers/entity-factory'; import { @@ -86,9 +85,8 @@ export class CloudFoundryEndpointService { createEntityRelationKey(organizationSchemaKey, domainSchemaKey), createEntityRelationKey(organizationSchemaKey, quotaDefinitionSchemaKey), createEntityRelationKey(organizationSchemaKey, privateDomainsSchemaKey), - createEntityRelationKey(spaceSchemaKey, serviceInstancesSchemaKey), createEntityRelationKey(spaceSchemaKey, routeSchemaKey), // Not really needed at top level, but if we drop down into an org with - // lots of spaces it saves n x routes requests + // lots of spaces it saves spaces x routes requests ]); } static createGetAllOrganizationsLimitedSchema(cfGuid: string) { diff --git a/src/frontend/packages/core/src/features/cloud-foundry/services/cloud-foundry-organization.service.ts b/src/frontend/packages/core/src/features/cloud-foundry/services/cloud-foundry-organization.service.ts index ca5404cf9c..0be8f48ddf 100644 --- a/src/frontend/packages/core/src/features/cloud-foundry/services/cloud-foundry-organization.service.ts +++ b/src/frontend/packages/core/src/features/cloud-foundry/services/cloud-foundry-organization.service.ts @@ -14,18 +14,20 @@ import { privateDomainsSchemaKey, quotaDefinitionSchemaKey, routeSchemaKey, - serviceInstancesSchemaKey, spaceSchemaKey, } from '../../../../../store/src/helpers/entity-factory'; import { createEntityRelationKey } from '../../../../../store/src/helpers/entity-relations/entity-relations.types'; import { APIResource, EntityInfo } from '../../../../../store/src/types/api.types'; import { OrgUserRoleNames } from '../../../../../store/src/types/user.types'; -import { IServiceInstance } from '../../../core/cf-api-svc.types'; import { IApp, IOrganization, IPrivateDomain, IQuotaDefinition, ISpace } from '../../../core/cf-api.types'; import { getEntityFlattenedList, getStartedAppInstanceCount } from '../../../core/cf.helpers'; import { EntityServiceFactory } from '../../../core/entity-service-factory.service'; import { CfUserService } from '../../../shared/data-services/cf-user.service'; import { PaginationMonitorFactory } from '../../../shared/monitors/pagination-monitor.factory'; +import { + CloudFoundryUserProvidedServicesService, +} from '../../../shared/services/cloud-foundry-user-provided-services.service'; +import { fetchServiceInstancesCount } from '../../service-catalog/services-helper'; import { ActiveRouteCfOrgSpace } from '../cf-page.types'; import { getOrgRolesString } from '../cf.helpers'; import { CloudFoundryEndpointService } from './cloud-foundry-endpoint.service'; @@ -52,7 +54,8 @@ export class CloudFoundryOrganizationService { totalMem$: Observable; privateDomains$: Observable[]>; routes$: Observable[]>; - serviceInstances$: Observable[]>; + serviceInstancesCount$: Observable; + userProvidedServiceInstancesCount$: Observable; spaces$: Observable[]>; appInstances$: Observable; apps$: Observable[]>; @@ -68,6 +71,7 @@ export class CloudFoundryOrganizationService { private cfUserService: CfUserService, private paginationMonitorFactory: PaginationMonitorFactory, private cfEndpointService: CloudFoundryEndpointService, + private cfUserProvidedServicesService: CloudFoundryUserProvidedServicesService ) { this.orgGuid = activeRouteCfOrgSpace.orgGuid; this.cfGuid = activeRouteCfOrgSpace.cfGuid; @@ -91,7 +95,6 @@ export class CloudFoundryOrganizationService { createEntityRelationKey(organizationSchemaKey, domainSchemaKey), createEntityRelationKey(organizationSchemaKey, quotaDefinitionSchemaKey), createEntityRelationKey(organizationSchemaKey, privateDomainsSchemaKey), - createEntityRelationKey(spaceSchemaKey, serviceInstancesSchemaKey), createEntityRelationKey(spaceSchemaKey, routeSchemaKey), ]; if (!isAdmin) { @@ -129,10 +132,13 @@ export class CloudFoundryOrganizationService { map(u => getOrgRolesString(u)) ); + this.serviceInstancesCount$ = fetchServiceInstancesCount(this.cfGuid, this.orgGuid, null, this.store, this.paginationMonitorFactory); + this.userProvidedServiceInstancesCount$ = + this.cfUserProvidedServicesService.fetchUserProvidedServiceInstancesCount(this.cfGuid, this.orgGuid); + } private initialiseSpaceObservables() { - this.serviceInstances$ = this.spaces$.pipe(this.getFlattenedList('service_instances')); this.routes$ = this.spaces$.pipe(this.getFlattenedList('routes')); } diff --git a/src/frontend/packages/core/src/features/cloud-foundry/services/cloud-foundry-space.service.ts b/src/frontend/packages/core/src/features/cloud-foundry/services/cloud-foundry-space.service.ts index 946119b411..4d52ed9d8e 100644 --- a/src/frontend/packages/core/src/features/cloud-foundry/services/cloud-foundry-space.service.ts +++ b/src/frontend/packages/core/src/features/cloud-foundry/services/cloud-foundry-space.service.ts @@ -18,12 +18,15 @@ import { import { createEntityRelationKey } from '../../../../../store/src/helpers/entity-relations/entity-relations.types'; import { APIResource, EntityInfo } from '../../../../../store/src/types/api.types'; import { SpaceUserRoleNames } from '../../../../../store/src/types/user.types'; -import { IServiceInstance } from '../../../core/cf-api-svc.types'; import { IApp, IQuotaDefinition, IRoute, ISpace } from '../../../core/cf-api.types'; import { getStartedAppInstanceCount } from '../../../core/cf.helpers'; import { EntityServiceFactory } from '../../../core/entity-service-factory.service'; import { CfUserService } from '../../../shared/data-services/cf-user.service'; import { PaginationMonitorFactory } from '../../../shared/monitors/pagination-monitor.factory'; +import { + CloudFoundryUserProvidedServicesService, +} from '../../../shared/services/cloud-foundry-user-provided-services.service'; +import { fetchServiceInstancesCount } from '../../service-catalog/services-helper'; import { ActiveRouteCfOrgSpace } from '../cf-page.types'; import { getSpaceRolesString } from '../cf.helpers'; import { CloudFoundryEndpointService } from './cloud-foundry-endpoint.service'; @@ -40,7 +43,8 @@ export class CloudFoundrySpaceService { allowSsh$: Observable; totalMem$: Observable; routes$: Observable[]>; - serviceInstances$: Observable[]>; + serviceInstancesCount$: Observable; + userProvidedServiceInstancesCount$: Observable; appInstances$: Observable; apps$: Observable[]>; appCount$: Observable; @@ -55,6 +59,7 @@ export class CloudFoundrySpaceService { private cfUserService: CfUserService, private paginationMonitorFactory: PaginationMonitorFactory, private cfEndpointService: CloudFoundryEndpointService, + private cfUserProvidedServicesService: CloudFoundryUserProvidedServicesService ) { this.spaceGuid = activeRouteCfOrgSpace.spaceGuid; @@ -90,7 +95,6 @@ export class CloudFoundrySpaceService { this.space$ = this.cfUserService.isConnectedUserAdmin(this.cfGuid).pipe( switchMap(isAdmin => { const relations = [ - createEntityRelationKey(spaceSchemaKey, serviceInstancesSchemaKey), createEntityRelationKey(spaceSchemaKey, spaceQuotaSchemaKey), createEntityRelationKey(serviceInstancesSchemaKey, serviceBindingSchemaKey), createEntityRelationKey(serviceBindingSchemaKey, applicationSchemaKey), @@ -119,7 +123,14 @@ export class CloudFoundrySpaceService { refCount() ); - this.serviceInstances$ = this.space$.pipe(map(o => o.entity.entity.service_instances)); + this.serviceInstancesCount$ = fetchServiceInstancesCount( + this.cfGuid, + this.orgGuid, + this.spaceGuid, + this.store, + this.paginationMonitorFactory); + this.userProvidedServiceInstancesCount$ = + this.cfUserProvidedServicesService.fetchUserProvidedServiceInstancesCount(this.cfGuid, this.orgGuid, this.spaceGuid); this.routes$ = this.space$.pipe(map(o => o.entity.entity.routes)); this.allowSsh$ = this.space$.pipe(map(o => o.entity.entity.allow_ssh ? 'true' : 'false')); this.quotaDefinition$ = this.space$.pipe(map(q => { diff --git a/src/frontend/packages/core/src/features/cloud-foundry/tabs/cloud-foundry-organizations/cloud-foundry-organization-spaces/tabs/cloud-foundry-space-summary/cloud-foundry-space-summary.component.html b/src/frontend/packages/core/src/features/cloud-foundry/tabs/cloud-foundry-organizations/cloud-foundry-organization-spaces/tabs/cloud-foundry-space-summary/cloud-foundry-space-summary.component.html index d79fa835dc..9db4d45acd 100644 --- a/src/frontend/packages/core/src/features/cloud-foundry/tabs/cloud-foundry-organizations/cloud-foundry-organization-spaces/tabs/cloud-foundry-space-summary/cloud-foundry-space-summary.component.html +++ b/src/frontend/packages/core/src/features/cloud-foundry/tabs/cloud-foundry-organizations/cloud-foundry-organization-spaces/tabs/cloud-foundry-space-summary/cloud-foundry-space-summary.component.html @@ -9,31 +9,54 @@ - + + - + - + - + + - + + + + - + - + diff --git a/src/frontend/packages/core/src/features/cloud-foundry/tabs/cloud-foundry-organizations/cloud-foundry-organization-spaces/tabs/cloud-foundry-space-summary/cloud-foundry-space-summary.component.ts b/src/frontend/packages/core/src/features/cloud-foundry/tabs/cloud-foundry-organizations/cloud-foundry-organization-spaces/tabs/cloud-foundry-space-summary/cloud-foundry-space-summary.component.ts index 6b849d6583..74cf7b3e48 100644 --- a/src/frontend/packages/core/src/features/cloud-foundry/tabs/cloud-foundry-organizations/cloud-foundry-organization-spaces/tabs/cloud-foundry-space-summary/cloud-foundry-space-summary.component.ts +++ b/src/frontend/packages/core/src/features/cloud-foundry/tabs/cloud-foundry-organizations/cloud-foundry-organization-spaces/tabs/cloud-foundry-space-summary/cloud-foundry-space-summary.component.ts @@ -22,6 +22,7 @@ export class CloudFoundrySpaceSummaryComponent { cfEndpointService.appsPagObs.fetchingEntities$.pipe( filter(loading => !loading) ), + cfSpaceService.userProvidedServiceInstancesCount$ ]).pipe( map(() => false), startWith(true) diff --git a/src/frontend/packages/core/src/features/cloud-foundry/tabs/cloud-foundry-organizations/cloud-foundry-organization-summary/cloud-foundry-organization-summary.component.html b/src/frontend/packages/core/src/features/cloud-foundry/tabs/cloud-foundry-organizations/cloud-foundry-organization-summary/cloud-foundry-organization-summary.component.html index 4aca8881ea..32737698ff 100644 --- a/src/frontend/packages/core/src/features/cloud-foundry/tabs/cloud-foundry-organizations/cloud-foundry-organization-summary/cloud-foundry-organization-summary.component.html +++ b/src/frontend/packages/core/src/features/cloud-foundry/tabs/cloud-foundry-organizations/cloud-foundry-organization-summary/cloud-foundry-organization-summary.component.html @@ -9,35 +9,56 @@ - + + - + - + - + - + - + - + + + + - + - + diff --git a/src/frontend/packages/core/src/features/cloud-foundry/tabs/cloud-foundry-organizations/cloud-foundry-organization-summary/cloud-foundry-organization-summary.component.ts b/src/frontend/packages/core/src/features/cloud-foundry/tabs/cloud-foundry-organizations/cloud-foundry-organization-summary/cloud-foundry-organization-summary.component.ts index 6ea5709037..0eb0785867 100644 --- a/src/frontend/packages/core/src/features/cloud-foundry/tabs/cloud-foundry-organizations/cloud-foundry-organization-summary/cloud-foundry-organization-summary.component.ts +++ b/src/frontend/packages/core/src/features/cloud-foundry/tabs/cloud-foundry-organizations/cloud-foundry-organization-summary/cloud-foundry-organization-summary.component.ts @@ -31,6 +31,7 @@ export class CloudFoundryOrganizationSummaryComponent { cfEndpointService.appsPagObs.fetchingEntities$.pipe( filter(loading => !loading) ), + cfOrgService.userProvidedServiceInstancesCount$ ]).pipe( map(() => false), startWith(true) diff --git a/src/frontend/packages/core/src/features/service-catalog/services-helper.ts b/src/frontend/packages/core/src/features/service-catalog/services-helper.ts index ccffc915ee..c41ee078c0 100644 --- a/src/frontend/packages/core/src/features/service-catalog/services-helper.ts +++ b/src/frontend/packages/core/src/features/service-catalog/services-helper.ts @@ -9,14 +9,17 @@ import { GetService, GetServicePlansForService } from '../../../../store/src/act import { AppState } from '../../../../store/src/app-state'; import { entityFactory, + organizationSchemaKey, serviceBrokerSchemaKey, serviceInstancesSchemaKey, servicePlanSchemaKey, serviceSchemaKey, + spaceSchemaKey, } from '../../../../store/src/helpers/entity-factory'; import { createEntityRelationPaginationKey } from '../../../../store/src/helpers/entity-relations/entity-relations.types'; import { getPaginationObservables } from '../../../../store/src/reducers/pagination-reducer/pagination-reducer.helper'; import { APIResource } from '../../../../store/src/types/api.types'; +import { QParam } from '../../../../store/src/types/pagination.types'; import { IService, IServiceBroker, @@ -30,7 +33,7 @@ import { EntityServiceFactory } from '../../core/entity-service-factory.service' import { safeStringToObj } from '../../core/utils.service'; import { PaginationMonitorFactory } from '../../shared/monitors/pagination-monitor.factory'; import { CardStatus } from '../../shared/shared.types'; -import { getIdFromRoute } from '../cloud-foundry/cf.helpers'; +import { fetchTotalResults, getIdFromRoute } from '../cloud-foundry/cf.helpers'; import { ServicePlanAccessibility } from './services.service'; @@ -85,6 +88,25 @@ export const getServiceInstancesInCf = (cfGuid: string, store: Store, }, true).entities$; }; +export const fetchServiceInstancesCount = ( + cfGuid: string, + orgGuid: string = null, + spaceGuid: string = null, + store: Store, + paginationMonitorFactory: PaginationMonitorFactory): Observable => { + const parentSchemaKey = spaceGuid ? spaceSchemaKey : orgGuid ? organizationSchemaKey : 'cf'; + const uniqueKey = spaceGuid || orgGuid || cfGuid; + const action = new GetServiceInstances(cfGuid, createEntityRelationPaginationKey(parentSchemaKey, uniqueKey), [], false); + action.initialParams.q = []; + if (orgGuid) { + action.initialParams.q.push(new QParam('organization_guid', orgGuid, ' IN ')); + } + if (spaceGuid) { + action.initialParams.q.push(new QParam('space_guid', spaceGuid, ' IN ')); + } + return fetchTotalResults(action, store, paginationMonitorFactory); +}; + export const getServicePlans = ( service$: Observable>, cfGuid: string, diff --git a/src/frontend/packages/core/src/shared/components/cards/card-cf-org-usage/card-cf-org-usage.component.html b/src/frontend/packages/core/src/shared/components/cards/card-cf-org-usage/card-cf-org-usage.component.html deleted file mode 100644 index 3cb41e9bf0..0000000000 --- a/src/frontend/packages/core/src/shared/components/cards/card-cf-org-usage/card-cf-org-usage.component.html +++ /dev/null @@ -1,27 +0,0 @@ - - Usage - - Applications - {{ (cfOrganizationService.apps$ | async)?.length }} - - - Application Instances - {{ (cfOrganizationService.appInstances$ | async) }} / {{ (cfOrganizationService.quotaDefinition$ | async)?.app_instance_limit | infinityPipe}} - - - Service Instances - {{ (cfOrganizationService.serviceInstances$ | async)?.length }} / {{ (cfOrganizationService.quotaDefinition$ | async)?.total_services | infinityPipe }} - - - Routes - {{ (cfOrganizationService.routes$ | async)?.length }}/ {{ (cfOrganizationService.quotaDefinition$ | async)?.total_routes | infinityPipe }} - - - Private Domains - {{ (cfOrganizationService.privateDomains$ | async)?.length }} / {{ (cfOrganizationService.quotaDefinition$ | async)?.total_private_domains | infinityPipe}} - - - Memory Usage - {{ (cfOrganizationService.totalMem$ | async) | MbToHumanSize}} / {{ (cfOrganizationService.quotaDefinition$ | async)?.memory_limit | MbToHumanSize }} - - diff --git a/src/frontend/packages/core/src/shared/components/cards/card-cf-org-usage/card-cf-org-usage.component.scss b/src/frontend/packages/core/src/shared/components/cards/card-cf-org-usage/card-cf-org-usage.component.scss deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/src/frontend/packages/core/src/shared/components/cards/card-cf-org-usage/card-cf-org-usage.component.spec.ts b/src/frontend/packages/core/src/shared/components/cards/card-cf-org-usage/card-cf-org-usage.component.spec.ts deleted file mode 100644 index 6a440b7743..0000000000 --- a/src/frontend/packages/core/src/shared/components/cards/card-cf-org-usage/card-cf-org-usage.component.spec.ts +++ /dev/null @@ -1,50 +0,0 @@ -import { async, ComponentFixture, TestBed } from '@angular/core/testing'; - -import { EntityServiceFactory } from '../../../../core/entity-service-factory.service'; -import { - CloudFoundryOrganizationService, -} from '../../../../features/cloud-foundry/services/cloud-foundry-organization.service'; -import { - generateTestCfEndpointServiceProvider, - BaseTestModulesNoShared, - MetadataCardTestComponents, -} from '../../../../../test-framework/cloud-foundry-endpoint-service.helper'; -import { CloudFoundryOrganizationServiceMock } from '../../../../../test-framework/cloud-foundry-organization.service.mock'; -import { CfOrgSpaceDataService } from '../../../data-services/cf-org-space-service.service'; -import { CfUserService } from '../../../data-services/cf-user.service'; -import { EntityMonitorFactory } from '../../../monitors/entity-monitor.factory.service'; -import { PaginationMonitorFactory } from '../../../monitors/pagination-monitor.factory'; -import { CardCfOrgUsageComponent } from './card-cf-org-usage.component'; -import { BaseTestModules } from '../../../../../test-framework/cloud-foundry-endpoint-service.helper'; - -describe('CardCfOrgUsageComponent', () => { - let component: CardCfOrgUsageComponent; - let fixture: ComponentFixture; - - beforeEach(async(() => { - TestBed.configureTestingModule({ - declarations: [CardCfOrgUsageComponent, ...MetadataCardTestComponents], - imports: [...BaseTestModulesNoShared], - providers: [ - { provide: CloudFoundryOrganizationService, useClass: CloudFoundryOrganizationServiceMock }, - generateTestCfEndpointServiceProvider(), - EntityServiceFactory, - CfOrgSpaceDataService, - CfUserService, - PaginationMonitorFactory, - EntityMonitorFactory - ] - }) - .compileComponents(); - })); - - beforeEach(() => { - fixture = TestBed.createComponent(CardCfOrgUsageComponent); - component = fixture.componentInstance; - fixture.detectChanges(); - }); - - it('should create', () => { - expect(component).toBeTruthy(); - }); -}); diff --git a/src/frontend/packages/core/src/shared/components/cards/card-cf-org-usage/card-cf-org-usage.component.ts b/src/frontend/packages/core/src/shared/components/cards/card-cf-org-usage/card-cf-org-usage.component.ts deleted file mode 100644 index 9074b08c69..0000000000 --- a/src/frontend/packages/core/src/shared/components/cards/card-cf-org-usage/card-cf-org-usage.component.ts +++ /dev/null @@ -1,14 +0,0 @@ -import { Component } from '@angular/core'; - -import { - CloudFoundryOrganizationService, -} from '../../../../features/cloud-foundry/services/cloud-foundry-organization.service'; - -@Component({ - selector: 'app-card-cf-org-usage', - templateUrl: './card-cf-org-usage.component.html', - styleUrls: ['./card-cf-org-usage.component.scss'] -}) -export class CardCfOrgUsageComponent { - constructor(public cfOrganizationService: CloudFoundryOrganizationService) { } -} diff --git a/src/frontend/packages/core/src/shared/components/list/list-types/cf-spaces/cf-space-card/cf-space-card.component.html b/src/frontend/packages/core/src/shared/components/list/list-types/cf-spaces/cf-space-card/cf-space-card.component.html index b1dc4a4ada..b1fb6428a0 100644 --- a/src/frontend/packages/core/src/shared/components/list/list-types/cf-spaces/cf-space-card/cf-space-card.component.html +++ b/src/frontend/packages/core/src/shared/components/list/list-types/cf-spaces/cf-space-card/cf-space-card.component.html @@ -1,4 +1,6 @@ - + {{ row.entity.name }} @@ -13,7 +15,8 @@ App Instances - {{appInstancesCount }} / {{ appInstancesLimit | infinityPipe }} + {{appInstancesCount }} / + {{ appInstancesLimit | infinityPipe }} {{ appInstancesCount }} @@ -23,17 +26,11 @@ {{ appInstancesLimit | infinityPipe }} - - Service Instances - - {{serviceInstancesCount }} / {{ serviceInstancesLimit | infinityPipe }} - {{ serviceInstancesCount }} - - Memory - {{ memoryTotal | MbToHumanSize }} / {{ memoryLimit | MbToHumanSize }} + {{ memoryTotal | MbToHumanSize }} / + {{ memoryLimit | MbToHumanSize }} {{ memoryTotal }} diff --git a/src/frontend/packages/core/src/shared/components/list/list-types/cf-spaces/cf-space-card/cf-space-card.component.ts b/src/frontend/packages/core/src/shared/components/list/list-types/cf-spaces/cf-space-card/cf-space-card.component.ts index 4a1bc49617..6207e3f77d 100644 --- a/src/frontend/packages/core/src/shared/components/list/list-types/cf-spaces/cf-space-card/cf-space-card.component.ts +++ b/src/frontend/packages/core/src/shared/components/list/list-types/cf-spaces/cf-space-card/cf-space-card.component.ts @@ -42,9 +42,7 @@ import { CardCell } from '../../../list.types'; export class CfSpaceCardComponent extends CardCell> implements OnInit, OnDestroy { cardMenu: MetaCardMenuItem[]; spaceGuid: string; - serviceInstancesCount: number; appInstancesCount: number; - serviceInstancesLimit: string; appInstancesLimit: string; orgGuid: string; normalisedMemoryUsage: number; @@ -149,9 +147,7 @@ export class CfSpaceCardComponent extends CardCell> implemen this.normalisedMemoryUsage = this.memoryTotal / quotaDefinition.entity.memory_limit * 100; } this.appInstancesLimit = truthyIncludingZeroString(quotaDefinition.entity.app_instance_limit); - this.serviceInstancesLimit = truthyIncludingZeroString(quotaDefinition.entity.total_services); this.memoryLimit = truthyIncludingZeroString(quotaDefinition.entity.memory_limit); - this.serviceInstancesCount = this.row.entity.service_instances ? this.row.entity.service_instances.length : 0; } ngOnDestroy = () => this.subscriptions.forEach(p => p.unsubscribe()); diff --git a/src/frontend/packages/core/src/shared/components/list/list-types/cf-spaces/cf-spaces-data-source.service.ts b/src/frontend/packages/core/src/shared/components/list/list-types/cf-spaces/cf-spaces-data-source.service.ts index 928c7bcfb6..1d993cf596 100644 --- a/src/frontend/packages/core/src/shared/components/list/list-types/cf-spaces/cf-spaces-data-source.service.ts +++ b/src/frontend/packages/core/src/shared/components/list/list-types/cf-spaces/cf-spaces-data-source.service.ts @@ -1,29 +1,27 @@ import { Store } from '@ngrx/store'; -import { ListDataSource } from '../../data-sources-controllers/list-data-source'; -import { IListConfig } from '../../list.component.types'; -import { getRowMetadata } from '../../../../../features/cloud-foundry/cf.helpers'; -import { APIResource } from '../../../../../../../store/src/types/api.types'; +import { GetAllOrganizationSpaces } from '../../../../../../../store/src/actions/organization.actions'; import { AppState } from '../../../../../../../store/src/app-state'; -import { - createEntityRelationPaginationKey, - createEntityRelationKey -} from '../../../../../../../store/src/helpers/entity-relations/entity-relations.types'; import { entityFactory, organizationSchemaKey, - serviceInstancesSchemaKey, spaceQuotaSchemaKey, spaceSchemaKey, spaceWithOrgKey, } from '../../../../../../../store/src/helpers/entity-factory'; -import { GetAllOrganizationSpaces } from '../../../../../../../store/src/actions/organization.actions'; +import { + createEntityRelationKey, + createEntityRelationPaginationKey, +} from '../../../../../../../store/src/helpers/entity-relations/entity-relations.types'; +import { APIResource } from '../../../../../../../store/src/types/api.types'; +import { getRowMetadata } from '../../../../../features/cloud-foundry/cf.helpers'; +import { ListDataSource } from '../../data-sources-controllers/list-data-source'; +import { IListConfig } from '../../list.component.types'; export class CfSpacesDataSourceService extends ListDataSource { constructor(cfGuid: string, orgGuid: string, store: Store, listConfig?: IListConfig) { const paginationKey = createEntityRelationPaginationKey(organizationSchemaKey, orgGuid); const action = new GetAllOrganizationSpaces(paginationKey, orgGuid, cfGuid, [ - createEntityRelationKey(spaceSchemaKey, serviceInstancesSchemaKey), createEntityRelationKey(spaceSchemaKey, spaceQuotaSchemaKey), ]); super({ 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 a2e5ce482f..2c0d346363 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 @@ -162,7 +162,7 @@ export class EndpointListHelper { } destroyEndpointDetails(refs: EndpointDetailsContainerRefs) { - if (refs.componentRef) { + if (refs.componentRef && refs.componentRef.destroy) { refs.componentRef.destroy(); } if (refs.endpointDetails) { diff --git a/src/frontend/packages/core/src/shared/services/cloud-foundry-user-provided-services.service.ts b/src/frontend/packages/core/src/shared/services/cloud-foundry-user-provided-services.service.ts index d7a5fc6dda..26f239de68 100644 --- a/src/frontend/packages/core/src/shared/services/cloud-foundry-user-provided-services.service.ts +++ b/src/frontend/packages/core/src/shared/services/cloud-foundry-user-provided-services.service.ts @@ -14,16 +14,21 @@ import { import { AppState } from '../../../../store/src/app-state'; import { entityFactory, + organizationSchemaKey, serviceInstancesSchemaKey, serviceSchemaKey, + spaceSchemaKey, userProvidedServiceInstanceSchemaKey, } from '../../../../store/src/helpers/entity-factory'; +import { createEntityRelationPaginationKey } from '../../../../store/src/helpers/entity-relations/entity-relations.types'; import { RequestInfoState } from '../../../../store/src/reducers/api-request-reducer/types'; import { getPaginationObservables } from '../../../../store/src/reducers/pagination-reducer/pagination-reducer.helper'; import { selectRequestInfo } from '../../../../store/src/selectors/api.selectors'; import { APIResource } from '../../../../store/src/types/api.types'; +import { QParam } from '../../../../store/src/types/pagination.types'; import { IUserProvidedServiceInstance } from '../../core/cf-api-svc.types'; import { EntityServiceFactory } from '../../core/entity-service-factory.service'; +import { fetchTotalResults } from '../../features/cloud-foundry/cf.helpers'; import { EntityMonitor } from '../monitors/entity-monitor'; import { PaginationMonitorFactory } from '../monitors/pagination-monitor.factory'; @@ -42,7 +47,7 @@ export class CloudFoundryUserProvidedServicesService { public getUserProvidedServices(cfGuid: string, spaceGuid?: string, relations = getUserProvidedServiceInstanceRelations) : Observable[]> { - const action = new GetAllUserProvidedServices(cfGuid, relations, false, spaceGuid); + const action = new GetAllUserProvidedServices(null, cfGuid, relations, false, spaceGuid); const pagObs = getPaginationObservables({ store: this.store, action, @@ -60,6 +65,21 @@ export class CloudFoundryUserProvidedServicesService { ); } + public fetchUserProvidedServiceInstancesCount(cfGuid: string, orgGuid?: string, spaceGuid?: string) + : Observable { + const parentSchemaKey = spaceGuid ? spaceSchemaKey : orgGuid ? organizationSchemaKey : 'cf'; + const uniqueKey = spaceGuid || orgGuid || cfGuid; + const action = new GetAllUserProvidedServices(createEntityRelationPaginationKey(parentSchemaKey, uniqueKey), cfGuid, [], false); + action.initialParams.q = []; + if (orgGuid) { + action.initialParams.q.push(new QParam('organization_guid', orgGuid, ' IN ')); + } + if (spaceGuid) { + action.initialParams.q.push(new QParam('space_guid', spaceGuid, ' IN ')); + } + return fetchTotalResults(action, this.store, this.paginationMonitorFactory); + } + public getUserProvidedService(cfGuid: string, upsGuid: string): Observable> { const service = this.entityServiceFactory.create>( userProvidedServiceInstanceSchemaKey, diff --git a/src/frontend/packages/core/src/shared/shared.module.ts b/src/frontend/packages/core/src/shared/shared.module.ts index 8f9b62f38c..bcff00b233 100644 --- a/src/frontend/packages/core/src/shared/shared.module.ts +++ b/src/frontend/packages/core/src/shared/shared.module.ts @@ -41,7 +41,6 @@ import { CardAppStatusComponent } from './components/cards/card-app-status/card- import { CardAppUptimeComponent } from './components/cards/card-app-uptime/card-app-uptime.component'; import { CardAppUsageComponent } from './components/cards/card-app-usage/card-app-usage.component'; import { CardCfInfoComponent } from './components/cards/card-cf-info/card-cf-info.component'; -import { CardCfOrgUsageComponent } from './components/cards/card-cf-org-usage/card-cf-org-usage.component'; import { CardCfOrgUserDetailsComponent, } from './components/cards/card-cf-org-user-details/card-cf-org-user-details.component'; @@ -222,7 +221,6 @@ import { UserPermissionDirective } from './user-permission.directive'; MetaCardKeyComponent, MetaCardValueComponent, NestedTabsComponent, - CardCfOrgUsageComponent, CardCfOrgUserDetailsComponent, BooleanIndicatorComponent, CardCfSpaceDetailsComponent, @@ -329,7 +327,6 @@ import { UserPermissionDirective } from './user-permission.directive'; MetaCardKeyComponent, MetaCardValueComponent, NestedTabsComponent, - CardCfOrgUsageComponent, CardCfOrgUserDetailsComponent, CardCfSpaceDetailsComponent, RingChartComponent, diff --git a/src/frontend/packages/core/test-framework/store-test-helper.ts b/src/frontend/packages/core/test-framework/store-test-helper.ts index f1bb91526e..18e6746de9 100644 --- a/src/frontend/packages/core/test-framework/store-test-helper.ts +++ b/src/frontend/packages/core/test-framework/store-test-helper.ts @@ -2,7 +2,7 @@ import { ModuleWithProviders } from '@angular/core'; import { StoreModule } from '@ngrx/store'; import { AppState } from '../../store/src/app-state'; -import { addEntityToCache, EntitySchema } from '../../store/src/helpers/entity-factory'; +import { addEntityToCache, EntitySchema, userProvidedServiceInstanceSchemaKey } from '../../store/src/helpers/entity-factory'; import { appReducers } from '../../store/src/reducers.module'; import { registerAPIRequestEntity } from '../../store/src/reducers/api-request-reducers.generator'; import { getDefaultEndpointRoles, getDefaultRolesRequestState } from '../../store/src/types/current-user-roles.types'; @@ -611,7 +611,8 @@ function getDefaultInitialTestStoreState(): AppState { gitCommits: {}, domain: {}, metrics: {}, - servicePlan: {} + servicePlan: {}, + [userProvidedServiceInstanceSchemaKey]: {} }, dashboard: { sidenavOpen: true, @@ -3906,6 +3907,7 @@ function getDefaultInitialTestStoreState(): AppState { system: {}, private_domains: {}, space_quota_definition: {}, + [userProvidedServiceInstanceSchemaKey]: {} }, requestData: { userFavorites: {}, @@ -21794,7 +21796,8 @@ function getDefaultInitialTestStoreState(): AppState { } ], passwordLastModified: '' - } + }, + [userProvidedServiceInstanceSchemaKey]: {} }, actionHistory: [], lists: {}, diff --git a/src/frontend/packages/store/src/actions/service-instances.actions.ts b/src/frontend/packages/store/src/actions/service-instances.actions.ts index 001a450c6e..75d5fa16ec 100644 --- a/src/frontend/packages/store/src/actions/service-instances.actions.ts +++ b/src/frontend/packages/store/src/actions/service-instances.actions.ts @@ -51,6 +51,7 @@ export class GetServiceInstances 'results-per-page': 100, 'order-direction': 'asc', 'order-direction-field': 'creation', + q: [] }; flattenPagination = true; } diff --git a/src/frontend/packages/store/src/actions/user-provided-service.actions.ts b/src/frontend/packages/store/src/actions/user-provided-service.actions.ts index 9d3518ecb1..ed204596b9 100644 --- a/src/frontend/packages/store/src/actions/user-provided-service.actions.ts +++ b/src/frontend/packages/store/src/actions/user-provided-service.actions.ts @@ -30,14 +30,15 @@ export const getUserProvidedServiceInstanceRelations = [ export class GetAllUserProvidedServices extends CFStartAction implements PaginatedAction, EntityInlineParentAction { constructor( + paginationKey: string = null, public endpointGuid: string = null, public includeRelations: string[] = getUserProvidedServiceInstanceRelations, public populateMissing = true, public spaceGuid?: string ) { super(); - this.paginationKey = spaceGuid ? createEntityRelationPaginationKey(spaceSchemaKey, spaceGuid) : - createEntityRelationPaginationKey(endpointSchemaKey, endpointGuid); + this.paginationKey = paginationKey || (spaceGuid ? createEntityRelationPaginationKey(spaceSchemaKey, spaceGuid) : + createEntityRelationPaginationKey(endpointSchemaKey, endpointGuid)); this.options = new RequestOptions(); this.options.url = `user_provided_service_instances`; this.options.method = 'get';