converge/pkg/server/templates/basepage.templ
Erik Brakkee 567d9a4031 now a single websocket is opened from the webui to converge.
The browser sends a hello message anytime the user switches to the
sessions page, upon which the server sends the current state back.
THis also improves the timeout handling of broken connecions.
2024-09-08 11:16:49 +02:00

111 lines
3.7 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">
<link rel="stylesheet" href="../static/icons/font/bootstrap-icons.css">
<link rel="stylesheet" href="../static/css/converge.css">
<link rel="preload" as="image" href="../static/images/wamblee_logo.png">
<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>
<script type="module" src="../static/js/modules.js"></script>
<script src="../static/js/persistentforms.js"></script>
<title>Converge</title>
</head>
<body hx-boost="true" hx-ext="ws" ws-connect="../ws/sessions">
<div id="banner">
<img src="../static/images/wamblee_logo.png" />
<span class="title fs-4">
converge
<br/>
<span class="fs-5">a rendez-vous server for debugging continuous integration jobs<sup class="small">*</sup>
</span>
<br/>
<span class="verysmall text-muted">* not written in java</span>
</span>
</div>
<!-- script>
htmx.logAll();
</script -->
<script>
function getTimezone() {
return Intl.DateTimeFormat().resolvedOptions().timeZone;
}
if (!window.originalWebSocket) {
window.originalWebSocket = htmx.createWebSocket
htmx.createWebSocket = function(url) {
url = new URL(url, window.location.href).href
url = url.replace(/^http/, 'ws');
let modifiedUrl = url + "?timezone=" + getTimezone()
return window.originalWebSocket(modifiedUrl)
}
}
document.body.addEventListener(
"htmx:configRequest",
function(evt) {
//console.log("Adding timezone to htmx request headers and making URL absolute");
evt.detail.headers["X-Timezone"] = getTimezone();
}
);
</script>
<script src="../static/js/bootstrap.bundle.min.js"
crossorigin="anonymous"></script>
<div class="container-fluid">
<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>
}