Removed widgets from tile definitions

This commit is contained in:
Meierschlumpf
2022-12-18 21:50:08 +01:00
parent 864371e3c2
commit b4cfa1ac05
12 changed files with 126 additions and 15 deletions

View File

@@ -1,7 +1,9 @@
import { Card, Group, Title } from '@mantine/core';
import { CategoryType } from '../../../../types/category';
import { IWidgetDefinition } from '../../../../widgets/widgets';
import { HomarrCardWrapper } from '../../Tiles/HomarrCardWrapper';
import { Tiles } from '../../Tiles/tilesDefinitions';
import Widgets from '../../../../widgets';
import { GridstackTileWrapper } from '../../Tiles/TileWrapper';
import { useEditModeStore } from '../../Views/useEditModeStore';
import { useGridstack } from '../gridstack/use-gridstack';
@@ -44,19 +46,20 @@ export const DashboardCategory = ({ category }: DashboardCategoryProps) => {
);
})}
{Object.entries(integrations).map(([k, v]) => {
const { component: TileComponent, ...tile } = Tiles[k as keyof typeof Tiles];
const widget = Widgets[k as keyof typeof Widgets] as IWidgetDefinition | undefined;
if (!widget) return null;
return (
<GridstackTileWrapper
id={k}
type="module"
key={k}
itemRef={refs.items.current[k]}
{...tile}
id={widget.id}
{...widget.gridstack}
{...v.shape.location}
{...v.shape.size}
>
<TileComponent className="grid-stack-item-content" module={v} />
<widget.component className="grid-stack-item-content" module={v} />
</GridstackTileWrapper>
);
})}

View File

@@ -1,6 +1,8 @@
import { Card } from '@mantine/core';
import { RefObject } from 'react';
import { IWidgetDefinition } from '../../../../widgets/widgets';
import { Tiles } from '../../Tiles/tilesDefinitions';
import Widgets from '../../../../widgets';
import { GridstackTileWrapper } from '../../Tiles/TileWrapper';
import { useGridstack } from '../gridstack/use-gridstack';
@@ -46,19 +48,20 @@ export const DashboardSidebar = ({ location }: DashboardSidebarProps) => {
);
})}
{Object.entries(integrations).map(([k, v]) => {
const { component: TileComponent, ...tile } = Tiles[k as keyof typeof Tiles];
const widget = Widgets[k as keyof typeof Widgets] as IWidgetDefinition | undefined;
if (!widget) return null;
return (
<GridstackTileWrapper
id={k}
type="module"
key={k}
itemRef={refs.items.current[k]}
{...tile}
id={widget.id}
{...widget.gridstack}
{...v.shape.location}
{...v.shape.size}
>
<TileComponent className="grid-stack-item-content" module={v} />
<widget.component className="grid-stack-item-content" module={v} />
</GridstackTileWrapper>
);
})}

View File

@@ -1,4 +1,6 @@
import { WrapperType } from '../../../../types/wrapper';
import Widgets from '../../../../widgets';
import { IWidget, IWidgetDefinition } from '../../../../widgets/widgets';
import { Tiles } from '../../Tiles/tilesDefinitions';
import { GridstackTileWrapper } from '../../Tiles/TileWrapper';
import { useGridstack } from '../gridstack/use-gridstack';
@@ -34,19 +36,20 @@ export const DashboardWrapper = ({ wrapper }: DashboardWrapperProps) => {
);
})}
{Object.entries(integrations).map(([k, v]) => {
const { component: TileComponent, ...tile } = Tiles[k as keyof typeof Tiles];
const widget = Widgets[k as keyof typeof Widgets] as IWidgetDefinition | undefined;
if (!widget) return null;
return (
<GridstackTileWrapper
id={k}
type="module"
key={k}
itemRef={refs.items.current[k]}
{...tile}
id={widget.id}
{...widget.gridstack}
{...v.shape.location}
{...v.shape.size}
>
<TileComponent className="grid-stack-item-content" module={v} />
<widget.component className="grid-stack-item-content" module={v} />
</GridstackTileWrapper>
);
})}