Skip to content

Commit

Permalink
SNRGY-2919: add save and release button to smart-service designer
Browse files Browse the repository at this point in the history
  • Loading branch information
IngoRoessner committed Oct 25, 2023
1 parent 43b9126 commit fac3e22
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@
<button mat-icon-button matTooltip="Save" (click)="save()">
<mat-icon>save</mat-icon>
</button>
<button mat-icon-button matTooltip="Save and Release" (click)="saveAndRelease()">
<mat-icon>save_as</mat-icon>
</button>
</div>
<div fxLayout="row" fxFlex [fxShow]="ready">
<div class="canvas" id="js-canvas" fxFlex></div>
Expand Down
48 changes: 40 additions & 8 deletions src/app/modules/smart-services/designer/designer.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,31 @@ export class SmartServiceDesignerComponent implements OnInit {
}, this.handleError);
}

saveAndRelease(): void {
this.saveThen((design: SmartServiceDesignModel | null) => {
if (design) {
this.snackBar.open('Model saved.', undefined, { duration: 2000 });
this.releaseDesign(design, ()=>{
if(this.id === '') {
this.router.navigate(['/smart-services/designer/'+design.id]);
}
})
}
})
}

save(): void {
this.saveThen((design: SmartServiceDesignModel | null) => {
if (design) {
this.snackBar.open('Model saved.', undefined, { duration: 2000 });
if(this.id === '') {
this.router.navigate(['/smart-services/designer/'+design.id]);
}
}
})
}

saveThen(then: ((design: SmartServiceDesignModel | null)=>void)): void {
this.saveXML((errXML, processXML) => {
if (errXML) {
this.snackBar.open('Error XML! ' + errXML, 'close', { panelClass: 'snack-bar-error' });
Expand All @@ -215,14 +239,7 @@ export class SmartServiceDesignerComponent implements OnInit {
this.name = result.name;
this.description = result.description;
const model = { id: this.id, svg_xml: svgXML, bpmn_xml: processXML, name: result.name, description: result.description, user_id: '' };
this.designsService.saveDesign(model).subscribe((result2: SmartServiceDesignModel | null) => {
if (result2) {
this.snackBar.open('Model saved.', undefined, { duration: 2000 });
if(this.id === '') {
this.router.navigate(['/smart-services/designer/'+result2.id]);
}
}
});
this.designsService.saveDesign(model).subscribe(then);
}
});
}
Expand All @@ -231,6 +248,21 @@ export class SmartServiceDesignerComponent implements OnInit {
});
}

releaseDesign(design: SmartServiceDesignModel, then: ()=>void): void {
this.dialogService.openInputDialog('Release Name and Description', {name: design.name, description: design.description}, ['name'])
.afterClosed()
.subscribe((result: {name: string; description: string}) => {
this.releaseService.createRelease({design_id: design.id, name: result.name, description: result.description}).subscribe(value => {
if(value) {
this.snackBar.open('Release created.', undefined, { duration: 2000 });
} else {
this.snackBar.open('Error while creating a release !', 'close', { panelClass: 'snack-bar-error' });
}
then();
});
});
}

importBPMN(event: any): void {
const file = event.target.files[0];
if (file) {
Expand Down

0 comments on commit fac3e22

Please sign in to comment.