-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: allow querying capabilities matching a given qualifier pattern
closes: #188
- Loading branch information
1 parent
818187e
commit 16d1fa7
Showing
11 changed files
with
264 additions
and
92 deletions.
There are no files selected for viewing
5 changes: 0 additions & 5 deletions
5
...platform/dev-tools-app/src/app/dev-tools/application-list/application-list.component.html
This file was deleted.
Oops, something went wrong.
10 changes: 0 additions & 10 deletions
10
...platform/dev-tools-app/src/app/dev-tools/application-list/application-list.component.scss
This file was deleted.
Oops, something went wrong.
58 changes: 0 additions & 58 deletions
58
...n-platform/dev-tools-app/src/app/dev-tools/application-list/application-list.component.ts
This file was deleted.
Oops, something went wrong.
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
54 changes: 54 additions & 0 deletions
54
...h-application-platform/dev-tools-app/src/app/dev-tools/dev-tools/dev-tools.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,54 @@ | ||
<section [class.expanded]="appListPanelExpanded"> | ||
<header (click)="toggleAppListPanel()"> | ||
<h2>Application List</h2> | ||
<span class="toggle material-icons"></span> | ||
</header> | ||
|
||
<sci-viewport class="app-list"> | ||
<sci-list (filter)="onFilter($event)"> | ||
<ng-template *ngFor="let manifest of manifests$ | async; trackBy: trackByFn" sciListItem [key]="manifest.symbolicName"> | ||
<app-application-list-item [manifest]="manifest"></app-application-list-item> | ||
</ng-template> | ||
</sci-list> | ||
</sci-viewport> | ||
</section> | ||
|
||
<section [class.expanded]="capabilityLookupPanelExpanded"> | ||
<header (click)="toggleCapabilityLookupPanel()"> | ||
<h2>Lookup Capabilities</h2> | ||
<span class="toggle material-icons"></span> | ||
</header> | ||
|
||
<sci-viewport class="lookup-capabilities"> | ||
<input [formControl]="form.get(CAPABILITY_LOOKUP_TYPE)" placeholder="Enter capability type" list="capability-types"> | ||
<sci-params-enter class="qualifier" [title]="'Qualifier'" [paramsFormArray]="form.get(CAPABILITY_LOOKUP_QUALIFIER)" [addable]="true" [removable]="true"></sci-params-enter> | ||
<button class="search" (click)="onLookupClick()" [disabled]="!form.valid">Lookup</button> | ||
|
||
<output *ngIf="capabilityLookupResult$ | async as capabilities"> | ||
<h3>Capabilities matching the type and qualifier:</h3> | ||
<sci-accordion *ngIf="capabilities.length else notFound"> | ||
<ng-container *ngFor="let capability of capabilities"> | ||
<ng-template sciAccordionItem [panel]="panel"> | ||
<app-capability-accordion-item [capability]="capability"></app-capability-accordion-item> | ||
</ng-template> | ||
|
||
<ng-template #panel> | ||
<app-capability-accordion-panel [capability]="capability"></app-capability-accordion-panel> | ||
</ng-template> | ||
</ng-container> | ||
</sci-accordion> | ||
<ng-template #notFound> | ||
No capabilities found. | ||
</ng-template> | ||
</output> | ||
</sci-viewport> | ||
</section> | ||
|
||
<datalist id="capability-types"> | ||
<option [value]="PlatformCapabilityTypes.View"> | ||
<option [value]="PlatformCapabilityTypes.Popup"> | ||
<option [value]="PlatformCapabilityTypes.Activity"> | ||
<option [value]="PlatformCapabilityTypes.MessageBox"> | ||
<option [value]="PlatformCapabilityTypes.Notification"> | ||
<option [value]="PlatformCapabilityTypes.ManifestRegistry"> | ||
</datalist> |
79 changes: 79 additions & 0 deletions
79
...h-application-platform/dev-tools-app/src/app/dev-tools/dev-tools/dev-tools.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,79 @@ | ||
@import 'common'; | ||
|
||
:host { | ||
display: flex; | ||
flex-direction: column; | ||
padding: app-padding(); | ||
|
||
> section { | ||
flex: 1 1 0; | ||
display: flex; | ||
flex-direction: column; | ||
overflow: hidden; | ||
|
||
&:not(:first-of-type) { | ||
margin-top: 1.75em; | ||
} | ||
|
||
&:not(.expanded) { | ||
flex: none; | ||
} | ||
|
||
> header { | ||
flex: none; | ||
display: flex; | ||
justify-content: space-between; | ||
align-items: center; | ||
cursor: pointer; | ||
|
||
> h2 { | ||
flex: auto; | ||
font-size: 1.25em; | ||
margin-top: 0; | ||
} | ||
|
||
> span.toggle { | ||
flex: none; | ||
margin-left: .5em; | ||
user-select: none; | ||
|
||
&::after { | ||
content: 'expand_more' | ||
} | ||
} | ||
} | ||
|
||
&.expanded > header > span.toggle::after { | ||
content: 'expand_less'; | ||
} | ||
|
||
&:not(.expanded) > sci-viewport { | ||
height: 0; | ||
} | ||
|
||
> sci-viewport.app-list, sci-viewport.lookup-capabilities { | ||
flex: auto; | ||
|
||
&.lookup-capabilities { | ||
--grid-template-rows: min-content min-content min-content 1fr; | ||
--gap: .5em 0; | ||
|
||
output { | ||
flex: auto; | ||
margin-top: 1em; | ||
display: flex; | ||
flex-direction: column; | ||
|
||
> h3 { | ||
flex: none; | ||
} | ||
|
||
> sci-accordion { | ||
flex: auto; | ||
min-height: 10em; | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} |
96 changes: 96 additions & 0 deletions
96
...nch-application-platform/dev-tools-app/src/app/dev-tools/dev-tools/dev-tools.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,96 @@ | ||
/* | ||
* Copyright (c) 2018-2019 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, TrackByFunction } from '@angular/core'; | ||
import { BehaviorSubject, combineLatest, MonoTypeOperatorFunction, Observable, OperatorFunction } from 'rxjs'; | ||
import { PlatformCapabilityTypes, Capability, Manifest, ManifestRegistryService, Qualifier } from '@scion/workbench-application.core'; | ||
import { map } from 'rxjs/operators'; | ||
import { PARAM_NAME, PARAM_VALUE, SciParamsEnterComponent, toFilterRegExp } from '@scion/app/common'; | ||
import { FormArray, FormBuilder, FormGroup, Validators } from '@angular/forms'; | ||
|
||
const CAPABILITY_LOOKUP_TYPE = 'type'; | ||
const CAPABILITY_LOOKUP_QUALIFIER = 'qualifier'; | ||
|
||
@Component({ | ||
selector: 'app-dev-tools', | ||
templateUrl: './dev-tools.component.html', | ||
styleUrls: ['./dev-tools.component.scss'], | ||
}) | ||
export class DevToolsComponent { | ||
|
||
public readonly CAPABILITY_LOOKUP_TYPE = CAPABILITY_LOOKUP_TYPE; | ||
public readonly CAPABILITY_LOOKUP_QUALIFIER = CAPABILITY_LOOKUP_QUALIFIER; | ||
|
||
public readonly PlatformCapabilityTypes = PlatformCapabilityTypes; | ||
|
||
public form: FormGroup; | ||
public manifests$: Observable<Manifest[]>; | ||
|
||
public appListPanelExpanded = true; | ||
public capabilityLookupPanelExpanded = false; | ||
public capabilityLookupResult$: Observable<Capability[]>; | ||
|
||
private _appListFilter$ = new BehaviorSubject<string>(null); | ||
|
||
constructor(formBuilder: FormBuilder, private _manifestRegistryService: ManifestRegistryService) { | ||
this.form = formBuilder.group({ | ||
[CAPABILITY_LOOKUP_TYPE]: formBuilder.control([], Validators.required), | ||
[CAPABILITY_LOOKUP_QUALIFIER]: formBuilder.array([ | ||
formBuilder.group({ | ||
[PARAM_NAME]: formBuilder.control('*'), | ||
[PARAM_VALUE]: formBuilder.control('*'), | ||
}) | ||
]), | ||
}); | ||
|
||
this.manifests$ = combineLatest([this._appListFilter$, this._manifestRegistryService.manifests$]) | ||
.pipe( | ||
filterManifests(), | ||
sortManifests(), | ||
); | ||
} | ||
|
||
public onLookupClick(): void { | ||
const type = this.form.get(CAPABILITY_LOOKUP_TYPE).value; | ||
const qualifier: Qualifier = SciParamsEnterComponent.toParams(this.form.get(CAPABILITY_LOOKUP_QUALIFIER) as FormArray); | ||
this.capabilityLookupResult$ = this._manifestRegistryService.capabilities$(type, qualifier); | ||
} | ||
|
||
public toggleAppListPanel(): void { | ||
this.appListPanelExpanded = !this.appListPanelExpanded; | ||
} | ||
|
||
public toggleCapabilityLookupPanel(): void { | ||
this.capabilityLookupPanelExpanded = !this.capabilityLookupPanelExpanded; | ||
} | ||
|
||
public onFilter(filterText: string): void { | ||
this._appListFilter$.next(filterText); | ||
} | ||
|
||
public trackByFn: TrackByFunction<Manifest> = (index: number, manifest: Manifest): any => { | ||
return manifest.symbolicName; | ||
}; | ||
} | ||
|
||
function filterManifests(): OperatorFunction<[string, Manifest[]], Manifest[]> { | ||
return map(([filter, manifests]: [string, Manifest[]]): Manifest[] => { | ||
if (!filter) { | ||
return manifests; | ||
} | ||
|
||
const filterRegExp = toFilterRegExp(filter); | ||
return manifests.filter(manifest => filterRegExp.test(manifest.name) || filterRegExp.test(manifest.symbolicName)); | ||
}); | ||
} | ||
|
||
function sortManifests(): MonoTypeOperatorFunction<Manifest[]> { | ||
return map((manifests: Manifest[]): Manifest[] => [...manifests].sort((mf1, mf2) => mf1.name.localeCompare(mf2.name))); | ||
} |
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.