Add safe mode page that is just the config editor

This commit is contained in:
Nicolas Mowen 2025-05-24 10:09:39 -06:00
parent acefab19b2
commit 35ece12f44
2 changed files with 67 additions and 41 deletions

View File

@ -12,6 +12,8 @@ import { cn } from "./lib/utils";
import { isPWA } from "./utils/isPWA"; import { isPWA } from "./utils/isPWA";
import ProtectedRoute from "@/components/auth/ProtectedRoute"; import ProtectedRoute from "@/components/auth/ProtectedRoute";
import { AuthProvider } from "@/context/auth-context"; import { AuthProvider } from "@/context/auth-context";
import useSWR from "swr";
import { FrigateConfig } from "./types/frigateConfig";
const Live = lazy(() => import("@/pages/Live")); const Live = lazy(() => import("@/pages/Live"));
const Events = lazy(() => import("@/pages/Events")); const Events = lazy(() => import("@/pages/Events"));
@ -26,11 +28,25 @@ const Logs = lazy(() => import("@/pages/Logs"));
const AccessDenied = lazy(() => import("@/pages/AccessDenied")); const AccessDenied = lazy(() => import("@/pages/AccessDenied"));
function App() { function App() {
const { data: config } = useSWR<FrigateConfig>("config", {
revalidateOnFocus: false,
});
return ( return (
<Providers> <Providers>
<AuthProvider> <AuthProvider>
<BrowserRouter basename={window.baseUrl}> <BrowserRouter basename={window.baseUrl}>
<Wrapper> <Wrapper>
{config?.safe_mode ? <SafeAppView /> : <DefaultAppView />}
</Wrapper>
</BrowserRouter>
</AuthProvider>
</Providers>
);
}
function DefaultAppView() {
return (
<div className="size-full overflow-hidden"> <div className="size-full overflow-hidden">
{isDesktop && <Sidebar />} {isDesktop && <Sidebar />}
{isDesktop && <Statusbar />} {isDesktop && <Statusbar />}
@ -47,9 +63,7 @@ function App() {
<Suspense> <Suspense>
<Routes> <Routes>
<Route <Route
element={ element={<ProtectedRoute requiredRoles={["viewer", "admin"]} />}
<ProtectedRoute requiredRoles={["viewer", "admin"]} />
}
> >
<Route index element={<Live />} /> <Route index element={<Live />} />
<Route path="/review" element={<Events />} /> <Route path="/review" element={<Events />} />
@ -57,9 +71,7 @@ function App() {
<Route path="/export" element={<Exports />} /> <Route path="/export" element={<Exports />} />
<Route path="/settings" element={<Settings />} /> <Route path="/settings" element={<Settings />} />
</Route> </Route>
<Route <Route element={<ProtectedRoute requiredRoles={["admin"]} />}>
element={<ProtectedRoute requiredRoles={["admin"]} />}
>
<Route path="/system" element={<System />} /> <Route path="/system" element={<System />} />
<Route path="/config" element={<ConfigEditor />} /> <Route path="/config" element={<ConfigEditor />} />
<Route path="/logs" element={<Logs />} /> <Route path="/logs" element={<Logs />} />
@ -72,10 +84,21 @@ function App() {
</Suspense> </Suspense>
</div> </div>
</div> </div>
</Wrapper> );
</BrowserRouter> }
</AuthProvider>
</Providers> function SafeAppView() {
return (
<div className="size-full overflow-hidden">
<div
id="pageRoot"
className={cn("absolute bottom-0 left-0 right-0 top-0 overflow-hidden")}
>
<Suspense>
<ConfigEditor />
</Suspense>
</div>
</div>
); );
} }

View File

@ -283,6 +283,9 @@ export type AllGroupsStreamingSettings = {
}; };
export interface FrigateConfig { export interface FrigateConfig {
version: string;
safe_mode: boolean;
audio: { audio: {
enabled: boolean; enabled: boolean;
enabled_in_config: boolean | null; enabled_in_config: boolean | null;