2022-09-26 12:04:37 +03:00
|
|
|
import dynamic from "next/dynamic";
|
2022-08-24 10:44:35 +03:00
|
|
|
|
2022-10-05 13:43:22 +03:00
|
|
|
import ErrorBoundary from "components/errorboundry";
|
|
|
|
|
2022-08-24 10:44:35 +03:00
|
|
|
const widgetMappings = {
|
2022-09-26 12:04:37 +03:00
|
|
|
weatherapi: dynamic(() => import("components/widgets/weather/weather")),
|
|
|
|
openweathermap: dynamic(() => import("components/widgets/openweathermap/weather")),
|
|
|
|
resources: dynamic(() => import("components/widgets/resources/resources")),
|
|
|
|
search: dynamic(() => import("components/widgets/search/search")),
|
|
|
|
greeting: dynamic(() => import("components/widgets/greeting/greeting")),
|
|
|
|
datetime: dynamic(() => import("components/widgets/datetime/datetime")),
|
2022-10-08 16:04:24 +03:00
|
|
|
logo: dynamic(() => import("components/widgets/logo/logo"), { ssr: false }),
|
2022-10-09 09:15:46 -07:00
|
|
|
unifi_console: dynamic(() => import("components/widgets/unifi_console/unifi_console")),
|
2022-10-10 11:18:29 -07:00
|
|
|
glances: dynamic(() => import("components/widgets/glances/glances")),
|
2022-10-20 01:52:47 -07:00
|
|
|
openmeteo: dynamic(() => import("components/widgets/openmeteo/openmeteo")),
|
2022-10-25 13:35:38 -05:00
|
|
|
longhorn: dynamic(() => import("components/widgets/longhorn/longhorn")),
|
2022-11-18 18:02:23 -06:00
|
|
|
kubernetes: dynamic(() => import("components/widgets/kubernetes/kubernetes")),
|
2022-08-24 10:44:35 +03:00
|
|
|
};
|
|
|
|
|
2023-06-10 23:30:44 -07:00
|
|
|
export default function Widget({ widget }) {
|
2022-09-16 10:53:12 +03:00
|
|
|
const InfoWidget = widgetMappings[widget.type];
|
2022-08-24 10:44:35 +03:00
|
|
|
|
2022-09-16 10:53:12 +03:00
|
|
|
if (InfoWidget) {
|
2022-10-05 13:43:22 +03:00
|
|
|
return (
|
|
|
|
<ErrorBoundary>
|
2023-06-10 23:30:44 -07:00
|
|
|
<InfoWidget options={widget.options} />
|
2022-10-05 13:43:22 +03:00
|
|
|
</ErrorBoundary>
|
|
|
|
);
|
2022-08-24 10:44:35 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
return (
|
|
|
|
<div className="flex-none flex flex-row items-center justify-center">
|
|
|
|
Missing <strong>{widget.type}</strong>
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|