Add OK/Offline field and small improvements

This commit is contained in:
raul 2024-06-04 12:41:09 +02:00
parent 5fed7f5de2
commit b6a6c28bd8
3 changed files with 25 additions and 17 deletions

View File

@ -24,6 +24,7 @@ func WebServer() {
r := gin.Default() r := gin.Default()
LoadHTMLFromEmbedFS(r, templatesFolder, "templates/*.html") LoadHTMLFromEmbedFS(r, templatesFolder, "templates/*.html")
r.StaticFileFS("/style.css", "./templates/style.css", http.FS(templatesFolder)) r.StaticFileFS("/style.css", "./templates/style.css", http.FS(templatesFolder))
r.StaticFileFS("/htmx.js", "./templates/htmx.js", http.FS(templatesFolder))
r.GET("/", getRoot) r.GET("/", getRoot)
r.Run(":" + WebPort) r.Run(":" + WebPort)
} }

View File

@ -2,10 +2,12 @@
<html lang="en"> <html lang="en">
<head> <head>
<title>AEMET Client</title> <title>Tiamat Dashboard</title>
<meta charset="UTF-8"> <meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1"> <meta name="viewport" content="width=device-width, initial-scale=1">
<link href="style.css" rel="stylesheet"> <link href="style.css" rel="stylesheet">
<script href="htmx.js" integrity="sha384-qbtR4rS9RrUMECUWDWM2+YGgN3U4V4ZncZ0BvUcg9FGct0jqXz3PUdVpU1p0yrXS"
crossorigin="anonymous"></script>
</head> </head>
<body> <body>
@ -13,12 +15,12 @@
<div id="main"> <div id="main">
<p>Hello {{ .UserAgent }}</p> <p>Hello {{ .UserAgent }}</p>
<hr> <hr>
<h2>Current clients</h2> <h2 align=center>Current clients</h2>
{{ range .Clients }} {{ range .Clients }}
<table border=1> <table border=1>
<tr> <tr>
<td rowspan=2>Status</td> <td>Status</td>
<td>IP</td> <td>IP</td>
<td>Username</td> <td>Username</td>
<td>Hostname</td> <td>Hostname</td>
@ -26,20 +28,25 @@
<td rowspan=2>Actions</td> <td rowspan=2>Actions</td>
</tr> </tr>
<tr> <tr>
<td>{{ .PublicIP }}</td> <td>
<td>{{ .Username }}</td> {{ if .IsOnline }}
<td>{{ .Hostname }}</td> <on>
<td>{{ .OperatingSystem }}</td> OK
</on>
{{ else }}
<off>
Offline
</off>
{{ end }}
</td>
<td>{{ .ClientBasicInfo.PublicIP }}</td>
<td>{{ .ClientBasicInfo.Username }}</td>
<td>{{ .ClientBasicInfo.Hostname }}</td>
<td>{{ .ClientBasicInfo.OperatingSystem }}</td>
</tr> </tr>
</table> </table>
<hr> <hr>
{{ end }} {{ end }}
<!-- <p>{{ .Username }}</p> -->
<!-- <p>{{ .UID }}</p> -->
<!-- <p>{{ .GID }}</p> -->
<!-- <p>{{ .Hostname }}</p> -->
<!-- <p>{{ .OperatingSystem }}</p> -->
</div> </div>
</div> </div>
</body> </body>

View File

@ -37,13 +37,13 @@ td.date {
padding-right: 5px; padding-right: 5px;
} }
cold { on {
color: darkcyan; color: green;
font-weight: 500; font-weight: 500;
} }
hot { off {
color: darkorange; color: red;
font-weight: 500; font-weight: 500;
} }