mirror of
https://github.com/luckfox-eng29/kvm.git
synced 2026-01-18 03:28:19 +01:00
feat(cloud): Add support for custom cloud app URL configuration (#207)
* feat(cloud): Add support for custom cloud app URL configuration - Extend CloudState and Config to include CloudAppURL - Update RPC methods to handle both API and app URLs - Modify cloud adoption and settings routes to support custom app URLs - Remove hardcoded cloud app URL environment file - Simplify cloud URL configuration in UI * fix(cloud): Improve cloud URL configuration and adoption flow - Update error handling in cloud URL configuration RPC method - Modify cloud adoption route to support dynamic cloud URLs - Remove hardcoded default cloud URLs in device access settings - Refactor cloud adoption click handler to be more flexible * refactor(cloud): Simplify cloud URL configuration RPC method - Update rpcSetCloudUrl to return only an error - Remove unnecessary boolean return value - Improve error handling consistency * refactor(ui): Simplify cloud provider configuration and URL handling
This commit is contained in:
33
jsonrpc.go
33
jsonrpc.go
@@ -753,37 +753,17 @@ func rpcSetSerialSettings(settings SerialSettings) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func rpcSetCloudUrl(url string) error {
|
||||
if url == "" {
|
||||
// Reset to default by removing from config
|
||||
config.CloudURL = defaultConfig.CloudURL
|
||||
} else {
|
||||
config.CloudURL = url
|
||||
}
|
||||
func rpcSetCloudUrl(apiUrl string, appUrl string) error {
|
||||
config.CloudURL = apiUrl
|
||||
config.CloudAppURL = appUrl
|
||||
|
||||
if err := SaveConfig(); err != nil {
|
||||
return fmt.Errorf("failed to save config: %w", err)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func rpcGetCloudUrl() (string, error) {
|
||||
return config.CloudURL, nil
|
||||
}
|
||||
|
||||
func rpcResetCloudUrl() error {
|
||||
// Reset to default by removing from config
|
||||
config.CloudURL = defaultConfig.CloudURL
|
||||
if err := SaveConfig(); err != nil {
|
||||
return fmt.Errorf("failed to reset cloud URL: %w", err)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func rpcGetDefaultCloudUrl() (string, error) {
|
||||
return defaultConfig.CloudURL, nil
|
||||
}
|
||||
|
||||
var rpcHandlers = map[string]RPCHandler{
|
||||
"ping": {Func: rpcPing},
|
||||
"getDeviceID": {Func: rpcGetDeviceID},
|
||||
@@ -842,8 +822,5 @@ var rpcHandlers = map[string]RPCHandler{
|
||||
"setATXPowerAction": {Func: rpcSetATXPowerAction, Params: []string{"action"}},
|
||||
"getSerialSettings": {Func: rpcGetSerialSettings},
|
||||
"setSerialSettings": {Func: rpcSetSerialSettings, Params: []string{"settings"}},
|
||||
"setCloudUrl": {Func: rpcSetCloudUrl, Params: []string{"url"}},
|
||||
"getCloudUrl": {Func: rpcGetCloudUrl},
|
||||
"resetCloudUrl": {Func: rpcResetCloudUrl},
|
||||
"getDefaultCloudUrl": {Func: rpcGetDefaultCloudUrl},
|
||||
"setCloudUrl": {Func: rpcSetCloudUrl, Params: []string{"apiUrl", "appUrl"}},
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user