mirror of https://github.com/jetkvm/kvm.git
refactor: rename to RedirectTo
This commit is contained in:
parent
632125e38f
commit
e2fd6961e2
|
|
@ -29,7 +29,7 @@ func (s *RpcNetworkSettings) ToNetworkConfig() *types.NetworkConfig {
|
|||
|
||||
type PostRebootAction struct {
|
||||
HealthCheck string `json:"healthCheck"`
|
||||
RedirectUrl string `json:"redirectUrl"`
|
||||
RedirectTo string `json:"redirectTo"`
|
||||
}
|
||||
|
||||
func toRpcNetworkSettings(config *types.NetworkConfig) *RpcNetworkSettings {
|
||||
|
|
@ -202,7 +202,7 @@ func shouldRebootForNetworkChange(oldConfig, newConfig *types.NetworkConfig) (re
|
|||
if newIPv4Mode == "static" && oldIPv4Mode != "static" {
|
||||
postRebootAction = &PostRebootAction{
|
||||
HealthCheck: fmt.Sprintf("//%s/device/status", newConfig.IPv4Static.Address.String),
|
||||
RedirectUrl: fmt.Sprintf("//%s", newConfig.IPv4Static.Address.String),
|
||||
RedirectTo: fmt.Sprintf("//%s", newConfig.IPv4Static.Address.String),
|
||||
}
|
||||
l.Info().Interface("postRebootAction", postRebootAction).Msg("IPv4 mode changed to static, reboot required")
|
||||
}
|
||||
|
|
@ -219,7 +219,7 @@ func shouldRebootForNetworkChange(oldConfig, newConfig *types.NetworkConfig) (re
|
|||
newConfig.IPv4Static.Address.String != oldConfig.IPv4Static.Address.String {
|
||||
postRebootAction = &PostRebootAction{
|
||||
HealthCheck: fmt.Sprintf("//%s/device/status", newConfig.IPv4Static.Address.String),
|
||||
RedirectUrl: fmt.Sprintf("//%s", newConfig.IPv4Static.Address.String),
|
||||
RedirectTo: fmt.Sprintf("//%s", newConfig.IPv4Static.Address.String),
|
||||
}
|
||||
|
||||
l.Info().Interface("postRebootAction", postRebootAction).Msg("IPv4 static config changed, reboot required")
|
||||
|
|
|
|||
6
ota.go
6
ota.go
|
|
@ -490,7 +490,7 @@ func TryUpdate(ctx context.Context, deviceId string, includePreRelease bool) err
|
|||
scopedLogger.Info().Msg("System Rebooting due to OTA update")
|
||||
|
||||
// Build redirect URL with conditional query parameters
|
||||
redirectUrl := "/settings/general/update"
|
||||
redirectTo := "/settings/general/update"
|
||||
queryParams := url.Values{}
|
||||
if systemUpdateAvailable {
|
||||
queryParams.Set("systemVersion", remote.SystemVersion)
|
||||
|
|
@ -499,12 +499,12 @@ func TryUpdate(ctx context.Context, deviceId string, includePreRelease bool) err
|
|||
queryParams.Set("appVersion", remote.AppVersion)
|
||||
}
|
||||
if len(queryParams) > 0 {
|
||||
redirectUrl += "?" + queryParams.Encode()
|
||||
redirectTo += "?" + queryParams.Encode()
|
||||
}
|
||||
|
||||
postRebootAction := &PostRebootAction{
|
||||
HealthCheck: "/device/status",
|
||||
RedirectUrl: redirectUrl,
|
||||
RedirectTo: redirectTo,
|
||||
}
|
||||
|
||||
if err := hwReboot(true, postRebootAction, 10*time.Second); err != nil {
|
||||
|
|
|
|||
|
|
@ -474,13 +474,13 @@ export function RebootingOverlay({ show, postRebootAction }: RebootingOverlayPro
|
|||
|
||||
if (response.ok) {
|
||||
// Device is available, redirect to the specified URL
|
||||
console.log('Device is available, redirecting to:', postRebootAction.redirectUrl);
|
||||
console.log('Device is available, redirecting to:', postRebootAction.redirectTo);
|
||||
|
||||
// URL constructor handles all cases elegantly:
|
||||
// - Absolute paths: resolved against current origin
|
||||
// - Protocol-relative URLs: resolved with current protocol
|
||||
// - Fully qualified URLs: used as-is
|
||||
const targetUrl = new URL(postRebootAction.redirectUrl, window.location.origin);
|
||||
const targetUrl = new URL(postRebootAction.redirectTo, window.location.origin);
|
||||
|
||||
window.location.href = targetUrl.href;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ interface JsonRpcResponse {
|
|||
|
||||
export type PostRebootAction = {
|
||||
healthCheck: string;
|
||||
redirectUrl: string;
|
||||
redirectTo: string;
|
||||
} | null;
|
||||
|
||||
// Utility function to append stats to a Map
|
||||
|
|
|
|||
Loading…
Reference in New Issue