frigate/web/src/App.jsx

50 lines
2.0 KiB
React
Raw Normal View History

2021-02-08 00:46:05 +03:00
import * as Routes from './routes';
2021-01-09 20:26:46 +03:00
import { h } from 'preact';
import ActivityIndicator from './components/ActivityIndicator';
2021-02-08 00:46:05 +03:00
import AsyncRoute from 'preact-async-route';
import AppBar from './AppBar';
2021-02-08 00:46:05 +03:00
import Cameras from './routes/Cameras';
2021-01-09 20:26:46 +03:00
import { Router } from 'preact-router';
import Sidebar from './Sidebar';
import { DarkModeProvider, DrawerProvider } from './context';
2022-02-26 22:11:00 +03:00
import useSWR from 'swr';
2021-01-09 20:26:46 +03:00
export default function App() {
2022-02-26 22:11:00 +03:00
const { data: config } = useSWR('config');
2022-02-27 17:04:12 +03:00
const cameraComponent = config && config.ui.use_experimental ? Routes.getCameraV2 : Routes.getCamera;
2022-02-26 22:11:00 +03:00
2021-02-02 07:28:25 +03:00
return (
2021-01-31 17:24:04 +03:00
<DarkModeProvider>
<DrawerProvider>
2021-02-14 07:37:22 +03:00
<div data-testid="app" className="w-full">
<AppBar />
2022-02-26 22:11:00 +03:00
{!config ? (
<div className="flex flex-grow-1 min-h-screen justify-center items-center">
<ActivityIndicator />
2021-01-31 17:24:04 +03:00
</div>
) : (
<div className="flex flex-row min-h-screen w-full bg-white dark:bg-gray-900 text-gray-900 dark:text-white">
<Sidebar />
2022-02-27 17:04:12 +03:00
<div className="w-full flex-auto mt-16 min-w-0">
<Router>
2021-02-08 00:46:05 +03:00
<AsyncRoute path="/cameras/:camera/editor" getComponent={Routes.getCameraMap} />
2022-02-27 17:04:12 +03:00
<AsyncRoute path="/cameras/:camera" getComponent={cameraComponent} />
2021-06-12 17:55:40 +03:00
<AsyncRoute path="/birdseye" getComponent={Routes.getBirdseye} />
2021-02-08 00:46:05 +03:00
<AsyncRoute path="/events" getComponent={Routes.getEvents} />
2022-05-10 15:48:29 +03:00
<AsyncRoute
path="/recording/:camera/:date?/:hour?/:minute?/:second?"
getComponent={Routes.getRecording}
/>
2021-02-08 00:46:05 +03:00
<AsyncRoute path="/debug" getComponent={Routes.getDebug} />
<AsyncRoute path="/styleguide" getComponent={Routes.getStyleGuide} />
<Cameras default path="/" />
</Router>
</div>
</div>
)}
</div>
</DrawerProvider>
2021-01-31 17:24:04 +03:00
</DarkModeProvider>
2021-01-09 20:26:46 +03:00
);
}