Skip to content

Commit

Permalink
when changing date and time in general setting was getting as 0 in st…
Browse files Browse the repository at this point in the history
…art and end time in query so solved that
  • Loading branch information
ktx-vaidehi authored and ktx-abhay committed May 21, 2024
1 parent 10f3cb1 commit 7fe4486
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 10 deletions.
1 change: 1 addition & 0 deletions web/src/components/DateTime.vue
Original file line number Diff line number Diff line change
Expand Up @@ -779,6 +779,7 @@ export default defineComponent({
setSavedDate,
optionsFn,
setDateType,
getConsumableDateTime,
};
},
});
Expand Down
5 changes: 5 additions & 0 deletions web/src/components/DateTimePickerDashboard.vue
Original file line number Diff line number Diff line change
Expand Up @@ -80,11 +80,16 @@ export default defineComponent({
dateTimePicker.value.setCustomDate(type, dateObj);
};
const getConsumableDateTime = () => {
return dateTimePicker.value.getConsumableDateTime();
};
return {
updateDateTime,
refresh,
dateTimePicker,
setCustomDate,
getConsumableDateTime,
};
},
});
Expand Down
26 changes: 16 additions & 10 deletions web/src/views/Dashboards/ViewDashboard.vue
Original file line number Diff line number Diff line change
Expand Up @@ -397,23 +397,25 @@ export default defineComponent({
// check if route has time realated query params
// if not, take dashboard default time settings
if (!((route.query.from && route.query.to) || route.query.period)) {

// if dashboard has relative time settings
if (
(currentDashboardData.data?.defaultDatetimeDuration?.type ?? "relative") ===
"relative"
(currentDashboardData.data?.defaultDatetimeDuration?.type ??
"relative") === "relative"
) {
selectedDate.value = {
valueType: "relative",
relativeTimePeriod:
currentDashboardData.data?.defaultDatetimeDuration?.relativeTimePeriod ?? "15m",
currentDashboardData.data?.defaultDatetimeDuration
?.relativeTimePeriod ?? "15m",
};
} else {
// else, dashboard will have absolute time settings
selectedDate.value = {
valueType: "absolute",
startTime: currentDashboardData.data?.defaultDatetimeDuration?.startTime,
endTime: currentDashboardData.data?.defaultDatetimeDuration?.endTime,
startTime:
currentDashboardData.data?.defaultDatetimeDuration?.startTime,
endTime:
currentDashboardData.data?.defaultDatetimeDuration?.endTime,
};
}
} else {
Expand All @@ -428,10 +430,14 @@ export default defineComponent({

// when the date changes from the picker, update the current time object for the dashboard
watch(selectedDate, () => {
currentTimeObj.value = {
start_time: new Date(selectedDate.value.startTime),
end_time: new Date(selectedDate.value.endTime),
};
if (selectedDate.value && dateTimePicker.value) {
const date = dateTimePicker.value?.getConsumableDateTime();

currentTimeObj.value = {
start_time: new Date(date.startTime),
end_time: new Date(date.endTime),
};
}
});

const getQueryParamsForDuration = (data: any) => {
Expand Down

0 comments on commit 7fe4486

Please sign in to comment.