From 7638e7acbfc021e023d5691177f044bc4df795f8 Mon Sep 17 00:00:00 2001 From: Yash Maheshwari Date: Wed, 7 Feb 2024 18:56:37 +0530 Subject: [PATCH] Implemented: support to display the run history for the current run(#64) --- src/locales/en.json | 1 + src/services/RoutingService.ts | 8 ++++++++ src/utils/index.ts | 12 ++++++++++-- src/views/BrokeringRoute.vue | 36 +++++++++++++++++++++++++++++----- src/views/BrokeringRuns.vue | 6 +++--- 5 files changed, 53 insertions(+), 10 deletions(-) diff --git a/src/locales/en.json b/src/locales/en.json index 6a78c88..188d7b9 100644 --- a/src/locales/en.json +++ b/src/locales/en.json @@ -51,6 +51,7 @@ "greater": "greater", "greater than or equal to": "greater than or equal to", "High": "High", + "History": "History", "Inventory Filters": "Inventory Filters", "Inventory rule created successfully": "Inventory rule created successfully", "Inventory Sort": "Inventory Sort", diff --git a/src/services/RoutingService.ts b/src/services/RoutingService.ts index 4cce185..b821403 100644 --- a/src/services/RoutingService.ts +++ b/src/services/RoutingService.ts @@ -22,6 +22,13 @@ const fetchRoutingScheduleInformation = async (routingGroupId: string): Promise< }); } +const fetchRoutingHistory = async (routingGroupId: string): Promise => { + return api({ + url: `groups/${routingGroupId}/routingRuns`, + method: "GET" + }); +} + const createRoutingGroup = async (payload: any): Promise => { return api({ url: "groups", @@ -133,6 +140,7 @@ export const OrderRoutingService = { fetchOrderRouting, fetchRoutingGroupInformation, fetchRoutingGroups, + fetchRoutingHistory, fetchRoutingScheduleInformation, fetchRule, runNow, diff --git a/src/utils/index.ts b/src/utils/index.ts index 74eec03..264e263 100644 --- a/src/utils/index.ts +++ b/src/utils/index.ts @@ -26,11 +26,19 @@ const sortSequence = (sequence: Array) => { } const getTime = (time: any) => { - return time ? DateTime.fromMillis(time).toLocaleString(DateTime.DATETIME_MED) : "-"; + return time ? DateTime.fromMillis(time).toLocaleString(DateTime.TIME_24_WITH_SECONDS) : "-"; } const getTimeFromSeconds = (time: any) => { return time ? DateTime.fromSeconds(time).toLocaleString(DateTime.DATETIME_MED) : "-"; } -export { getTime, getTimeFromSeconds, showToast, hasError, sortSequence } +function getDate(runTime: any) { + return DateTime.fromMillis(runTime).toLocaleString(DateTime.DATE_MED); +} + +function getDateAndTime(time: any) { + return time ? DateTime.fromMillis(time).toLocaleString(DateTime.DATETIME_MED) : "-"; +} + +export { getDate, getDateAndTime, getTime, getTimeFromSeconds, showToast, hasError, sortSequence } diff --git a/src/views/BrokeringRoute.vue b/src/views/BrokeringRoute.vue index df1e01b..38a2e19 100644 --- a/src/views/BrokeringRoute.vue +++ b/src/views/BrokeringRoute.vue @@ -57,7 +57,7 @@
- {{ translate("Description") }} +

{{ translate("Description") }}

{{ translate(isDescUpdating ? "Save" : "Edit") }} @@ -66,6 +66,16 @@ {{ description }}
+ +

{{ translate("History") }}

+
+ + +

{{ getTime(routing.startDate) }}

+

{{ getDate(routing.startDate) }}

+
+ {{ getTime(routing.endDate - routing.startDate) }} +
@@ -132,7 +142,7 @@ import ArchivedRoutingModal from "@/components/ArchivedRoutingModal.vue" import { OrderRoutingService } from "@/services/RoutingService"; import logger from "@/logger"; import { DateTime } from "luxon"; -import { hasError, getTime, getTimeFromSeconds, showToast, sortSequence } from "@/utils"; +import { hasError, getDate, getDateAndTime, getTime, getTimeFromSeconds, showToast, sortSequence } from "@/utils"; import emitter from "@/event-bus"; import { translate } from "@/i18n"; @@ -153,6 +163,7 @@ let hasUnsavedChanges = ref(false) let job = ref({}) as any let orderRoutings = ref([]) as any +let routingHistory = ref([]) as any const currentRoutingGroup: any = computed((): Group => store.getters["orderRouting/getCurrentRoutingGroup"]) const currentEComStore = computed(() => store.getters["user/getCurrentEComStore"]) @@ -160,7 +171,7 @@ const isOmsConnectionExist = computed(() => store.getters["util/isOmsConnectionE const getStatusDesc = computed(() => (id: string) => store.getters["util/getStatusDesc"](id)) onIonViewWillEnter(async () => { - await store.dispatch("orderRouting/fetchCurrentRoutingGroup", props.routingGroupId) + await Promise.all([store.dispatch("orderRouting/fetchCurrentRoutingGroup", props.routingGroupId), fetchRoutingHistory()]) store.dispatch("util/fetchStatusInformation") job.value = currentRoutingGroup.value["schedule"] ? JSON.parse(JSON.stringify(currentRoutingGroup.value))["schedule"] : {} @@ -232,6 +243,21 @@ async function saveChanges() { return alert.present(); } +async function fetchRoutingHistory() { + routingHistory.value = [] + try { + const resp = await OrderRoutingService.fetchRoutingHistory(props.routingGroupId) + + if(!hasError(resp)) { + routingHistory.value = resp.data + } else { + throw resp.data; + } + } catch(err) { + logger.error(err) + } +} + async function saveSchedule() { // If this is the first time then we are fetching the omsConnection status, as if the value of isOmsConnectionExist value is a boolean it means we have previously fetched the connection status if(typeof isOmsConnectionExist.value !== "boolean") { diff --git a/src/views/BrokeringRuns.vue b/src/views/BrokeringRuns.vue index df839c3..6bcd2bb 100644 --- a/src/views/BrokeringRuns.vue +++ b/src/views/BrokeringRuns.vue @@ -36,10 +36,10 @@ {{ group.runTime ? group.runTime : "-" }} - {{ getTime(group.createdDate) }} + {{ getDateAndTime(group.createdDate) }} - {{ getTime(group.lastUpdatedStamp) }} + {{ getDateAndTime(group.lastUpdatedStamp) }} @@ -54,7 +54,7 @@