From e91bb43c8ad6f95076d6da579419a613023581d0 Mon Sep 17 00:00:00 2001 From: anudeep-ks Date: Thu, 3 Oct 2024 15:28:41 +0530 Subject: [PATCH] Loading message for Survey creation --- .../template-selection.component.html | 11 ++++++++--- .../template-selection.component.ts | 19 ++++++++++++++----- 2 files changed, 22 insertions(+), 8 deletions(-) diff --git a/src/app/modules/template/template-selection/template-selection.component.html b/src/app/modules/template/template-selection/template-selection.component.html index 88d2c38..89f955a 100644 --- a/src/app/modules/template/template-selection/template-selection.component.html +++ b/src/app/modules/template/template-selection/template-selection.component.html @@ -8,9 +8,14 @@

Solution Upload Portal

-
- -
+
+
+ +

{{ loadingMessage }}

+ +
+
+
diff --git a/src/app/modules/template/template-selection/template-selection.component.ts b/src/app/modules/template/template-selection/template-selection.component.ts index 07cb14e..81edae4 100644 --- a/src/app/modules/template/template-selection/template-selection.component.ts +++ b/src/app/modules/template/template-selection/template-selection.component.ts @@ -16,6 +16,7 @@ export class TemplateSelectionComponent implements OnInit { fileInput: any; fileName = ''; loader: boolean = false; + loadingMessage: string = ''; userSelectedFile: any; userUploadedFileType: any; templateLinks: any; @@ -111,44 +112,52 @@ export class TemplateSelectionComponent implements OnInit { validateAndCreateSurvey() { this.loader = true; + this.loadingMessage = 'Survey creation is in progress. Please wait...'; // Set initial loading message if (this.userSelectedFile) { this.templateService.uploadTemplates(this.userSelectedFile).subscribe( (event: any) => { this.templateService.validateTemplates(event.result.templatePath, this.userUploadedFileType, this.templateLinks).subscribe( (data) => { this.templateService.userSelectedFile = event.result.templatePath; - this.loader = false; if (data.result.advancedErrors.data.length == 0 && data.result.basicErrors.data.length == 0) { this.templateService.surveyCreation(this.templateService.userSelectedFile).subscribe( (surveyEvent: any) => { this.solutiondetails = surveyEvent.result[0]; + this.loadingMessage = 'Survey creation completed successfully!'; // Update loading message to success this.router.navigate(['/template/template-success', this.solutiondetails.solutionId], { queryParams: { downloadbleUrl: this.solutiondetails.downloadbleUrl } - }); // Navigate to success page + }); + this.loader = false; // Set loader to false after successful navigation }, (surveyError: any) => { + this.loadingMessage = 'Error creating survey. Please try again.'; // Update loading message to error console.error('Error creating survey:', surveyError); - this.validateTemplate(); + this.validateTemplate(); // Handle error (optional) + this.loader = false; } ); } else { this.templateService.templateError = data.result; + this.loadingMessage = 'Survey validation failed. Please check the errors.'; // Update loading message to validation failure this.router.navigate(['/template/validation-result']); // Navigate to validation result page + this.loader = false; } }, (validationError: any) => { - this.loader = false; + this.loadingMessage = 'Error validating template. Please try again.'; // Update loading message to validation error console.error('Error validating template:', validationError); this.toaster.error('Error validating template'); // Display error message to user + this.loader = false; } ); }, (uploadError: any) => { - this.loader = false; + this.loadingMessage = 'Error uploading file. Please try again.'; // Update loading message to upload error console.error('Error uploading file:', uploadError); this.toaster.error('Error uploading file'); // Display error message to user + this.loader = false; } ); } else {