-
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-1270 Initial commit for comparison
- Loading branch information
Showing
16 changed files
with
182 additions
and
22 deletions.
There are no files selected for viewing
47 changes: 47 additions & 0 deletions
47
ui/src/app/metadata/configuration/action/compare.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,47 @@ | ||
import { Action } from '@ngrx/store'; | ||
import { MetadataHistory } from '../model/history'; | ||
import { MetadataVersion } from '../model/version'; | ||
import { Metadata } from '../../domain/domain.type'; | ||
|
||
export enum CompareActionTypes { | ||
COMPARE_METADATA_REQUEST = '[Compare Version] Compare Version Request', | ||
COMPARE_METADATA_SUCCESS = '[Compare Version] Compare Version Success', | ||
COMPARE_METADATA_ERROR = '[Compare Version] Compare Version Error', | ||
SET_VERSIONS = '[Compare Version] Set Versions', | ||
CLEAR_VERSIONS = '[Compare Version] Clear Versions' | ||
} | ||
|
||
export class CompareVersionRequest implements Action { | ||
readonly type = CompareActionTypes.COMPARE_METADATA_REQUEST; | ||
|
||
constructor(public payload: MetadataVersion[]) { } | ||
} | ||
|
||
export class CompareVersionSuccess implements Action { | ||
readonly type = CompareActionTypes.COMPARE_METADATA_SUCCESS; | ||
|
||
constructor(public payload: MetadataHistory) { } | ||
} | ||
|
||
export class CompareVersionError implements Action { | ||
readonly type = CompareActionTypes.COMPARE_METADATA_ERROR; | ||
|
||
constructor(public payload: any) { } | ||
} | ||
|
||
export class SetMetadataVersions implements Action { | ||
readonly type = CompareActionTypes.SET_VERSIONS; | ||
|
||
constructor(public payload: Metadata[]) { } | ||
} | ||
|
||
export class ClearVersions implements Action { | ||
readonly type = CompareActionTypes.CLEAR_VERSIONS; | ||
} | ||
|
||
export type CompareActionsUnion = | ||
| CompareVersionRequest | ||
| CompareVersionSuccess | ||
| CompareVersionError | ||
| SetMetadataVersions | ||
| ClearVersions; |
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
Empty file.
Empty file.
24 changes: 24 additions & 0 deletions
24
ui/src/app/metadata/configuration/container/metadata-comparison.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,24 @@ | ||
import { Component, ChangeDetectionStrategy } from '@angular/core'; | ||
import { Observable } from 'rxjs'; | ||
import { Store } from '@ngrx/store'; | ||
import { ConfigurationState, getVersionCollection } from '../reducer'; | ||
import { Metadata } from '../../domain/domain.type'; | ||
import { ActivatedRoute } from '@angular/router'; | ||
|
||
@Component({ | ||
selector: 'metadata-comparison', | ||
changeDetection: ChangeDetectionStrategy.OnPush, | ||
templateUrl: './metadata-comparison.component.html', | ||
styleUrls: [] | ||
}) | ||
export class MetadataComparisonComponent { | ||
|
||
versions$: Observable<Metadata[]>; | ||
|
||
constructor( | ||
private store: Store<ConfigurationState>, | ||
private activatedRoute: ActivatedRoute | ||
) { | ||
this.activatedRoute.queryParams.subscribe(versions => console.log(versions)); | ||
} | ||
} |
4 changes: 3 additions & 1 deletion
4
ui/src/app/metadata/configuration/container/metadata-history.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,3 +1,5 @@ | ||
<div class="container"> | ||
<history-list [history]="history$ | async"></history-list> | ||
<history-list | ||
[history]="history$ | async" | ||
(compare)="compareVersions($event)"></history-list> | ||
</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
28 changes: 28 additions & 0 deletions
28
ui/src/app/metadata/configuration/effect/compare.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,28 @@ | ||
import { Injectable } from '@angular/core'; | ||
import { Effect, Actions, ofType } from '@ngrx/effects'; | ||
import { switchMap, catchError, tap, withLatestFrom } from 'rxjs/operators'; | ||
import { of } from 'rxjs'; | ||
import { MetadataHistoryService } from '../service/history.service'; | ||
import { CompareVersionRequest, CompareActionTypes } from '../action/compare.action'; | ||
import { Store } from '@ngrx/store'; | ||
import { State, getConfigurationModel } from '../reducer'; | ||
import { ActivatedRoute, RouterState, RouterStateSnapshot } from '@angular/router'; | ||
|
||
@Injectable() | ||
export class CompareVersionEffects { | ||
|
||
@Effect({dispatch: false}) | ||
compareVersionRequest$ = this.actions$.pipe( | ||
ofType<CompareVersionRequest>(CompareActionTypes.COMPARE_METADATA_REQUEST), | ||
withLatestFrom( | ||
this.store.select(getConfigurationModel) | ||
), | ||
tap((data) => console.log(data, '@type' in data[1])) | ||
); | ||
|
||
constructor( | ||
private historyService: MetadataHistoryService, | ||
private store: Store<State>, | ||
private actions$: Actions | ||
) { } | ||
} |
30 changes: 30 additions & 0 deletions
30
ui/src/app/metadata/configuration/reducer/compare.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,30 @@ | ||
import { CompareActionTypes, CompareActionsUnion } from '../action/compare.action'; | ||
import { Metadata } from '../../domain/domain.type'; | ||
|
||
export interface State { | ||
models: Metadata[]; | ||
loaded: Boolean; | ||
} | ||
|
||
export const initialState: State = { | ||
models: [], | ||
loaded: false | ||
}; | ||
|
||
export function reducer(state = initialState, action: CompareActionsUnion): State { | ||
switch (action.type) { | ||
case CompareActionTypes.SET_VERSIONS: | ||
return { | ||
...state, | ||
models: action.payload, | ||
loaded: true | ||
}; | ||
case CompareActionTypes.CLEAR_VERSIONS: | ||
return { | ||
...initialState | ||
}; | ||
default: { | ||
return state; | ||
} | ||
} | ||
} |
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