about summary refs log tree commit diff
path: root/bundles/prometheus/files/console_libraries/menu.lib
diff options
context:
space:
mode:
authorRobert Günzler <r@gnzler.io>2025-09-07 17:32:13 +0200
committerRobert Günzler <r@gnzler.io>2025-09-07 17:42:42 +0200
commit38be6c13f76e893cf47636257071b440dec0c5b2 (patch)
treef7ded3235a7e3362cbd1ed3d91523968fe0faf90 /bundles/prometheus/files/console_libraries/menu.lib
initial commit
Signed-off-by: Robert Günzler <r@gnzler.io>
Diffstat (limited to 'bundles/prometheus/files/console_libraries/menu.lib')
-rw-r--r--bundles/prometheus/files/console_libraries/menu.lib64
1 files changed, 64 insertions, 0 deletions
diff --git a/bundles/prometheus/files/console_libraries/menu.lib b/bundles/prometheus/files/console_libraries/menu.lib
new file mode 100644
index 0000000..dc87f9f
--- /dev/null
+++ b/bundles/prometheus/files/console_libraries/menu.lib
@@ -0,0 +1,64 @@
+{{/* vim: set ft=html: */}}
+
+{{/* Navbar, should be passed . */}}
+{{ define "navbar" }}
+<nav class="navbar fixed-top navbar-expand-sm navbar-dark bg-dark">
+  <div class="container-fluid">
+    <!-- Brand and toggle get grouped for better mobile display -->
+    <div class="navbar-header">
+      <button type="button" class="navbar-toggler" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1"
+        aria-expanded="false" aria-controls="navbar-nav" aria-label="toggle navigation">
+        <span class="navbar-toggler-icon"></span>
+      </button>
+      <a class="navbar-brand" href="{{ pathPrefix }}/">Prometheus</a>
+    </div>
+
+    <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
+      <ul class="nav navbar-nav">
+        <li class="nav-item"><a class="nav-link" href="{{ pathPrefix }}/alerts">Alerts</a></li>
+      </ul>
+    </div>
+  </div>
+</nav>
+{{ end }}
+
+{{/* LHS menu, should be passed . */}}
+{{ define "menu" }}
+<div class="prom_lhs_menu row">
+  <nav class="col-md-2 md-block bg-dark sidebar prom_lhs_menu_nav">
+    <div class="sidebar-sticky">
+      <ul class="nav flex-column">
+
+        {{ template "_menuItem" (args . "index.html" "Overview") }}
+
+        {{ $ctx := . }}
+
+        {{ range query "up{job='node-exporter'}" | sortByLabel "instance" }}
+        {{ $instance := .Labels.instance }}
+        <ul>
+          {{ template "_menuItem" (args $ctx (printf "node-overview.html?instance=%v" $instance) $instance) }}
+          <ul>
+            {{ template "_menuItem" (args $ctx (printf "node-cpu.html?instance=%v" $instance) "CPU") }}
+            {{ template "_menuItem" (args $ctx (printf "node-disk.html?instance=%v" $instance) "Disk") }}
+          </ul>
+        </ul>
+        {{ end }}
+
+        {{/* XXX: there is only one prometheus instance in my setup */}}
+        {{ with query "up{job='prometheus'}" | first }}
+        {{ template "_menuItem" (args $ctx (printf "prometheus-overview.html?instance=%v" .Labels.instance) "Prometheus") }}
+        {{ end }}
+
+      </ul>
+    </div>
+  </nav>
+</div>
+{{ end }}
+
+{{/* Helper, pass (args . path name) */}}
+{{ define "_menuItem" }}
+{{ $pagelink := .arg0.Path }}
+{{ if .arg0.Params.instance }}{{ $pagelink = (printf "%v?instance=%v" .arg0.Path .arg0.Params.instance) }}{{ end }}
+<li class="{{ if eq $pagelink .arg1 }}prom_lhs_menu_selected {{ end }}nav-item"><a class="nav-link"
+    href="{{ .arg1 }}">{{ .arg2 }}</a></li>
+{{ end }}