Files
openobserve/web/src/components/alerts/VariablesInput.vue
T
Sai Nikhil 14360b4e86 fix: add alert page UI changes (#7571)
### **User description**
1. this will reduce the padding all over the page (white space)
2. this will query for the data if multi time range is selected , upto
specific period that user selected not the entire period

___

### **PR Type**
Enhancement, Bug fix


___

### **Description**
- Revamp alert creation page layout and spacing

- Refactor SQL/VRL editors responsiveness

- Add AI generate SQL/VRL buttons

- Prevent wildcard queries before running


___

### **Changes diagram**

```mermaid
flowchart LR
  A["Layout adjustments"] --> B["Editor layout refactor"]
  B --> C["AI generate button addition"]
  C --> D["Query validation guard"]
```


___



### **Changes walkthrough** 📝
<table><thead><tr><th></th><th align="left">Relevant
files</th></tr></thead><tbody><tr><td><strong>Enhancement</strong></td><td><details><summary>3
files</summary><table>
<tr>
<td><strong>AddAlert.vue</strong><dd><code>Update AddAlert layout, logic
and styling</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
</dd></td>
<td><a
href="https://github.com/openobserve/openobserve/pull/7571/files#diff-7b426bb23e9ed0250c3877d6d97b099c42b2d20e22ddf4459915381b2233a0a8">+22/-22</a>&nbsp;
</td>

</tr>

<tr>
<td><strong>SelectFolderDropDown.vue</strong><dd><code>Mark SelectFolder
label as required</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dd></td>
<td><a
href="https://github.com/openobserve/openobserve/pull/7571/files#diff-11c088754f74fee2ec616bb2e73680410356248c8c05b3817db4924d73bd5d95">+1/-1</a>&nbsp;
&nbsp; &nbsp; </td>

</tr>

<tr>
<td><strong>FullViewContainer.vue</strong><dd><code>Extend
FullViewContainer expand behavior</code>&nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; </dd></td>
<td><a
href="https://github.com/openobserve/openobserve/pull/7571/files#diff-c0722446274c88c250042e38b051201b81450cb5da1ee827cd5a4a927424a357">+7/-1</a>&nbsp;
&nbsp; &nbsp; </td>

</tr>

</table></details></td></tr><tr><td><strong>Formatting</strong></td><td><details><summary>5
files</summary><table>
<tr>
<td><strong>AlertsContainer.vue</strong><dd><code>Adjust AlertsContainer
spacing and font size</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dd></td>
<td><a
href="https://github.com/openobserve/openobserve/pull/7571/files#diff-39b487d54970cff4a1ccdfbb49a4ccb38f7131bb9d30944ce1c6e86d3f818148">+2/-2</a>&nbsp;
&nbsp; &nbsp; </td>

</tr>

<tr>
<td><strong>PreviewAlert.vue</strong><dd><code>Tweak PreviewAlert
container spacing</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; </dd></td>
<td><a
href="https://github.com/openobserve/openobserve/pull/7571/files#diff-760f5f0a261910f17eb167f81802e8a52477b99a83d2d7fc1aeefc7185801795">+1/-1</a>&nbsp;
&nbsp; &nbsp; </td>

</tr>

<tr>
<td><strong>RealTimeAlert.vue</strong><dd><code>Update RealTimeAlert
layout spacing</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dd></td>
<td><a
href="https://github.com/openobserve/openobserve/pull/7571/files#diff-c3ae6b47832eb33f9ca877cc7165d079de14850e5c5d43a227102ba40326b9d8">+4/-4</a>&nbsp;
&nbsp; &nbsp; </td>

</tr>

<tr>
<td><strong>ScheduledAlert.vue</strong><dd><code>Refine ScheduledAlert
spacing and styles</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; </dd></td>
<td><a
href="https://github.com/openobserve/openobserve/pull/7571/files#diff-5e143a17ab0fa5d7817f6d9301667fb5597236f27184248c7a71728e85b8d999">+310/-231</a></td>

</tr>

<tr>
<td><strong>VariablesInput.vue</strong><dd><code>Fix VariablesInput
layout width</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
</dd></td>
<td><a
href="https://github.com/openobserve/openobserve/pull/7571/files#diff-23a647aa1acfc95bc726629f0daa54005e3da1ed5b16482ceccef0649f680a74">+6/-3</a>&nbsp;
&nbsp; &nbsp; </td>

</tr>
</table></details></td></tr></tr></tbody></table>

___

> <details> <summary> Need help?</summary><li>Type <code>/help how to
...</code> in the comments thread for any questions about PR-Agent
usage.</li><li>Check out the <a
href="https://qodo-merge-docs.qodo.ai/usage-guide/">documentation</a>
for more information.</li></details>
2025-07-16 13:02:35 +05:30

184 lines
4.9 KiB
Vue

<!-- Copyright 2023 OpenObserve Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
-->
<template>
<div class="col-12 q-py-sm variables-input "
:class="{
'flex tw-gap-2 items-center tw-w-full': variables.length == 0,
}"
>
<div class="q-pb-xs custom-input-label text-bold">
<span>
Variable
</span>
<q-btn
style="color: #A0A0A0;"
no-caps
padding="xs"
class=""
size="sm"
flat
icon="info_outline"
>
<q-tooltip>
Variables are used to pass data from the alert to the destination.
</q-tooltip>
</q-btn>
</div>
<template v-if="!variables.length">
<div class="flex justify-between items-center tw-ml-auto">
<q-btn
data-test="alert-variables-add-btn"
label="Add Variable"
size="sm"
class="text-bold add-variable no-border q-py-sm"
icon="add"
color="primary"
style="
border-radius: 4px;
text-transform: capitalize;
color: #fff !important;
font-size: 12px;
"
@click="addVariable"
/>
</div>
</template>
<template v-else>
<div
v-for="(variable, index) in variables as any"
:key="variable.uuid"
class="q-col-gutter-sm q-pb-sm flex items-center"
:data-test="`alert-variables-${index + 1}`"
>
<div class="q-ml-none">
<q-input
data-test="alert-variables-key-input"
v-model="variable.key"
color="input-border"
:class="store.state.theme === 'dark' ? 'input-bg-dark' : 'input-bg-light'"
stack-label
outlined
filled
:placeholder="t('common.name')"
dense
tabindex="0"
/>
</div>
<div class="q-ml-none">
<q-input
data-test="alert-variables-value-input"
v-model="variable.value"
:placeholder="t('common.value')"
color="input-border"
:class="store.state.theme === 'dark' ? 'input-bg-dark' : 'input-bg-light'"
stack-label
outlined
filled
dense
isUpdatingDestination
tabindex="0"
style="min-width: 250px"
/>
</div>
<div class="col-2 q-ml-none">
<q-btn
data-test="alert-variables-delete-variable-btn"
:icon="outlinedDelete"
class="q-ml-xs iconHoverBtn"
:class="store.state?.theme === 'dark' ? 'icon-dark' : ''"
padding="sm"
unelevated
size="sm"
round
flat
:title="t('alert_templates.edit')"
@click="removeVariable(variable)"
/>
<q-btn
data-test="alert-variables-add-variable-btn"
v-if="index === variables.length - 1"
icon="add"
class="q-ml-xs iconHoverBtn"
:class="store.state?.theme === 'dark' ? 'icon-dark' : ''"
padding="sm"
unelevated
size="sm"
round
flat
:title="t('alert_templates.edit')"
@click="addVariable"
/>
</div>
</div>
</template>
</div>
</template>
<script setup lang="ts">
import { defineProps } from "vue";
import { useI18n } from "vue-i18n";
import { outlinedDelete, outlinedInfo } from "@quasar/extras/material-icons-outlined";
import { useStore } from "vuex";
const props = defineProps({
variables: {
type: Array,
required: true,
},
});
const emits = defineEmits(["add:variable", "remove:variable"]);
const store = useStore();
const { t } = useI18n();
const removeVariable = (variable: any) => {
emits("remove:variable", variable);
};
const addVariable = () => {
emits("add:variable");
};
</script>
<style lang="scss">
.add-variable {
.q-icon {
margin-right: 4px !important;
font-size: 15px !important;
}
}
.variables-input {
.q-btn {
&.icon-dark {
filter: none !important;
}
}
}
.input-bg-dark .q-field__control{
background-color: #181a1b !important;
}
.input-bg-light .q-field__control{
background-color: #ffffff !important;
}
</style>