diff --git a/web/src/components/alerts/AddAlert.vue b/web/src/components/alerts/AddAlert.vue index c3451641e4..5265e7c2c1 100644 --- a/web/src/components/alerts/AddAlert.vue +++ b/web/src/components/alerts/AddAlert.vue @@ -60,7 +60,7 @@ along with this program. If not, see .
. @folder-selected="updateActiveFolderId" :activeFolderId="activeFolderId" :style="'height: 30px'" - /> + />
-
{ updatedAt: "", owner: "", lastEditedBy: "", - folder_id : "", + folder_id: "", }; }; let callAlert: Promise<{ data: any }>; @@ -655,8 +653,10 @@ export default defineComponent({ const vrlFunctionError = ref(""); const showTimezoneWarning = ref(false); - - const activeFolderId = ref(router.currentRoute.value.query.folder || "default"); + + const activeFolderId = ref( + router.currentRoute.value.query.folder || "default", + ); const isAlertSaving = ref(false); @@ -1217,8 +1217,8 @@ export default defineComponent({ query.query.start_time = query.query.start_time + 780000000; query.query.sql = formData.value.query_condition.sql; - //removed the encoding as it is not required for the alert queries - if(store.state.zoConfig.sql_base64_enabled && query?.encoding){ + //removed the encoding as it is not required for the alert queries + if (store.state.zoConfig.sql_base64_enabled && query?.encoding) { delete query.encoding; } @@ -1365,7 +1365,6 @@ export default defineComponent({ sqlQueryErrorMsg, vrlFunctionError, updateFunctionVisibility, - convertDateToTimestamp, getTimezonesByOffset, showTimezoneWarning, updateMultiTimeRange, @@ -1382,10 +1381,10 @@ export default defineComponent({ // TODO OK: Refactor this code this.formData.ingest = ref(false); this.formData = { ...defaultValue, ...cloneDeep(this.modelValue) }; - if(!this.isUpdated){ - this.formData.is_real_time = this.alertType === 'realTime'? true : false; + if (!this.isUpdated) { + this.formData.is_real_time = this.alertType === "realTime" ? true : false; } - this.formData.is_real_time = this.formData.is_real_time.toString(); + this.formData.is_real_time = this.formData.is_real_time.toString(); // Set default frequency to min_auto_refresh_interval if (this.store.state?.zoConfig?.min_auto_refresh_interval) @@ -1498,30 +1497,9 @@ export default defineComponent({ this.formData.is_real_time == "false" && this.formData.trigger_condition.frequency_type == "cron" ) { - const now = new Date(); - - // Get the day, month, and year from the date object - const day = String(now.getDate()).padStart(2, "0"); - const month = String(now.getMonth() + 1).padStart(2, "0"); // January is 0! - const year = now.getFullYear(); - - // Combine them in the DD-MM-YYYY format - const date = `${day}-${month}-${year}`; - - // Get the hours and minutes, ensuring they are formatted with two digits - const hours = String(now.getHours()).padStart(2, "0"); - const minutes = String(now.getMinutes()).padStart(2, "0"); - - // Combine them in the HH:MM format - const time = `${hours}:${minutes}`; - - const convertedDateTime = this.convertDateToTimestamp( - date, - time, + this.formData.tz_offset = getTimezoneOffset( this.formData.trigger_condition.timezone, ); - - this.formData.tz_offset = convertedDateTime.offset; } this.addAlertForm.validate().then(async (valid: any) => { @@ -1561,11 +1539,12 @@ export default defineComponent({ } if (this.beingUpdated) { - payload.folder_id = this.router.currentRoute.value.query.folder || "default"; + payload.folder_id = + this.router.currentRoute.value.query.folder || "default"; callAlert = alertsService.update_by_alert_id( this.store.state.selectedOrganization.identifier, payload, - this.activeFolderId + this.activeFolderId, ); callAlert .then((res: { data: any }) => { @@ -1598,7 +1577,7 @@ export default defineComponent({ callAlert = alertsService.create_by_alert_id( this.store.state.selectedOrganization.identifier, payload, - this.activeFolderId + this.activeFolderId, ); callAlert diff --git a/web/src/components/pipeline/NodeForm/Query.vue b/web/src/components/pipeline/NodeForm/Query.vue index 361b069965..d3bc0ba051 100644 --- a/web/src/components/pipeline/NodeForm/Query.vue +++ b/web/src/components/pipeline/NodeForm/Query.vue @@ -42,7 +42,9 @@ along with this program. If not, see . v-model:trigger="streamRoute.trigger_condition" v-model:sql="streamRoute.query_condition.sql" v-model:promql="streamRoute.query_condition.promql" - v-model:promql_condition="streamRoute.query_condition.promql_condition" + v-model:promql_condition=" + streamRoute.query_condition.promql_condition + " v-model:query_type="streamRoute.query_condition.type" v-model:aggregation="streamRoute.query_condition.aggregation" v-model:stream_type="streamRoute.stream_type" @@ -78,7 +80,7 @@ import { onActivated, } from "vue"; import { useI18n } from "vue-i18n"; -import { getUUID } from "@/utils/zincutils"; +import { getTimezoneOffset, getUUID } from "@/utils/zincutils"; import { useStore } from "vuex"; import { useRouter } from "vue-router"; import useStreams from "@/composables/useStreams"; @@ -251,7 +253,6 @@ const getDefaultStreamRoute: any = () => { }; onMounted(() => { - if (pipelineObj.isEditNode) { streamRoute.value = pipelineObj.currentSelectedNodeData ?.data as StreamRoute; @@ -379,6 +380,7 @@ const saveQueryData = async () => { formData.trigger_condition.period, ); } + let queryPayload: any = { node_type: "query", // required stream_type: formData.stream_type, // required @@ -406,6 +408,12 @@ const saveQueryData = async () => { timezone: formData.trigger_condition.timezone, }, }; + + if (formData.trigger_condition.frequency_type === "cron") { + queryPayload.tz_offset = + getTimezoneOffset(formData.trigger_condition.timezone) || 0; + } + if (formData.query_condition.type == "promql") { if (queryPayload?.query_condition) { queryPayload.query_condition.sql = ""; @@ -479,8 +487,8 @@ const validateSqlQuery = () => { query.query.sql = streamRoute.value.query_condition.sql; - //removed the encoding as it is not required for the pipeline queries - if(store.state.zoConfig.sql_base64_enabled && query?.encoding){ + //removed the encoding as it is not required for the pipeline queries + if (store.state.zoConfig.sql_base64_enabled && query?.encoding) { delete query.encoding; } diff --git a/web/src/utils/zincutils.ts b/web/src/utils/zincutils.ts index 5ad31e893f..8c6a9dc0ec 100644 --- a/web/src/utils/zincutils.ts +++ b/web/src/utils/zincutils.ts @@ -826,7 +826,7 @@ export const durationFormatter = (durationInSeconds: number): string => { return formattedDuration; }; -export const getTimezoneOffset = () => { +export const getTimezoneOffset = (timezone: string |null = null) => { const now = new Date(); // Get the day, month, and year from the date object @@ -844,7 +844,7 @@ export const getTimezoneOffset = () => { // Combine them in the HH:MM format const scheduleTime = `${hours}:${minutes}`; - const ScheduleTimezone = Intl.DateTimeFormat().resolvedOptions().timeZone; + const ScheduleTimezone = timezone ? timezone : Intl.DateTimeFormat().resolvedOptions().timeZone; const convertedDateTime = convertDateToTimestamp( scheduleDate,