From dda102a0fc162cad9eeccc86af7a563fbe7bd007 Mon Sep 17 00:00:00 2001 From: JackTheRooster Date: Wed, 5 Mar 2025 22:24:17 -0600 Subject: [PATCH 1/8] added NameConfig config added gosimple/slug dependency --- config.go | 10 ++++++++++ go.mod | 2 ++ go.sum | 4 ++++ 3 files changed, 16 insertions(+) diff --git a/config.go b/config.go index e4e27d7..005efc8 100644 --- a/config.go +++ b/config.go @@ -12,6 +12,11 @@ type WakeOnLanDevice struct { MacAddress string `json:"macAddress"` } +type NameConfig struct { + Name string `json:"name"` + DNS string `json:"dns"` +} + type UsbConfig struct { VendorId string `json:"vendor_id"` ProductId string `json:"product_id"` @@ -34,6 +39,7 @@ type Config struct { WakeOnLanDevices []WakeOnLanDevice `json:"wake_on_lan_devices"` EdidString string `json:"hdmi_edid_string"` ActiveExtension string `json:"active_extension"` + NameConfig NameConfig `json:"name_config"` DisplayMaxBrightness int `json:"display_max_brightness"` DisplayDimAfterSec int `json:"display_dim_after_sec"` DisplayOffAfterSec int `json:"display_off_after_sec"` @@ -57,6 +63,10 @@ var defaultConfig = &Config{ Manufacturer: "JetKVM", Product: "USB Emulation Device", }, + NameConfig: NameConfig{ + Name: "JetKVM", + DNS: "jetkvm.local", + }, } var ( diff --git a/go.mod b/go.mod index 5748e64..d4212aa 100644 --- a/go.mod +++ b/go.mod @@ -46,6 +46,8 @@ require ( github.com/go-playground/universal-translator v0.18.1 // indirect github.com/go-playground/validator/v10 v10.20.0 // indirect github.com/goccy/go-json v0.10.2 // indirect + github.com/gosimple/slug v1.15.0 // indirect + github.com/gosimple/unidecode v1.0.1 // indirect github.com/json-iterator/go v1.1.12 // indirect github.com/klauspost/compress v1.17.11 // indirect github.com/klauspost/cpuid/v2 v2.2.7 // indirect diff --git a/go.sum b/go.sum index a5ce4cd..8f6f732 100644 --- a/go.sum +++ b/go.sum @@ -50,6 +50,10 @@ github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeN github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= +github.com/gosimple/slug v1.15.0 h1:wRZHsRrRcs6b0XnxMUBM6WK1U1Vg5B0R7VkIf1Xzobo= +github.com/gosimple/slug v1.15.0/go.mod h1:UiRaFH+GEilHstLUmcBgWcI42viBN7mAb818JrYOeFQ= +github.com/gosimple/unidecode v1.0.1 h1:hZzFTMMqSswvf0LBJZCZgThIZrpDHFXux9KeGmn6T/o= +github.com/gosimple/unidecode v1.0.1/go.mod h1:CP0Cr1Y1kogOtx0bJblKzsVWrqYaqfNOnHzpgWw4Awc= github.com/gwatts/rootcerts v0.0.0-20240401182218-3ab9db955caf h1:JO6ISZIvEUitto5zjQ3/VEnDM5rPbqIFuOhS0U0ByeA= github.com/gwatts/rootcerts v0.0.0-20240401182218-3ab9db955caf/go.mod h1:5Kt9XkWvkGi2OHOq0QsGxebHmhCcqJ8KCbNg/a6+n+g= github.com/hanwen/go-fuse/v2 v2.5.1 h1:OQBE8zVemSocRxA4OaFJbjJ5hlpCmIWbGr7r0M4uoQQ= From 2c6c148765cad3693531eb43dfe8b5d3c428d6d4 Mon Sep 17 00:00:00 2001 From: JackTheRooster Date: Wed, 5 Mar 2025 22:26:00 -0600 Subject: [PATCH 2/8] ran go mod tidy --- go.mod | 2 -- go.sum | 4 ---- 2 files changed, 6 deletions(-) diff --git a/go.mod b/go.mod index d4212aa..5748e64 100644 --- a/go.mod +++ b/go.mod @@ -46,8 +46,6 @@ require ( github.com/go-playground/universal-translator v0.18.1 // indirect github.com/go-playground/validator/v10 v10.20.0 // indirect github.com/goccy/go-json v0.10.2 // indirect - github.com/gosimple/slug v1.15.0 // indirect - github.com/gosimple/unidecode v1.0.1 // indirect github.com/json-iterator/go v1.1.12 // indirect github.com/klauspost/compress v1.17.11 // indirect github.com/klauspost/cpuid/v2 v2.2.7 // indirect diff --git a/go.sum b/go.sum index 8f6f732..a5ce4cd 100644 --- a/go.sum +++ b/go.sum @@ -50,10 +50,6 @@ github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeN github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= -github.com/gosimple/slug v1.15.0 h1:wRZHsRrRcs6b0XnxMUBM6WK1U1Vg5B0R7VkIf1Xzobo= -github.com/gosimple/slug v1.15.0/go.mod h1:UiRaFH+GEilHstLUmcBgWcI42viBN7mAb818JrYOeFQ= -github.com/gosimple/unidecode v1.0.1 h1:hZzFTMMqSswvf0LBJZCZgThIZrpDHFXux9KeGmn6T/o= -github.com/gosimple/unidecode v1.0.1/go.mod h1:CP0Cr1Y1kogOtx0bJblKzsVWrqYaqfNOnHzpgWw4Awc= github.com/gwatts/rootcerts v0.0.0-20240401182218-3ab9db955caf h1:JO6ISZIvEUitto5zjQ3/VEnDM5rPbqIFuOhS0U0ByeA= github.com/gwatts/rootcerts v0.0.0-20240401182218-3ab9db955caf/go.mod h1:5Kt9XkWvkGi2OHOq0QsGxebHmhCcqJ8KCbNg/a6+n+g= github.com/hanwen/go-fuse/v2 v2.5.1 h1:OQBE8zVemSocRxA4OaFJbjJ5hlpCmIWbGr7r0M4uoQQ= From 6771755b32d27e9f9f0f93d63f7bc602b7573233 Mon Sep 17 00:00:00 2001 From: JackTheRooster Date: Wed, 5 Mar 2025 22:55:06 -0600 Subject: [PATCH 3/8] added rpc calls to pass name config --- go.mod | 2 + go.sum | 4 ++ jsonrpc.go | 32 ++++++++++++ network.go | 12 ++++- ui/src/hooks/stores.ts | 5 ++ .../devices.$id.settings.appearance.tsx | 49 ++++++++++++++++++- 6 files changed, 101 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 5748e64..68408af 100644 --- a/go.mod +++ b/go.mod @@ -12,6 +12,7 @@ require ( github.com/creack/pty v1.1.23 github.com/gin-gonic/gin v1.9.1 github.com/google/uuid v1.6.0 + github.com/gosimple/slug v1.15.0 github.com/gwatts/rootcerts v0.0.0-20240401182218-3ab9db955caf github.com/hanwen/go-fuse/v2 v2.5.1 github.com/hashicorp/go-envparse v0.1.0 @@ -46,6 +47,7 @@ require ( github.com/go-playground/universal-translator v0.18.1 // indirect github.com/go-playground/validator/v10 v10.20.0 // indirect github.com/goccy/go-json v0.10.2 // indirect + github.com/gosimple/unidecode v1.0.1 // indirect github.com/json-iterator/go v1.1.12 // indirect github.com/klauspost/compress v1.17.11 // indirect github.com/klauspost/cpuid/v2 v2.2.7 // indirect diff --git a/go.sum b/go.sum index a5ce4cd..8f6f732 100644 --- a/go.sum +++ b/go.sum @@ -50,6 +50,10 @@ github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeN github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= +github.com/gosimple/slug v1.15.0 h1:wRZHsRrRcs6b0XnxMUBM6WK1U1Vg5B0R7VkIf1Xzobo= +github.com/gosimple/slug v1.15.0/go.mod h1:UiRaFH+GEilHstLUmcBgWcI42viBN7mAb818JrYOeFQ= +github.com/gosimple/unidecode v1.0.1 h1:hZzFTMMqSswvf0LBJZCZgThIZrpDHFXux9KeGmn6T/o= +github.com/gosimple/unidecode v1.0.1/go.mod h1:CP0Cr1Y1kogOtx0bJblKzsVWrqYaqfNOnHzpgWw4Awc= github.com/gwatts/rootcerts v0.0.0-20240401182218-3ab9db955caf h1:JO6ISZIvEUitto5zjQ3/VEnDM5rPbqIFuOhS0U0ByeA= github.com/gwatts/rootcerts v0.0.0-20240401182218-3ab9db955caf/go.mod h1:5Kt9XkWvkGi2OHOq0QsGxebHmhCcqJ8KCbNg/a6+n+g= github.com/hanwen/go-fuse/v2 v2.5.1 h1:OQBE8zVemSocRxA4OaFJbjJ5hlpCmIWbGr7r0M4uoQQ= diff --git a/jsonrpc.go b/jsonrpc.go index b1b36c5..df2742d 100644 --- a/jsonrpc.go +++ b/jsonrpc.go @@ -13,6 +13,7 @@ import ( "strconv" "time" + "github.com/gosimple/slug" "github.com/pion/webrtc/v4" "go.bug.st/serial" ) @@ -43,6 +44,11 @@ type BacklightSettings struct { OffAfter int `json:"off_after"` } +type NameSettings struct { + Name string `json:"name"` + DNS string `json:"dns"` +} + func writeJSONRPCResponse(response JSONRPCResponse, session *Session) { responseBytes, err := json.Marshal(response) if err != nil { @@ -293,6 +299,30 @@ type SSHKeyState struct { SSHKey string `json:"sshKey"` } +func rpcGetNameConfig() (NameConfig, error) { + LoadConfig() + return config.NameConfig, nil +} + +func rpcSetNameConfig(deviceName string) (NameConfig, error) { + LoadConfig() + config.NameConfig = NameConfig{ + Name: deviceName, + DNS: slug.Make(deviceName) + ".local", + } + + RestartMDNS() + + err := SaveConfig() + if err != nil { + return NameConfig{}, fmt.Errorf("failed to save device name: %w", err) + } + + nameConfig := config.NameConfig + log.Printf("[jsonrpc.go:rpcSetNameConfig] device name set to %s, dns name set to %s", nameConfig.Name, nameConfig.DNS) + return nameConfig, nil +} + func rpcGetDevModeState() (DevModeState, error) { devModeEnabled := false if _, err := os.Stat(devModeFile); err != nil { @@ -789,6 +819,8 @@ var rpcHandlers = map[string]RPCHandler{ "setDevChannelState": {Func: rpcSetDevChannelState, Params: []string{"enabled"}}, "getUpdateStatus": {Func: rpcGetUpdateStatus}, "tryUpdate": {Func: rpcTryUpdate}, + "setNameConfig": {Func: rpcSetNameConfig, Params: []string{"deviceName"}}, + "getNameConfig": {Func: rpcGetNameConfig}, "getDevModeState": {Func: rpcGetDevModeState}, "setDevModeState": {Func: rpcSetDevModeState, Params: []string{"enabled"}}, "getSSHKeyState": {Func: rpcGetSSHKeyState}, diff --git a/network.go b/network.go index 3553015..8e8e2fd 100644 --- a/network.go +++ b/network.go @@ -113,6 +113,13 @@ func checkNetworkState() { } } +func RestartMDNS() { + err := startMDNS() + if err != nil { + return + } +} + func startMDNS() error { // If server was previously running, stop it if mDNSConn != nil { @@ -124,7 +131,8 @@ func startMDNS() error { } // Start a new server - fmt.Printf("Starting mDNS server on jetkvm.local\n") + LoadConfig() + fmt.Printf("Starting mDNS server on %v\n", config.NameConfig.DNS) addr4, err := net.ResolveUDPAddr("udp4", mdns.DefaultAddressIPv4) if err != nil { return err @@ -146,7 +154,7 @@ func startMDNS() error { } mDNSConn, err = mdns.Server(ipv4.NewPacketConn(l4), ipv6.NewPacketConn(l6), &mdns.Config{ - LocalNames: []string{"jetkvm.local"}, //TODO: make it configurable + LocalNames: []string{config.NameConfig.DNS}, }) if err != nil { mDNSConn = nil diff --git a/ui/src/hooks/stores.ts b/ui/src/hooks/stores.ts index 3dfc96c..b549f89 100644 --- a/ui/src/hooks/stores.ts +++ b/ui/src/hooks/stores.ts @@ -23,6 +23,11 @@ const appendStatToMap = ( export type AvailableSidebarViews = "connection-stats"; export type AvailableTerminalTypes = "kvm" | "serial" | "none"; +export interface NameConfig { + name: string; + dns: string; +} + export interface User { sub: string; email?: string; diff --git a/ui/src/routes/devices.$id.settings.appearance.tsx b/ui/src/routes/devices.$id.settings.appearance.tsx index 11a9536..01026e4 100644 --- a/ui/src/routes/devices.$id.settings.appearance.tsx +++ b/ui/src/routes/devices.$id.settings.appearance.tsx @@ -1,12 +1,22 @@ import { useCallback, useState } from "react"; +import { Button } from "@components/Button"; +import { InputFieldWithLabel } from "@components/InputField"; import { SettingsPageHeader } from "../components/SettingsPageheader"; import { SelectMenuBasic } from "../components/SelectMenuBasic"; import { SettingsItem } from "./devices.$id.settings"; +import { NameConfig } from "@/hooks/stores"; +import { useJsonRpc } from "@/hooks/useJsonRpc"; +import notifications from "@/notifications"; export default function SettingsAppearanceRoute() { const [currentTheme, setCurrentTheme] = useState(() => { return localStorage.theme || "system"; }); + const [nameConfig, setNameConfig] = useState({ + name: '', + dns: '', + }); + const [send] = useJsonRpc(); const handleThemeChange = useCallback((value: string) => { const root = document.documentElement; @@ -26,7 +36,26 @@ export default function SettingsAppearanceRoute() { } }, []); - return ( + const handleDeviceNameChange = (deviceName: string) => { + setNameConfig({... nameConfig, name: deviceName}) + }; + + const handleUpdateNameConfig = useCallback(() => { + send("setNameConfig", { deviceName: nameConfig.name }, resp => { + if ("error" in resp) { + notifications.error( + `Failed to set name config: ${resp.error.data || "Unknown error"}`, + ); + return; + } + const rNameConfig = resp.result as NameConfig; + setNameConfig(rNameConfig); + document.title = rNameConfig.name; + notifications.success(`Device name set to "${rNameConfig.name}" successfully.\nDNS Name set to "${rNameConfig.dns}"`); + }); + }, [send, nameConfig]); + + return (
+ + handleDeviceNameChange(e.target.value)} + /> + +
+
); } From 5a5a4779661e33543dde6b63822610a965d5c0f6 Mon Sep 17 00:00:00 2001 From: JackTheRooster Date: Thu, 6 Mar 2025 17:36:37 -0600 Subject: [PATCH 4/8] now loads name config on page load --- ui/src/routes/devices.$id.settings.appearance.tsx | 7 +++++++ ui/src/routes/devices.$id.tsx | 11 ++++++++++- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/ui/src/routes/devices.$id.settings.appearance.tsx b/ui/src/routes/devices.$id.settings.appearance.tsx index 01026e4..bea162f 100644 --- a/ui/src/routes/devices.$id.settings.appearance.tsx +++ b/ui/src/routes/devices.$id.settings.appearance.tsx @@ -18,6 +18,13 @@ export default function SettingsAppearanceRoute() { }); const [send] = useJsonRpc(); + send("getNameConfig", {}, resp => { + if ("error" in resp) return; + const results = resp.result as NameConfig; + setNameConfig(results); + document.title = results.name; + }); + const handleThemeChange = useCallback((value: string) => { const root = document.documentElement; diff --git a/ui/src/routes/devices.$id.tsx b/ui/src/routes/devices.$id.tsx index 5576d75..1c9723d 100644 --- a/ui/src/routes/devices.$id.tsx +++ b/ui/src/routes/devices.$id.tsx @@ -1,7 +1,7 @@ import { useCallback, useEffect, useRef, useState } from "react"; import { cx } from "@/cva.config"; import { - HidState, + HidState, NameConfig, UpdateState, useDeviceStore, useHidStore, @@ -378,6 +378,15 @@ export default function KvmIdRoute() { }); }, [rpcDataChannel?.readyState, send, setHdmiState]); + useEffect(() => { + send("getNameConfig", {}, resp => { + if ("error" in resp) return; + const results = resp.result as NameConfig; + document.title = results.name; + }); + }, [send]); + + // eslint-disable-next-line @typescript-eslint/ban-ts-comment // @ts-expect-error window.send = send; From ee1c8eb424a5f6bc2886a6d74383aef0138d12ee Mon Sep 17 00:00:00 2001 From: JackTheRooster Date: Thu, 6 Mar 2025 18:22:40 -0600 Subject: [PATCH 5/8] now loads name config on page load --- ui/src/routes/devices.$id.settings.appearance.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ui/src/routes/devices.$id.settings.appearance.tsx b/ui/src/routes/devices.$id.settings.appearance.tsx index bea162f..77f16d8 100644 --- a/ui/src/routes/devices.$id.settings.appearance.tsx +++ b/ui/src/routes/devices.$id.settings.appearance.tsx @@ -89,7 +89,7 @@ export default function SettingsAppearanceRoute() { required label="" placeholder="Enter Device Name" - description={`DNS Name: ${nameConfig.dns}`} + description={`DNS: ${nameConfig.dns}`} defaultValue={nameConfig.name} onChange={e => handleDeviceNameChange(e.target.value)} /> From 9cc18ee9ffd63b0947b2587ac224bc3dc1eb1b6b Mon Sep 17 00:00:00 2001 From: JackTheRooster Date: Sat, 8 Mar 2025 11:25:25 -0600 Subject: [PATCH 6/8] now storing name config settings in store removed extra LoadConfig calls --- jsonrpc.go | 2 - network.go | 1 - ui/src/hooks/stores.ts | 9 ++++ .../devices.$id.settings.appearance.tsx | 47 ++++++++----------- ui/src/routes/devices.$id.tsx | 9 +++- 5 files changed, 36 insertions(+), 32 deletions(-) diff --git a/jsonrpc.go b/jsonrpc.go index df2742d..e3f9a14 100644 --- a/jsonrpc.go +++ b/jsonrpc.go @@ -300,12 +300,10 @@ type SSHKeyState struct { } func rpcGetNameConfig() (NameConfig, error) { - LoadConfig() return config.NameConfig, nil } func rpcSetNameConfig(deviceName string) (NameConfig, error) { - LoadConfig() config.NameConfig = NameConfig{ Name: deviceName, DNS: slug.Make(deviceName) + ".local", diff --git a/network.go b/network.go index 8e8e2fd..474dab8 100644 --- a/network.go +++ b/network.go @@ -131,7 +131,6 @@ func startMDNS() error { } // Start a new server - LoadConfig() fmt.Printf("Starting mDNS server on %v\n", config.NameConfig.DNS) addr4, err := net.ResolveUDPAddr("udp4", mdns.DefaultAddressIPv4) if err != nil { diff --git a/ui/src/hooks/stores.ts b/ui/src/hooks/stores.ts index b549f89..3b37738 100644 --- a/ui/src/hooks/stores.ts +++ b/ui/src/hooks/stores.ts @@ -278,6 +278,9 @@ interface SettingsState { backlightSettings: BacklightSettings; setBacklightSettings: (settings: BacklightSettings) => void; + + nameConfig: NameConfig; + setNameConfig: (config: NameConfig) => void; } export const useSettingsStore = create( @@ -303,6 +306,12 @@ export const useSettingsStore = create( }, setBacklightSettings: (settings: BacklightSettings) => set({ backlightSettings: settings }), + + nameConfig: { + name: "JetKVM", + dns: "jetkvm.local" + }, + setNameConfig: (config: NameConfig) => set({ nameConfig: config }), }), { name: "settings", diff --git a/ui/src/routes/devices.$id.settings.appearance.tsx b/ui/src/routes/devices.$id.settings.appearance.tsx index 77f16d8..b5a0796 100644 --- a/ui/src/routes/devices.$id.settings.appearance.tsx +++ b/ui/src/routes/devices.$id.settings.appearance.tsx @@ -4,7 +4,7 @@ import { InputFieldWithLabel } from "@components/InputField"; import { SettingsPageHeader } from "../components/SettingsPageheader"; import { SelectMenuBasic } from "../components/SelectMenuBasic"; import { SettingsItem } from "./devices.$id.settings"; -import { NameConfig } from "@/hooks/stores"; +import {NameConfig, useSettingsStore} from "@/hooks/stores"; import { useJsonRpc } from "@/hooks/useJsonRpc"; import notifications from "@/notifications"; @@ -12,18 +12,11 @@ export default function SettingsAppearanceRoute() { const [currentTheme, setCurrentTheme] = useState(() => { return localStorage.theme || "system"; }); - const [nameConfig, setNameConfig] = useState({ - name: '', - dns: '', - }); const [send] = useJsonRpc(); + const [name, setName] = useState(""); - send("getNameConfig", {}, resp => { - if ("error" in resp) return; - const results = resp.result as NameConfig; - setNameConfig(results); - document.title = results.name; - }); + const nameConfigSettings = useSettingsStore(state => state.nameConfig); + const setNameConfigSettings = useSettingsStore(state => state.setNameConfig); const handleThemeChange = useCallback((value: string) => { const root = document.documentElement; @@ -43,24 +36,24 @@ export default function SettingsAppearanceRoute() { } }, []); - const handleDeviceNameChange = (deviceName: string) => { - setNameConfig({... nameConfig, name: deviceName}) + const handleNameChange = (value: string) => { + setName(value); }; - const handleUpdateNameConfig = useCallback(() => { - send("setNameConfig", { deviceName: nameConfig.name }, resp => { + const handleNameSave = useCallback(() => { + send("setNameConfig", { deviceName: name }, resp => { if ("error" in resp) { - notifications.error( - `Failed to set name config: ${resp.error.data || "Unknown error"}`, - ); + notifications.error(`Failed to set name config: ${resp.error.data || "Unknown error"}`); return; } - const rNameConfig = resp.result as NameConfig; - setNameConfig(rNameConfig); - document.title = rNameConfig.name; - notifications.success(`Device name set to "${rNameConfig.name}" successfully.\nDNS Name set to "${rNameConfig.dns}"`); + const nameConfig = resp.result as NameConfig; + setNameConfigSettings(nameConfig); + document.title = nameConfig.name; + notifications.success( + `Device name set to "${nameConfig.name}" successfully.\nDNS Name set to "${nameConfig.dns}"` + ); }); - }, [send, nameConfig]); + }, [send, name, setNameConfigSettings]); return (
@@ -89,9 +82,9 @@ export default function SettingsAppearanceRoute() { required label="" placeholder="Enter Device Name" - description={`DNS: ${nameConfig.dns}`} - defaultValue={nameConfig.name} - onChange={e => handleDeviceNameChange(e.target.value)} + description={`DNS: ${nameConfigSettings.dns}`} + defaultValue={nameConfigSettings.name} + onChange={e => handleNameChange(e.target.value)} />
@@ -99,7 +92,7 @@ export default function SettingsAppearanceRoute() { size="SM" theme="primary" text="Update Device Name" - onClick={handleUpdateNameConfig} + onClick={() => {handleNameSave()}} />
diff --git a/ui/src/routes/devices.$id.tsx b/ui/src/routes/devices.$id.tsx index 1c9723d..bb7ac99 100644 --- a/ui/src/routes/devices.$id.tsx +++ b/ui/src/routes/devices.$id.tsx @@ -8,6 +8,7 @@ import { useMountMediaStore, User, useRTCStore, + useSettingsStore, useUiStore, useUpdateStore, useVideoStore, @@ -129,6 +130,7 @@ export default function KvmIdRoute() { const setRpcDataChannel = useRTCStore(state => state.setRpcDataChannel); const setTransceiver = useRTCStore(state => state.setTransceiver); + const navigate = useNavigate(); const { otaState, setOtaState, setModalView } = useUpdateStore(); @@ -378,14 +380,17 @@ export default function KvmIdRoute() { }); }, [rpcDataChannel?.readyState, send, setHdmiState]); + const setNameConfig = useSettingsStore(state => state.setNameConfig); + useEffect(() => { send("getNameConfig", {}, resp => { if ("error" in resp) return; const results = resp.result as NameConfig; + console.log(`getNameConfig# name: ${results.name}, dns: ${results.dns}`); + setNameConfig(results) document.title = results.name; }); - }, [send]); - + }, [send, setNameConfig]) // eslint-disable-next-line @typescript-eslint/ban-ts-comment // @ts-expect-error From 43fb892e24d5c81d1a06936be156276ebd1678fc Mon Sep 17 00:00:00 2001 From: JackTheRooster Date: Sat, 8 Mar 2025 11:26:51 -0600 Subject: [PATCH 7/8] formatting --- ui/src/routes/devices.$id.tsx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ui/src/routes/devices.$id.tsx b/ui/src/routes/devices.$id.tsx index bb7ac99..a95730d 100644 --- a/ui/src/routes/devices.$id.tsx +++ b/ui/src/routes/devices.$id.tsx @@ -1,7 +1,8 @@ import { useCallback, useEffect, useRef, useState } from "react"; import { cx } from "@/cva.config"; import { - HidState, NameConfig, + HidState, + NameConfig, UpdateState, useDeviceStore, useHidStore, From a09e7c5b7254220e3fc0e6d14ee5f87559b2eec4 Mon Sep 17 00:00:00 2001 From: JackTheRooster Date: Sat, 8 Mar 2025 11:34:26 -0600 Subject: [PATCH 8/8] formatting --- ui/src/routes/devices.$id.tsx | 1 - 1 file changed, 1 deletion(-) diff --git a/ui/src/routes/devices.$id.tsx b/ui/src/routes/devices.$id.tsx index a95730d..72b33be 100644 --- a/ui/src/routes/devices.$id.tsx +++ b/ui/src/routes/devices.$id.tsx @@ -387,7 +387,6 @@ export default function KvmIdRoute() { send("getNameConfig", {}, resp => { if ("error" in resp) return; const results = resp.result as NameConfig; - console.log(`getNameConfig# name: ${results.name}, dns: ${results.dns}`); setNameConfig(results) document.title = results.name; });