in frontend/src/app/content-creator/service/add-service/add-service.component.ts [152:167]
async generateImages() {
if (this.firstFormGroup.value.firstCtrl && this.firstFormGroup.value.secondCtrl) {
this.loading = true;
this.isImageGenerated = true;
const imagePrompt = `Generate an image for this service: \n Title: ${this.firstFormGroup.value.firstCtrl} Description: ${this.firstFormGroup.value.secondCtrl}`
this.creatorService.generateImage(imagePrompt, NUM_IMAGES_TO_GENERATE).subscribe((res) => {
this.imagesNames = res.generated_images.map((generatedImage: any) => generatedImage.image_name);
Promise.all(this.imagesNames.map(
(imageName) => this.firebaseService.imageNameToDownloadURL(imageName).then(
(imageURL) => this.previews.push(imageURL)))).then(() => this.imageDisplay = this.previews[0]);
this.loading = false;
this.stepper.next();
});
}
}