dev: main entity info on dashboard

This commit is contained in:
cha0s 2024-07-10 23:40:11 -05:00
parent 532792595a
commit 41baef2571

View File

@ -1,6 +1,10 @@
import {useState} from 'react';
import {Tab, Tabs, TabList, TabPanel} from 'react-tabs'; import {Tab, Tabs, TabList, TabPanel} from 'react-tabs';
import 'react-tabs/style/react-tabs.css'; import 'react-tabs/style/react-tabs.css';
import {useEcs, useEcsTick} from '@/context/ecs.js';
import {useMainEntity} from '@/context/main-entity.js';
import styles from './devtools.module.css'; import styles from './devtools.module.css';
import Tiles from './devtools/tiles.jsx'; import Tiles from './devtools/tiles.jsx';
@ -10,15 +14,22 @@ export default function Devtools({
eventsChannel, eventsChannel,
setApplyFilters, setApplyFilters,
}) { }) {
const [ecs] = useEcs();
const [mainEntity] = useMainEntity();
const [mainEntityJson, setMainEntityJson] = useState({});
useEcsTick(() => {
if (!ecs || !mainEntity) {
return;
}
setMainEntityJson(ecs.get(mainEntity).toJSON());
}, [ecs, mainEntity]);
return ( return (
<div className={styles.devtools}> <div className={styles.devtools}>
<Tabs> <Tabs>
<TabList> <TabList>
<Tab>Dashboard</Tab> <Tab>Dashboard</Tab>
<Tab>Tiles</Tab> <Tab>Tiles</Tab>
</TabList> </TabList>
<TabPanel> <TabPanel>
<div className={styles.dashboard}> <div className={styles.dashboard}>
<form> <form>
@ -35,9 +46,9 @@ export default function Devtools({
</label> </label>
</div> </div>
</form> </form>
<pre><code><small>{JSON.stringify(mainEntityJson, null, 2)}</small></code></pre>
</div> </div>
</TabPanel> </TabPanel>
<TabPanel> <TabPanel>
<Tiles <Tiles
eventsChannel={eventsChannel} eventsChannel={eventsChannel}