mirror of https://github.com/jetkvm/kvm.git
Compare commits
8 Commits
2641d7068c
...
65b76b4e42
| Author | SHA1 | Date |
|---|---|---|
|
|
65b76b4e42 | |
|
|
70cd19ddbc | |
|
|
72e2367011 | |
|
|
d7a56213ea | |
|
|
85c98ee998 | |
|
|
69f429d0a5 | |
|
|
0984ca7e40 | |
|
|
2fce23c5d6 |
|
|
@ -85,7 +85,7 @@ export async function checkDeviceAuth() {
|
|||
}
|
||||
|
||||
export async function checkAuth() {
|
||||
return import.meta.env.MODE === "device" ? checkDeviceAuth() : checkCloudAuth();
|
||||
return isOnDevice ? checkDeviceAuth() : checkCloudAuth();
|
||||
}
|
||||
|
||||
let router;
|
||||
|
|
|
|||
|
|
@ -292,7 +292,7 @@ function UpdatingDeviceState({
|
|||
<span className="font-medium text-black dark:text-white">
|
||||
Rebooting the device to complete the update...
|
||||
</span>
|
||||
<p className="font-medium text-black dark:text-white">
|
||||
<p className="flex-col text-black dark:text-white">
|
||||
This may take a few minutes. The device will automatically
|
||||
reconnect once it is back online.<br/>
|
||||
If it doesn{"'"}t reconnect automatically, you can manually
|
||||
|
|
@ -304,7 +304,7 @@ function UpdatingDeviceState({
|
|||
LeadingIcon={MdConnectWithoutContact}
|
||||
textAlign="center"
|
||||
reloadDocument={true}
|
||||
to={"/"}
|
||||
to={".."}
|
||||
/>
|
||||
</p>
|
||||
</div>
|
||||
|
|
@ -314,7 +314,7 @@ function UpdatingDeviceState({
|
|||
<span className="font-medium text-black dark:text-white">
|
||||
Device reboot is pending...
|
||||
</span>
|
||||
<p className="font-medium text-black dark:text-white">
|
||||
<p className="flex-col text-black dark:text-white">
|
||||
The JetKVM is preparing to reboot. This may take a while.<br/>
|
||||
If it doesn{"'"}t automatically reboot after a few minutes, you
|
||||
can manually request a reboot by clicking here:
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
import { lazy, useCallback, useEffect, useMemo, useRef, useState } from "react";
|
||||
import {
|
||||
Outlet,
|
||||
redirect,
|
||||
useLoaderData,
|
||||
useLocation,
|
||||
useNavigate,
|
||||
|
|
@ -15,7 +14,7 @@ import { FocusTrap } from "focus-trap-react";
|
|||
import { motion, AnimatePresence } from "framer-motion";
|
||||
import useWebSocket from "react-use-websocket";
|
||||
|
||||
import { CLOUD_API, DEVICE_API } from "@/ui.config";
|
||||
import { CLOUD_API } from "@/ui.config";
|
||||
import api from "@/api";
|
||||
import { checkAuth, isInCloud, isOnDevice } from "@/main";
|
||||
import { cx } from "@/cva.config";
|
||||
|
|
@ -48,7 +47,6 @@ import {
|
|||
} from "@/components/VideoOverlay";
|
||||
import { useDeviceUiNavigation } from "@/hooks/useAppNavigation";
|
||||
import { FeatureFlagProvider } from "@/providers/FeatureFlagProvider";
|
||||
import { DeviceStatus } from "@routes/welcome-local";
|
||||
import { useVersion } from "@/hooks/useVersion";
|
||||
|
||||
interface LocalLoaderResp {
|
||||
|
|
@ -70,20 +68,8 @@ export interface LocalDevice {
|
|||
}
|
||||
|
||||
const deviceLoader = async () => {
|
||||
const res = await api
|
||||
.GET(`${DEVICE_API}/device/status`)
|
||||
.then(res => res.json() as Promise<DeviceStatus>);
|
||||
|
||||
if (!res.isSetup) return redirect("/welcome");
|
||||
|
||||
const deviceRes = await api.GET(`${DEVICE_API}/device`);
|
||||
if (deviceRes.status === 401) return redirect("/login-local");
|
||||
if (deviceRes.ok) {
|
||||
const device = (await deviceRes.json()) as LocalDevice;
|
||||
return { authMode: device.authMode };
|
||||
}
|
||||
|
||||
throw new Error("Error fetching device");
|
||||
const device = await checkAuth();
|
||||
return { authMode: device.authMode } as LocalLoaderResp;
|
||||
};
|
||||
|
||||
const cloudLoader = async (params: Params<string>): Promise<CloudLoaderResp> => {
|
||||
|
|
@ -106,11 +92,11 @@ const cloudLoader = async (params: Params<string>): Promise<CloudLoaderResp> =>
|
|||
device: { id: string; name: string; user: { googleId: string } };
|
||||
};
|
||||
|
||||
return { user, iceConfig, deviceName: device.name || device.id };
|
||||
return { user, iceConfig, deviceName: device.name || device.id } as CloudLoaderResp;
|
||||
};
|
||||
|
||||
const loader: LoaderFunction = ({ params }: LoaderFunctionArgs) => {
|
||||
return import.meta.env.MODE === "device" ? deviceLoader() : cloudLoader(params);
|
||||
return isOnDevice ? deviceLoader() : cloudLoader(params);
|
||||
};
|
||||
|
||||
export default function KvmIdRoute() {
|
||||
|
|
|
|||
Loading…
Reference in New Issue