From 41baef257166f965fb83dae7b34e67acef9ba36e Mon Sep 17 00:00:00 2001 From: cha0s Date: Wed, 10 Jul 2024 23:40:11 -0500 Subject: [PATCH] dev: main entity info on dashboard --- app/react-components/devtools.jsx | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/app/react-components/devtools.jsx b/app/react-components/devtools.jsx index 4b31f7f..46e8c73 100644 --- a/app/react-components/devtools.jsx +++ b/app/react-components/devtools.jsx @@ -1,6 +1,10 @@ +import {useState} from 'react'; import {Tab, Tabs, TabList, TabPanel} from 'react-tabs'; 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 Tiles from './devtools/tiles.jsx'; @@ -10,15 +14,22 @@ export default function Devtools({ eventsChannel, setApplyFilters, }) { + const [ecs] = useEcs(); + const [mainEntity] = useMainEntity(); + const [mainEntityJson, setMainEntityJson] = useState({}); + useEcsTick(() => { + if (!ecs || !mainEntity) { + return; + } + setMainEntityJson(ecs.get(mainEntity).toJSON()); + }, [ecs, mainEntity]); return (
- Dashboard Tiles -
@@ -35,9 +46,9 @@ export default function Devtools({
+
{JSON.stringify(mainEntityJson, null, 2)}
-