-
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.
- Loading branch information
Showing
22 changed files
with
479 additions
and
6 deletions.
There are no files selected for viewing
61 changes: 61 additions & 0 deletions
61
ui/src/app/metadata/configuration/action/configuration.action.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,61 @@ | ||
import { Action } from '@ngrx/store'; | ||
import { Metadata } from '../../domain/domain.type'; | ||
import { Schema } from '../model/schema'; | ||
import { Wizard } from '../../../wizard/model'; | ||
|
||
export enum ConfigurationActionTypes { | ||
LOAD_METADATA_REQUEST = '[Metadata Configuration] Load Metadata Request', | ||
LOAD_METADATA_SUCCESS = '[Metadata Configuration] Load Metadata Success', | ||
LOAD_METADATA_ERROR = '[Metadata Configuration] Load Metadata Error', | ||
|
||
SET_METADATA = '[Metadata Configuration] Set Metadata Model', | ||
SET_DEFINITION = '[Metadata Configuration] Set Metadata Definition', | ||
SET_SCHEMA = '[Metadata Configuration] Set Metadata Schema', | ||
CLEAR = '[Metadata Configuration] Clear' | ||
} | ||
|
||
export class LoadMetadataRequest implements Action { | ||
readonly type = ConfigurationActionTypes.LOAD_METADATA_REQUEST; | ||
|
||
constructor(public payload: { id: string, type: string }) { } | ||
} | ||
|
||
export class LoadMetadataSuccess implements Action { | ||
readonly type = ConfigurationActionTypes.LOAD_METADATA_SUCCESS; | ||
|
||
constructor(public payload: Metadata) { } | ||
} | ||
|
||
export class LoadMetadataError implements Action { | ||
readonly type = ConfigurationActionTypes.LOAD_METADATA_ERROR; | ||
|
||
constructor(public payload: any) { } | ||
} | ||
|
||
export class SetMetadata implements Action { | ||
readonly type = ConfigurationActionTypes.SET_METADATA; | ||
|
||
constructor(public payload: Metadata) { } | ||
} | ||
|
||
export class SetDefinition implements Action { | ||
readonly type = ConfigurationActionTypes.SET_DEFINITION; | ||
|
||
constructor(public payload: Wizard<Metadata>) { } | ||
} | ||
|
||
export class SetSchema implements Action { | ||
readonly type = ConfigurationActionTypes.SET_SCHEMA; | ||
|
||
constructor(public payload: Schema) { } | ||
} | ||
|
||
export class ClearConfiguration implements Action { | ||
readonly type = ConfigurationActionTypes.CLEAR; | ||
} | ||
|
||
export type ConfigurationActionsUnion = | ||
| SetMetadata | ||
| SetDefinition | ||
| SetSchema | ||
| ClearConfiguration; |
10 changes: 10 additions & 0 deletions
10
ui/src/app/metadata/configuration/component/metadata-configuration.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,10 @@ | ||
<div class="row" *ngIf="configuration && configuration.columns"> | ||
<div class="col-xl-6 col-xs-12" *ngFor="let sections of configuration.columns"> | ||
<section class="px-3" *ngFor="let section of sections; let i = index;"> | ||
{{ i + 1 }}: {{ section.label }} | ||
<ng-container *ngFor="let prop of section.properties"> | ||
{{ prop | json }} | ||
</ng-container> | ||
</section> | ||
</div> | ||
</div> |
Empty file.
16 changes: 16 additions & 0 deletions
16
ui/src/app/metadata/configuration/component/metadata-configuration.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,16 @@ | ||
import { Component, ChangeDetectionStrategy, Input } from '@angular/core'; | ||
import { WizardStep } from '../../../wizard/model'; | ||
import Section from '../model/section'; | ||
import { MetadataConfiguration } from '../model/metadata-configuration'; | ||
|
||
@Component({ | ||
selector: 'metadata-configuration', | ||
changeDetection: ChangeDetectionStrategy.OnPush, | ||
templateUrl: './metadata-configuration.component.html', | ||
styleUrls: [] | ||
}) | ||
export class MetadataConfigurationComponent { | ||
@Input() configuration: MetadataConfiguration; | ||
|
||
constructor() { } | ||
} |
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 @@ | ||
import { NgModule, ModuleWithProviders } from '@angular/core'; | ||
import { CommonModule } from '@angular/common'; | ||
import { StoreModule } from '@ngrx/store'; | ||
import { EffectsModule } from '@ngrx/effects'; | ||
|
||
import { I18nModule } from '../../i18n/i18n.module'; | ||
import { MetadataConfigurationComponent } from './component/metadata-configuration.component'; | ||
import { ConfigurationComponent } from './container/configuration.component'; | ||
import { MetadataConfigurationService } from './service/configuration.service'; | ||
import * as fromConfig from './reducer'; | ||
import { MetadataConfigurationEffects } from './effect/configuration.effect'; | ||
|
||
@NgModule({ | ||
declarations: [ | ||
MetadataConfigurationComponent, | ||
ConfigurationComponent | ||
], | ||
entryComponents: [], | ||
imports: [ | ||
CommonModule, | ||
I18nModule | ||
], | ||
exports: [], | ||
providers: [] | ||
}) | ||
export class MetadataConfigurationModule { | ||
static forRoot(): ModuleWithProviders { | ||
return { | ||
ngModule: RootMetadataConfigurationModule, | ||
providers: [ | ||
MetadataConfigurationService | ||
] | ||
}; | ||
} | ||
} | ||
|
||
@NgModule({ | ||
imports: [ | ||
MetadataConfigurationModule, | ||
StoreModule.forFeature('metadata-configuration', fromConfig.reducers), | ||
EffectsModule.forFeature([MetadataConfigurationEffects]) | ||
], | ||
providers: [] | ||
}) | ||
export class RootMetadataConfigurationModule { } |
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,9 @@ | ||
import { Routes } from '@angular/router'; | ||
import { ConfigurationComponent } from './container/configuration.component'; | ||
|
||
export const ConfigurationRoutes: Routes = [ | ||
{ | ||
path: ':type/:id/configuration', | ||
component: ConfigurationComponent | ||
} | ||
]; |
17 changes: 17 additions & 0 deletions
17
ui/src/app/metadata/configuration/container/configuration.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,17 @@ | ||
<div class="container-fluid p-3"> | ||
<section class="section" aria-label="View Metadata Version History" tabindex="0"> | ||
<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"> | ||
<i class="fa fa-fw fa-gears"></i> | ||
<translate-i18n key="label.metadata-resolver-history">Metadata resolver history</translate-i18n> | ||
</span> | ||
</div> | ||
</div> | ||
</div> | ||
<div class="section-body p-4 border border-top-0 border-info"> | ||
<metadata-configuration></metadata-configuration> | ||
</div> | ||
</section> | ||
</div> |
Empty file.
44 changes: 44 additions & 0 deletions
44
ui/src/app/metadata/configuration/container/configuration.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,44 @@ | ||
import { Store } from '@ngrx/store'; | ||
import { Component, ChangeDetectionStrategy, OnDestroy } from '@angular/core'; | ||
import { Observable, Subject } from 'rxjs'; | ||
import { ActivatedRoute } from '@angular/router'; | ||
|
||
import * as fromConfiguration from '../reducer'; | ||
import { MetadataConfiguration } from '../model/metadata-configuration'; | ||
import { METADATA_SOURCE_EDITOR } from '../../resolver/wizard-definition'; | ||
import { takeUntil, map } from 'rxjs/operators'; | ||
import { LoadMetadataRequest, ClearConfiguration } from '../action/configuration.action'; | ||
|
||
@Component({ | ||
selector: 'configuration-page', | ||
changeDetection: ChangeDetectionStrategy.OnPush, | ||
templateUrl: './configuration.component.html', | ||
styleUrls: [] | ||
}) | ||
export class ConfigurationComponent implements OnDestroy { | ||
private ngUnsubscribe: Subject<void> = new Subject<void>(); | ||
|
||
configuration$: Observable<MetadataConfiguration>; | ||
|
||
constructor( | ||
private store: Store<fromConfiguration.ConfigurationState>, | ||
private routerState: ActivatedRoute | ||
) { | ||
this.configuration$ = this.store.select(fromConfiguration.getConfigurationColumns); | ||
|
||
this.routerState.params.pipe( | ||
takeUntil(this.ngUnsubscribe), | ||
map(params => new LoadMetadataRequest({id: params.id, type: params.type})) | ||
).subscribe(store); | ||
|
||
this.configuration$.subscribe(c => console.log(c)); | ||
|
||
// this.resolver$ = this.store.select(fromResolvers.getSelectedResolver).pipe(skipWhile(p => !p)); | ||
} | ||
|
||
ngOnDestroy() { | ||
this.ngUnsubscribe.next(); | ||
this.ngUnsubscribe.complete(); | ||
this.store.dispatch(new ClearConfiguration()); | ||
} | ||
} |
48 changes: 48 additions & 0 deletions
48
ui/src/app/metadata/configuration/effect/configuration.effect.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,48 @@ | ||
import { Injectable } from '@angular/core'; | ||
import { Effect, Actions, ofType } from '@ngrx/effects'; | ||
import { switchMap, catchError, map } from 'rxjs/operators'; | ||
import { of } from 'rxjs'; | ||
|
||
import { MetadataConfigurationService } from '../service/configuration.service'; | ||
import { | ||
LoadMetadataRequest, | ||
LoadMetadataSuccess, | ||
LoadMetadataError, | ||
ConfigurationActionTypes, | ||
SetMetadata, | ||
SetDefinition | ||
} from '../action/configuration.action'; | ||
|
||
@Injectable() | ||
export class MetadataConfigurationEffects { | ||
|
||
@Effect() | ||
loadMetadata$ = this.actions$.pipe( | ||
ofType<LoadMetadataRequest>(ConfigurationActionTypes.LOAD_METADATA_REQUEST), | ||
switchMap(action => | ||
this.configService | ||
.find(action.payload.id, action.payload.type) | ||
.pipe( | ||
map(md => new LoadMetadataSuccess(md)), | ||
catchError(error => of(new LoadMetadataError(error))) | ||
) | ||
) | ||
); | ||
|
||
@Effect() | ||
setMetadataOnLoad$ = this.actions$.pipe( | ||
ofType<LoadMetadataSuccess>(ConfigurationActionTypes.LOAD_METADATA_SUCCESS), | ||
map(action => new SetMetadata(action.payload)) | ||
); | ||
|
||
@Effect() | ||
setDefinitionOnMetadataSet$ = this.actions$.pipe( | ||
ofType<SetMetadata>(ConfigurationActionTypes.SET_METADATA), | ||
map(action => new SetDefinition(this.configService.getDefinition(action.payload))) | ||
); | ||
|
||
constructor( | ||
private configService: MetadataConfigurationService, | ||
private actions$: Actions | ||
) { } | ||
} |
5 changes: 5 additions & 0 deletions
5
ui/src/app/metadata/configuration/model/metadata-configuration.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,5 @@ | ||
import Section from './section'; | ||
|
||
export interface MetadataConfiguration { | ||
columns: Array<Section>[]; | ||
} |
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,3 @@ | ||
export interface Schema { | ||
[prop: string]: any; | ||
} |
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,11 @@ | ||
import { Property } from '../../domain/model/property'; | ||
|
||
export interface Section { | ||
id: string; | ||
index: number; | ||
label: string; | ||
pageNumber: number; | ||
properties: Property[]; | ||
} | ||
|
||
export default Section; |
51 changes: 51 additions & 0 deletions
51
ui/src/app/metadata/configuration/reducer/configuration.reducer.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,51 @@ | ||
import { ConfigurationActionTypes, ConfigurationActionsUnion } from '../action/configuration.action'; | ||
import { Metadata } from '../../domain/domain.type'; | ||
import { Wizard, WizardStep } from '../../../wizard/model'; | ||
import { Schema } from '../model/schema'; | ||
|
||
export interface State { | ||
model: Metadata; | ||
schema: Schema; | ||
definition: Wizard<Metadata>; | ||
} | ||
|
||
export const initialState: State = { | ||
model: null, | ||
schema: null, | ||
definition: null | ||
}; | ||
|
||
export function reducer(state = initialState, action: ConfigurationActionsUnion): State { | ||
switch (action.type) { | ||
case ConfigurationActionTypes.SET_SCHEMA: | ||
return { | ||
...state, | ||
schema: action.payload | ||
}; | ||
break; | ||
case ConfigurationActionTypes.SET_DEFINITION: | ||
return { | ||
...state, | ||
definition: action.payload | ||
}; | ||
break; | ||
case ConfigurationActionTypes.SET_METADATA: | ||
return { | ||
...state, | ||
model: action.payload | ||
}; | ||
break; | ||
case ConfigurationActionTypes.CLEAR: | ||
return { | ||
...initialState | ||
}; | ||
break; | ||
default: { | ||
return state; | ||
} | ||
} | ||
} | ||
|
||
export const getModel = (state: State) => state.model; | ||
export const getDefinition = (state: State) => state.definition; | ||
export const getSchema = (state: State) => state.schema; |
Oops, something went wrong.