@@ -38,6 +38,9 @@ import {
3838 updateModel ,
3939 updateModelFail ,
4040 updateModelSuccess ,
41+ loadModel ,
42+ loadModelFail ,
43+ loadModelSuccess ,
4144} from './action' ;
4245import { ServiceTypes } from 'src/app/data/enums/service-types.enum' ;
4346import { Store } from '@ngrx/store' ;
@@ -51,7 +54,18 @@ export class ModelEffects {
5154 private snackBarService : SnackBarService ,
5255 private router : Router ,
5356 private store : Store < any >
54- ) { }
57+ ) { }
58+
59+ @Effect ( )
60+ loadModel$ = this . actions . pipe (
61+ ofType ( loadModel ) ,
62+ switchMap ( action =>
63+ this . modelService . getModel ( action . applicationId , action . selectedModelId ) . pipe (
64+ map ( model => loadModelSuccess ( { model } ) ) ,
65+ catchError ( error => of ( loadModelFail ( { error } ) ) )
66+ )
67+ )
68+ ) ;
5569
5670 @Effect ( )
5771 loadModels$ = this . actions . pipe (
@@ -69,8 +83,8 @@ export class ModelEffects {
6983 @Effect ( )
7084 createModel$ = this . actions . pipe (
7185 ofType ( createModel ) ,
72- tap ( ( { model } ) => this . isFirtsService = model . isFirstService ) ,
73- switchMap ( ( action ) =>
86+ tap ( ( { model } ) => ( this . isFirtsService = model . isFirstService ) ) ,
87+ switchMap ( action =>
7488 this . modelService . create ( action . model . applicationId , action . model . name , action . model . type ) . pipe (
7589 map ( model => createModelSuccess ( { model } ) ) ,
7690 catchError ( error => of ( createModelFail ( { error } ) ) )
@@ -83,24 +97,25 @@ export class ModelEffects {
8397 ofType ( createModelSuccess ) ,
8498 withLatestFrom ( this . store . select ( selectCurrentApp ) ) ,
8599 tap ( ( [ { model } , app ] ) => {
86- if ( this . isFirtsService ) {
87- model . type === ServiceTypes . Recognition ?
88- this . router . navigate ( [ Routes . ManageCollection ] , {
89- queryParams : {
90- app : app . id ,
91- model : model . id ,
92- type : model . type ,
93- } ,
94- } ) : this . router . navigate ( [ Routes . TestModel ] , {
95- queryParams : {
96- app : app . id ,
97- model : model . id ,
98- type : model . type ,
99- } ,
100- } ) ;
100+ if ( this . isFirtsService ) {
101+ model . type === ServiceTypes . Recognition
102+ ? this . router . navigate ( [ Routes . ManageCollection ] , {
103+ queryParams : {
104+ app : app . id ,
105+ model : model . id ,
106+ type : model . type ,
107+ } ,
108+ } )
109+ : this . router . navigate ( [ Routes . TestModel ] , {
110+ queryParams : {
111+ app : app . id ,
112+ model : model . id ,
113+ type : model . type ,
114+ } ,
115+ } ) ;
101116 }
102117 } )
103- )
118+ ) ;
104119
105120 @Effect ( )
106121 updateModel$ = this . actions . pipe (
0 commit comments