mirror of
https://github.com/luckfox-eng29/kvm.git
synced 2026-01-18 03:28:19 +01:00
Feature/usb config - Rebasing USB Config Changes on Dev Branch (#185)
* rebasing on dev branch * fixed formatting * fixed formatting * removed query params * moved usb settings to hardware setting * swapped from error to log * added fix for any change to product name now resulting in show the spinner as custom on page reload * formatting --------- Co-authored-by: JackTheRooster <adrian@rydeas.com> Co-authored-by: Adam Shiervani <adam.shiervani@gmail.com>
This commit is contained in:
25
jsonrpc.go
25
jsonrpc.go
@@ -538,6 +538,29 @@ func rpcSetUsbEmulationState(enabled bool) error {
|
||||
}
|
||||
}
|
||||
|
||||
func rpcGetUsbConfig() (UsbConfig, error) {
|
||||
LoadConfig()
|
||||
return config.UsbConfig, nil
|
||||
}
|
||||
|
||||
func rpcSetUsbConfig(usbConfig UsbConfig) error {
|
||||
LoadConfig()
|
||||
config.UsbConfig = usbConfig
|
||||
|
||||
err := UpdateGadgetConfig()
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to write gadget config: %w", err)
|
||||
}
|
||||
|
||||
err = SaveConfig()
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to save usb config: %w", err)
|
||||
}
|
||||
|
||||
log.Printf("[jsonrpc.go:rpcSetUsbConfig] usb config set to %s", usbConfig)
|
||||
return nil
|
||||
}
|
||||
|
||||
func rpcGetWakeOnLanDevices() ([]WakeOnLanDevice, error) {
|
||||
if config.WakeOnLanDevices == nil {
|
||||
return []WakeOnLanDevice{}, nil
|
||||
@@ -791,6 +814,8 @@ var rpcHandlers = map[string]RPCHandler{
|
||||
"isUpdatePending": {Func: rpcIsUpdatePending},
|
||||
"getUsbEmulationState": {Func: rpcGetUsbEmulationState},
|
||||
"setUsbEmulationState": {Func: rpcSetUsbEmulationState, Params: []string{"enabled"}},
|
||||
"getUsbConfig": {Func: rpcGetUsbConfig},
|
||||
"setUsbConfig": {Func: rpcSetUsbConfig, Params: []string{"usbConfig"}},
|
||||
"checkMountUrl": {Func: rpcCheckMountUrl, Params: []string{"url"}},
|
||||
"getVirtualMediaState": {Func: rpcGetVirtualMediaState},
|
||||
"getStorageSpace": {Func: rpcGetStorageSpace},
|
||||
|
||||
Reference in New Issue
Block a user