Add logs route

This commit is contained in:
Nick Mowen 2022-11-30 10:00:46 -07:00
parent 2a94db688b
commit 01284740a8
4 changed files with 33 additions and 0 deletions

View File

@ -48,6 +48,7 @@ export default function Sidebar() {
<Destination href="/storage" text="Storage" />
<Destination href="/system" text="System" />
<Destination href="/config" text="Config" />
<Destination href="/logs" text="Logs" />
<Separator />
<div className="flex flex-grow" />
{ENV !== 'production' ? (

View File

@ -38,6 +38,7 @@ export default function App() {
<AsyncRoute path="/storage" getComponent={Routes.getStorage} />
<AsyncRoute path="/system" getComponent={Routes.getSystem} />
<AsyncRoute path="/config" getComponent={Routes.getConfig} />
<AsyncRoute path="/logs" getComponent={Routes.getLogs} />
<AsyncRoute path="/styleguide" getComponent={Routes.getStyleGuide} />
<Cameras default path="/" />
</Router>

26
web/src/routes/Logs.jsx Normal file
View File

@ -0,0 +1,26 @@
import { h } from 'preact';
import Heading from '../components/Heading';
import { useEffect } from 'preact/hooks';
import { tail } from 'tail';
const Tail = tail.Tail;
export default function Logs() {
const stdout = new Tail("/dev/stdout");
useEffect(() => {
stdout.on("line", (data) => {
console.log(data);
});
return () => {
stdout.unwatch();
};
});
return (
<div className="space-y-4 p-2 px-4">
<Heading>Logs</Heading>
</div>
);
}

View File

@ -43,6 +43,11 @@ export async function getConfig(_url, _cb, _props) {
return module.default;
}
export async function getLogs(_url, _cb, _props) {
const module = await import('./Logs.jsx');
return module.default;
}
export async function getStyleGuide(_url, _cb, _props) {
const module = await import('./StyleGuide.jsx');
return module.default;