Basic disk page implementation
+ Basic information about the disk
This commit is contained in:
parent
f17d8b44a3
commit
145362b7ef
|
@ -15,6 +15,21 @@ func setupFrontend(r *gin.Engine) {
|
||||||
r.LoadHTMLGlob("templates/*")
|
r.LoadHTMLGlob("templates/*")
|
||||||
r.Static("/static", "./static")
|
r.Static("/static", "./static")
|
||||||
|
|
||||||
|
r.GET("/disk/:id", func(ctx *gin.Context) {
|
||||||
|
id := ctx.Param("id")
|
||||||
|
var hdd hardware.HardDrive
|
||||||
|
tx := svc.GetDatabaseRef().Where("id = ?", id).Preload("Temperatures").First(&hdd)
|
||||||
|
if tx.Error != nil {
|
||||||
|
ctx.AbortWithError(500, tx.Error)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// Render the HTML template
|
||||||
|
ctx.HTML(http.StatusOK, "drive.html", gin.H{
|
||||||
|
"hdd": hdd,
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
// Set up a route for the root URL
|
// Set up a route for the root URL
|
||||||
r.GET("/", func(ctx *gin.Context) {
|
r.GET("/", func(ctx *gin.Context) {
|
||||||
hardDrives, err := hardware.GetSystemHardDrives(svc.GetDatabaseRef(), nil, nil)
|
hardDrives, err := hardware.GetSystemHardDrives(svc.GetDatabaseRef(), nil, nil)
|
||||||
|
|
|
@ -12,47 +12,31 @@
|
||||||
|
|
||||||
<div class="container-titlebar">
|
<div class="container-titlebar">
|
||||||
<div class="pad">
|
<div class="pad">
|
||||||
<h4>Available Disks</h4>
|
<h4>{{ .hdd.Model }} <span class="grooved">{{ .hdd.Size }}</span></h4>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="container-body">
|
<div class="container-body">
|
||||||
<div class="pad">
|
<div class="pad">
|
||||||
{{ if len .drives }}
|
<table id="disks-table">
|
||||||
<table id="disks-table">
|
<thead>
|
||||||
<thead>
|
<tr>
|
||||||
<tr>
|
<td>ID</td>
|
||||||
<td>ID</td>
|
<td>Name</td>
|
||||||
<td>Name</td>
|
<td>Model</td>
|
||||||
<td>Model</td>
|
<td>Serial</td>
|
||||||
<td>Serial</td>
|
<td>Temperature</td>
|
||||||
<td>Temperature</td>
|
</tr>
|
||||||
</tr>
|
</thead>
|
||||||
</thead>
|
<tbody id="disk-table-body">
|
||||||
<tbody id="disk-table-body">
|
<tr>
|
||||||
{{ range .drives }}
|
<td>#{{ .hdd.ID }}</td>
|
||||||
{{ $temp := .GetTemperature }}
|
<td> {{ .hdd.Name }}</td>
|
||||||
|
<td> {{ .hdd.Model }}</td>
|
||||||
<tr>
|
<td> {{ .hdd.Serial }}</td>
|
||||||
<td>#{{ .ID }}</td>
|
</tr>
|
||||||
<td> {{ .Name }}</td>
|
</tbody>
|
||||||
<td> {{ .Model }}</td>
|
</table>
|
||||||
<td> {{ .Serial }}</td>
|
|
||||||
|
|
||||||
{{ if gt $temp 50 }} <!-- Temperature greater than 50°C -->
|
|
||||||
<td style="color: red;">{{ $temp }}°C</td>
|
|
||||||
{{ else if gt $temp 30 }} <!-- Temperature between 31°C and 50°C -->
|
|
||||||
<td style="color: orange;">{{ $temp }}°C</td>
|
|
||||||
{{ else }} <!-- Temperature 30°C or below -->
|
|
||||||
<td style="color: lime;">{{ $temp }}°C</td>
|
|
||||||
{{ end }}
|
|
||||||
</tr>
|
|
||||||
{{ end }}
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
{{ else }}
|
|
||||||
<p>No hard drives found.</p>
|
|
||||||
{{ end }}
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue