2022-06-27 10:12:16 +00:00
|
|
|
{% import (
|
2022-07-06 08:46:01 +00:00
|
|
|
"net/http"
|
|
|
|
"path"
|
2022-08-07 21:28:52 +00:00
|
|
|
"net/url"
|
2022-07-08 08:26:13 +00:00
|
|
|
|
|
|
|
"github.com/VictoriaMetrics/VictoriaMetrics/app/vmalert/utils"
|
2022-06-27 10:12:16 +00:00
|
|
|
) %}
|
|
|
|
|
2023-07-03 12:59:52 +00:00
|
|
|
{% func Header(r *http.Request, navItems []NavItem, title string, userErr error) %}
|
|
|
|
{%code prefix := utils.Prefix(r.URL.Path) %}
|
2021-09-07 19:39:22 +00:00
|
|
|
<!DOCTYPE html>
|
|
|
|
<html lang="en">
|
|
|
|
<head>
|
|
|
|
<title>vmalert{% if title != "" %} - {%s title %}{% endif %}</title>
|
2022-07-06 08:46:01 +00:00
|
|
|
<link href="{%s prefix %}static/css/bootstrap.min.css" rel="stylesheet" />
|
2021-09-07 19:39:22 +00:00
|
|
|
<style>
|
|
|
|
body{
|
|
|
|
min-height: 75rem;
|
|
|
|
padding-top: 4.5rem;
|
|
|
|
}
|
|
|
|
.group-heading {
|
|
|
|
cursor: pointer;
|
|
|
|
padding: 5px;
|
|
|
|
margin-top: 5px;
|
|
|
|
position: relative;
|
|
|
|
}
|
|
|
|
.group-heading .anchor {
|
|
|
|
position:absolute;
|
|
|
|
top:-60px;
|
|
|
|
}
|
|
|
|
.group-heading span {
|
|
|
|
float: right;
|
|
|
|
margin-left: 5px;
|
|
|
|
margin-right: 5px;
|
|
|
|
}
|
|
|
|
.group-heading:hover {
|
|
|
|
background-color: #f8f9fa!important;
|
|
|
|
}
|
2022-05-04 16:02:18 +00:00
|
|
|
.table {
|
|
|
|
table-layout: fixed;
|
|
|
|
}
|
2021-09-07 19:39:22 +00:00
|
|
|
.table .error-cell{
|
|
|
|
word-break: break-word;
|
2022-05-04 16:02:18 +00:00
|
|
|
font-size: 14px;
|
|
|
|
}
|
|
|
|
pre {
|
|
|
|
overflow: scroll;
|
|
|
|
min-height: 30px;
|
|
|
|
max-width: 100%;
|
|
|
|
}
|
|
|
|
pre::-webkit-scrollbar {
|
|
|
|
-webkit-appearance: none;
|
|
|
|
width: 0px;
|
|
|
|
height: 5px;
|
|
|
|
}
|
|
|
|
pre::-webkit-scrollbar-thumb {
|
|
|
|
border-radius: 5px;
|
|
|
|
background-color: rgba(0,0,0,.5);
|
|
|
|
-webkit-box-shadow: 0 0 1px rgba(255,255,255,.5);
|
2021-09-07 19:39:22 +00:00
|
|
|
}
|
2022-09-15 10:40:22 +00:00
|
|
|
textarea.curl-area{
|
|
|
|
width: 100%;
|
|
|
|
line-height: 1;
|
|
|
|
font-size: 12px;
|
|
|
|
border: none;
|
|
|
|
margin: 0;
|
|
|
|
padding: 0;
|
|
|
|
overflow: scroll;
|
|
|
|
}
|
2021-09-07 19:39:22 +00:00
|
|
|
</style>
|
|
|
|
</head>
|
|
|
|
<body>
|
2023-07-03 12:59:52 +00:00
|
|
|
{%= printNavItems(r, title, navItems, userErr) %}
|
2021-09-07 19:39:22 +00:00
|
|
|
<main class="px-2">
|
2023-07-03 12:59:52 +00:00
|
|
|
{%= errorBody(userErr) %}
|
2021-09-07 19:39:22 +00:00
|
|
|
{% endfunc %}
|
2022-07-06 08:46:01 +00:00
|
|
|
|
|
|
|
|
|
|
|
{% code
|
|
|
|
type NavItem struct {
|
|
|
|
Name string
|
|
|
|
Url string
|
|
|
|
}
|
|
|
|
%}
|
|
|
|
|
2023-07-03 12:59:52 +00:00
|
|
|
{% func printNavItems(r *http.Request, current string, items []NavItem, userErr error) %}
|
2022-07-06 08:46:01 +00:00
|
|
|
{%code
|
2023-05-29 05:38:13 +00:00
|
|
|
prefix := utils.Prefix(r.URL.Path)
|
2022-07-06 08:46:01 +00:00
|
|
|
%}
|
|
|
|
<nav class="navbar navbar-expand-md navbar-dark fixed-top bg-dark">
|
|
|
|
<div class="container-fluid">
|
|
|
|
<div class="collapse navbar-collapse" id="navbarCollapse">
|
|
|
|
<ul class="navbar-nav me-auto mb-2 mb-md-0">
|
|
|
|
{% for _, item := range items %}
|
|
|
|
<li class="nav-item">
|
2022-08-07 21:28:52 +00:00
|
|
|
{% code
|
|
|
|
u, _ := url.Parse(item.Url)
|
|
|
|
%}
|
|
|
|
<a class="nav-link{% if current == item.Name %} active{% endif %}"
|
|
|
|
href="{% if u.IsAbs() %}{%s item.Url %}{% else %}{%s path.Join(prefix,item.Url) %}{% endif %}">
|
2022-07-06 08:46:01 +00:00
|
|
|
{%s item.Name %}
|
|
|
|
</a>
|
|
|
|
</li>
|
|
|
|
{% endfor %}
|
|
|
|
</ul>
|
|
|
|
</div>
|
2023-07-03 12:59:52 +00:00
|
|
|
{%= errorIcon(userErr) %}
|
2022-07-06 08:46:01 +00:00
|
|
|
</nav>
|
2022-08-07 21:28:52 +00:00
|
|
|
{% endfunc %}
|
2023-07-03 12:59:52 +00:00
|
|
|
|
|
|
|
{% 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 %}
|