frigate/web/src/routes/Logs.jsx

30 lines
1.0 KiB
React
Raw Normal View History

2022-11-30 20:00:46 +03:00
import { h } from 'preact';
import Heading from '../components/Heading';
2022-12-05 21:22:49 +03:00
import { useEffect, useState } from 'preact/hooks';
import ButtonsTabbed from '../components/ButtonsTabbed';
import useSWR from 'swr';
import Button from '../components/Button';
2022-11-30 20:00:46 +03:00
export default function Logs() {
2022-12-05 21:22:49 +03:00
const [logService, setLogService] = useState('frigate');
const { data: frigateLogs } = useSWR('logs/frigate');
const { data: go2rtcLogs } = useSWR('logs/go2rtc');
const { data: nginxLogs } = useSWR('logs/nginx');
2022-11-30 20:00:46 +03:00
return (
<div className="space-y-4 p-2 px-4">
<Heading>Logs</Heading>
2022-12-05 21:22:49 +03:00
<ButtonsTabbed viewModes={['frigate', 'go2rtc', 'nginx']} setViewMode={setLogService} />
2022-12-05 21:30:38 +03:00
<div className='overflow-auto font-mono text-sm text-gray-900 dark:text-gray-100 rounded bg-gray-100 dark:bg-gray-800 p-2 whitespace-pre-wrap'>
{logService == 'frigate' ? frigateLogs : (logService == 'go2rtc' ? go2rtcLogs : nginxLogs)}
2022-12-05 21:22:49 +03:00
</div>
<Button className="">
Copy to Clipboard
</Button>
2022-11-30 20:00:46 +03:00
</div>
);
}