converge/pkg/server/templates/basepage.templ
Erik Brakkee e141007f0a Now displaying agent number instead of id.
Passing timezone to server side for rendering of time stamps
Configuration of preferred shells.
2024-09-08 11:16:49 +02:00

91 lines
2.9 KiB
Plaintext

package templates
func active(actual int, active int) string {
res := "nav-item nav-link"
if actual == active {
return res + " active"
}
return res
}
templ BasePage(tab int) {
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<link rel="stylesheet" href="../static/css/bootstrap.min.css"
crossorigin="anonymous">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<script src="../static/js/htmx.1.9.12.js"></script>
<script src="../static/js/htmx.ws.1.9.12.js"></script>
<title>Converge</title>
</head>
<body>
<!-- script>
htmx.logAll();
</script -->
<script>
function getTimezone() {
return Intl.DateTimeFormat().resolvedOptions().timeZone;
}
if (!window.originalWebSocket) {
console.log("timezone override for websockets")
window.originalWebSocket = htmx.createWebSocket
htmx.createWebSocket = function(url) {
let modifiedUrl = url + "?timezone=" + getTimezone()
return window.originalWebSocket(modifiedUrl)
}
}
document.body.addEventListener(
"htmx:configRequest",
function(evt) {
console.log("Adding timezone to htmx request headers");
evt.detail.headers["X-Timezone"] = getTimezone();
}
);
</script>
<script src="../static/js/bootstrap.bundle.min.js"
crossorigin="anonymous"></script>
<div class="container-fluid" hx-boost="true">
<div class="row">
<div class="col">
<nav class="navbar navbar-expand-sm navbar-light bg-light">
<button class="navbar-toggler" type="button" data-bs-toggle="collapse"
data-bs-target="#navbarNavAltMarkup"
aria-controls="navbarNav" aria-expanded="false"
aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarNavAltMarkup">
<div class="nav nav-pills">
<a class={active(1,tab)} href="index.html">overview</a>
<a class={active(2,tab)} href="usage.html">usage</a>
<a class={active(3,tab)} href="downloads.html">downloads</a>
<a class={active(4,tab)} href="sessions.html">sessions</a>
</div>
</div>
</nav>
</div>
</div>
<div class="row">
<div class="col">
{ children... }
</div>
</div>
</div>
</body>
</html>
}