Skip to content

Commit 07c7f0e

Browse files
author
Hassane Diaby
committed
Bug #15500 : pastis - Cannot open profile from desktop
1 parent 7e68678 commit 07c7f0e

File tree

2 files changed

+30
-7
lines changed

2 files changed

+30
-7
lines changed

ui/ui-frontend/projects/pastis/src/app/main/main.component.ts

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,6 @@ import { finalize, map, Subscription, switchMap } from 'rxjs';
7979
import { FileService } from '../core/services/file.service';
8080
import { ToggleSidenavService } from '../core/services/toggle-sidenav.service';
8181
import { FileNode, FileNodeInsertAttributeParams, FileNodeInsertParams } from '../models/file-node';
82-
import { ProfileDescription } from '../models/profile-description.model';
8382
import { ProfileResponse } from '../models/profile-response';
8483
import { EditProfileComponent } from '../profile/edit-profile/edit-profile.component';
8584
import { 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
}

ui/ui-frontend/projects/pastis/src/app/shared/pastis-popup-option/pastis-popup-option.component.ts

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -147,9 +147,15 @@ export class PastisPopupOptionComponent implements OnInit, OnDestroy {
147147
const formData = new FormData();
148148
formData.append('file', fileToUpload, fileToUpload.name);
149149
this.profileService.uploadProfile(formData).subscribe((response: any) => {
150-
if (response && response.id) {
151-
// Navigate to edit page with the profile ID
152-
this.router.navigate(['edit', response.id], {
150+
if (response) {
151+
this.router.navigate(['new'], {
152+
state: {
153+
payload: response,
154+
},
155+
queryParams: {
156+
type: response.type,
157+
version: response.sedaVersion,
158+
},
153159
relativeTo: this.route,
154160
});
155161
}

0 commit comments

Comments
 (0)