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
@@ -1188,6 +1188,22 @@ func main() {
|
||||
}
|
||||
log.Info("Device ACL loaded from %s (%d binding(s))", aclFile, len(deviceACL.Snapshot()))
|
||||
|
||||
// Per-device remarks (the web card's "hostname (remark)" label) live next
|
||||
// to the ACL. A malformed file only loses labels — it carries no access
|
||||
// rights — so the server still starts; the store then refuses every edit
|
||||
// so the unreadable file is never overwritten.
|
||||
notesFile := os.Getenv("YAMA_DEVICE_NOTES_FILE")
|
||||
if notesFile == "" {
|
||||
notesFile = filepath.Join(filepath.Dir(usersFile), "device_notes.json")
|
||||
rememberDefault("YAMA_DEVICE_NOTES_FILE", notesFile)
|
||||
}
|
||||
deviceNotes := web.NewDeviceNotes(notesFile)
|
||||
if err := deviceNotes.Load(); err != nil {
|
||||
log.Warn("Failed to load device remarks from %s: %v (remark edits are refused until the file is fixed)", notesFile, err)
|
||||
} else {
|
||||
log.Info("Device remarks loaded from %s (%d remark(s))", notesFile, len(deviceNotes.Snapshot()))
|
||||
}
|
||||
|
||||
// TCP authorization (TOKEN_AUTH) brute-force throttle. Keyed by source IP
|
||||
// (the real TCP peer — there is no X-Forwarded-For on the device port).
|
||||
// Generous enough that a NAT office whose devices all re-auth at once is
|
||||
@@ -1416,6 +1432,7 @@ func main() {
|
||||
BrandName: brandName,
|
||||
SSO: ssoDetector,
|
||||
DeviceACL: deviceACL,
|
||||
DeviceNotes: deviceNotes,
|
||||
TransferTarget: transferTarget,
|
||||
TransferDays: transferDays,
|
||||
TransferTransport: transferTransport,
|
||||
|
||||
Reference in new issue
Block a user