Skip to content

Commit

Permalink
Merge pull request #59 from ymaheshwari1/#58
Browse files Browse the repository at this point in the history
Implemented: support to run the schedule now(#58)
  • Loading branch information
ymaheshwari1 authored Feb 1, 2024
2 parents 2ad5ef7 + eedb65f commit f891e68
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/services/RoutingService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,13 @@ const scheduleBrokering = async (payload: any): Promise<any> => {
});
}

const runNow = async (routingGroupId: string): Promise<any> => {
return api({
url: `groups/${routingGroupId}/runNow`,
method: "POST"
});
}

export const OrderRoutingService = {
createOrderRouting,
createRoutingGroup,
Expand All @@ -128,6 +135,7 @@ export const OrderRoutingService = {
fetchRoutingGroups,
fetchRoutingScheduleInformation,
fetchRule,
runNow,
scheduleBrokering,
updateRouting,
updateRoutingGroup,
Expand Down
33 changes: 33 additions & 0 deletions src/views/BrokeringRoute.vue
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@
</div>
<div>
<ion-button :disabled="typeof isOmsConnectionExist === 'boolean' && !isOmsConnectionExist" size="small" fill="outline" @click="saveChanges()">{{ "Save changes" }}</ion-button>
<ion-button :disabled="typeof isOmsConnectionExist === 'boolean' && !isOmsConnectionExist" size="small" fill="outline" @click="runNow()">{{ "Run Now" }}</ion-button>
</div>
</div>
<ion-item>
Expand Down Expand Up @@ -261,6 +262,38 @@ async function disable() {
}
}
async function runNow() {
const scheduleAlert = await alertController
.create({
header: "Run now",
message: "Running this schedule now will not replace this schedule. A copy of this schedule will be created and run immediately. You may not be able to reverse this action.",
buttons: [
{
text: "Cancel",
role: "cancel",
},
{
text: "Run now",
handler: async () => {
try {
const resp = await OrderRoutingService.runNow(props.routingGroupId)
if(!hasError(resp) && resp.data.jobRunId) {
showToast("Service has been scheduled")
} else {
throw resp.data
}
} catch(err) {
showToast("Failed to schedule service")
logger.error(err)
}
}
}
]
});
return scheduleAlert.present();
}
async function redirect(orderRouting: Route) {
await store.dispatch("orderRouting/setCurrentOrderRouting", orderRouting)
router.push(`${orderRouting.orderRoutingId}/rules`)
Expand Down

0 comments on commit f891e68

Please sign in to comment.