From c2664e4e36c63390f47b9e0c11c87fbba36f7663 Mon Sep 17 00:00:00 2001 From: Yash Maheshwari Date: Fri, 16 Feb 2024 11:14:45 +0530 Subject: [PATCH 1/2] Implemented: support to display the runTime and frequency for a group on the list page --- src/store/modules/orderRouting/actions.ts | 19 +++++++++++++++++++ src/views/BrokeringRuns.vue | 12 +++++++++--- 2 files changed, 28 insertions(+), 3 deletions(-) diff --git a/src/store/modules/orderRouting/actions.ts b/src/store/modules/orderRouting/actions.ts index 50631e1..4d3a3c6 100644 --- a/src/store/modules/orderRouting/actions.ts +++ b/src/store/modules/orderRouting/actions.ts @@ -31,6 +31,25 @@ const actions: ActionTree = { } if(routingGroups.length) { + const groupScheduleInfoPayload = routingGroups.map((group: any) => { + return group.routingGroupId + }) + + const resp = await Promise.allSettled(groupScheduleInfoPayload.map((routingGroupId: any) => OrderRoutingService.fetchRoutingScheduleInformation(routingGroupId))) + + // Performing check on only those responses for which the status is fulfilled + const schedules = resp.filter((response: any) => response.status === "fulfilled").reduce((schedules: any, response: any) => { + if(response.value.data.schedule) { + schedules[response.value.data.schedule.jobName] = response.value.data.schedule + } + return schedules; + }, {}) + + routingGroups = routingGroups.map((group: any) => ({ + ...group, + schedule: schedules[group.jobName] + })) + routingGroups = sortSequence(routingGroups) } diff --git a/src/views/BrokeringRuns.vue b/src/views/BrokeringRuns.vue index 241f757..347e3da 100644 --- a/src/views/BrokeringRuns.vue +++ b/src/views/BrokeringRuns.vue @@ -48,8 +48,8 @@ {{ group.description }} - {{ group.frequency ? group.frequency : "-" }} - {{ group.runTime ? group.runTime : "-" }} + {{ group.schedule ? getScheduleFrequency(group.schedule.cronExpression) : "-" }} + {{ group.schedule ? getTimeFromSeconds(group.schedule.nextExecutionDateTime) : "-" }} {{ getDateAndTime(group.createdDate) }} @@ -72,7 +72,7 @@ import emitter from "@/event-bus"; import { translate } from "@/i18n"; import { Group } from "@/types"; -import { getDateAndTime, showToast } from "@/utils"; +import { getDateAndTime, getTimeFromSeconds, showToast } from "@/utils"; import { IonButton, IonButtons, IonCard, IonCardHeader, IonCardTitle, IonContent, IonHeader, IonIcon, IonItem, IonLabel, IonList, IonListHeader, IonPage, IonRadioGroup, IonRadio, IonSearchbar, IonSpinner, IonTitle, IonToolbar, alertController, onIonViewWillEnter } from "@ionic/vue"; import { addOutline } from "ionicons/icons" import { computed, ref } from "vue"; @@ -85,6 +85,8 @@ const groups = computed(() => store.getters["orderRouting/getRoutingGroups"]) const userProfile = computed(() => store.getters["user/getUserProfile"]) const currentEComStore = computed(() => store.getters["user/getCurrentEComStore"]) +const cronExpressions = JSON.parse(process.env?.VUE_APP_CRON_EXPRESSIONS) + let isLoading = ref(false) let queryString = ref("") let brokeringGroups = ref([]) as any @@ -150,6 +152,10 @@ async function setEComStore(event: CustomEvent) { emitter.emit("dismissLoader") } +function getScheduleFrequency(cronExp: string) { + return Object.entries(cronExpressions).find(([description, expression]) => expression === cronExp)?.[0] || "-" +} + async function redirect(group: Group) { router.push(`brokering/${group.routingGroupId}/routes`) } From f0c01f358bea8def35ab1482ea13f7fd90895fa1 Mon Sep 17 00:00:00 2001 From: Yash Maheshwari Date: Fri, 16 Feb 2024 11:41:08 +0530 Subject: [PATCH 2/2] Improved: UI for the schedule card on the route page --- src/views/BrokeringRoute.vue | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/src/views/BrokeringRoute.vue b/src/views/BrokeringRoute.vue index d547135..e7ea4e2 100644 --- a/src/views/BrokeringRoute.vue +++ b/src/views/BrokeringRoute.vue @@ -85,12 +85,10 @@