diff --git a/ui/src/routes/devices.$id.settings.access._index.tsx b/ui/src/routes/devices.$id.settings.access._index.tsx index a72a35b..e9ab053 100644 --- a/ui/src/routes/devices.$id.settings.access._index.tsx +++ b/ui/src/routes/devices.$id.settings.access._index.tsx @@ -6,7 +6,6 @@ import { CLOUD_APP, DEVICE_API } from "../ui.config"; import api from "../api"; import { LocalDevice } from "./devices.$id"; import { useDeviceUiNavigation } from "../hooks/useAppNavigation"; -import { isOnDevice } from "../main"; import { GridCard } from "../components/Card"; import { ShieldCheckIcon } from "@heroicons/react/24/outline"; import notifications from "../notifications"; @@ -15,16 +14,21 @@ import { useJsonRpc } from "../hooks/useJsonRpc"; import { InputFieldWithLabel } from "../components/InputField"; import { SelectMenuBasic } from "../components/SelectMenuBasic"; import { SettingsSectionHeader } from "../components/SettingsSectionHeader"; +import { isOnDevice } from "../main"; export const loader = async () => { - const status = await api - .GET(`${DEVICE_API}/device`) - .then(res => res.json() as Promise); - return status; + if (isOnDevice) { + const status = await api + .GET(`${DEVICE_API}/device`) + .then(res => res.json() as Promise); + return status; + } + return null; }; export default function SettingsAccessIndexRoute() { - const { authMode } = useLoaderData() as LocalDevice; + const loaderData = useLoaderData() as LocalDevice | null; + const { navigateTo } = useDeviceUiNavigation(); const [send] = useJsonRpc(); @@ -137,8 +141,6 @@ export default function SettingsAccessIndexRoute() { syncCloudUrl(); }, [cloudProviders, syncCloudUrl]); - console.log("is adopted:", isAdopted); - return (
-
- - - {authMode === "password" ? ( -
+
+ + )} - {authMode === "password" && ( - -
-
- {isOnDevice && ( - <> -
- {!isAdopted && ( - <> - - { - const value = e.target.value; - setSelectedUrlOption(value); - }} - options={cloudProviders ?? []} - /> - +
+ {!isAdopted && ( + <> + + { + const value = e.target.value; + setSelectedUrlOption(value); + }} + options={cloudProviders ?? []} + /> + - {selectedUrlOption === "custom" && ( -
- setCloudUrl(e.target.value)} - placeholder="https://api.example.com" - /> -
- )} - + {selectedUrlOption === "custom" && ( +
+ setCloudUrl(e.target.value)} + placeholder="https://api.example.com" + /> +
)} + + )} - {/* + {/* We do the harcoding here to avoid flickering when the default Cloud URL being fetched. I've tried to avoid harcoding api.jetkvm.com, but it's the only reasonable way I could think of to avoid flickering for now. */} - {selectedUrlOption === (defaultCloudUrl || "https://api.jetkvm.com") && ( - -
- -
-
-

- Cloud Security -

-
-
    -
  • End-to-end encryption using WebRTC (DTLS and SRTP)
  • -
  • Zero Trust security model
  • -
  • OIDC (OpenID Connect) authentication
  • -
  • All streams encrypted in transit
  • -
-
+ {selectedUrlOption === (defaultCloudUrl || "https://api.jetkvm.com") && ( + +
+ +
+
+

+ Cloud Security +

+
+
    +
  • End-to-end encryption using WebRTC (DTLS and SRTP)
  • +
  • Zero Trust security model
  • +
  • OIDC (OpenID Connect) authentication
  • +
  • All streams encrypted in transit
  • +
+
-
- All cloud components are open-source and available on{" "} - - GitHub - - . -
-
-
- -
- -
+
+ All cloud components are open-source and available on{" "} + + GitHub + + .
- - )} +
- {!isAdopted ? ( -
+
+ +
+
+
+
+ )} + + {!isAdopted ? ( +
+
+ ) : ( +
+
+

+ Your device is adopted to JetKVM Cloud +

+
- ) : ( -
-
-

- Your device is adopted to JetKVM Cloud -

-
-
-
-
- )} +
- - )} + )} +
);