From fc7cb92755d0ed861d20b468ddf4be7c72918762 Mon Sep 17 00:00:00 2001 From: Ryan Mathis Date: Thu, 6 Dec 2018 11:40:49 -0700 Subject: [PATCH] Updated UI, updated schema --- .../main/resources/nameid-filter.schema.json | 23 ++++++++++++-- .../filter/container/edit-filter.component.ts | 25 +++++++++++----- .../filter/effect/collection.effect.ts | 8 +++++ ui/src/app/metadata/filter/reducer/index.ts | 7 ++++- .../array/inline-obj-list.component.html | 30 ++++++++++++++----- .../assets/schema/filter/nameid.schema.json | 23 ++++++++++++-- 6 files changed, 94 insertions(+), 22 deletions(-) diff --git a/backend/src/main/resources/nameid-filter.schema.json b/backend/src/main/resources/nameid-filter.schema.json index 47cb75304..129f543f2 100644 --- a/backend/src/main/resources/nameid-filter.schema.json +++ b/backend/src/main/resources/nameid-filter.schema.json @@ -69,14 +69,13 @@ "description": "tooltip.nameid-formats", "items": { "type": "object", + "title": "label.nameid-format", "widget": { "id": "inline-obj" }, "properties": { "format": { - "type": "string", - "title": "label.nameid-formats-format", - "description": "tooltip.nameid-formats-format" + "$ref": "#/definitions/NameIDFormat" }, "value": { "type": "string", @@ -114,5 +113,23 @@ } } } + }, + "definitions": { + "NameIDFormat": { + "type": "string", + "title": "label.nameid-formats-format", + "description": "tooltip.nameid-formats-format", + "minLength": 1, + "maxLength": 255, + "widget": { + "id": "datalist", + "data": [ + "urn:oasis:names:tc:SAML:1.1:nameid-format:unspecified", + "urn:oasis:names:tc:SAML:1.1:nameid-format:emailAddress", + "urn:oasis:names:tc:SAML:2.0:nameid-format:persistent", + "urn:oasis:names:tc:SAML:2.0:nameid-format:transient" + ] + } + } } } \ No newline at end of file diff --git a/ui/src/app/metadata/filter/container/edit-filter.component.ts b/ui/src/app/metadata/filter/container/edit-filter.component.ts index c71e7a489..5ffb8e58e 100644 --- a/ui/src/app/metadata/filter/container/edit-filter.component.ts +++ b/ui/src/app/metadata/filter/container/edit-filter.component.ts @@ -11,7 +11,7 @@ import { UpdateFilterRequest } from '../action/collection.action'; import { CancelCreateFilter, UpdateFilterChanges } from '../action/filter.action'; import { PreviewEntity } from '../../domain/action/entity.action'; import { EntityAttributesFilterEntity } from '../../domain/entity'; -import { shareReplay, map, withLatestFrom } from 'rxjs/operators'; +import { shareReplay, map, withLatestFrom, filter, switchMap } from 'rxjs/operators'; @Component({ selector: 'edit-filter-page', @@ -25,7 +25,7 @@ export class EditFilterComponent { statusChangeSubject = new Subject<{ value: any[] }>(); private statusChangeEmitted$ = this.statusChangeSubject.asObservable(); - definition: FormDefinition; + definition$: Observable>; schema$: Observable; model$: Observable; @@ -41,9 +41,17 @@ export class EditFilterComponent { private store: Store, private schemaService: SchemaService ) { - this.definition = MetadataFilterTypes.EntityAttributes; - - this.schema$ = this.schemaService.get(this.definition.schema).pipe(shareReplay()); + this.definition$ = this.store.select(fromFilter.getFilterType).pipe( + filter(t => !!t), + map(t => MetadataFilterTypes[t]) + ); + this.schema$ = this.definition$.pipe( + filter(d => !!d), + switchMap(d => { + return this.schemaService.get(d.schema); + }), + shareReplay() + ); this.isSaving$ = this.store.select(fromFilter.getCollectionSaving); this.model$ = this.store.select(fromFilter.getSelectedFilter); @@ -54,9 +62,10 @@ export class EditFilterComponent { this.validators$ = this.store.select(fromFilter.getFilterNames).pipe( withLatestFrom( - this.store.select(fromFilter.getSelectedFilter) + this.store.select(fromFilter.getSelectedFilter), + this.definition$ ), - map(([names, provider]) => this.definition.getValidators( + map(([names, provider, definition]) => definition.getValidators( names.filter(n => n !== provider.name) )) ); @@ -70,6 +79,8 @@ export class EditFilterComponent { this.preview(parameters.id); } }; + + this.definition$.subscribe(d => console.log(d)); } save(): void { diff --git a/ui/src/app/metadata/filter/effect/collection.effect.ts b/ui/src/app/metadata/filter/effect/collection.effect.ts index 8e640d75e..65d5f8d2c 100644 --- a/ui/src/app/metadata/filter/effect/collection.effect.ts +++ b/ui/src/app/metadata/filter/effect/collection.effect.ts @@ -39,6 +39,7 @@ import { removeNulls, array_move } from '../../../shared/util'; import { EntityAttributesFilterEntity } from '../../domain/entity/filter/entity-attributes-filter'; import { MetadataFilterService } from '../../domain/service/filter.service'; import { SelectProviderRequest } from '../../provider/action/collection.action'; +import { UpdateFilterChanges } from '../action/filter.action'; /* istanbul ignore next */ @Injectable() @@ -74,6 +75,13 @@ export class FilterCollectionEffects { ) ); + @Effect() + selectFilterRequestSetChanges$ = this.actions$.pipe( + ofType(FilterCollectionActionTypes.SELECT_FILTER_SUCCESS), + map(action => action.payload), + map(filter => new UpdateFilterChanges({...filter, type: filter['@type']})) + ); + @Effect() addFilter$ = this.actions$.pipe( ofType(FilterCollectionActionTypes.ADD_FILTER_REQUEST), diff --git a/ui/src/app/metadata/filter/reducer/index.ts b/ui/src/app/metadata/filter/reducer/index.ts index fdf577027..c1da3cab4 100644 --- a/ui/src/app/metadata/filter/reducer/index.ts +++ b/ui/src/app/metadata/filter/reducer/index.ts @@ -79,7 +79,12 @@ export const getFilterNames = createSelector(getAllFilters, (filters: MetadataFi */ export const mergeFn = (changes, filter) => ({ ...filter, ...changes }); +export const detectFilterType = (changes) => changes.type ? changes.type : changes.hasOwnProperty('@type') ? changes['@type'] : null; export const getFilterWithChanges = createSelector(getFilter, getSelectedFilter, mergeFn); -export const getFilterType = createSelector(getFilter, (changes: MetadataFilter) => changes ? changes.type : null); +export const getFilterType = createSelector(getFilter, (changes: MetadataFilter) => { + const type = changes ? detectFilterType(changes) : null; + console.log(type, changes); + return type; +}); diff --git a/ui/src/app/schema-form/widget/array/inline-obj-list.component.html b/ui/src/app/schema-form/widget/array/inline-obj-list.component.html index af4099b54..876ea01f7 100644 --- a/ui/src/app/schema-form/widget/array/inline-obj-list.component.html +++ b/ui/src/app/schema-form/widget/array/inline-obj-list.component.html @@ -21,14 +21,28 @@
  • -
    -
    - -
    - +
    +
    +
    +
    + + +   + + + + (default) + + + +
    +
    +
    + +
    diff --git a/ui/src/assets/schema/filter/nameid.schema.json b/ui/src/assets/schema/filter/nameid.schema.json index 47cb75304..129f543f2 100644 --- a/ui/src/assets/schema/filter/nameid.schema.json +++ b/ui/src/assets/schema/filter/nameid.schema.json @@ -69,14 +69,13 @@ "description": "tooltip.nameid-formats", "items": { "type": "object", + "title": "label.nameid-format", "widget": { "id": "inline-obj" }, "properties": { "format": { - "type": "string", - "title": "label.nameid-formats-format", - "description": "tooltip.nameid-formats-format" + "$ref": "#/definitions/NameIDFormat" }, "value": { "type": "string", @@ -114,5 +113,23 @@ } } } + }, + "definitions": { + "NameIDFormat": { + "type": "string", + "title": "label.nameid-formats-format", + "description": "tooltip.nameid-formats-format", + "minLength": 1, + "maxLength": 255, + "widget": { + "id": "datalist", + "data": [ + "urn:oasis:names:tc:SAML:1.1:nameid-format:unspecified", + "urn:oasis:names:tc:SAML:1.1:nameid-format:emailAddress", + "urn:oasis:names:tc:SAML:2.0:nameid-format:persistent", + "urn:oasis:names:tc:SAML:2.0:nameid-format:transient" + ] + } + } } } \ No newline at end of file