### **PR Type**
Enhancement, Bug fix
___
### **Description**
- Add alert context menu on charts
- Pass threshold/condition to Add Alert
- Correct query-type handling from panels
- Sync HAVING with threshold when aggregated
___
### Diagram Walkthrough
```mermaid
flowchart LR
Chart["ChartRenderer (ECharts)"] -- "emit contextmenu {x,y,value}" --> Panel["PanelSchemaRenderer"]
Panel -- "show AlertContextMenu" --> Menu["AlertContextMenu (above/below)"]
Menu -- "select {condition, threshold}" --> Panel
Panel -- "router.push addAlert?panelData=..." --> AddAlert["AddAlert.vue"]
AddAlert -- "init form from panelData" --> Form["Query/Trigger setup"]
AddAlert -- "set threshold/operator/HAVING" --> Form
```
<details> <summary><h3> File Walkthrough</h3></summary>
<table><thead><tr><th></th><th align="left">Relevant
files</th></tr></thead><tbody><tr><td><strong>Enhancement</strong></td><td><table>
<tr>
<td>
<details>
<summary><strong>AddAlert.vue</strong><dd><code>Robust panel-driven
alert initialization and thresholds</code> </dd></summary>
<hr>
web/src/components/alerts/AddAlert.vue
<ul><li>Set query type based on panel data<br> <li> Populate SQL/PromQL
only if present<br> <li> Enable aggregation only for SQL builder
queries<br> <li> Apply threshold/operator and HAVING from panel<br> <li>
Avoid default 'custom' type when from panel</ul>
</details>
</td>
<td><a
href="https://github.com/openobserve/openobserve/pull/8711/files#diff-7b426bb23e9ed0250c3877d6d97b099c42b2d20e22ddf4459915381b2233a0a8">+50/-6</a>
</td>
</tr>
<tr>
<td>
<details>
<summary><strong>AlertContextMenu.vue</strong><dd><code>Add alert
creation context menu component</code>
</dd></summary>
<hr>
web/src/components/dashboards/AlertContextMenu.vue
<ul><li>New context menu component for alerts<br> <li> Provides
above/below threshold actions<br> <li> Handles outside click and Escape
close<br> <li> Dark/light themed styling</ul>
</details>
</td>
<td><a
href="https://github.com/openobserve/openobserve/pull/8711/files#diff-1fef708fc24bed7cc2b198f86b39554690fd6ba3ba778651c3fffb42969770c5">+200/-0</a>
</td>
</tr>
<tr>
<td>
<details>
<summary><strong>PanelSchemaRenderer.vue</strong><dd><code>Integrate
context menu and route to Add Alert</code>
</dd></summary>
<hr>
web/src/components/dashboards/PanelSchemaRenderer.vue
<ul><li>Wire chart contextmenu to open alert menu<br> <li> Lazy-load and
render AlertContextMenu<br> <li> Build panelData payload with
threshold/condition<br> <li> Navigate to Add Alert with encoded
data</ul>
</details>
</td>
<td><a
href="https://github.com/openobserve/openobserve/pull/8711/files#diff-e5376e7e77bf3aaf6590c2522d8c2dbffcc95a8006ae0d6dc0040a37825367d6">+76/-0</a>
</td>
</tr>
<tr>
<td>
<details>
<summary><strong>ChartRenderer.vue</strong><dd><code>Add contextmenu
support for data point alerts</code>
</dd></summary>
<hr>
web/src/components/dashboards/panels/ChartRenderer.vue
<ul><li>Emit contextmenu with point coords and value<br> <li> Prevent
default menu, support bar/line charts<br> <li> Unbind/bind contextmenu
listener on lifecycle<br> <li> Extract value from diverse data
formats</ul>
</details>
</td>
<td><a
href="https://github.com/openobserve/openobserve/pull/8711/files#diff-353fab39cd76197438814db862c4a506636ea7e15633ee92d9269adbd97fe67c">+54/-0</a>
</td>
</tr>
</table></td></tr></tr></tbody></table>
</details>
___
web
This template should help get you started developing with Vue 3 in Vite.
Recommended IDE Setup
VSCode + Volar (and disable Vetur) + TypeScript Vue Plugin (Volar).
Type Support for .vue Imports in TS
TypeScript cannot handle type information for .vue imports by default, so we replace the tsc CLI with vue-tsc for type checking. In editors, we need TypeScript Vue Plugin (Volar) to make the TypeScript language service aware of .vue types.
If the standalone TypeScript plugin doesn't feel fast enough to you, Volar has also implemented a Take Over Mode that is more performant. You can enable it by the following steps:
- Disable the built-in TypeScript Extension
- Run
Extensions: Show Built-in Extensionsfrom VSCode's command palette - Find
TypeScript and JavaScript Language Features, right click and selectDisable (Workspace)
- Run
- Reload the VSCode window by running
Developer: Reload Windowfrom the command palette.
Customize configuration
See Vite Configuration Reference.
Project Setup
npm install
Compile and Hot-Reload for Development
For stand-alone UI development environment, create .env file and which contains below environment variable
VITE_OPENOBSERVE_ENDPOINT=http://localhost:5080/
npm run dev
Type-Check, Compile and Minify for Production
npm run build
Run Unit Tests with Vitest
npm run test:unit
Run End-to-End Tests with Cypress
npm run test:e2e:dev
This runs the end-to-end tests against the Vite development server. It is much faster than the production build.
But it's still recommended to test the production build with test:e2e before deploying (e.g. in CI environments):
npm run build
npm run test:e2e
Lint with ESLint
npm run lint