Implemented frontend

+ Graph Generation as images for frontend performance
+ A new decent style
This commit is contained in:
2024-01-21 18:25:23 +02:00
parent eb94ce4552
commit 545eed44cd
7 changed files with 315 additions and 40 deletions

View File

@@ -8,17 +8,77 @@
</head>
<body>
<div class="container">
<h1>Drive Health Dashboard</h1>
<table>
<thead>
</thead>
<tbody id="disk-table-body">
</tbody>
</table>
<hr>
<div class="container-titlebar">
<div class="pad">
<h4>Available Disks</h4>
</div>
</div>
<div class="container-body">
<div class="pad">
{{ if len .drives }}
<table id="disks-table">
<thead>
<tr>
<td>ID</td>
<td>Name</td>
<td>Model</td>
<td>Serial</td>
<td>Temperature</td>
</tr>
</thead>
<tbody id="disk-table-body">
{{ range .drives }}
{{ $temp := .GetTemperature }}
<tr>
<td>#{{ .ID }}</td>
<td> {{ .Name }}</td>
<td> {{ .Model }}</td>
<td> {{ .Serial }}</td>
{{ if gt $temp 50 }} <!-- Temperature greater than 50°C -->
<td style="color: red;">{{ $temp }}&deg;C</td>
{{ else if gt $temp 30 }} <!-- Temperature between 31°C and 50°C -->
<td style="color: orange;">{{ $temp }}&deg;C</td>
{{ else }} <!-- Temperature 30°C or below -->
<td style="color: lime;">{{ $temp }}&deg;C</td>
{{ end }}
</tr>
{{ end }}
</tbody>
</table>
{{ else }}
<p>No hard drives found.</p>
{{ end }}
</div>
</div>
</div>
<div class="container">
<div class="container-titlebar">
<div class="pad">
<h4>Temperature Graph</h4>
</div>
</div>
<div class="container-body">
<div class="pad">
{{ if len .drives }}
{{ range .drives }}
<div id="disk-temp-{{ .ID }}">
<a href="/api/v1/disks/{{.ID}}/chart" target="_blank">
<img class="graph-image" src="/api/v1/disks/{{.ID}}/chart" alt="{{ .Model }} Image">
</a>
</div>
{{ end }}
{{ else }}
<p>No hard drives found.</p>
{{ end }}
</div>
</div>
</div>