From 84e7c517d3f0d79684a031ecc46d459c8b6964f7 Mon Sep 17 00:00:00 2001 From: Roman Khavronenko Date: Wed, 6 Jul 2022 10:46:01 +0200 Subject: [PATCH] vmalert: make UI and assets links relative (#2831) * make all links in vmalert relative, so links continue to work even if vmalert sits behind the proxy; * update vmalert's routing to always have component-unique path prefix, e.g. /vmalert; See https://github.com/VictoriaMetrics/VictoriaMetrics/issues/2825 Signed-off-by: hagen1778 --- app/vmalert/tpl/footer.qtpl | 17 +- app/vmalert/tpl/footer.qtpl.go | 74 +-- app/vmalert/tpl/header.qtpl | 48 +- app/vmalert/tpl/header.qtpl.go | 168 +++++-- app/vmalert/tpl/nav.qtpl | 25 - app/vmalert/tpl/nav.qtpl.go | 96 ---- app/vmalert/web.go | 88 ++-- app/vmalert/web.qtpl | 35 +- app/vmalert/web.qtpl.go | 855 ++++++++++++++++----------------- 9 files changed, 716 insertions(+), 690 deletions(-) delete mode 100644 app/vmalert/tpl/nav.qtpl delete mode 100644 app/vmalert/tpl/nav.qtpl.go diff --git a/app/vmalert/tpl/footer.qtpl b/app/vmalert/tpl/footer.qtpl index 28cfec5d7f..eef27785d4 100644 --- a/app/vmalert/tpl/footer.qtpl +++ b/app/vmalert/tpl/footer.qtpl @@ -1,12 +1,19 @@ {% import ( - "github.com/VictoriaMetrics/VictoriaMetrics/lib/httpserver" + "net/http" + "strings" ) %} -{% func Footer() %} - {% code pathPrefix := httpserver.GetPathPrefix() %} + +{% func Footer(r *http.Request) %} +{%code + prefix := "/vmalert/" + if strings.HasPrefix(r.URL.Path, prefix) { + prefix = "" + } +%} - - + + +//line app/vmalert/tpl/footer.qtpl:15 + qw422016.E().S(prefix) +//line app/vmalert/tpl/footer.qtpl:15 + qw422016.N().S(`static/js/jquery-3.6.0.min.js" type="text/javascript"> +//line app/vmalert/tpl/footer.qtpl:16 + qw422016.E().S(prefix) +//line app/vmalert/tpl/footer.qtpl:16 + qw422016.N().S(`static/js/bootstrap.bundle.min.js" type="text/javascript">