diff --git a/lib/web/frontend.go b/lib/web/frontend.go index f0f65cf..6bf7b1c 100644 --- a/lib/web/frontend.go +++ b/lib/web/frontend.go @@ -15,6 +15,21 @@ func setupFrontend(r *gin.Engine) { r.LoadHTMLGlob("templates/*") 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 r.GET("/", func(ctx *gin.Context) { hardDrives, err := hardware.GetSystemHardDrives(svc.GetDatabaseRef(), nil, nil) diff --git a/templates/drive.html b/templates/drive.html index 5eb6b28..8ae4c24 100644 --- a/templates/drive.html +++ b/templates/drive.html @@ -12,47 +12,31 @@
ID | -Name | -Model | -Serial | -Temperature | -||
#{{ .ID }} | -{{ .Name }} | -{{ .Model }} | -{{ .Serial }} | - - {{ if gt $temp 50 }} -{{ $temp }}°C | - {{ else if gt $temp 30 }} -{{ $temp }}°C | - {{ else }} -{{ $temp }}°C | - {{ end }} -
No hard drives found.
- {{ end }} +ID | +Name | +Model | +Serial | +Temperature | +
#{{ .hdd.ID }} | +{{ .hdd.Name }} | +{{ .hdd.Model }} | +{{ .hdd.Serial }} | +