Add save image parameter
FarmMaps.Develop/FarmMapsLib/pipeline/head This commit looks good Details

2022.01
Willem Dantuma 2021-03-02 13:15:16 +01:00
parent 08163f86bf
commit 2b1cb1ac8f
1 changed files with 12 additions and 7 deletions

View File

@ -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");
}
}
}