Change integration structure to array and rename to widgets in config

This commit is contained in:
Meierschlumpf
2022-12-19 17:03:39 +01:00
parent ed0146e7b0
commit 8f7a3111ca
21 changed files with 154 additions and 134 deletions

View File

@@ -10,7 +10,7 @@ interface DashboardWrapperProps {
}
export const DashboardWrapper = ({ wrapper }: DashboardWrapperProps) => {
const { refs, items, integrations } = useGridstack('wrapper', wrapper.id);
const { refs, items, widgets } = useGridstack('wrapper', wrapper.id);
return (
<div
@@ -35,21 +35,23 @@ export const DashboardWrapper = ({ wrapper }: DashboardWrapperProps) => {
</GridstackTileWrapper>
);
})}
{Object.entries(integrations).map(([k, v]) => {
const widget = Widgets[k as keyof typeof Widgets] as IWidgetDefinition | undefined;
if (!widget) return null;
{widgets.map((widget) => {
const definition = Widgets[widget.id as keyof typeof Widgets] as
| IWidgetDefinition
| undefined;
if (!definition) return null;
return (
<GridstackTileWrapper
type="module"
key={k}
itemRef={refs.items.current[k]}
id={widget.id}
{...widget.gridstack}
{...v.shape.location}
{...v.shape.size}
type="widget"
key={widget.id}
itemRef={refs.items.current[widget.id]}
id={definition.id}
{...definition.gridstack}
{...widget.shape.location}
{...widget.shape.size}
>
<widget.component className="grid-stack-item-content" module={v} />
<definition.component className="grid-stack-item-content" widget={widget} />
</GridstackTileWrapper>
);
})}