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
|
// ToFrontend converts a DockerHost to DockerHostFrontend
|
||||||
func (d DockerHost) ToFrontend() DockerHostFrontend {
|
func (d DockerHost) ToFrontend() DockerHostFrontend {
|
||||||
h := DockerHostFrontend{
|
h := DockerHostFrontend{
|
||||||
ID: d.ID,
|
ID: d.ID,
|
||||||
AgentID: d.AgentID,
|
AgentID: d.AgentID,
|
||||||
Hostname: d.Hostname,
|
Hostname: d.Hostname,
|
||||||
DisplayName: d.DisplayName,
|
DisplayName: d.DisplayName,
|
||||||
MachineID: d.MachineID,
|
CustomDisplayName: d.CustomDisplayName,
|
||||||
OS: d.OS,
|
MachineID: d.MachineID,
|
||||||
KernelVersion: d.KernelVersion,
|
OS: d.OS,
|
||||||
Architecture: d.Architecture,
|
KernelVersion: d.KernelVersion,
|
||||||
Runtime: d.Runtime,
|
Architecture: d.Architecture,
|
||||||
RuntimeVersion: d.RuntimeVersion,
|
Runtime: d.Runtime,
|
||||||
DockerVersion: d.DockerVersion,
|
RuntimeVersion: d.RuntimeVersion,
|
||||||
CPUs: d.CPUs,
|
DockerVersion: d.DockerVersion,
|
||||||
TotalMemoryBytes: d.TotalMemoryBytes,
|
CPUs: d.CPUs,
|
||||||
UptimeSeconds: d.UptimeSeconds,
|
TotalMemoryBytes: d.TotalMemoryBytes,
|
||||||
CPUUsagePercent: d.CPUUsage,
|
UptimeSeconds: d.UptimeSeconds,
|
||||||
Status: d.Status,
|
CPUUsagePercent: d.CPUUsage,
|
||||||
LastSeen: d.LastSeen.Unix() * 1000,
|
Status: d.Status,
|
||||||
IntervalSeconds: d.IntervalSeconds,
|
LastSeen: d.LastSeen.Unix() * 1000,
|
||||||
AgentVersion: d.AgentVersion,
|
IntervalSeconds: d.IntervalSeconds,
|
||||||
Containers: make([]DockerContainerFrontend, len(d.Containers)),
|
AgentVersion: d.AgentVersion,
|
||||||
|
Containers: make([]DockerContainerFrontend, len(d.Containers)),
|
||||||
}
|
}
|
||||||
|
|
||||||
if h.DisplayName == "" {
|
if h.DisplayName == "" {
|
||||||
|
|
|
||||||
|
|
@ -102,6 +102,7 @@ type DockerHostFrontend struct {
|
||||||
AgentID string `json:"agentId"`
|
AgentID string `json:"agentId"`
|
||||||
Hostname string `json:"hostname"`
|
Hostname string `json:"hostname"`
|
||||||
DisplayName string `json:"displayName"`
|
DisplayName string `json:"displayName"`
|
||||||
|
CustomDisplayName string `json:"customDisplayName,omitempty"`
|
||||||
MachineID string `json:"machineId,omitempty"`
|
MachineID string `json:"machineId,omitempty"`
|
||||||
OS string `json:"os,omitempty"`
|
OS string `json:"os,omitempty"`
|
||||||
KernelVersion string `json:"kernelVersion,omitempty"`
|
KernelVersion string `json:"kernelVersion,omitempty"`
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue