-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(platform): provide services to manage and query capabilities and…
… intentions
- Loading branch information
Showing
26 changed files
with
3,743 additions
and
0 deletions.
There are no files selected for viewing
36 changes: 36 additions & 0 deletions
36
...-platform-testing-app/src/app/manifest/lookup-capability/lookup-capability.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,36 @@ | ||
<form autocomplete="off" [formGroup]="form"> | ||
<sci-form-field label="ID"> | ||
<input [formControlName]="ID" class="e2e-id"> | ||
</sci-form-field> | ||
<sci-form-field label="Type"> | ||
<input [formControlName]="TYPE" class="e2e-type"> | ||
</sci-form-field> | ||
<sci-form-field label="Qualifier"> | ||
<sci-params-enter [paramsFormArray]="form.get(QUALIFIER)" [addable]="true" [removable]="true" class="e2e-qualifier"></sci-params-enter> | ||
</sci-form-field> | ||
<sci-form-field label="NilQualifier if empty"> | ||
<sci-checkbox [formControlName]="NILQUALIFIER_IF_EMPTY" class="e2e-nilqualifier-if-empty"></sci-checkbox> | ||
</sci-form-field> | ||
<sci-form-field label="Application"> | ||
<input [formControlName]="APP_SYMBOLIC_NAME" class="e2e-app-symbolic-name"> | ||
</sci-form-field> | ||
|
||
<section class="buttons"> | ||
<button type="submit" *ngIf="!capabilities$" (click)="onLookup()" [disabled]="form.invalid" class="e2e-lookup">Lookup</button> | ||
<button type="submit" *ngIf="capabilities$" (click)="onLookupCancel()" class="e2e-cancel-lookup">Cancel the lookup</button> | ||
<button type="button" (click)="onReset()" [disabled]="form.pristine" class="e2e-reset">Reset</button> | ||
</section> | ||
</form> | ||
|
||
<sci-list class="capabilities e2e-capabilities"> | ||
<ng-container *ngFor="let capability of capabilities$ | async"> | ||
<ng-template sciListItem> | ||
<section class="capability"> | ||
<sci-qualifier-chip-list [qualifier]="capability.qualifier" [type]="capability.type"></sci-qualifier-chip-list> | ||
<span class="app">{{capability.metadata.appSymbolicName}}</span> | ||
<span class="id e2e-id">{{capability.metadata.id}}</span> | ||
<span class="visibility">{{capability.private ? 'PRIVATE' : 'PUBLIC'}}</span> | ||
</section> | ||
</ng-template> | ||
</ng-container> | ||
</sci-list> |
45 changes: 45 additions & 0 deletions
45
...-platform-testing-app/src/app/manifest/lookup-capability/lookup-capability.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,45 @@ | ||
@use 'sci-toolkit-styles' as sci-toolkit-styles; | ||
|
||
:host { | ||
display: grid; | ||
grid-template-rows: min-content 1fr; | ||
gap: 1em; | ||
|
||
> form { | ||
display: grid; | ||
grid-auto-rows: min-content; | ||
row-gap: .25em; | ||
|
||
> section.buttons { | ||
display: grid; | ||
grid-template-columns: 1fr 75px; | ||
grid-auto-rows: min-content; | ||
column-gap: .25em; | ||
} | ||
} | ||
|
||
> sci-list.capabilities { | ||
min-height: 300px; | ||
|
||
section.capability { | ||
display: flex; | ||
justify-content: space-between; | ||
|
||
> sci-qualifier-chip-list { | ||
flex: auto; | ||
} | ||
|
||
> span.id, > span.visibility, > span.app { | ||
flex: none; | ||
align-self: flex-start; | ||
font-weight: bold; | ||
@include sci-toolkit-styles.chip(var(--sci-color-accent), null, var(--sci-color-accent)); | ||
user-select: text; | ||
} | ||
|
||
> span.visibility { | ||
user-select: none; | ||
} | ||
} | ||
} | ||
} |
71 changes: 71 additions & 0 deletions
71
...nd-platform-testing-app/src/app/manifest/lookup-capability/lookup-capability.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,71 @@ | ||
/* | ||
* Copyright (c) 2018-2020 Swiss Federal Railways | ||
* | ||
* This program and the accompanying materials are made | ||
* available under the terms of the Eclipse Public License 2.0 | ||
* which is available at https://www.eclipse.org/legal/epl-2.0/ | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
*/ | ||
import { Component } from '@angular/core'; | ||
import { FormArray, FormBuilder, FormControl, FormGroup } from '@angular/forms'; | ||
import { Beans, Capability, ManifestObjectFilter, ManifestService } from '@scion/microfrontend-platform'; | ||
import { SciParamsEnterComponent } from '@scion/toolkit.internal/widgets'; | ||
import { Observable } from 'rxjs'; | ||
import { finalize } from 'rxjs/operators'; | ||
|
||
const ID = 'id'; | ||
const TYPE = 'type'; | ||
const QUALIFIER = 'qualifier'; | ||
const NILQUALIFIER_IF_EMPTY = 'nilQualifierIfEmpty'; | ||
const APP_SYMBOLIC_NAME = 'appSymbolicName'; | ||
|
||
@Component({ | ||
selector: 'app-lookup-capability', | ||
templateUrl: './lookup-capability.component.html', | ||
styleUrls: ['./lookup-capability.component.scss'], | ||
}) | ||
export class LookupCapabilityComponent { | ||
|
||
public readonly ID = ID; | ||
public readonly TYPE = TYPE; | ||
public readonly QUALIFIER = QUALIFIER; | ||
public readonly NILQUALIFIER_IF_EMPTY = NILQUALIFIER_IF_EMPTY; | ||
public readonly APP_SYMBOLIC_NAME = APP_SYMBOLIC_NAME; | ||
|
||
public form: FormGroup; | ||
public capabilities$: Observable<Capability[]>; | ||
|
||
constructor(fb: FormBuilder) { | ||
this.form = fb.group({ | ||
[ID]: new FormControl(''), | ||
[TYPE]: new FormControl(''), | ||
[QUALIFIER]: fb.array([]), | ||
[NILQUALIFIER_IF_EMPTY]: new FormControl(false), | ||
[APP_SYMBOLIC_NAME]: new FormControl(''), | ||
}); | ||
} | ||
|
||
public onLookup(): void { | ||
const nilQualifierIfEmpty = this.form.get(NILQUALIFIER_IF_EMPTY).value; | ||
const qualifier = SciParamsEnterComponent.toParamsDictionary(this.form.get(QUALIFIER) as FormArray, false); | ||
|
||
const filter: ManifestObjectFilter = { | ||
id: this.form.get(ID).value || undefined, | ||
type: this.form.get(TYPE).value || undefined, | ||
qualifier: Object.keys(qualifier).length ? qualifier : (nilQualifierIfEmpty ? {} : undefined), | ||
appSymbolicName: this.form.get(APP_SYMBOLIC_NAME).value || undefined, | ||
}; | ||
this.capabilities$ = Beans.get(ManifestService).lookupCapabilities$(filter) | ||
.pipe(finalize(() => this.capabilities$ = null)); | ||
} | ||
|
||
public onLookupCancel(): void { | ||
this.capabilities$ = null; | ||
} | ||
|
||
public onReset(): void { | ||
this.form.reset(); | ||
this.form.setControl(QUALIFIER, new FormArray([])); | ||
} | ||
} |
35 changes: 35 additions & 0 deletions
35
...nd-platform-testing-app/src/app/manifest/lookup-intention/lookup-intention.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,35 @@ | ||
<form autocomplete="off" [formGroup]="form"> | ||
<sci-form-field label="ID"> | ||
<input [formControlName]="ID" class="e2e-id"> | ||
</sci-form-field> | ||
<sci-form-field label="Type"> | ||
<input [formControlName]="TYPE" class="e2e-type"> | ||
</sci-form-field> | ||
<sci-form-field label="Qualifier"> | ||
<sci-params-enter [paramsFormArray]="form.get(QUALIFIER)" [addable]="true" [removable]="true" class="e2e-qualifier"></sci-params-enter> | ||
</sci-form-field> | ||
<sci-form-field label="NilQualifier if empty"> | ||
<sci-checkbox [formControlName]="NILQUALIFIER_IF_EMPTY" class="e2e-nilqualifier-if-empty"></sci-checkbox> | ||
</sci-form-field> | ||
<sci-form-field label="Application"> | ||
<input [formControlName]="APP_SYMBOLIC_NAME" class="e2e-app-symbolic-name"> | ||
</sci-form-field> | ||
|
||
<section class="buttons"> | ||
<button type="submit" *ngIf="!intentions$" (click)="onLookup()" [disabled]="form.invalid" class="e2e-lookup">Lookup</button> | ||
<button type="submit" *ngIf="intentions$" (click)="onLookupCancel()" class="e2e-cancel-lookup">Cancel the lookup</button> | ||
<button type="button" (click)="onReset()" [disabled]="form.pristine" class="e2e-reset">Reset</button> | ||
</section> | ||
</form> | ||
|
||
<sci-list class="intentions e2e-intentions"> | ||
<ng-container *ngFor="let intention of intentions$ | async"> | ||
<ng-template sciListItem> | ||
<section class="intention"> | ||
<sci-qualifier-chip-list [qualifier]="intention.qualifier" [type]="intention.type"></sci-qualifier-chip-list> | ||
<span class="app">{{intention.metadata.appSymbolicName}}</span> | ||
<span class="id e2e-id">{{intention.metadata.id}}</span> | ||
</section> | ||
</ng-template> | ||
</ng-container> | ||
</sci-list> |
45 changes: 45 additions & 0 deletions
45
...nd-platform-testing-app/src/app/manifest/lookup-intention/lookup-intention.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,45 @@ | ||
@use 'sci-toolkit-styles' as sci-toolkit-styles; | ||
|
||
:host { | ||
display: grid; | ||
grid-template-rows: min-content 1fr; | ||
gap: 1em; | ||
|
||
> form { | ||
display: grid; | ||
grid-auto-rows: min-content; | ||
row-gap: .25em; | ||
|
||
> section.buttons { | ||
display: grid; | ||
grid-template-columns: 1fr 75px; | ||
grid-auto-rows: min-content; | ||
column-gap: .25em; | ||
} | ||
} | ||
|
||
> sci-list.intentions { | ||
min-height: 300px; | ||
|
||
section.intention { | ||
display: flex; | ||
justify-content: space-between; | ||
|
||
> sci-qualifier-chip-list { | ||
flex: auto; | ||
} | ||
|
||
> span.id, > span.visibility, > span.app { | ||
flex: none; | ||
align-self: flex-start; | ||
font-weight: bold; | ||
@include sci-toolkit-styles.chip(var(--sci-color-accent), null, var(--sci-color-accent)); | ||
user-select: text; | ||
} | ||
|
||
> span.visibility { | ||
user-select: none; | ||
} | ||
} | ||
} | ||
} |
71 changes: 71 additions & 0 deletions
71
...tend-platform-testing-app/src/app/manifest/lookup-intention/lookup-intention.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,71 @@ | ||
/* | ||
* Copyright (c) 2018-2020 Swiss Federal Railways | ||
* | ||
* This program and the accompanying materials are made | ||
* available under the terms of the Eclipse Public License 2.0 | ||
* which is available at https://www.eclipse.org/legal/epl-2.0/ | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
*/ | ||
import { Component } from '@angular/core'; | ||
import { FormArray, FormBuilder, FormControl, FormGroup } from '@angular/forms'; | ||
import { Beans, Intention, ManifestObjectFilter, ManifestService } from '@scion/microfrontend-platform'; | ||
import { SciParamsEnterComponent } from '@scion/toolkit.internal/widgets'; | ||
import { Observable } from 'rxjs'; | ||
import { finalize } from 'rxjs/operators'; | ||
|
||
const ID = 'id'; | ||
const TYPE = 'type'; | ||
const QUALIFIER = 'qualifier'; | ||
const NILQUALIFIER_IF_EMPTY = 'nilQualifierIfEmpty'; | ||
const APP_SYMBOLIC_NAME = 'appSymbolicName'; | ||
|
||
@Component({ | ||
selector: 'app-lookup-intention', | ||
templateUrl: './lookup-intention.component.html', | ||
styleUrls: ['./lookup-intention.component.scss'], | ||
}) | ||
export class LookupIntentionComponent { | ||
|
||
public readonly ID = ID; | ||
public readonly TYPE = TYPE; | ||
public readonly QUALIFIER = QUALIFIER; | ||
public readonly NILQUALIFIER_IF_EMPTY = NILQUALIFIER_IF_EMPTY; | ||
public readonly APP_SYMBOLIC_NAME = APP_SYMBOLIC_NAME; | ||
|
||
public form: FormGroup; | ||
public intentions$: Observable<Intention[]>; | ||
|
||
constructor(fb: FormBuilder) { | ||
this.form = fb.group({ | ||
[ID]: new FormControl(''), | ||
[TYPE]: new FormControl(''), | ||
[QUALIFIER]: fb.array([]), | ||
[NILQUALIFIER_IF_EMPTY]: new FormControl(false), | ||
[APP_SYMBOLIC_NAME]: new FormControl(''), | ||
}); | ||
} | ||
|
||
public onLookup(): void { | ||
const nilQualifierIfEmpty = this.form.get(NILQUALIFIER_IF_EMPTY).value; | ||
const qualifier = SciParamsEnterComponent.toParamsDictionary(this.form.get(QUALIFIER) as FormArray, false); | ||
|
||
const filter: ManifestObjectFilter = { | ||
id: this.form.get(ID).value || undefined, | ||
type: this.form.get(TYPE).value || undefined, | ||
qualifier: Object.keys(qualifier).length ? qualifier : (nilQualifierIfEmpty ? {} : undefined), | ||
appSymbolicName: this.form.get(APP_SYMBOLIC_NAME).value || undefined, | ||
}; | ||
this.intentions$ = Beans.get(ManifestService).lookupIntentions$(filter) | ||
.pipe(finalize(() => this.intentions$ = null)); | ||
} | ||
|
||
public onLookupCancel(): void { | ||
this.intentions$ = null; | ||
} | ||
|
||
public onReset(): void { | ||
this.form.reset(); | ||
this.form.setControl(QUALIFIER, new FormArray([])); | ||
} | ||
} |
64 changes: 64 additions & 0 deletions
64
...tform-testing-app/src/app/manifest/register-capability/register-capability.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,64 @@ | ||
<section class="register e2e-register"> | ||
<header>Register a capability</header> | ||
<form autocomplete="off" [formGroup]="registerForm"> | ||
<sci-form-field label="Type *" direction="column"> | ||
<input [formControlName]="TYPE" class="e2e-type"> | ||
</sci-form-field> | ||
<sci-form-field label="Qualifier" direction="column"> | ||
<sci-params-enter [paramsFormArray]="registerForm.get(QUALIFIER)" [addable]="true" [removable]="true" class="e2e-qualifier"></sci-params-enter> | ||
</sci-form-field> | ||
<sci-form-field label="Private" direction="column"> | ||
<sci-checkbox [formControlName]="PRIVATE" class="e2e-private"></sci-checkbox> | ||
</sci-form-field> | ||
<button type="submit" (click)="onRegister()" [disabled]="registerForm.invalid" class="e2e-register">Register</button> | ||
</form> | ||
|
||
<output class="error e2e-register-error" *ngIf="registerError"> | ||
{{registerError}} | ||
</output> | ||
<output class="response e2e-register-response" *ngIf="registerResponse"> | ||
Capability ID: <span class="e2e-capability-id">{{registerResponse}}</span> | ||
</output> | ||
</section> | ||
|
||
<section class="unregister e2e-unregister"> | ||
<header>Unregister capability(-ies)</header> | ||
<form autocomplete="off" [formGroup]="unregisterForm"> | ||
<sci-form-field label="ID" direction="column"> | ||
<input [formControlName]="ID" class="e2e-id"> | ||
</sci-form-field> | ||
<sci-form-field label="Type" direction="column"> | ||
<input [formControlName]="TYPE" class="e2e-type"> | ||
</sci-form-field> | ||
<sci-form-field label="Qualifier" direction="column"> | ||
<sci-params-enter [paramsFormArray]="unregisterForm.get(QUALIFIER)" [addable]="true" [removable]="true" class="e2e-qualifier"></sci-params-enter> | ||
</sci-form-field> | ||
<sci-form-field label="NilQualifier if empty" direction="column"> | ||
<sci-checkbox [formControlName]="NILQUALIFIER_IF_EMPTY" class="e2e-nilqualifier-if-empty"></sci-checkbox> | ||
</sci-form-field> | ||
<sci-form-field label="Application" direction="column"> | ||
<input [formControlName]="APP_SYMBOLIC_NAME" class="e2e-app-symbolic-name"> | ||
</sci-form-field> | ||
<button type="submit" (click)="onUnregister()" [disabled]="unregisterForm.invalid" class="e2e-unregister">Unregister</button> | ||
</form> | ||
|
||
<output class="error e2e-unregister-error" *ngIf="unregisterError"> | ||
{{unregisterError}} | ||
</output> | ||
<output class="response e2e-unregister-response" *ngIf="unregisterResponse"> | ||
{{unregisterResponse}} | ||
</output> | ||
</section> | ||
|
||
<sci-list class="capabilities"> | ||
<ng-container *ngFor="let capability of capabilities$ | async"> | ||
<ng-template sciListItem> | ||
<section class="capability"> | ||
<sci-qualifier-chip-list [qualifier]="capability.qualifier" [type]="capability.type"></sci-qualifier-chip-list> | ||
<span class="app">{{capability.metadata.appSymbolicName}}</span> | ||
<span class="id">{{capability.metadata.id}}</span> | ||
<span class="visibility">{{capability.private ? 'PRIVATE' : 'PUBLIC'}}</span> | ||
</section> | ||
</ng-template> | ||
</ng-container> | ||
</sci-list> |
Oops, something went wrong.