diff --git a/src/services/RoutingService.ts b/src/services/RoutingService.ts index ca866ad..4cce185 100644 --- a/src/services/RoutingService.ts +++ b/src/services/RoutingService.ts @@ -116,6 +116,13 @@ const scheduleBrokering = async (payload: any): Promise => { }); } +const runNow = async (routingGroupId: string): Promise => { + return api({ + url: `groups/${routingGroupId}/runNow`, + method: "POST" + }); +} + export const OrderRoutingService = { createOrderRouting, createRoutingGroup, @@ -128,6 +135,7 @@ export const OrderRoutingService = { fetchRoutingGroups, fetchRoutingScheduleInformation, fetchRule, + runNow, scheduleBrokering, updateRouting, updateRoutingGroup, diff --git a/src/views/BrokeringRoute.vue b/src/views/BrokeringRoute.vue index e3aa464..b091c76 100644 --- a/src/views/BrokeringRoute.vue +++ b/src/views/BrokeringRoute.vue @@ -95,6 +95,7 @@
{{ "Save changes" }} + {{ "Run Now" }}
@@ -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`)