Unifi widgets support sites other than default

pull/931/head
shamoon 2 years ago
parent c2983197a0
commit 17ebdd8226

@ -20,7 +20,6 @@ export default function Widget({ options }) {
<BiError className="w-8 h-8 text-theme-800 dark:text-theme-200" />
<div className="flex flex-col ml-3 text-left">
<span className="text-theme-800 dark:text-theme-200 text-sm">{t("widget.api_error")}</span>
<span className="text-theme-800 dark:text-theme-200 text-xs">-</span>
</div>
</div>
</div>
@ -28,7 +27,7 @@ export default function Widget({ options }) {
);
}
const defaultSite = statsData?.data?.find(s => s.name === "default");
const defaultSite = options.site ? statsData?.data.find(s => s.desc === options.site) : statsData?.data?.find(s => s.name === "default");
if (!defaultSite) {
return (

@ -233,6 +233,7 @@ export function cleanServiceGroups(groups) {
currency, // coinmarketcap widget
symbols,
defaultinterval,
site, // unifi widget
namespace, // kubernetes widget
app,
podSelector,
@ -256,6 +257,9 @@ export function cleanServiceGroups(groups) {
if (server) cleanedService.widget.server = server;
if (container) cleanedService.widget.container = container;
}
if (type === "unifi") {
if (site) cleanedService.widget.site = site;
}
if (type === "kubernetes") {
if (namespace) cleanedService.widget.namespace = namespace;
if (app) cleanedService.widget.app = app;

@ -15,7 +15,7 @@ export default function Component({ service }) {
return <Container error={statsError} />;
}
const defaultSite = statsData?.data?.find(s => s.name === "default");
const defaultSite = widget.site ? statsData?.data.find(s => s.desc === widget.site) : statsData?.data?.find(s => s.name === "default");
if (!defaultSite) {
return (

Loading…
Cancel
Save