-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
SHIBUI-914 Implemented dynamic wizard for sources
- Loading branch information
Showing
11 changed files
with
168 additions
and
53 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
8 changes: 8 additions & 0 deletions
8
ui/src/app/metadata/resolver/container/resolver-wizard-step.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,8 @@ | ||
<ng-container *ngIf="definition$ | async"> | ||
<sf-form | ||
[schema]="schema$ | async" | ||
[model]="model$ | async" | ||
[validators]="validators$ | async" | ||
(onChange)="valueChangeSubject.next($event)" | ||
(onErrorChange)="statusChangeSubject.next($event)"></sf-form> | ||
</ng-container> |
89 changes: 89 additions & 0 deletions
89
ui/src/app/metadata/resolver/container/resolver-wizard-step.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,89 @@ | ||
import { Component, OnDestroy } from '@angular/core'; | ||
import { Observable, Subject } from 'rxjs'; | ||
import { withLatestFrom, map, distinctUntilChanged, skipWhile } from 'rxjs/operators'; | ||
import { Store } from '@ngrx/store'; | ||
|
||
import * as fromResolver from '../reducer'; | ||
import * as fromWizard from '../../../wizard/reducer'; | ||
|
||
import { SetDefinition } from '../../../wizard/action/wizard.action'; | ||
import { UpdateStatus, UpdateChanges } from '../action/entity.action'; | ||
import { Wizard } from '../../../wizard/model'; | ||
import { MetadataResolver } from '../../domain/model'; | ||
import { pick } from '../../../shared/util'; | ||
|
||
@Component({ | ||
selector: 'resolver-wizard-step', | ||
templateUrl: './resolver-wizard-step.component.html', | ||
styleUrls: [] | ||
}) | ||
|
||
export class ResolverWizardStepComponent implements OnDestroy { | ||
valueChangeSubject = new Subject<Partial<any>>(); | ||
private valueChangeEmitted$ = this.valueChangeSubject.asObservable(); | ||
|
||
statusChangeSubject = new Subject<Partial<any>>(); | ||
private statusChangeEmitted$ = this.statusChangeSubject.asObservable(); | ||
|
||
schema$: Observable<any>; | ||
schema: any; | ||
definition$: Observable<Wizard<MetadataResolver>>; | ||
changes$: Observable<MetadataResolver>; | ||
currentPage: string; | ||
valid$: Observable<boolean>; | ||
model$: Observable<any>; | ||
|
||
namesList: string[] = []; | ||
|
||
validators$: Observable<{ [key: string]: any }>; | ||
|
||
constructor( | ||
private store: Store<fromResolver.ResolverState>, | ||
) { | ||
this.schema$ = this.store.select(fromWizard.getSchema); | ||
this.definition$ = this.store.select(fromWizard.getWizardDefinition); | ||
this.changes$ = this.store.select(fromResolver.getEntityChanges); | ||
|
||
this.validators$ = this.definition$.pipe( | ||
map((def) => def.getValidators()) | ||
); | ||
|
||
this.model$ = this.schema$.pipe( | ||
withLatestFrom( | ||
this.store.select(fromWizard.getModel), | ||
this.changes$, | ||
this.definition$ | ||
), | ||
map(([schema, model, changes, definition]) => ({ | ||
model: { | ||
...model, | ||
...changes | ||
}, | ||
definition | ||
})), | ||
skipWhile(({ model, definition }) => !definition || !model), | ||
map(({ model, definition }) => definition.formatter(model)) | ||
); | ||
|
||
this.valueChangeEmitted$.pipe( | ||
withLatestFrom(this.definition$), | ||
skipWhile(([ changes, definition ]) => !definition || !changes), | ||
map(([ changes, definition ]) => definition.parser(changes)) | ||
) | ||
.subscribe(changes => this.store.dispatch(new UpdateChanges(changes))); | ||
|
||
this.statusChangeEmitted$.pipe(distinctUntilChanged()).subscribe(errors => this.updateStatus(errors)); | ||
|
||
this.store.select(fromWizard.getWizardIndex).subscribe(i => this.currentPage = i); | ||
} | ||
|
||
updateStatus(errors: any): void { | ||
const status = { [this.currentPage]: !(errors.value) ? 'VALID' : 'INVALID' }; | ||
this.store.dispatch(new UpdateStatus(status)); | ||
} | ||
|
||
ngOnDestroy() { | ||
this.valueChangeSubject.complete(); | ||
} | ||
} | ||
|
46 changes: 7 additions & 39 deletions
46
ui/src/app/metadata/resolver/container/resolver-wizard.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 |
---|---|---|
@@ -1,42 +1,10 @@ | ||
<div class="container-fluid p-3" role="main"> | ||
<section class="section" *ngIf="resolver$ | async" tabindex="0" [attr.aria-label]="'Add a new metadata source wizard form - ' + (currentPage$ | async).label + ' ' + (resolver$ | async).serviceProviderName"> | ||
<div class="section-header bg-info p-2 text-white"> | ||
<div class="row justify-content-between"> | ||
<div class="col-md-12"> | ||
<span class="display-6" role="heading" aria-level="1"> | ||
<i class="fa fa-fw fa-plus-square"></i> | ||
<translate-i18n key="message.add-new-md-resolver">Add a new metadata source</translate-i18n> | ||
– {{ (currentPage$ | async).label | translate }} ({{ (resolver$ | async).serviceProviderName }}) | ||
<!--<span class="pull-right"> | ||
(<translate-i18n key="message.wizard-status" [params]="{ index: wizardIndex$ | async, length: wizard.length + 1 }"> | ||
Step {{ wizardIndex }} of {{ wizard.length + 1 }} | ||
</translate-i18n>) | ||
</span>--> | ||
</span> | ||
</div> | ||
</div> | ||
</div> | ||
<div class="section-body p-4 border border-top-0 border-info" *ngIf="wizardIndex$ | async"> | ||
<wizard-nav [index]="wizardIndex$ | async" | ||
<div class="container-fluid" role="main"> | ||
<!--<wizard-nav [index]="wizardIndex$ | async" | ||
(onNext)="next($event)" | ||
(onPrevious)="previous($event)" | ||
(onSave)="save($event)"></wizard-nav> | ||
<hr /> | ||
<div [ngSwitch]="wizardIndex$ | async" class="py-4"> | ||
<org-info-form *ngSwitchDefault [resolver]="resolver$ | async"></org-info-form> | ||
<metadata-ui-form *ngSwitchCase="3" [resolver]="resolver$ | async"></metadata-ui-form> | ||
<descriptor-info-form *ngSwitchCase="4" [resolver]="resolver$ | async"></descriptor-info-form> | ||
<logout-form *ngSwitchCase="5" [resolver]="resolver$ | async"></logout-form> | ||
<key-info-form *ngSwitchCase="6" [resolver]="resolver$ | async"></key-info-form> | ||
<assertion-form *ngSwitchCase="7" [resolver]="resolver$ | async"></assertion-form> | ||
<div class="row" *ngSwitchCase="8"> | ||
<relying-party-form [resolver]="resolver$ | async" class="col-xl-6"></relying-party-form> | ||
</div> | ||
<div class="row" *ngSwitchCase="9"> | ||
<attribute-release-form [resolver]="resolver$ | async" class="col-xl-6"></attribute-release-form> | ||
</div> | ||
<finish-form *ngSwitchCase="10" [resolver]="resolver$ | async"></finish-form> | ||
</div> | ||
</div> | ||
</section> | ||
(onSave)="save($event)"></wizard-nav>--> | ||
<hr /> | ||
<div class="py-4"> | ||
<router-outlet></router-outlet> | ||
</div> | ||
</div> |
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
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