@@ -79,7 +79,6 @@ import { finalize, map, Subscription, switchMap } from 'rxjs';
7979import { FileService } from '../core/services/file.service' ;
8080import { ToggleSidenavService } from '../core/services/toggle-sidenav.service' ;
8181import { FileNode , FileNodeInsertAttributeParams , FileNodeInsertParams } from '../models/file-node' ;
82- import { ProfileDescription } from '../models/profile-description.model' ;
8382import { ProfileResponse } from '../models/profile-response' ;
8483import { EditProfileComponent } from '../profile/edit-profile/edit-profile.component' ;
8584import { ProfileService } from '../core/services/profile.service' ;
@@ -108,8 +107,7 @@ export class MainComponent implements OnInit, OnDestroy {
108107 events : string [ ] = [ ] ;
109108
110109 uploadedProfileResponse : ProfileResponse ;
111-
112- uploadedProfileSelected : ProfileDescription ;
110+ uploadedProfileByFile : ProfileResponse ;
113111
114112 private _routeParamsSubscription : Subscription ;
115113 private _profileLoadingSubscription : Subscription ;
@@ -130,6 +128,8 @@ export class MainComponent implements OnInit, OnDestroy {
130128 this . pendingSub = this . sideNavService . isPending . subscribe ( ( status ) => {
131129 this . pending = status ;
132130 } ) ;
131+ const navigation = this . router . getCurrentNavigation ( ) ;
132+ this . uploadedProfileByFile = navigation ?. extras . state ?. payload ;
133133 }
134134
135135 ngOnInit ( ) {
@@ -144,7 +144,9 @@ export class MainComponent implements OnInit, OnDestroy {
144144 } else {
145145 // Check for query params to create a new profile
146146 this . route . queryParams . subscribe ( ( queryParams ) => {
147- if ( queryParams [ 'type' ] && queryParams [ 'version' ] ) {
147+ if ( this . uploadedProfileByFile !== undefined ) {
148+ this . uploadNewProfile ( ) ;
149+ } else if ( queryParams [ 'type' ] && queryParams [ 'version' ] ) {
148150 const type : ProfileType = queryParams ?. type ;
149151 const version : ProfileVersion = queryParams ?. version ;
150152 this . createNewProfile ( type , version ) ;
@@ -241,4 +243,19 @@ export class MainComponent implements OnInit, OnDestroy {
241243 )
242244 . subscribe ( ) ;
243245 }
246+
247+ private uploadNewProfile ( ) {
248+ this . loaderService . start ( ) ;
249+ this . profileService
250+ . getMetaModel ( this . uploadedProfileByFile . sedaVersion )
251+ . pipe (
252+ map ( ( metaModel ) => {
253+ this . sedaService . setMetaModel ( metaModel ) ;
254+ this . fileService . linkFileNodeToSedaData ( null , [ this . uploadedProfileByFile . profile ] ) ;
255+ this . fileService . updateTreeWithProfile ( this . uploadedProfileByFile ) ;
256+ } ) ,
257+ finalize ( ( ) => this . loaderService . stop ( ) ) ,
258+ )
259+ . subscribe ( ) ;
260+ }
244261}
0 commit comments