Skip to content

Commit

Permalink
Merged in feature/SHIBUI-321 (pull request #55)
Browse files Browse the repository at this point in the history
Implementation of Edit Filter pages

Approved-by: Ryan Mathis <rmathis@unicon.net>
  • Loading branch information
rmathis committed Apr 13, 2018
1 parent 0343c82 commit b8fc3c5
Show file tree
Hide file tree
Showing 50 changed files with 1,422 additions and 653 deletions.
2 changes: 1 addition & 1 deletion ui/src/app/app.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
</button>
<div ngbDropdownMenu aria-labelledby="addNewDropdown">
<a class="nav-link"
routerLink="/metadata-filter/new"
routerLink="/filter/new"
routerLinkActive="active"
aria-label="Add a new metadata filter"
role="button">
Expand Down
2 changes: 2 additions & 0 deletions ui/src/app/app.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { VersionInfo } from './core/model/version';
import { LoadProviderRequest } from './domain/action/provider-collection.action';
import { LoadDraftRequest } from './domain/action/draft-collection.action';
import { VersionInfoLoadRequestAction } from './core/action/version.action';
import { LoadFilterRequest } from './domain/action/filter-collection.action';
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
Expand All @@ -27,6 +28,7 @@ export class AppComponent implements OnInit {

ngOnInit(): void {
this.store.dispatch(new LoadProviderRequest());
this.store.dispatch(new LoadFilterRequest());
this.store.dispatch(new LoadDraftRequest());
this.store.dispatch(new VersionInfoLoadRequestAction());
}
Expand Down
8 changes: 3 additions & 5 deletions ui/src/app/dashboard/container/dashboard.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,11 +81,9 @@ export class DashboardComponent implements OnInit {
}

edit(entity: MetadataEntity): void {
if (entity.type === DomainTypes.provider) {
let path = entity.id ? 'edit' : 'wizard',
id = entity.id ? entity.id : entity.entityId;
this.router.navigate(['provider', id, path]);
}
let path = entity.id ? 'edit' : 'wizard',
id = entity.id ? entity.id : entity.entityId;
this.router.navigate([entity.type, id, path]);
}

toggleProvider(entity: MetadataEntity): void {
Expand Down
4 changes: 2 additions & 2 deletions ui/src/app/dashboard/effect/search.effects.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { MetadataProvider } from '../../domain/model/metadata-provider';
import { EntityDescriptorService } from '../../domain/service/entity-descriptor.service';
import { Provider } from '../../domain/entity/provider';
import { Filter } from '../../domain/entity/filter';
import { MetadataEntity, DomainTypes } from '../../domain/domain.type';
import { MetadataEntity, DomainTypes, MetadataFilter } from '../../domain/domain.type';

@Injectable()
export class SearchEffects {
Expand All @@ -39,7 +39,7 @@ export class SearchEffects {
return combineLatest(
this.store.select(fromCollections.getAllProviders),
this.store.select(fromCollections.getAllFilters),
(p, f): MetadataEntity[] => [].concat(
(p: MetadataProvider[], f: MetadataFilter[]): Array<MetadataEntity> => [].concat(
f.map(filter => new Filter(filter)),
p.map(provider => new Provider(provider))
)
Expand Down
132 changes: 119 additions & 13 deletions ui/src/app/domain/action/filter-collection.action.ts
Original file line number Diff line number Diff line change
@@ -1,29 +1,135 @@
import { Action } from '@ngrx/store';
import { MetadataFilter } from '../../domain/model/metadata-filter';

export const SAVE_FILTER = '[Filter] Save Filter';
export const SAVE_FILTER_SUCCESS = '[Filter] Save Filter Success';
export const SAVE_FILTER_ERROR = '[Filter] Save Filter Error';
export const FIND = '[Metadata Filter] Find';
export const SELECT = '[Metadata Filter] Select';
export const SELECT_FILTER_SUCCESS = '[Metadata Filter] Select Success';
export const SELECT_FILTER_FAIL = '[Metadata Filter] Select Fail';

export class SaveFilter implements Action {
readonly type = SAVE_FILTER;
export const UPDATE_FILTER_REQUEST = '[Metadata Filter] Update Request';
export const UPDATE_FILTER_SUCCESS = '[Metadata Filter] Update Success';
export const UPDATE_FILTER_FAIL = '[Metadata Filter] Update Fail';

constructor(public payload: Partial<MetadataFilter>) { }
export const LOAD_FILTER_REQUEST = '[Metadata Filter Collection] Filter REQUEST';
export const LOAD_FILTER_SUCCESS = '[Metadata Filter Collection] Filter SUCCESS';
export const LOAD_FILTER_ERROR = '[Metadata Filter Collection] Filter ERROR';
export const ADD_FILTER = '[Metadata Filter Collection] Add Filter';
export const ADD_FILTER_SUCCESS = '[Metadata Filter Collection] Add Filter Success';
export const ADD_FILTER_FAIL = '[Metadata Filter Collection] Add Filter Fail';
export const REMOVE_FILTER = '[Metadata Filter Collection] Remove Filter';
export const REMOVE_FILTER_SUCCESS = '[Metadata Filter Collection] Remove Filter Success';
export const REMOVE_FILTER_FAIL = '[Metadata Filter Collection] Remove Filter Fail';

export class FindFilter implements Action {
readonly type = FIND;

constructor(public payload: string) { }
}

export class SelectFilter implements Action {
readonly type = SELECT;

constructor(public payload: string) { }
}

export class SaveFilterSuccess implements Action {
readonly type = SAVE_FILTER_SUCCESS;
export class SelectFilterSuccess implements Action {
readonly type = SELECT_FILTER_SUCCESS;

constructor(public payload: MetadataFilter) { }
}

export class SaveFilterError implements Action {
readonly type = SAVE_FILTER_ERROR;
export class SelectFilterFail implements Action {
readonly type = SELECT_FILTER_FAIL;

constructor(public payload: Error) { }
}

export class LoadFilterRequest implements Action {
readonly type = LOAD_FILTER_REQUEST;

constructor() { }
}

export class LoadFilterSuccess implements Action {
readonly type = LOAD_FILTER_SUCCESS;

constructor(public payload: MetadataFilter[]) { }
}

export class LoadFilterError implements Action {
readonly type = LOAD_FILTER_ERROR;

constructor(public payload: any) { }
}

export class UpdateFilterRequest implements Action {
readonly type = UPDATE_FILTER_REQUEST;

constructor(public payload: MetadataFilter) { }
}

export class UpdateFilterSuccess implements Action {
readonly type = UPDATE_FILTER_SUCCESS;

constructor(public payload: MetadataFilter) { }
}

export class UpdateFilterFail implements Action {
readonly type = UPDATE_FILTER_FAIL;

constructor(public err: any) { }
}

export class AddFilterRequest implements Action {
readonly type = ADD_FILTER;

constructor(public payload: MetadataFilter) { }
}

export class AddFilterSuccess implements Action {
readonly type = ADD_FILTER_SUCCESS;

constructor(public payload: MetadataFilter) { }
}

export class AddFilterFail implements Action {
readonly type = ADD_FILTER_FAIL;

constructor(public payload: any) { }
}

export class RemoveFilterRequest implements Action {
readonly type = REMOVE_FILTER;

constructor(public payload: MetadataFilter) { }
}

export class RemoveFilterSuccess implements Action {
readonly type = REMOVE_FILTER_SUCCESS;

constructor(public payload: MetadataFilter) { }
}

export class RemoveFilterFail implements Action {
readonly type = REMOVE_FILTER_FAIL;

constructor(public payload: MetadataFilter) { }
}

export type Actions =
| SaveFilter
| SaveFilterSuccess
| SaveFilterError;
| LoadFilterRequest
| LoadFilterSuccess
| LoadFilterError
| AddFilterRequest
| AddFilterSuccess
| AddFilterFail
| RemoveFilterRequest
| RemoveFilterSuccess
| RemoveFilterFail
| FindFilter
| SelectFilter
| SelectFilterSuccess
| SelectFilterFail
| UpdateFilterRequest
| UpdateFilterSuccess
| UpdateFilterFail;
4 changes: 2 additions & 2 deletions ui/src/app/domain/domain.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ import { ListValuesService } from './service/list-values.service';
import { ProviderStatusEmitter, ProviderValueEmitter } from './service/provider-change-emitter.service';
import { EntityIdService } from './service/entity-id.service';
import { EntityDraftService } from './service/entity-draft.service';
import { MetadataFilterService } from './service/filter.service';

import { reducers } from './reducer';
import { DraftCollectionEffects } from './effect/draft-collection.effects';
import { ProviderCollectionEffects } from './effect/provider-collection.effects';
import { FilterCollectionEffects } from './effect/filter-collection.effect';
import { MetadataResolverService } from './service/metadata-resolver.service';

@NgModule({
declarations: [],
Expand All @@ -32,7 +32,7 @@ export class DomainModule {
ListValuesService,
ProviderStatusEmitter,
ProviderValueEmitter,
MetadataFilterService
MetadataResolverService
]
};
}
Expand Down
79 changes: 72 additions & 7 deletions ui/src/app/domain/effect/filter-collection.effect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,29 +15,94 @@ import * as actions from '../action/filter-collection.action';
import * as fromFilter from '../reducer';

import { EntityIdService } from '../../domain/service/entity-id.service';
import { MetadataFilterService } from '../service/filter.service';
import { MetadataResolverService } from '../service/metadata-resolver.service';
import { MetadataFilter } from '../../domain/model/metadata-filter';
import { removeNulls } from '../../shared/util';

@Injectable()
export class FilterCollectionEffects {

@Effect()
saveFilter$ = this.actions$
.ofType<actions.SaveFilter>(actions.SAVE_FILTER)
loadFilters$ = this.actions$
.ofType<actions.LoadFilterRequest>(actions.LOAD_FILTER_REQUEST)
.switchMap(() =>
this.resolverService
.query()
.map(filters => new actions.LoadFilterSuccess(filters))
.catch(error => Observable.of(new actions.LoadFilterError(error)))
);
@Effect()
selectFilterRequest$ = this.actions$
.ofType<actions.SelectFilter>(actions.SELECT)
.map(action => action.payload)
.switchMap(id =>
this.resolverService
.find(id)
.map(p => new actions.SelectFilterSuccess(p))
.catch(error => Observable.of(new actions.SelectFilterFail(error)))
);

@Effect()
addFilter$ = this.actions$
.ofType<actions.AddFilterRequest>(actions.ADD_FILTER)
.map(action => action.payload)
.map(filter => {
return {
...filter,
relyingPartyOverrides: removeNulls(filter.relyingPartyOverrides)
};
})
.switchMap(unsaved =>
this.filterService
this.resolverService
.save(unsaved as MetadataFilter)
.map(saved => new actions.SaveFilterSuccess(saved))
.catch(error => Observable.of(new actions.SaveFilterError(error)))
.map(saved => new actions.AddFilterSuccess(saved))
.catch(error => Observable.of(new actions.AddFilterFail(error)))
);
@Effect({ dispatch: false })
addFilterSuccessRedirect$ = this.actions$
.ofType<actions.AddFilterSuccess>(actions.ADD_FILTER_SUCCESS)
.map(action => action.payload)
.do(filter => {
this.router.navigate(['/dashboard']);
});

@Effect()
addFilterSuccessReload$ = this.actions$
.ofType<actions.AddFilterSuccess>(actions.ADD_FILTER_SUCCESS)
.map(action => action.payload)
.map(filter => new actions.LoadFilterRequest());

@Effect()
updateFilter$ = this.actions$
.ofType<actions.UpdateFilterRequest>(actions.UPDATE_FILTER_REQUEST)
.map(action => action.payload)
.switchMap(filter => {
delete filter.modifiedDate;
delete filter.createdDate;
return this.resolverService
.update(filter)
.map(p => new actions.UpdateFilterSuccess(p))
.catch(err => Observable.of(new actions.UpdateFilterFail(err)));
});
@Effect({ dispatch: false })
updateFilterSuccessRedirect$ = this.actions$
.ofType<actions.UpdateFilterSuccess>(actions.UPDATE_FILTER_SUCCESS)
.map(action => action.payload)
.do(filter => {
this.router.navigate(['/dashboard']);
});
@Effect()
updateFilterSuccessReload$ = this.actions$
.ofType<actions.UpdateFilterSuccess>(actions.UPDATE_FILTER_SUCCESS)
.map(action => action.payload)
.map(filter => new actions.LoadFilterRequest());

constructor(
private actions$: Actions,
private router: Router,
private modalService: NgbModal,
private idService: EntityIdService,
private filterService: MetadataFilterService,
private resolverService: MetadataResolverService,
private store: Store<fromFilter.State>
) { }
}
3 changes: 2 additions & 1 deletion ui/src/app/domain/effect/provider-collection.effects.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import * as providerActions from '../action/provider-collection.action';
import * as draftActions from '../action/draft-collection.action';
import { MetadataProvider } from '../../domain/model/metadata-provider';
import { EntityDescriptorService } from '../../domain/service/entity-descriptor.service';
import { removeNulls } from '../../shared/util';

@Injectable()
export class ProviderCollectionEffects {
Expand Down Expand Up @@ -64,7 +65,7 @@ export class ProviderCollectionEffects {
.map(provider => {
return {
...provider,
relyingPartyOverrides: this.descriptorService.removeNulls(provider.relyingPartyOverrides)
relyingPartyOverrides: removeNulls(provider.relyingPartyOverrides)
};
})
.switchMap(provider =>
Expand Down
17 changes: 15 additions & 2 deletions ui/src/app/domain/entity/filter.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { MetadataFilter, RelyingPartyOverrides } from '../model/metadata-filter';
import { DomainTypes } from '../domain.type';
import { FilterTarget } from '../model/filter-target';

export class Filter implements MetadataFilter {
id = '';
createdDate?: string;
modifiedDate?: string;

entityId = '';
filterName = '';
filterEnabled = false;

Expand All @@ -17,8 +17,13 @@ export class Filter implements MetadataFilter {

attributeRelease = [] as string[];

filterTarget: FilterTarget = {
type: 'entity',
value: ''
};

constructor(obj?: Partial<MetadataFilter>) {
Object.assign(this, obj);
Object.assign(this, obj || {});
}

get name(): string {
Expand All @@ -32,4 +37,12 @@ export class Filter implements MetadataFilter {
get type(): string {
return DomainTypes.filter;
}

get entityId(): string {
return this.filterTarget.value;
}

set entityId(val: string) {
this.filterTarget.value = val;
}
}
Loading

0 comments on commit b8fc3c5

Please sign in to comment.