mirror of https://github.com/jetkvm/kvm.git
Merge branch 'dev' into r/ota
This commit is contained in:
commit
740d9b61a0
|
|
@ -603,6 +603,9 @@ export interface UpdateState {
|
||||||
|
|
||||||
updateErrorMessage: string | null;
|
updateErrorMessage: string | null;
|
||||||
setUpdateErrorMessage: (errorMessage: string) => void;
|
setUpdateErrorMessage: (errorMessage: string) => void;
|
||||||
|
|
||||||
|
shouldReload: boolean;
|
||||||
|
setShouldReload: (reloadRequired: boolean) => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const useUpdateStore = create<UpdateState>(set => ({
|
export const useUpdateStore = create<UpdateState>(set => ({
|
||||||
|
|
@ -640,6 +643,9 @@ export const useUpdateStore = create<UpdateState>(set => ({
|
||||||
updateErrorMessage: null,
|
updateErrorMessage: null,
|
||||||
setUpdateErrorMessage: (errorMessage: string) =>
|
setUpdateErrorMessage: (errorMessage: string) =>
|
||||||
set({ updateErrorMessage: errorMessage }),
|
set({ updateErrorMessage: errorMessage }),
|
||||||
|
|
||||||
|
shouldReload: false,
|
||||||
|
setShouldReload: (reloadRequired: boolean) => set({ shouldReload: reloadRequired }),
|
||||||
}));
|
}));
|
||||||
|
|
||||||
export type UsbConfigModalViews = "updateUsbConfig" | "updateUsbConfigSuccess";
|
export type UsbConfigModalViews = "updateUsbConfig" | "updateUsbConfigSuccess";
|
||||||
|
|
@ -850,12 +856,12 @@ export interface MacrosState {
|
||||||
loadMacros: () => Promise<void>;
|
loadMacros: () => Promise<void>;
|
||||||
saveMacros: (macros: KeySequence[]) => Promise<void>;
|
saveMacros: (macros: KeySequence[]) => Promise<void>;
|
||||||
sendFn:
|
sendFn:
|
||||||
| ((
|
| ((
|
||||||
method: string,
|
method: string,
|
||||||
params: unknown,
|
params: unknown,
|
||||||
callback?: ((resp: JsonRpcResponse) => void) | undefined,
|
callback?: ((resp: JsonRpcResponse) => void) | undefined,
|
||||||
) => void)
|
) => void)
|
||||||
| null;
|
| null;
|
||||||
setSendFn: (
|
setSendFn: (
|
||||||
sendFn: (
|
sendFn: (
|
||||||
method: string,
|
method: string,
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,7 @@ export default function SettingsGeneralUpdateRoute() {
|
||||||
const [searchParams] = useSearchParams();
|
const [searchParams] = useSearchParams();
|
||||||
const { updateSuccess } = location.state || {};
|
const { updateSuccess } = location.state || {};
|
||||||
|
|
||||||
const { setModalView, otaState } = useUpdateStore();
|
const { setModalView, otaState, shouldReload, setShouldReload } = useUpdateStore();
|
||||||
const { send } = useJsonRpc();
|
const { send } = useJsonRpc();
|
||||||
|
|
||||||
const customAppVersion = useMemo(() => searchParams.get("custom_app_version") || undefined, [searchParams]);
|
const customAppVersion = useMemo(() => searchParams.get("custom_app_version") || undefined, [searchParams]);
|
||||||
|
|
@ -28,15 +28,19 @@ export default function SettingsGeneralUpdateRoute() {
|
||||||
|
|
||||||
const onClose = useCallback(async () => {
|
const onClose = useCallback(async () => {
|
||||||
navigate(".."); // back to the devices.$id.settings page
|
navigate(".."); // back to the devices.$id.settings page
|
||||||
// Add 1s delay between navigation and calling reload() to prevent reload from interrupting the navigation.
|
|
||||||
await sleep(1000);
|
if (shouldReload) {
|
||||||
window.location.reload(); // force a full reload to ensure the current device/cloud UI version is loaded
|
setShouldReload(false);
|
||||||
}, [navigate]);
|
await sleep(1000); // Add 1s delay between navigation and calling reload() to prevent reload from interrupting the navigation.
|
||||||
|
window.location.reload(); // force a full reload to ensure the current device/cloud UI version is loaded
|
||||||
|
}
|
||||||
|
}, [navigate, setShouldReload, shouldReload]);
|
||||||
|
|
||||||
const onConfirmUpdate = useCallback(() => {
|
const onConfirmUpdate = useCallback(() => {
|
||||||
|
setShouldReload(true);
|
||||||
send("tryUpdate", {});
|
send("tryUpdate", {});
|
||||||
setModalView("updating");
|
setModalView("updating");
|
||||||
}, [send, setModalView]);
|
}, [send, setModalView, setShouldReload]);
|
||||||
|
|
||||||
const onConfirmCustomUpdate = useCallback((appTargetVersion?: string, systemTargetVersion?: string) => {
|
const onConfirmCustomUpdate = useCallback((appTargetVersion?: string, systemTargetVersion?: string) => {
|
||||||
const components = [];
|
const components = [];
|
||||||
|
|
|
||||||
4
web.go
4
web.go
|
|
@ -814,7 +814,7 @@ func handleSendWOLMagicPacket(c *gin.Context) {
|
||||||
inputMacAddr := c.Param("mac-addr")
|
inputMacAddr := c.Param("mac-addr")
|
||||||
macAddr, err := net.ParseMAC(inputMacAddr)
|
macAddr, err := net.ParseMAC(inputMacAddr)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logger.Warn().Err(err).Str("sendWol", inputMacAddr).Msg("Invalid mac address provided")
|
logger.Warn().Err(err).Str("inputMacAddr", inputMacAddr).Msg("Invalid MAC address provided")
|
||||||
c.String(http.StatusBadRequest, "Invalid mac address provided")
|
c.String(http.StatusBadRequest, "Invalid mac address provided")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
@ -822,7 +822,7 @@ func handleSendWOLMagicPacket(c *gin.Context) {
|
||||||
macAddrString := macAddr.String()
|
macAddrString := macAddr.String()
|
||||||
err = rpcSendWOLMagicPacket(macAddrString)
|
err = rpcSendWOLMagicPacket(macAddrString)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logger.Warn().Err(err).Str("sendWOL", macAddrString).Msg("Failed to send WOL magic packet")
|
logger.Warn().Err(err).Str("macAddrString", macAddrString).Msg("Failed to send WOL magic packet")
|
||||||
c.String(http.StatusInternalServerError, "Failed to send WOL to %s: %v", macAddrString, err)
|
c.String(http.StatusInternalServerError, "Failed to send WOL to %s: %v", macAddrString, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue