From 952812f9f3c4d3a479328d0b4ccaf0af0f1e1388 Mon Sep 17 00:00:00 2001 From: Shaun Lum Date: Fri, 15 Nov 2024 15:31:52 -0800 Subject: [PATCH] fixed download batch and added snackbar close --- frontend/src/components/Batch/BatchRuns.vue | 23 +----- .../Batch/Forms/ArchiveSchoolReportsForm.vue | 6 +- .../Batch/Forms/ArchiveStudentsForm.vue | 6 +- .../components/Batch/Forms/DistrunForm.vue | 14 ++-- .../Batch/Forms/DistrunFormYearEndForm.vue | 6 +- .../Batch/Forms/DistrunUserForm.vue | 78 ++++++++++++------- .../Batch/Forms/GraduationAlgorithmForm.vue | 6 +- .../Batch/Forms/NongradDistrunForm.vue | 6 +- .../src/components/Batch/Forms/PSIForm.vue | 6 +- .../Batch/Forms/RegenerateCertificateForm.vue | 6 +- .../Forms/RegenerateSchoolReportForm.vue | 6 +- .../Forms/TranscriptAlgorithmDeleteForm.vue | 6 +- .../Batch/Forms/TranscriptAlgorithmForm.vue | 6 +- frontend/src/components/Common/Snackbar.vue | 6 +- frontend/src/store/modules/snackbar.js | 2 +- frontend/src/views/BatchProcessing.vue | 1 + 16 files changed, 95 insertions(+), 89 deletions(-) diff --git a/frontend/src/components/Batch/BatchRuns.vue b/frontend/src/components/Batch/BatchRuns.vue index a3e8bfbc..ac72b729 100644 --- a/frontend/src/components/Batch/BatchRuns.vue +++ b/frontend/src/components/Batch/BatchRuns.vue @@ -331,9 +331,7 @@ export default { ], }; }, - created() { - this.getAdminDashboardData(); - }, + created() {}, computed: { ...mapState(useBatchProcessingStore, { batchRuns: "getBatchRuns", @@ -342,10 +340,6 @@ export default { }, methods: { ...mapActions(useBatchProcessingStore, ["setBatchJobs"]), - getRowClass(item) { - // Conditionally apply a class based on the item's status - return item.jobExecutionId === "104848" ? "highlight-row" : ""; - }, rerunBatch(bid) { BatchProcessingService.rerunBatch(bid).then((response) => { if (response) { @@ -400,14 +394,8 @@ export default { }, rerunBatchSchoolReports(bid) { - this.$refs["popover-" + bid].$emit("close"); BatchProcessingService.rerunBatchSchoolReports(bid).then((response) => { if (response) { - // this.$bvToast.toast("Running school reports for batch job #" + bid, { - // title: "SCHOOL REPORTS BATCH", - // variant: "success", - // noAutoHide: true, - // }); this.snackbarStore.showSnackbar( "Running school reports for batch job #" + bid, "success", @@ -419,17 +407,8 @@ export default { }); }, rerunBatch(bid) { - this.$refs["popover-" + bid].$emit("close"); BatchProcessingService.rerunBatch(bid).then((response) => { if (response) { - // this.$bvToast.toast( - // "Created a new batch job based on batch #" + bid, - // { - // title: "NEW BATCH JOB STARTED", - // variant: "success", - // noAutoHide: true, - // } - // ); this.snackbarStore.showSnackbar( "Created a new batch job based on batch #" + bid, "success", diff --git a/frontend/src/components/Batch/Forms/ArchiveSchoolReportsForm.vue b/frontend/src/components/Batch/Forms/ArchiveSchoolReportsForm.vue index e212ec73..9d923cb0 100644 --- a/frontend/src/components/Batch/Forms/ArchiveSchoolReportsForm.vue +++ b/frontend/src/components/Batch/Forms/ArchiveSchoolReportsForm.vue @@ -383,7 +383,7 @@ export default { if (this.getBatchRequestCrontime) { this.snackbarStore.showSnackbar( "Archive School Reports Process has been successfully scheduled", - 5000 + 10000 ); } else { this.snackbarStore.showSnackbar( @@ -391,7 +391,7 @@ export default { response.data.batchId + "- Archive School Reports Process submitted", "success", - 5000 + 10000 ); } this.batchLoading = false; @@ -405,7 +405,7 @@ export default { this.snackbarStore.showSnackbar( "An error occurred: " + error.message, "danger", - 5000 + 10000 ); } }, diff --git a/frontend/src/components/Batch/Forms/ArchiveStudentsForm.vue b/frontend/src/components/Batch/Forms/ArchiveStudentsForm.vue index 8c437fdd..ec3f87e3 100644 --- a/frontend/src/components/Batch/Forms/ArchiveStudentsForm.vue +++ b/frontend/src/components/Batch/Forms/ArchiveStudentsForm.vue @@ -413,7 +413,7 @@ export default { if (this.getBatchRequestCrontime) { this.snackbarStore.showSnackbar( "Archive student batch process has been successfully scheduled", - 5000 + 10000 ); } else { this.snackbarStore.showSnackbar( @@ -421,7 +421,7 @@ export default { response.data.batchId + "- Archive student batch process submitted", "success", - 5000 + 10000 ); } this.closeDialogAndResetForm(); @@ -435,7 +435,7 @@ export default { this.snackbarStore.showSnackbar( "An error occurred: " + error.message, "danger", - 5000 + 10000 ); } }, diff --git a/frontend/src/components/Batch/Forms/DistrunForm.vue b/frontend/src/components/Batch/Forms/DistrunForm.vue index 27e3f6c1..d9123a9d 100644 --- a/frontend/src/components/Batch/Forms/DistrunForm.vue +++ b/frontend/src/components/Batch/Forms/DistrunForm.vue @@ -279,12 +279,12 @@ export default { if (error.response.statusText) { this.snackbarStore.showSnackbar( "ERROR " + error.response.statusText, - 5000 + 10000 ); } else { this.snackbarStore.showSnackbar( "ERROR " + "error with webservervice", - 5000 + 10000 ); } }); @@ -299,12 +299,12 @@ export default { if (error.response.statusText) { this.snackbarStore.showSnackbar( "ERROR " + error.response.statusText, - 5000 + 10000 ); } else { this.snackbarStore.showSnackbar( "ERROR " + "error with webservervice", - 5000 + 10000 ); } }); @@ -353,7 +353,7 @@ export default { if (this.getBatchRequestCrontime) { this.snackbarStore.showSnackbar( "Credentials and Transcript Distribution Run request has been successfully scheduled", - 5000 + 10000 ); } else { this.snackbarStore.showSnackbar( @@ -361,7 +361,7 @@ export default { response.data.batchId + "- Credentials and Transcript Distribution Run request submitted", "success", - 5000 + 10000 ); } } @@ -377,7 +377,7 @@ export default { this.snackbarStore.showSnackbar( "An error occurred: " + error.message, "error", - 5000 + 10000 ); } }, diff --git a/frontend/src/components/Batch/Forms/DistrunFormYearEndForm.vue b/frontend/src/components/Batch/Forms/DistrunFormYearEndForm.vue index dc6e30a4..e4755d6f 100644 --- a/frontend/src/components/Batch/Forms/DistrunFormYearEndForm.vue +++ b/frontend/src/components/Batch/Forms/DistrunFormYearEndForm.vue @@ -287,7 +287,7 @@ export default { if (this.getBatchRequestCrontime) { this.snackbarStore.showSnackbar( "Year-End Credentials and Transcript Distribution Run has been successfully scheduled", - 5000 + 10000 ); } else { this.snackbarStore.showSnackbar( @@ -295,7 +295,7 @@ export default { response.data.batchId + "- Year-End Credentials and Transcript Distribution Run submitted", "success", - 5000 + 10000 ); } this.closeDialogAndResetForm(); @@ -308,7 +308,7 @@ export default { this.snackbarStore.showSnackbar( "An error occurred: " + error.message, "danger", - 5000 + 10000 ); } }, diff --git a/frontend/src/components/Batch/Forms/DistrunUserForm.vue b/frontend/src/components/Batch/Forms/DistrunUserForm.vue index 120e36a8..6ccd8f22 100644 --- a/frontend/src/components/Batch/Forms/DistrunUserForm.vue +++ b/frontend/src/components/Batch/Forms/DistrunUserForm.vue @@ -21,6 +21,7 @@ color="error" variant="outlined" class="m-4" + :loading="batchLoading" >Cancel @@ -539,7 +540,7 @@ export default { if (error.response.statusText) { console.log("ERROR " + error.response.statusText, "danger"); } else { - console.log("ERROR " + "error with webservervice", "danger"); + console.log("ERROR " + "error with webservice", "danger"); } }); }, @@ -553,12 +554,14 @@ export default { if (error.response.statusText) { this.snackbarStore.showSnackbar( "ERROR " + error.response.statusText, - 5000 + "danger", + 10000 ); } else { this.snackbarStore.showSnackbar( - "ERROR " + "error with webservervice", - 5000 + "ERROR " + "error with web service", + "danger", + 10000 ); } }); @@ -605,41 +608,64 @@ export default { ) { requestPayload.schoolOfRecords = ["00000000"]; } - let response = await BatchProcessingService.runDISTRUNUSER( + + BatchProcessingService.runDISTRUNUSER( requestPayload, this.getCredential, this.getBatchRequestCrontime - ); - if (response) { - this.batchLoading = false; - if (this.getBatchRequestCrontime) { - this.snackbarStore.showSnackbar( - "User distribution batch request has been successfully scheduled", - 5000 - ); - } else { + ) + .then((response) => { + if (response && this.batchLoading) { + this.batchLoading = false; + if (this.getBatchRequestCrontime) { + this.snackbarStore.showSnackbar( + "User distribution batch request has been successfully scheduled", + 10000 + ); + } else { + this.snackbarStore.showSnackbar( + "Batch " + + response.data.batchId + + "- User distribution batch request submitted", + "success", + 10000 + ); + } + this.setActiveTab("batchRuns"); + this.closeDialogAndResetForm(); + //add a wait before updating dashboard + setTimeout(() => { + this.updateDashboards(); + }, 2000); + } + }) + .catch((error) => { + // handle any errors here + }); + setTimeout(() => { + //Close the request after 5 seconds. + if (this.batchLoading) { + this.batchLoading = false; this.snackbarStore.showSnackbar( - "Batch " + - response.data.batchId + - "- User distribution batch request submitted", + "The user distribution batch request is currently running in the background. Click the Update button on the Batch Processing page to view the results once the job is complete.", "success", - 5000 + 10000 ); + this.setActiveTab("batchRuns"); + this.closeDialogAndResetForm(); + //add a wait before updating dashboard + setTimeout(() => { + this.updateDashboards(); + }, 2000); } - } - this.setActiveTab("batchRuns"); - this.closeDialogAndResetForm(); - //add a wait before updating dashboard - setTimeout(() => { - this.updateDashboards(); - }, 2000); + }, 10000); } catch (error) { // handle the error and show the notification console.error("Error:", error); this.snackbarStore.showSnackbar( "An error occurred: " + error.message, "error", - 5000 + 10000 ); } }, diff --git a/frontend/src/components/Batch/Forms/GraduationAlgorithmForm.vue b/frontend/src/components/Batch/Forms/GraduationAlgorithmForm.vue index 6ab6cf7c..a1071734 100644 --- a/frontend/src/components/Batch/Forms/GraduationAlgorithmForm.vue +++ b/frontend/src/components/Batch/Forms/GraduationAlgorithmForm.vue @@ -362,7 +362,7 @@ export default { if (this.getBatchRequestCrontime) { this.snackbarStore.showSnackbar( "Graduation Algorithm request has been successfully scheduled", - 5000 + 10000 ); } else { this.snackbarStore.showSnackbar( @@ -370,7 +370,7 @@ export default { response.data.batchId + "- Graduation Algorithm request submitted", "success", - 5000 + 10000 ); } @@ -385,7 +385,7 @@ export default { this.snackbarStore.showSnackbar( "An error occurred: " + error.message, "danger", - 5000 + 10000 ); this.batchLoading = false; console.error("Error:", error); diff --git a/frontend/src/components/Batch/Forms/NongradDistrunForm.vue b/frontend/src/components/Batch/Forms/NongradDistrunForm.vue index 224b25f3..f1310df5 100644 --- a/frontend/src/components/Batch/Forms/NongradDistrunForm.vue +++ b/frontend/src/components/Batch/Forms/NongradDistrunForm.vue @@ -288,7 +288,7 @@ export default { if (this.getBatchRequestCrontime) { this.snackbarStore.showSnackbar( "Non-Graduate Transcript Distribution Run has been successfully scheduled", - 5000 + 10000 ); } else { this.snackbarStore.showSnackbar( @@ -296,7 +296,7 @@ export default { response.data.batchId + "- Non-Graduate Transcript Distribution Run submitted", "success", - 5000 + 10000 ); } this.closeDialogAndResetForm(); @@ -309,7 +309,7 @@ export default { this.snackbarStore.showSnackbar( "An error occurred: " + error.message, "danger", - 5000 + 10000 ); } }, diff --git a/frontend/src/components/Batch/Forms/PSIForm.vue b/frontend/src/components/Batch/Forms/PSIForm.vue index 2a4cac7c..e50a1e27 100644 --- a/frontend/src/components/Batch/Forms/PSIForm.vue +++ b/frontend/src/components/Batch/Forms/PSIForm.vue @@ -299,7 +299,7 @@ export default { if (this.getBatchRequestCrontime) { this.snackbarStore.showSnackbar( "PSI Run FTP / Paper has been successfully scheduled", - 5000 + 10000 ); } else { this.snackbarStore.showSnackbar( @@ -307,7 +307,7 @@ export default { response.data.batchId + "- PSI Run FTP / Paper submitted", "success", - 5000 + 10000 ); } this.closeDialogAndResetForm(); @@ -320,7 +320,7 @@ export default { this.snackbarStore.showSnackbar( "An error occurred: " + error.message, "danger", - 5000 + 10000 ); } }, diff --git a/frontend/src/components/Batch/Forms/RegenerateCertificateForm.vue b/frontend/src/components/Batch/Forms/RegenerateCertificateForm.vue index c5929421..39943edf 100644 --- a/frontend/src/components/Batch/Forms/RegenerateCertificateForm.vue +++ b/frontend/src/components/Batch/Forms/RegenerateCertificateForm.vue @@ -301,7 +301,7 @@ export default { if (this.getBatchRequestCrontime) { this.snackbarStore.showSnackbar( "User Request Certificate Regeneration has been successfully scheduled", - 5000 + 10000 ); } else { this.snackbarStore.showSnackbar( @@ -309,7 +309,7 @@ export default { response.data.batchId + "- User Request Certificate Regeneration submitted", "success", - 5000 + 10000 ); } this.closeDialogAndResetForm(); @@ -322,7 +322,7 @@ export default { this.snackbarStore.showSnackbar( "An error occurred: " + error.message, "danger", - 5000 + 10000 ); } }, diff --git a/frontend/src/components/Batch/Forms/RegenerateSchoolReportForm.vue b/frontend/src/components/Batch/Forms/RegenerateSchoolReportForm.vue index 12a665f2..44ccb90b 100644 --- a/frontend/src/components/Batch/Forms/RegenerateSchoolReportForm.vue +++ b/frontend/src/components/Batch/Forms/RegenerateSchoolReportForm.vue @@ -333,7 +333,7 @@ export default { if (this.getBatchRequestCrontime) { this.snackbarStore.showSnackbar( "User Request School Report Regeneration has been successfully scheduled", - 5000 + 10000 ); } else { this.snackbarStore.showSnackbar( @@ -341,7 +341,7 @@ export default { response.data.batchId + "- User Request School Report Regeneration submitted", "success", - 5000 + 10000 ); } this.closeDialogAndResetForm(); @@ -354,7 +354,7 @@ export default { this.snackbarStore.showSnackbar( "An error occurred: " + error.message, "danger", - 5000 + 10000 ); } }, diff --git a/frontend/src/components/Batch/Forms/TranscriptAlgorithmDeleteForm.vue b/frontend/src/components/Batch/Forms/TranscriptAlgorithmDeleteForm.vue index e55b4cff..64796406 100644 --- a/frontend/src/components/Batch/Forms/TranscriptAlgorithmDeleteForm.vue +++ b/frontend/src/components/Batch/Forms/TranscriptAlgorithmDeleteForm.vue @@ -328,13 +328,13 @@ export default { if (this.getBatchRequestCrontime) { this.snackbarStore.showSnackbar( "Transcript verification report delete has been successfully scheduled", - 5000 + 10000 ); } else { this.snackbarStore.showSnackbar( "Transcript verification report delete request submitted", "success", - 5000 + 10000 ); } this.closeDialogAndResetForm(); @@ -348,7 +348,7 @@ export default { this.snackbarStore.showSnackbar( "An error occurred: " + error.message, "danger", - 5000 + 10000 ); } }, diff --git a/frontend/src/components/Batch/Forms/TranscriptAlgorithmForm.vue b/frontend/src/components/Batch/Forms/TranscriptAlgorithmForm.vue index ee492816..51564c47 100644 --- a/frontend/src/components/Batch/Forms/TranscriptAlgorithmForm.vue +++ b/frontend/src/components/Batch/Forms/TranscriptAlgorithmForm.vue @@ -345,13 +345,13 @@ export default { if (this.getBatchRequestCrontime) { this.snackbarStore.showSnackbar( "Transcript verification report has been successfully scheduled", - 5000 + 10000 ); } else { this.snackbarStore.showSnackbar( "Transcript verification report request submitted", "success", - 5000 + 10000 ); } this.setActiveTab("batchRuns"); @@ -365,7 +365,7 @@ export default { this.snackbarStore.showSnackbar( "An error occurred: " + error.message, "danger", - 5000 + 10000 ); console.error("Error:", error); } diff --git a/frontend/src/components/Common/Snackbar.vue b/frontend/src/components/Common/Snackbar.vue index 07d2f864..e3352b7a 100644 --- a/frontend/src/components/Common/Snackbar.vue +++ b/frontend/src/components/Common/Snackbar.vue @@ -4,12 +4,12 @@ :timeout="snackbarStore.timeout" :color="snackbarStore.color" location="top right" - vertical + multi-line >

{{ snackbarStore.title }}

{{ snackbarStore.message }}

- diff --git a/frontend/src/store/modules/snackbar.js b/frontend/src/store/modules/snackbar.js index 93ba0845..1023d96e 100644 --- a/frontend/src/store/modules/snackbar.js +++ b/frontend/src/store/modules/snackbar.js @@ -8,7 +8,7 @@ export const useSnackbarStore = defineStore("snackbar", () => { const timeout = ref(5000); const title = ref(""); - const showSnackbar = (msg = "", col = "success", time = 5000, ti = "") => { + const showSnackbar = (msg = "", col = "success", time = 7500, ti = "") => { message.value = msg; color.value = col; timeout.value = time; diff --git a/frontend/src/views/BatchProcessing.vue b/frontend/src/views/BatchProcessing.vue index 972a999f..55c1882d 100644 --- a/frontend/src/views/BatchProcessing.vue +++ b/frontend/src/views/BatchProcessing.vue @@ -85,6 +85,7 @@ hide-default-footer :sortBy="[{ key: 'displayOrder', order: 'asc' }]" class="pb-3" + :loading="!batchRunGradOptions" >