Skip to content

Commit

Permalink
Improved: support to check and refresh current job if the nextExecuti…
Browse files Browse the repository at this point in the history
…on time is passed (hotwax#734)
  • Loading branch information
amansinghbais committed Nov 15, 2024
1 parent 59779b5 commit 4304ade
Showing 1 changed file with 36 additions and 15 deletions.
51 changes: 36 additions & 15 deletions src/components/MaargJobConfiguration.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@
<ion-button fill="outline" slot="end" v-if="isRefreshRequired" @click="refreshCurrentJob">
<ion-icon :icon="refreshOutline" slot="icon-only" />
</ion-button>
<ion-badge slot="end" color="medium" v-if="currentMaargJob.paused === 'Y'">{{ translate("Disabled") }}</ion-badge>
<ion-badge slot="end" color="dark" v-else-if="currentMaargJob?.nextExecutionDateTime && !isRefreshRequired">{{ translate("running") }} {{ timeTillJob(currentMaargJob.nextExecutionDateTime) }}</ion-badge>
<ion-badge slot="end" color="dark" v-if="currentMaargJob.paused === 'N' && currentMaargJob?.nextExecutionDateTime && !isRefreshRequired">{{ translate("running") }} {{ timeTillJob(currentMaargJob.nextExecutionDateTime) }}</ion-badge>
</ion-item>

<ion-list>
Expand Down Expand Up @@ -123,6 +122,7 @@ import { Actions, hasPermission } from '@/authorization'
import { MaargJobService } from "@/services/MaargJobService";
import ScheduleModal from "@/components/ScheduleModal.vue"
import MaargJobParameterModal from "@/components/MaargJobParameterModal.vue"
import emitter from '@/event-bus';
export default defineComponent({
name: "MaargJobConfiguration",
Expand Down Expand Up @@ -215,6 +215,13 @@ export default defineComponent({
}, {
text: translate('Cancel'),
handler: async () => {
if(this.isRuntimePassed()) {
this.isRefreshRequired = true
emitter.emit("productStoreOrConfigChanged")
showToast(translate("Job runtime has passed. Please refresh to get the latest job data in order to perform any action."))
return;
}
try {
const resp = await MaargJobService.updateMaargJob({ ...job, paused: "Y" })
if(!hasError(resp)) {
Expand Down Expand Up @@ -243,12 +250,12 @@ export default defineComponent({
}, {
text: translate('Confirm'),
handler: () => {
// if(this.isRuntimePassed()) {
// this.isRefreshRequired = true
// emitter.emit("productStoreOrConfigChanged")
// showToast(translate("Job runtime has passed. Please refresh to get the latest job data in order to perform any action."))
// return;
// }
if(this.isRuntimePassed()) {
this.isRefreshRequired = true
emitter.emit("productStoreOrConfigChanged")
showToast(translate("Job runtime has passed. Please refresh to get the latest job data in order to perform any action."))
return;
}
this.updateJob();
}
Expand All @@ -269,12 +276,12 @@ export default defineComponent({
}, {
text: translate('Save'),
handler: () => {
// if(this.isRuntimePassed()) {
// this.isRefreshRequired = true
// emitter.emit("productStoreOrConfigChanged")
// showToast(translate("Job runtime has passed. Please refresh to get the latest job data in order to perform any action."))
// return;
// }
if(this.isRuntimePassed()) {
this.isRefreshRequired = true
emitter.emit("productStoreOrConfigChanged")
showToast(translate("Job runtime has passed. Please refresh to get the latest job data in order to perform any action."))
return;
}
this.updateJob();
}
Expand Down Expand Up @@ -359,7 +366,21 @@ export default defineComponent({
})
await jobParameterModal.present();
}
},
async refreshCurrentJob() {
const job = this.getMaargJob(this.currentMaargJob.jobTypeEnumId)
await this.store.dispatch("maargJob/updateCurrentMaargJob", { job })
this.selectedCronExpression = this.currentMaargJob.cronExpression
this.customOptionalParameters = generateMaargJobCustomOptions(this.currentMaargJob).optionalParameters;
this.customRequiredParameters = generateMaargJobCustomOptions(this.currentMaargJob).requiredParameters;
this.isRefreshRequired = false
},
isRuntimePassed() {
return this.currentMaargJob.nextExecutionDateTime <= DateTime.now().toMillis()
},
},
setup() {
const store = useStore();
Expand Down

0 comments on commit 4304ade

Please sign in to comment.