2021-02-07 22:46:05 +01:00
|
|
|
import * as Routes from './routes';
|
2021-01-09 18:26:46 +01:00
|
|
|
import { h } from 'preact';
|
2021-01-30 17:52:37 +01:00
|
|
|
import ActivityIndicator from './components/ActivityIndicator';
|
2021-02-07 22:46:05 +01:00
|
|
|
import AsyncRoute from 'preact-async-route';
|
2021-02-10 22:21:43 +01:00
|
|
|
import AppBar from './AppBar';
|
2021-02-07 22:46:05 +01:00
|
|
|
import Cameras from './routes/Cameras';
|
2021-01-09 18:26:46 +01:00
|
|
|
import { Router } from 'preact-router';
|
|
|
|
import Sidebar from './Sidebar';
|
2021-02-04 19:13:47 +01:00
|
|
|
import { DarkModeProvider, DrawerProvider } from './context';
|
2022-02-26 20:11:00 +01:00
|
|
|
import useSWR from 'swr';
|
2021-01-09 18:26:46 +01:00
|
|
|
|
|
|
|
export default function App() {
|
2022-02-26 20:11:00 +01:00
|
|
|
const { data: config } = useSWR('config');
|
2022-11-13 17:31:36 +01:00
|
|
|
const cameraComponent = config && config.ui?.use_experimental ? Routes.getCameraV2 : Routes.getCamera;
|
2022-02-26 20:11:00 +01:00
|
|
|
|
2021-02-02 05:28:25 +01:00
|
|
|
return (
|
2021-01-31 15:24:04 +01:00
|
|
|
<DarkModeProvider>
|
2021-02-04 19:13:47 +01:00
|
|
|
<DrawerProvider>
|
2021-02-14 05:37:22 +01:00
|
|
|
<div data-testid="app" className="w-full">
|
2021-02-10 22:21:43 +01:00
|
|
|
<AppBar />
|
2022-02-26 20:11:00 +01:00
|
|
|
{!config ? (
|
2021-02-04 00:15:27 +01:00
|
|
|
<div className="flex flex-grow-1 min-h-screen justify-center items-center">
|
|
|
|
<ActivityIndicator />
|
2021-01-31 15:24:04 +01:00
|
|
|
</div>
|
2021-02-04 00:15:27 +01:00
|
|
|
) : (
|
|
|
|
<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 15:04:12 +01:00
|
|
|
<div className="w-full flex-auto mt-16 min-w-0">
|
2021-02-04 00:15:27 +01:00
|
|
|
<Router>
|
2021-02-07 22:46:05 +01:00
|
|
|
<AsyncRoute path="/cameras/:camera/editor" getComponent={Routes.getCameraMap} />
|
2022-02-27 15:04:12 +01:00
|
|
|
<AsyncRoute path="/cameras/:camera" getComponent={cameraComponent} />
|
2021-06-12 16:55:40 +02:00
|
|
|
<AsyncRoute path="/birdseye" getComponent={Routes.getBirdseye} />
|
2021-02-07 22:46:05 +01:00
|
|
|
<AsyncRoute path="/events" getComponent={Routes.getEvents} />
|
2022-05-10 14:48:29 +02:00
|
|
|
<AsyncRoute
|
|
|
|
path="/recording/:camera/:date?/:hour?/:minute?/:second?"
|
|
|
|
getComponent={Routes.getRecording}
|
|
|
|
/>
|
2022-11-30 02:59:56 +01:00
|
|
|
<AsyncRoute path="/storage" getComponent={Routes.getStorage} />
|
2022-11-20 15:56:48 +01:00
|
|
|
<AsyncRoute path="/system" getComponent={Routes.getSystem} />
|
2022-12-07 14:36:56 +01:00
|
|
|
<AsyncRoute path="/config" getComponent={Routes.getConfig} />
|
2021-02-07 22:46:05 +01:00
|
|
|
<AsyncRoute path="/styleguide" getComponent={Routes.getStyleGuide} />
|
2021-02-04 00:15:27 +01:00
|
|
|
<Cameras default path="/" />
|
|
|
|
</Router>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
)}
|
|
|
|
</div>
|
2021-02-04 19:13:47 +01:00
|
|
|
</DrawerProvider>
|
2021-01-31 15:24:04 +01:00
|
|
|
</DarkModeProvider>
|
2021-01-09 18:26:46 +01:00
|
|
|
);
|
|
|
|
}
|