Fix MachineResponse: expose last_seen_at/created_at, clean status string
The status field was being decorated with "(last seen ...)" suffix
which broke frontend statusVariant() matching and prevented the
LastSeen column from showing the separate timestamp.
Changes:
- machineToResp() now returns clean status ("online"/"offline")
- MachineResponse includes last_seen_at and created_at as separate fields
- Fix whitespace typo in WakeCheckIntervalSeconds field
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
BINARY=syncserver
|
BINARY=syncserver
|
||||||
VERSION?=1.0.41
|
VERSION?=1.0.42
|
||||||
GO?=go
|
GO?=go
|
||||||
LDFLAGS=-s -w -X main.version=$(VERSION) -X main.commit=$(shell git rev-parse --short HEAD 2>/dev/null || echo unknown)
|
LDFLAGS=-s -w -X main.version=$(VERSION) -X main.commit=$(shell git rev-parse --short HEAD 2>/dev/null || echo unknown)
|
||||||
BUILD_FLAGS=CGO_ENABLED=0
|
BUILD_FLAGS=CGO_ENABLED=0
|
||||||
|
|||||||
+1
-1
@@ -20,7 +20,7 @@ import (
|
|||||||
"github.com/syncserver/internal/syncengine"
|
"github.com/syncserver/internal/syncengine"
|
||||||
)
|
)
|
||||||
|
|
||||||
var version = "1.0.41"
|
var version = "1.0.42"
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
cfgPath := flag.String("config", "", "Path to config.yaml")
|
cfgPath := flag.String("config", "", "Path to config.yaml")
|
||||||
|
|||||||
@@ -28,6 +28,8 @@ type MachineResponse struct {
|
|||||||
FingerprintConfirmed bool `json:"fingerprint_confirmed"`
|
FingerprintConfirmed bool `json:"fingerprint_confirmed"`
|
||||||
HostKeyFingerprint *string `json:"host_key_fingerprint"`
|
HostKeyFingerprint *string `json:"host_key_fingerprint"`
|
||||||
Status string `json:"status"`
|
Status string `json:"status"`
|
||||||
|
LastSeenAt *string `json:"last_seen_at"`
|
||||||
|
CreatedAt string `json:"created_at"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type TestConnectionResponse struct {
|
type TestConnectionResponse struct {
|
||||||
|
|||||||
@@ -444,11 +444,10 @@ func (h *MachineHandler) Delete(w http.ResponseWriter, r *http.Request) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func machineToResp(m models.Machine) MachineResponse {
|
func machineToResp(m models.Machine) MachineResponse {
|
||||||
var status string
|
var lastSeen *string
|
||||||
if m.LastSeenAt != nil {
|
if m.LastSeenAt != nil {
|
||||||
status = m.Status + " (last seen " + m.LastSeenAt.Format(time.RFC3339) + ")"
|
s := m.LastSeenAt.Format(time.RFC3339)
|
||||||
} else {
|
lastSeen = &s
|
||||||
status = m.Status
|
|
||||||
}
|
}
|
||||||
return MachineResponse{
|
return MachineResponse{
|
||||||
ID: m.ID,
|
ID: m.ID,
|
||||||
@@ -461,10 +460,12 @@ func machineToResp(m models.Machine) MachineResponse {
|
|||||||
WoLEnabled: m.WoLEnabled,
|
WoLEnabled: m.WoLEnabled,
|
||||||
BroadcastAddr: m.BroadcastAddr,
|
BroadcastAddr: m.BroadcastAddr,
|
||||||
WakeTimeoutSeconds: m.WakeTimeoutSeconds,
|
WakeTimeoutSeconds: m.WakeTimeoutSeconds,
|
||||||
WakeCheckIntervalSeconds: m.WakeCheckIntervalSeconds,
|
WakeCheckIntervalSeconds: m.WakeCheckIntervalSeconds,
|
||||||
FingerprintConfirmed: m.FingerprintConfirmed,
|
FingerprintConfirmed: m.FingerprintConfirmed,
|
||||||
HostKeyFingerprint: m.HostKeyFingerprint,
|
HostKeyFingerprint: m.HostKeyFingerprint,
|
||||||
Status: status,
|
Status: m.Status,
|
||||||
|
LastSeenAt: lastSeen,
|
||||||
|
CreatedAt: m.CreatedAt.Format(time.RFC3339),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user