-
Notifications
You must be signed in to change notification settings - Fork 138
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
org/space quota: reusing styling and minor changes
Signed-off-by: Vítor Avelino <[email protected]>
- Loading branch information
Vítor Avelino
committed
Jun 18, 2019
1 parent
02d5da3
commit 783954b
Showing
14 changed files
with
247 additions
and
257 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
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; | ||
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; | ||
} | ||
} |
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
25 changes: 0 additions & 25 deletions
25
...packages/core/src/features/cloud-foundry/quota-definition/quota-definition.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 |
---|---|---|
@@ -1,25 +0,0 @@ | ||
.quota-definition-page { | ||
&__name-sub-text { | ||
font-size: 14px; | ||
margin-bottom: -3px; | ||
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; | ||
} | ||
} | ||
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
Oops, something went wrong.