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

Implemented: support to run the schedule now(#58) #59

Merged
merged 1 commit into from
Feb 1, 2024
Merged
Show file tree
Hide file tree
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
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 @@ -92,6 +92,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 @@ -258,6 +259,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
Loading