Files
Andrii ChubatiukandGitHub 1d98e524cf app/vmalert: follow-up for https://github.com/VictoriaMetrics/VictoriaMetrics/pull/8750 (#8875)
fixed not successful rebase in PR, moved svg icons to a sprite and added
VM logo to UI

<img width="1290" alt="image"
src="https://github.com/user-attachments/assets/34cfdc61-6349-4320-b133-38965cb6c30f"
/>


### Describe Your Changes

Please provide a brief description of the changes you made. Be as
specific as possible to help others understand the purpose and impact of
your modifications.

### Checklist

The following checks are **mandatory**:

- [ ] My change adheres to [VictoriaMetrics contributing
guidelines](https://docs.victoriametrics.com/victoriametrics/contributing/).
2025-05-05 15:31:47 +02:00

84 lines
3.1 KiB
Plaintext

{% import (
"net/http"
"net/url"
"path"
"github.com/VictoriaMetrics/VictoriaMetrics/app/vmalert/vmalertutil"
) %}
{% func Header(r *http.Request, navItems []NavItem, title string, userErr error) %}
{%code prefix := vmalertutil.Prefix(r.URL.Path) %}
<!DOCTYPE html>
<html lang="en">
<head>
<title>vmalert{% if title != "" %} - {%s title %}{% endif %}</title>
<link href="{%s prefix %}static/css/bootstrap.min.css" rel="stylesheet" />
<link href="{%s prefix %}static/css/custom.css" rel="stylesheet" />
<script src="{%s prefix %}static/js/bootstrap.bundle.min.js" type="text/javascript" defer></script>
<script src="{%s prefix %}static/js/custom.js" type="text/javascript" defer></script>
</head>
<body>
{%= printNavItems(r, title, navItems, userErr) %}
<main class="px-4 py-2">
{%= errorBody(userErr) %}
{% endfunc %}
{% code
type NavItem struct {
Name string
URL string
Icon string
}
%}
{% func printNavItems(r *http.Request, current string, items []NavItem, userErr error) %}
{%code prefix := vmalertutil.Prefix(r.URL.Path) %}
<nav class="navbar navbar-expand navbar-dark fixed-top bg-dark">
<div class="container-fluid">
<div class="collapse navbar-collapse" id="navbarCollapse">
<ul class="navbar-nav me-auto mb-0 align-items-center">
{% for _, item := range items %}
<li class="nav-item">
{% code
u, _ := url.Parse(item.URL)
%}
<a class="d-flex gap-2 align-items-center nav-link{% if current == item.Name %} active{% endif %}"
href="{% if u.IsAbs() %}{%s item.URL %}{% else %}{%s path.Join(prefix, item.URL) %}{% endif %}">
{% if item.Icon != "" %}
<svg width="40" height="40"><use href="{%s prefix %}static/icons/icons.svg#{%s item.Icon %}"></svg>
{% endif %}
{%s item.Name %}
</a>
</li>
{% endfor %}
</ul>
</div>
{%= errorIcon(userErr) %}
</nav>
{% endfunc %}
{% func errorIcon(err error) %}
{% if err != nil %}
<div class="d-flex" data-bs-toggle="tooltip" data-bs-placement="left" title="Configuration file failed to reload! Click to see more details.">
<a type="button" data-bs-toggle="collapse" href="#reload-groups-error">
<span class="text-danger">
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-exclamation-triangle-fill" viewBox="0 0 16 16">
<path d="M8.982 1.566a1.13 1.13 0 0 0-1.96 0L.165 13.233c-.457.778.091 1.767.98 1.767h13.713c.889 0 1.438-.99.98-1.767L8.982 1.566zM8 5c.535 0 .954.462.9.995l-.35 3.507a.552.552 0 0 1-1.1 0L7.1 5.995A.905.905 0 0 1 8 5zm.002 6a1 1 0 1 1 0 2 1 1 0 0 1 0-2z"/>
</svg>
</span>
</a>
</div>
{% endif %}
{% endfunc %}
{% func errorBody(err error) %}
{% if err != nil %}
<div class="collapse mt-2 mb-2" id="reload-groups-error">
<div class="card card-body">
{%s err.Error() %}
</div>
</div>
{% endif %}
{% endfunc %}