mirror of
https://github.com/VictoriaMetrics/VictoriaMetrics.git
synced 2024-12-11 14:53:49 +00:00
ea920edd32
Properly form path to static assets in WEB UI
if `http.pathPrefix` set.
https://github.com/VictoriaMetrics/VictoriaMetrics/issues/4349
Signed-off-by: hagen1778 <roman@victoriametrics.com>
(cherry picked from commit 51cea6cad4
)
Signed-off-by: hagen1778 <roman@victoriametrics.com>
107 lines
2.8 KiB
Text
107 lines
2.8 KiB
Text
{% import (
|
|
"net/http"
|
|
"path"
|
|
"net/url"
|
|
|
|
"github.com/VictoriaMetrics/VictoriaMetrics/app/vmalert/utils"
|
|
) %}
|
|
|
|
{% func Header(r *http.Request, navItems []NavItem, title string) %}
|
|
{%code prefix := utils.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" />
|
|
<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;
|
|
}
|
|
.table {
|
|
table-layout: fixed;
|
|
}
|
|
.table .error-cell{
|
|
word-break: break-word;
|
|
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);
|
|
}
|
|
textarea.curl-area{
|
|
width: 100%;
|
|
line-height: 1;
|
|
font-size: 12px;
|
|
border: none;
|
|
margin: 0;
|
|
padding: 0;
|
|
overflow: scroll;
|
|
}
|
|
</style>
|
|
</head>
|
|
<body>
|
|
{%= printNavItems(r, title, navItems) %}
|
|
<main class="px-2">
|
|
{% endfunc %}
|
|
|
|
|
|
{% code
|
|
type NavItem struct {
|
|
Name string
|
|
Url string
|
|
}
|
|
%}
|
|
|
|
{% func printNavItems(r *http.Request, current string, items []NavItem) %}
|
|
{%code
|
|
prefix := utils.Prefix(r.URL.Path)
|
|
%}
|
|
<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">
|
|
{% 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 %}">
|
|
{%s item.Name %}
|
|
</a>
|
|
</li>
|
|
{% endfor %}
|
|
</ul>
|
|
</div>
|
|
</nav>
|
|
{% endfunc %}
|