Feature: edit device remarks from the web console
The Go web console now stores a per-device remark and renders it as "hostname (remark)" on the card, the label displayName already supported. The card's "..." menu gets an Edit remark entry directly below Terminal; it opens a small dialog, and an empty value clears the label. Remarks live in device_notes.json next to users.json, independent of the device history and ACL, so offline records carry them too. The WebSocket command set_device_remark is admin-only and honors the device ACL (a private device of another owner is refused). Updates are audited as admin.device.remark and broadcast as devices_changed so every open console refreshes. Deleting a device drops its remark. The device_list reply reports remarkEdit only when a notes table is wired, so the shared page hides the entry on the MFC server, which does not implement it. A malformed or newer-version device_notes.json disables writes instead of letting the first save overwrite labels it could not parse; loaded values are re-sanitized and capped. Verified with go test ./..., vet, gofmt, and a node --check pass on the inline script. Co-Authored-By: deepseek-flash
This commit is contained in:
1 parent
1bd7fa5b2d
commit
95d2bbc1b6
9 files changed
+741
-7
No files matched your search
@@ -161,6 +161,7 @@ type wsHub struct {
|
||||
devices *hub.Hub
|
||||
history *devicehistory.Store // nil → device_list stays online-only
|
||||
acl *DeviceACL // nil → every device is public (tests/embedders)
|
||||
notes *DeviceNotes // nil → no "edit remark" entry (MFC backend)
|
||||
log *logger.Logger
|
||||
|
||||
mu sync.RWMutex
|
||||
@@ -237,6 +238,15 @@ func (h *wsHub) withDeviceACL(acl *DeviceACL) *wsHub {
|
||||
return h
|
||||
}
|
||||
|
||||
// withDeviceNotes installs the per-device remark table. A nil table disables
|
||||
// "edit remark": its presence is what the device_list reply reports as
|
||||
// remarkEdit, so the shared page only offers the menu entry on a backend that
|
||||
// implements it (the MFC server does not).
|
||||
func (h *wsHub) withDeviceNotes(notes *DeviceNotes) *wsHub {
|
||||
h.notes = notes
|
||||
return h
|
||||
}
|
||||
|
||||
// withTransferDefaults installs the pre-filled target/days and the link type
|
||||
// (protocol.TransferTransport*) for the web UI's "transfer host" dialog. An
|
||||
// empty target still enables the feature: the operator types the address in
|
||||
|
||||
Reference in new issue
Block a user