2022-12-10 22:14:31 +01:00
|
|
|
import { WrapperType } from '../../../../types/wrapper';
|
2022-12-18 21:50:08 +01:00
|
|
|
import Widgets from '../../../../widgets';
|
|
|
|
|
import { IWidget, IWidgetDefinition } from '../../../../widgets/widgets';
|
2022-12-10 22:14:31 +01:00
|
|
|
import { Tiles } from '../../Tiles/tilesDefinitions';
|
|
|
|
|
import { GridstackTileWrapper } from '../../Tiles/TileWrapper';
|
|
|
|
|
import { useGridstack } from '../gridstack/use-gridstack';
|
|
|
|
|
|
|
|
|
|
interface DashboardWrapperProps {
|
|
|
|
|
wrapper: WrapperType;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export const DashboardWrapper = ({ wrapper }: DashboardWrapperProps) => {
|
|
|
|
|
const { refs, items, integrations } = useGridstack('wrapper', wrapper.id);
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<div
|
|
|
|
|
className="grid-stack grid-stack-wrapper"
|
|
|
|
|
style={{ transitionDuration: '0s' }}
|
|
|
|
|
data-wrapper={wrapper.id}
|
|
|
|
|
ref={refs.wrapper}
|
|
|
|
|
>
|
2022-12-18 22:27:01 +01:00
|
|
|
{items?.map((app) => {
|
|
|
|
|
const { component: TileComponent, ...tile } = Tiles['app'];
|
2022-12-10 22:14:31 +01:00
|
|
|
return (
|
|
|
|
|
<GridstackTileWrapper
|
2022-12-18 22:27:01 +01:00
|
|
|
id={app.id}
|
|
|
|
|
type="app"
|
|
|
|
|
key={app.id}
|
|
|
|
|
itemRef={refs.items.current[app.id]}
|
2022-12-10 22:14:31 +01:00
|
|
|
{...tile}
|
2022-12-18 22:27:01 +01:00
|
|
|
{...app.shape.location}
|
|
|
|
|
{...app.shape.size}
|
2022-12-10 22:14:31 +01:00
|
|
|
>
|
2022-12-18 22:27:01 +01:00
|
|
|
<TileComponent className="grid-stack-item-content" app={app} />
|
2022-12-10 22:14:31 +01:00
|
|
|
</GridstackTileWrapper>
|
|
|
|
|
);
|
|
|
|
|
})}
|
|
|
|
|
{Object.entries(integrations).map(([k, v]) => {
|
2022-12-18 21:50:08 +01:00
|
|
|
const widget = Widgets[k as keyof typeof Widgets] as IWidgetDefinition | undefined;
|
|
|
|
|
if (!widget) return null;
|
2022-12-10 22:14:31 +01:00
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<GridstackTileWrapper
|
|
|
|
|
type="module"
|
|
|
|
|
key={k}
|
|
|
|
|
itemRef={refs.items.current[k]}
|
2022-12-18 21:50:08 +01:00
|
|
|
id={widget.id}
|
|
|
|
|
{...widget.gridstack}
|
2022-12-10 22:14:31 +01:00
|
|
|
{...v.shape.location}
|
|
|
|
|
{...v.shape.size}
|
|
|
|
|
>
|
2022-12-18 21:50:08 +01:00
|
|
|
<widget.component className="grid-stack-item-content" module={v} />
|
2022-12-10 22:14:31 +01:00
|
|
|
</GridstackTileWrapper>
|
|
|
|
|
);
|
|
|
|
|
})}
|
|
|
|
|
</div>
|
|
|
|
|
);
|
|
|
|
|
};
|