From db30551ffe0b021dd7e5a7badbafbc6a06952afa Mon Sep 17 00:00:00 2001 From: Sai Nikhil Date: Fri, 21 Nov 2025 18:33:37 +0530 Subject: [PATCH] fix: date time invalid if not enter correctly (#9235) This PR fixes the issue in #1975 --- web/src/components/DateTime.vue | 14 ++++----- .../NodeForm/ScheduledPipeline.spec.js | 8 +++++ .../pipeline/NodeForm/ScheduledPipeline.vue | 29 ++++++++++++++++++- web/src/composables/useLogs/useSearchBar.ts | 16 +++++----- web/src/composables/useLogs/useSearchQuery.ts | 14 +++------ web/src/plugins/logs/SearchHistory.vue | 22 ++++++++++++++ 6 files changed, 77 insertions(+), 26 deletions(-) diff --git a/web/src/components/DateTime.vue b/web/src/components/DateTime.vue index 221178ff13..9e3abbbcaf 100644 --- a/web/src/components/DateTime.vue +++ b/web/src/components/DateTime.vue @@ -711,9 +711,9 @@ export default defineComponent({ const saveDate = (dateType) => { // displayValue.value = getDisplayValue(); const date = getConsumableDateTime(); - if (isNaN(date.endTime) || isNaN(date.startTime)) { - return false; - } + // if (isNaN(date.endTime) || isNaN(date.startTime)) { + // // return false; + // } datePayload.value = date; date["valueType"] = dateType || selectedType.value; // date["relativeTimePeriod"] = ""; @@ -823,8 +823,8 @@ export default defineComponent({ selectedTime.value.startTime, ) ) { - console.error(`Invalid start date/time: ${startDateStr}`); - return new Date(); + // console.warn(`Invalid start date/time: ${startDateStr}`); + // return new Date(); } const endDateStr = @@ -835,8 +835,8 @@ export default defineComponent({ selectedTime.value.endTime, ) ) { - console.error(`Invalid end date/time: ${endDateStr}`); - return new Date(); + // console.error(`Invalid end date/time: ${endDateStr}`); + // return new Date(); } let start, end; diff --git a/web/src/components/pipeline/NodeForm/ScheduledPipeline.spec.js b/web/src/components/pipeline/NodeForm/ScheduledPipeline.spec.js index 811a0f55ce..3f75783642 100644 --- a/web/src/components/pipeline/NodeForm/ScheduledPipeline.spec.js +++ b/web/src/components/pipeline/NodeForm/ScheduledPipeline.spec.js @@ -197,6 +197,14 @@ describe("ScheduledPipeline Component", () => { threshold: 1 }; + // Initialize dateTime with valid values + wrapper.vm.dateTime = { + startTime: Date.now() - 3600000, // 1 hour ago + endTime: Date.now(), + relativeTimePeriod: "15m", + valueType: "relative" + }; + wrapper.vm.cronJobError = ""; await flushPromises(); }); diff --git a/web/src/components/pipeline/NodeForm/ScheduledPipeline.vue b/web/src/components/pipeline/NodeForm/ScheduledPipeline.vue index 1705120eaf..68a9bf6bbc 100644 --- a/web/src/components/pipeline/NodeForm/ScheduledPipeline.vue +++ b/web/src/components/pipeline/NodeForm/ScheduledPipeline.vue @@ -1147,6 +1147,15 @@ along with this program. If not, see . you can apply additional filters and adjust the date range to enhance search. +
+ {{ + notificationMsgValue + }} +
{ return [ { @@ -2162,6 +2173,17 @@ const updateDateChange = (date: any) => { }; const runQuery = async () => { + notificationMsgValue.value = ""; + //check if datetime is present or not + //else show the error message + if(!dateTime.value.startTime) { + notificationMsgValue.value = "Invalid start datetime"; + return null; + } + if(!dateTime.value.endTime){ + notificationMsgValue.value = "Invalid end datetime"; + return null; + } if (tab.value == "sql") { loading.value = true; @@ -2189,7 +2211,12 @@ const runQuery = async () => { } }) .catch((err: any) => { - console.log(err, "err"); + if(err.response?.data){ + notificationMsgValue.value = err.response?.data?.message || err.response?.data + } + else { + notificationMsgValue.value = "Error while getting results" + } }) .finally(() => { loading.value = false; diff --git a/web/src/composables/useLogs/useSearchBar.ts b/web/src/composables/useLogs/useSearchBar.ts index c2f18dffd9..4a2eae9748 100644 --- a/web/src/composables/useLogs/useSearchBar.ts +++ b/web/src/composables/useLogs/useSearchBar.ts @@ -430,14 +430,14 @@ export const useSearchBar = () => { return; } - if ( - isNaN(searchObj.data.datetime.endTime) || - isNaN(searchObj.data.datetime.startTime) - ) { - setDateTime( - (router.currentRoute.value?.query?.period as string) || "15m", - ); - } + // if ( + // isNaN(searchObj.data.datetime.endTime) || + // isNaN(searchObj.data.datetime.startTime) + // ) { + // setDateTime( + // (router.currentRoute.value?.query?.period as string) || "15m", + // ); + // } // Use the appropriate method to fetch data getDataThroughStream(isPagination); diff --git a/web/src/composables/useLogs/useSearchQuery.ts b/web/src/composables/useLogs/useSearchQuery.ts index 41e9fbeef2..2ff4fe6e4c 100644 --- a/web/src/composables/useLogs/useSearchQuery.ts +++ b/web/src/composables/useLogs/useSearchQuery.ts @@ -66,16 +66,8 @@ export const useSearchQuery = () => { return null; } - if ( - Number.isNaN(searchObj.data.datetime.endTime) || - Number.isNaN(searchObj.data.datetime.startTime) - ) { - const period = - (router.currentRoute.value?.query?.period as string) || "15m"; - const extractedDate: any = extractTimestamps(period); - searchObj.data.datetime.startTime = extractedDate.from; - searchObj.data.datetime.endTime = extractedDate.to; - } + if (Number.isNaN(searchObj.data.datetime.endTime)) searchObj.data.datetime.endTime = "Invalid Date" + if (Number.isNaN(searchObj.data.datetime.startTime)) searchObj.data.datetime.startTime = "Invalid Date" const queryReq: SearchRequestPayload = buildSearch(); @@ -283,6 +275,8 @@ export const useSearchQuery = () => { setChartInterval(req); } else { notificationMsg.value = "Invalid date format"; + if(timestamps.startTime == "Invalid Date") notificationMsg.value = "Invalid start datetime" + else if(timestamps.endTime == "Invalid Date") notificationMsg.value = "Invalid end datetime" return null; } diff --git a/web/src/plugins/logs/SearchHistory.vue b/web/src/plugins/logs/SearchHistory.vue index a44a4bd4ae..cb802ce815 100644 --- a/web/src/plugins/logs/SearchHistory.vue +++ b/web/src/plugins/logs/SearchHistory.vue @@ -397,6 +397,28 @@ export default defineComponent({ dateTimeToBeSent.value.endTime = convertedData.to * 1000; } const { startTime, endTime } = dateTimeToBeSent.value; + + //check if datetime is present or not + //else show the error message + if(!startTime) { + $q.notify({ + type: "negative", + message: "Invalid start datetime", + timeout: 5000, + }); + isLoading.value = false; + return; + } + if(!endTime){ + $q.notify({ + type: "negative", + message: "Invalid end datetime", + timeout: 5000, + }); + isLoading.value = false; + return; + } + const response = await searchService.get_history( org_identifier, startTime,