fix: date time invalid if not enter correctly (#9235)

This PR fixes the issue in #1975
This commit is contained in:
Sai Nikhil
2025-11-21 18:33:37 +05:30
committed by GitHub
parent 7a37f760e9
commit db30551ffe
6 changed files with 77 additions and 26 deletions
+7 -7
View File
@@ -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;
@@ -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();
});
@@ -1147,6 +1147,15 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
you can apply additional filters and adjust the date range
to enhance search.
</h6>
<h6
v-else-if="notificationMsgValue != ''"
data-test="logs-search-no-stream-selected-text"
class="text-center col-10 q-mx-none"
>
{{
notificationMsgValue
}}
</h6>
<h6
v-else
data-test="logs-search-no-stream-selected-text"
@@ -1357,6 +1366,8 @@ const selectedStreamName = ref("");
const streamOptions = ref([]);
const notificationMsgValue = ref("");
const getColumns = computed(() => {
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;
+8 -8
View File
@@ -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);
+4 -10
View File
@@ -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;
}
+22
View File
@@ -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,