From eedb65f114615cd5304461fcc11e358e06b732ea Mon Sep 17 00:00:00 2001 From: Yash Maheshwari Date: Thu, 1 Feb 2024 11:06:22 +0530 Subject: [PATCH] Implemented: support to run the schedule now(#58) --- src/services/RoutingService.ts | 8 ++++++++ src/views/BrokeringRoute.vue | 33 +++++++++++++++++++++++++++++++++ 2 files changed, 41 insertions(+) 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 6838527..ca68ed4 100644 --- a/src/views/BrokeringRoute.vue +++ b/src/views/BrokeringRoute.vue @@ -92,6 +92,7 @@
{{ "Save changes" }} + {{ "Run Now" }}
@@ -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`)