feat(control): show display block version in control block

closes #54
This commit is contained in:
E44
2026-06-12 10:59:09 +02:00
parent 9284a8f72a
commit a827a3e588
7 changed files with 63 additions and 24 deletions
+28 -5
View File
@@ -1,6 +1,7 @@
package main
import (
"encoding/json"
"log/slog"
"net"
"net/http"
@@ -83,18 +84,40 @@ func pingRoute(ctx echo.Context) error {
return ctx.JSON(http.StatusOK, PingResponse{Status: "host_offline"})
}
conn, err := net.DialTimeout("tcp", ip+":1323", 5*time.Second)
client := http.Client{
Timeout: 5 * time.Second,
}
resp, err := client.Get("http://" + ip + ":1323/api/ping")
if err != nil {
return ctx.JSON(http.StatusOK, PingResponse{Status: "app_offline"})
}
conn.Close()
defer resp.Body.Close()
if resp.StatusCode != http.StatusOK {
return ctx.JSON(http.StatusOK, PingResponse{Status: "app_offline"})
}
return ctx.JSON(http.StatusOK, PingResponse{Status: "app_online"})
var appPing AppPingResponse
if err := json.NewDecoder(resp.Body).Decode(&appPing); err != nil {
return ctx.JSON(http.StatusOK, PingResponse{
Status: "app_offline",
})
}
return ctx.JSON(http.StatusOK, PingResponse{
Status: "app_online",
Version: appPing.Version,
})
}
type AppPingResponse struct {
Version string `json:"version"`
}
type PingResponse struct {
Status string `json:"status"`
Error string `json:"error"`
Status string `json:"status"`
Version string `json:"version"`
Error string `json:"error"`
}
type WakeOnLanRequest struct {