Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improved: logic to run the job successfully on clicking runNow(#147) #153

Merged
merged 3 commits into from
Apr 4, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 25 additions & 4 deletions src/views/BrokeringRoute.vue
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@
<h2>{{ translate("History") }}</h2>
<ion-button v-if="groupHistory.length" fill="clear" @click="showGroupHistory" slot="end">{{ translate("View All") }}</ion-button>
</ion-item>
<p class="empty-state" v-if="!groupHistory.length">{{ translate("No available history for this group") }}</p>
<p class="empty-state" v-if="!groupHistory.length || !groupHistory[0].startTime">{{ translate("No available history for this group") }}</p>
<ion-item v-else>
<ion-label>
<h3>{{ getTime(groupHistory[0].startTime) }}</h3>
Expand Down Expand Up @@ -114,9 +114,9 @@
</ion-item>
<ion-item lines="none">
<ion-icon slot="start" :icon="timerOutline"/>
<!-- When the group is in draft status, do not display the frequency and juust display the label for schedule -->
<ion-label v-if="job.paused === 'Y'">{{ translate("Schedule") }}</ion-label>
<ion-label v-if="job.paused === 'Y'" slot="end">{{ "-" }}</ion-label>
<!-- When the group is in draft status or the job is not present, do not display the frequency and just display the label for schedule -->
<ion-label v-if="!job.paused || job.paused === 'Y'">{{ translate("Schedule") }}</ion-label>
<ion-label v-if="!job.paused || job.paused === 'Y'" slot="end">{{ "-" }}</ion-label>
<ion-select v-else :label="translate('Schedule')" interface="popover" :placeholder="translate('Select')" :value="job.cronExpression" @ionChange="updateCronExpression($event)">
<ion-select-option v-for="(expression, description) in cronExpressions" :key="expression" :value="expression">{{ description }}</ion-select-option>
</ion-select>
Expand Down Expand Up @@ -352,6 +352,27 @@ async function runNow() {
{
text: translate("Run now"),
handler: async () => {
// Checking that if we already have the job schedule before calling runNow, because if the job scheduler is not present then runNow action can't be performed
// If the scheduler for the job is available then we will have jobName, if not then first scheduling the job in draft status just to create a routing schedule and then calling runNow action
if(!job.value.jobName) {
const payload = {
routingGroupId: props.routingGroupId,
paused: "Y", // passing Y as we just need to configure the scheduler and do not need to schedule it in active state
}

try {
const resp = await OrderRoutingService.scheduleBrokering(payload)
if(hasError(resp)) {
throw resp.data
}
// Updating jobName as if the user again clicks the runNow button then in that we don't want to call the scheduleBrokering service
job.value.jobName = resp.data.jobName
} catch(err) {
logger.error(err)
return;
}
}

try {
const resp = await OrderRoutingService.runNow(props.routingGroupId)
if(!hasError(resp) && resp.data.jobRunId) {
Expand Down
Loading