Fix Docker host custom display name not persisting in UI (related to #662)
The custom display name feature added in cd627f33c had a critical bug where the backend successfully stored custom names but the frontend never received them, making the feature appear non-functional. Root cause: - DockerHost.CustomDisplayName was stored in backend state (models.go:201) - SetDockerHostCustomDisplayName() correctly updated the field - BUT DockerHostFrontend struct was missing customDisplayName field - AND ToFrontend() converter didn't copy CustomDisplayName - Result: WebSocket state broadcasts stripped out the custom name When users edited a Docker host display name: - API returned 200 OK ✓ - Success notification appeared ✓ - Edit state cleared ✓ - But subsequent state broadcasts lacked customDisplayName ✗ - UI continued showing original name ✗ Fix: - Add CustomDisplayName field to DockerHostFrontend (models_frontend.go:105) - Copy d.CustomDisplayName in ToFrontend() converter (converters.go:204) - Now custom display names properly propagate to frontend via WebSocket The feature now works as originally intended - custom names persist across agent reconnections and display correctly in the UI.
This commit is contained in:
parent
1a3abf7f3f
commit
8cea433443
2 changed files with 22 additions and 20 deletions
|
|
@ -197,26 +197,27 @@ func (c Container) ToFrontend() ContainerFrontend {
|
|||
// ToFrontend converts a DockerHost to DockerHostFrontend
|
||||
func (d DockerHost) ToFrontend() DockerHostFrontend {
|
||||
h := DockerHostFrontend{
|
||||
ID: d.ID,
|
||||
AgentID: d.AgentID,
|
||||
Hostname: d.Hostname,
|
||||
DisplayName: d.DisplayName,
|
||||
MachineID: d.MachineID,
|
||||
OS: d.OS,
|
||||
KernelVersion: d.KernelVersion,
|
||||
Architecture: d.Architecture,
|
||||
Runtime: d.Runtime,
|
||||
RuntimeVersion: d.RuntimeVersion,
|
||||
DockerVersion: d.DockerVersion,
|
||||
CPUs: d.CPUs,
|
||||
TotalMemoryBytes: d.TotalMemoryBytes,
|
||||
UptimeSeconds: d.UptimeSeconds,
|
||||
CPUUsagePercent: d.CPUUsage,
|
||||
Status: d.Status,
|
||||
LastSeen: d.LastSeen.Unix() * 1000,
|
||||
IntervalSeconds: d.IntervalSeconds,
|
||||
AgentVersion: d.AgentVersion,
|
||||
Containers: make([]DockerContainerFrontend, len(d.Containers)),
|
||||
ID: d.ID,
|
||||
AgentID: d.AgentID,
|
||||
Hostname: d.Hostname,
|
||||
DisplayName: d.DisplayName,
|
||||
CustomDisplayName: d.CustomDisplayName,
|
||||
MachineID: d.MachineID,
|
||||
OS: d.OS,
|
||||
KernelVersion: d.KernelVersion,
|
||||
Architecture: d.Architecture,
|
||||
Runtime: d.Runtime,
|
||||
RuntimeVersion: d.RuntimeVersion,
|
||||
DockerVersion: d.DockerVersion,
|
||||
CPUs: d.CPUs,
|
||||
TotalMemoryBytes: d.TotalMemoryBytes,
|
||||
UptimeSeconds: d.UptimeSeconds,
|
||||
CPUUsagePercent: d.CPUUsage,
|
||||
Status: d.Status,
|
||||
LastSeen: d.LastSeen.Unix() * 1000,
|
||||
IntervalSeconds: d.IntervalSeconds,
|
||||
AgentVersion: d.AgentVersion,
|
||||
Containers: make([]DockerContainerFrontend, len(d.Containers)),
|
||||
}
|
||||
|
||||
if h.DisplayName == "" {
|
||||
|
|
|
|||
|
|
@ -102,6 +102,7 @@ type DockerHostFrontend struct {
|
|||
AgentID string `json:"agentId"`
|
||||
Hostname string `json:"hostname"`
|
||||
DisplayName string `json:"displayName"`
|
||||
CustomDisplayName string `json:"customDisplayName,omitempty"`
|
||||
MachineID string `json:"machineId,omitempty"`
|
||||
OS string `json:"os,omitempty"`
|
||||
KernelVersion string `json:"kernelVersion,omitempty"`
|
||||
|
|
|
|||
Loading…
Reference in a new issue