blakeblackshear.frigate/web/src/App.jsx

44 lines
1.8 KiB
React
Raw Normal View History

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';
import ActivityIndicator from './components/ActivityIndicator';
2021-02-07 22:46:05 +01:00
import AsyncRoute from 'preact-async-route';
2021-02-02 05:28:25 +01:00
import AppBar from './components/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';
import Api, { FetchStatus, useConfig } from './api';
import { DarkModeProvider, DrawerProvider } from './context';
2021-01-09 18:26:46 +01:00
export default function App() {
2021-01-26 16:04:03 +01:00
const { data, status } = useConfig();
2021-02-02 05:28:25 +01:00
return (
2021-01-31 15:24:04 +01:00
<DarkModeProvider>
<DrawerProvider>
<div class="w-full">
<AppBar title="Frigate" />
{status !== FetchStatus.LOADED ? (
<div className="flex flex-grow-1 min-h-screen justify-center items-center">
<ActivityIndicator />
2021-01-31 15:24:04 +01: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 />
2021-02-04 00:35:28 +01:00
<div className="w-full flex-auto p-2 mt-24 px-4 min-w-0">
<Router>
2021-02-07 22:46:05 +01:00
<AsyncRoute path="/cameras/:camera/editor" getComponent={Routes.getCameraMap} />
<AsyncRoute path="/cameras/:camera" getComponent={Routes.getCamera} />
<AsyncRoute path="/events/:eventId" getComponent={Routes.getEvent} />
<AsyncRoute path="/events" getComponent={Routes.getEvents} />
<AsyncRoute path="/debug" getComponent={Routes.getDebug} />
<AsyncRoute path="/styleguide" getComponent={Routes.getStyleGuide} />
<Cameras default path="/" />
</Router>
</div>
</div>
)}
</div>
</DrawerProvider>
2021-01-31 15:24:04 +01:00
</DarkModeProvider>
2021-01-09 18:26:46 +01:00
);
}