-
Notifications
You must be signed in to change notification settings - Fork 135
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3630 from cloudfoundry-incubator/quota-details
org/space quota: details page
- Loading branch information
Showing
45 changed files
with
1,110 additions
and
79 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
...ore/src/features/cloud-foundry/quota-definition-base/quota-definition-base.component.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
.quota-definition-base { | ||
&__name-sub-text { | ||
font-size: 14px; | ||
opacity: .6; | ||
} | ||
&__title { | ||
margin: 10px 0; | ||
} | ||
&__name { | ||
margin: 0; | ||
} | ||
&__section-header { | ||
margin: 10px 0; | ||
opacity: .6; | ||
} | ||
&__basic-services { | ||
display: flex; | ||
margin: 8px 0; | ||
} | ||
&__basic-services-label { | ||
margin-right: 10px; | ||
opacity: .6; | ||
} | ||
} |
95 changes: 95 additions & 0 deletions
95
.../core/src/features/cloud-foundry/quota-definition-base/quota-definition-base.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
import { ActivatedRoute } from '@angular/router'; | ||
import { Store } from '@ngrx/store'; | ||
import { combineLatest, Observable, of, Subscription } from 'rxjs'; | ||
import { first, map } from 'rxjs/operators'; | ||
|
||
import { GetOrganization } from '../../../../../store/src/actions/organization.actions'; | ||
import { GetSpace } from '../../../../../store/src/actions/space.actions'; | ||
import { AppState } from '../../../../../store/src/app-state'; | ||
import { entityFactory, organizationSchemaKey, spaceSchemaKey } from '../../../../../store/src/helpers/entity-factory'; | ||
import { endpointEntitiesSelector } from '../../../../../store/src/selectors/endpoint.selectors'; | ||
import { APIResource } from '../../../../../store/src/types/api.types'; | ||
import { EndpointModel } from '../../../../../store/src/types/endpoint.types'; | ||
import { IOrganization, IQuotaDefinition, ISpace } from '../../../core/cf-api.types'; | ||
import { EntityServiceFactory } from '../../../core/entity-service-factory.service'; | ||
import { IHeaderBreadcrumb } from '../../../shared/components/page-header/page-header.types'; | ||
import { ActiveRouteCfOrgSpace } from '../cf-page.types'; | ||
|
||
export class QuotaDefinitionBaseComponent { | ||
breadcrumbs$: Observable<IHeaderBreadcrumb[]>; | ||
quotaDefinition$: Observable<APIResource<IQuotaDefinition>>; | ||
org$: Observable<APIResource<IOrganization>>; | ||
space$: Observable<APIResource<ISpace>>; | ||
cfGuid: string; | ||
orgGuid: string; | ||
spaceGuid: string; | ||
quotaGuid: string; | ||
detailsLoading$: Observable<boolean>; | ||
orgSubscriber: Subscription; | ||
|
||
constructor( | ||
protected entityServiceFactory: EntityServiceFactory, | ||
protected store: Store<AppState>, | ||
protected activeRouteCfOrgSpace: ActiveRouteCfOrgSpace, | ||
protected activatedRoute: ActivatedRoute, | ||
) { | ||
this.cfGuid = activeRouteCfOrgSpace.cfGuid || activatedRoute.snapshot.queryParams.cfGuid; | ||
this.orgGuid = activeRouteCfOrgSpace.orgGuid || activatedRoute.snapshot.queryParams.orgGuid; | ||
this.spaceGuid = activeRouteCfOrgSpace.spaceGuid || activatedRoute.snapshot.queryParams.spaceGuid; | ||
this.quotaGuid = activatedRoute.snapshot.params.quotaId || activatedRoute.snapshot.queryParams.quotaGuid; | ||
this.setupOrgObservable(); | ||
this.setupSpaceObservable(); | ||
this.setupBreadcrumbs(); | ||
} | ||
|
||
setupOrgObservable() { | ||
if (this.orgGuid) { | ||
this.org$ = this.entityServiceFactory.create<APIResource<IOrganization>>( | ||
organizationSchemaKey, | ||
entityFactory(organizationSchemaKey), | ||
this.orgGuid, | ||
new GetOrganization(this.orgGuid, this.cfGuid), | ||
true | ||
).waitForEntity$.pipe( | ||
map(data => data.entity), | ||
); | ||
} | ||
} | ||
|
||
setupSpaceObservable() { | ||
if (this.spaceGuid) { | ||
this.space$ = this.entityServiceFactory.create<APIResource<ISpace>>( | ||
spaceSchemaKey, | ||
entityFactory(spaceSchemaKey), | ||
this.spaceGuid, | ||
new GetSpace(this.spaceGuid, this.cfGuid), | ||
true | ||
).waitForEntity$.pipe( | ||
map(data => data.entity), | ||
); | ||
} | ||
} | ||
|
||
private setupBreadcrumbs() { | ||
const endpoints$ = this.store.select(endpointEntitiesSelector); | ||
const org$ = this.org$ ? this.org$ : of(null); | ||
const space$ = this.space$ ? this.space$ : of(null); | ||
this.breadcrumbs$ = combineLatest(endpoints$, org$, space$).pipe( | ||
map(([endpoints, org, space]) => this.getBreadcrumbs(endpoints[this.cfGuid], org, space)), | ||
first() | ||
); | ||
} | ||
|
||
protected setupQuotaDefinitionObservable() { | ||
throw new Error('Method not implemented.'); | ||
} | ||
|
||
protected getBreadcrumbs( | ||
endpoint: EndpointModel, | ||
org: APIResource<IOrganization>, | ||
space: APIResource<ISpace> | ||
) { | ||
throw new Error('Method not implemented.'); | ||
return null; | ||
} | ||
} |
82 changes: 82 additions & 0 deletions
82
...packages/core/src/features/cloud-foundry/quota-definition/quota-definition.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
<app-page-header [breadcrumbs]="breadcrumbs$ | async" *ngIf="quotaGuid"> | ||
<h1>{{ (quotaDefinition$ | async)?.entity?.name }}</h1> | ||
</app-page-header> | ||
|
||
<div class="quota-definition-base quota-definition-page" *ngIf="quotaDefinition$ | async as quotaDefinition"> | ||
|
||
<app-loading-page [isLoading]="detailsLoading$" text="Retrieving details"> | ||
<div class="quota-definition-base__name-sub-text">Name</div> | ||
<h2 class="quota-definition-base__name">{{ quotaDefinition.entity.name }}</h2> | ||
<div class="quota-definition-base__basic-services"> | ||
<div class="quota-definition-base__basic-services-label">Non Basic Services Allowed:</div> | ||
<app-boolean-indicator [isTrue]="quotaDefinition.entity?.non_basic_services_allowed" type="yes-no" subtle="true"> | ||
</app-boolean-indicator> | ||
</div> | ||
<app-tile-grid fit="true"> | ||
<h3 class="quota-definition-base__title">Quota Limits</h3> | ||
<h4 class="quota-definition-base__section-header">Memory</h4> | ||
<app-tile-group> | ||
<app-tile> | ||
<app-card-number-metric labelAtTop="true" icon="memory" label="Maximum Memory Usage" units="mb" | ||
value="{{ quotaDefinition.entity?.memory_limit }}"> | ||
</app-card-number-metric> | ||
</app-tile> | ||
<app-tile> | ||
<app-card-number-metric labelAtTop="true" icon="memory" label="Maximum Application Instance Memory Usage" | ||
value="{{ quotaDefinition.entity?.instance_memory_limit }}"> | ||
</app-card-number-metric> | ||
</app-tile> | ||
<app-tile></app-tile> | ||
</app-tile-group> | ||
|
||
<h4 class="quota-definition-base__section-header">Application</h4> | ||
<app-tile-group> | ||
<app-tile> | ||
<app-card-number-metric labelAtTop="true" icon="apps" label="Maximum Application Instances" | ||
value="{{ quotaDefinition.entity?.app_instance_limit }}"> | ||
</app-card-number-metric> | ||
</app-tile> | ||
<app-tile> | ||
<app-card-number-metric labelAtTop="true" icon="apps" label="Maximum Application Tasks" | ||
value="{{ quotaDefinition.entity?.app_task_limit }}"> | ||
</app-card-number-metric> | ||
</app-tile> | ||
<app-tile></app-tile> | ||
</app-tile-group> | ||
|
||
<h4 class="quota-definition-base__section-header">Service</h4> | ||
<app-tile-group> | ||
<app-tile> | ||
<app-card-number-metric labelAtTop="true" icon="service" iconFont="stratos-icons" label="Maximum Services" | ||
value="{{ quotaDefinition.entity?.total_services }}"> | ||
</app-card-number-metric> | ||
</app-tile> | ||
<app-tile> | ||
<app-card-number-metric labelAtTop="true" icon="service" iconFont="stratos-icons" label="Maximum Service Keys" | ||
value="{{ quotaDefinition.entity?.total_service_keys }}"> | ||
</app-card-number-metric> | ||
</app-tile> | ||
<app-tile></app-tile> | ||
</app-tile-group> | ||
|
||
<h4 class="quota-definition-base__section-header">Routes & Domains</h4> | ||
<app-tile-group> | ||
<app-tile> | ||
<app-card-number-metric labelAtTop="true" icon="network_route" iconFont="stratos-icons" label="Maximum Routes" | ||
value="{{ quotaDefinition.entity?.total_routes }}"> | ||
</app-card-number-metric> | ||
</app-tile> | ||
<app-tile> | ||
<app-card-number-metric labelAtTop="true" icon="network_route" iconFont="stratos-icons" | ||
label="Maximum Reserved Route Ports" value="{{ quotaDefinition.entity?.total_reserved_route_ports }}"> | ||
</app-card-number-metric> | ||
</app-tile> | ||
<app-tile> | ||
<app-card-number-metric labelAtTop="true" icon="domain" label="Maximum Private Domains" | ||
value="{{ quotaDefinition.entity?.total_private_domains }}"> | ||
</app-card-number-metric> | ||
</app-tile> | ||
</app-tile-group> | ||
</app-tile-grid> | ||
</app-loading-page> | ||
</div> |
Empty file.
46 changes: 46 additions & 0 deletions
46
...kages/core/src/features/cloud-foundry/quota-definition/quota-definition.component.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import { async, ComponentFixture, TestBed } from '@angular/core/testing'; | ||
import { ActivatedRoute } from '@angular/router'; | ||
|
||
import { TabNavService } from '../../../../tab-nav.service'; | ||
import { | ||
BaseTestModules, | ||
generateTestCfEndpointServiceProvider, | ||
} from '../../../../test-framework/cloud-foundry-endpoint-service.helper'; | ||
import { testSCFGuid } from '../../../../test-framework/store-test-helper'; | ||
import { QuotaDefinitionComponent } from './quota-definition.component'; | ||
|
||
describe('QuotaDefinitionComponent', () => { | ||
let component: QuotaDefinitionComponent; | ||
let fixture: ComponentFixture<QuotaDefinitionComponent>; | ||
|
||
beforeEach(async(() => { | ||
TestBed.configureTestingModule({ | ||
declarations: [QuotaDefinitionComponent], | ||
imports: [...BaseTestModules], | ||
providers: [ | ||
{ | ||
provide: ActivatedRoute, | ||
useValue: { | ||
snapshot: { | ||
queryParams: { cfGuid: testSCFGuid }, | ||
params: { quotaId: 'guid' } | ||
} | ||
} | ||
}, | ||
generateTestCfEndpointServiceProvider(), | ||
TabNavService | ||
] | ||
}) | ||
.compileComponents(); | ||
})); | ||
|
||
beforeEach(() => { | ||
fixture = TestBed.createComponent(QuotaDefinitionComponent); | ||
component = fixture.componentInstance; | ||
fixture.detectChanges(); | ||
}); | ||
|
||
it('should create', () => { | ||
expect(component).toBeTruthy(); | ||
}); | ||
}); |
Oops, something went wrong.