From 2b1cb1ac8f8eeaace6866771b4698f43d6d4eb2e Mon Sep 17 00:00:00 2001 From: Willem Dantuma Date: Tue, 2 Mar 2021 13:15:16 +0100 Subject: [PATCH] Add save image parameter --- .../edit-image-modal.component.ts | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/projects/common/src/fm/components/edit-image-modal/edit-image-modal.component.ts b/projects/common/src/fm/components/edit-image-modal/edit-image-modal.component.ts index c43eb88..a9ab44c 100644 --- a/projects/common/src/fm/components/edit-image-modal/edit-image-modal.component.ts +++ b/projects/common/src/fm/components/edit-image-modal/edit-image-modal.component.ts @@ -25,17 +25,19 @@ export class EditImageModalComponent implements OnInit { maxWidth:number = 200; roundImage:boolean = false; imageType:string = "jpeg"; + saveImage:boolean = true; ngOnInit(): void { } - open(endpoint:string,aspectRatio:number,roundImage?:boolean,maxWidth?:number, imageType?:string) { + open(endpoint:string,aspectRatio:number,roundImage?:boolean,maxWidth?:number,saveImage?:boolean, imageType?:string) { this.endpointUrl = endpoint; this.imageUrl = endpoint; this.aspectRatio= aspectRatio; this.roundImage = roundImage === undefined?this.roundImage:roundImage; this.maxWidth = maxWidth === undefined?this.maxWidth:maxWidth; this.imageType = imageType === undefined?this.imageType:imageType.substr(6); + this.saveImage = saveImage === undefined?this.saveImage:saveImage; this.modalService.open(this.modal,{ size: 'lg' }); } @@ -57,12 +59,15 @@ export class EditImageModalComponent implements OnInit { save() { if(this.croppedImage) { - - var body = this.croppedImage.substr(23); - this.imageService.putImage(this.endpointUrl,this.imageService.b64toBlob(body,"image/jpeg")).subscribe(() => { - this.changed.emit({}); - }); - this,this.modalService.dismissAll("Save"); + if(this.saveImage) { + var body = this.croppedImage.substr(23); + this.imageService.putImage(this.endpointUrl,this.imageService.b64toBlob(body,"image/jpeg")).subscribe(() => { + this.changed.emit({}); + }); + } else { + this.changed.emit(this.croppedImage); + } + this.modalService.dismissAll("Save"); } } }