forked from Github/frigate
swr events refactor
This commit is contained in:
@@ -4,21 +4,21 @@ import Button from '../components/Button';
|
||||
import Heading from '../components/Heading';
|
||||
import Link from '../components/Link';
|
||||
import { useMqtt } from '../api/mqtt';
|
||||
import { useConfig, useStats } from '../api';
|
||||
import useSWR from 'swr';
|
||||
import { Table, Tbody, Thead, Tr, Th, Td } from '../components/Table';
|
||||
import { useCallback } from 'preact/hooks';
|
||||
|
||||
const emptyObject = Object.freeze({});
|
||||
|
||||
export default function Debug() {
|
||||
const { data: config } = useConfig();
|
||||
const { data: config } = useSWR('config');
|
||||
|
||||
const {
|
||||
value: { payload: stats },
|
||||
} = useMqtt('stats');
|
||||
const { data: initialStats } = useStats();
|
||||
const { data: initialStats } = useSWR('stats');
|
||||
|
||||
const { detectors, service = {}, detection_fps, ...cameras } = stats || initialStats || emptyObject;
|
||||
const { detectors, service = {}, ...cameras } = stats || initialStats || emptyObject;
|
||||
|
||||
const detectorNames = Object.keys(detectors || emptyObject);
|
||||
const detectorDataKeys = Object.keys(detectors ? detectors[detectorNames[0]] : emptyObject);
|
||||
@@ -50,13 +50,13 @@ export default function Debug() {
|
||||
<Tr>
|
||||
<Th>detector</Th>
|
||||
{detectorDataKeys.map((name) => (
|
||||
<Th>{name.replace('_', ' ')}</Th>
|
||||
<Th key={name}>{name.replace('_', ' ')}</Th>
|
||||
))}
|
||||
</Tr>
|
||||
</Thead>
|
||||
<Tbody>
|
||||
{detectorNames.map((detector, i) => (
|
||||
<Tr index={i}>
|
||||
<Tr key={i} index={i}>
|
||||
<Td>{detector}</Td>
|
||||
{detectorDataKeys.map((name) => (
|
||||
<Td key={`${name}-${detector}`}>{detectors[detector][name]}</Td>
|
||||
@@ -73,13 +73,13 @@ export default function Debug() {
|
||||
<Tr>
|
||||
<Th>camera</Th>
|
||||
{cameraDataKeys.map((name) => (
|
||||
<Th>{name.replace('_', ' ')}</Th>
|
||||
<Th key={name}>{name.replace('_', ' ')}</Th>
|
||||
))}
|
||||
</Tr>
|
||||
</Thead>
|
||||
<Tbody>
|
||||
{cameraNames.map((camera, i) => (
|
||||
<Tr index={i}>
|
||||
<Tr key={i} index={i}>
|
||||
<Td>
|
||||
<Link href={`/cameras/${camera}`}>{camera}</Link>
|
||||
</Td>
|
||||
|
||||
Reference in New Issue
Block a user