mirror of
https://github.com/karl0ss/homepage.git
synced 2025-05-03 14:03:40 +01:00
Update unifi_console to use private widget options
This commit is contained in:
parent
c1a55ff6d3
commit
dced918804
@ -10,7 +10,7 @@ export default function Widget({ options }) {
|
|||||||
|
|
||||||
// eslint-disable-next-line no-param-reassign
|
// eslint-disable-next-line no-param-reassign
|
||||||
options.type = "unifi_console";
|
options.type = "unifi_console";
|
||||||
const { data: statsData, error: statsError } = useWidgetAPI(options, "stat/sites");
|
const { data: statsData, error: statsError } = useWidgetAPI(options, "stat/sites", { index: options.index });
|
||||||
|
|
||||||
if (statsError || statsData?.error) {
|
if (statsError || statsData?.error) {
|
||||||
return (
|
return (
|
||||||
|
@ -3,8 +3,7 @@ import cache from "memory-cache";
|
|||||||
import { formatApiCall } from "utils/proxy/api-helpers";
|
import { formatApiCall } from "utils/proxy/api-helpers";
|
||||||
import { httpProxy } from "utils/proxy/http";
|
import { httpProxy } from "utils/proxy/http";
|
||||||
import { addCookieToJar, setCookieHeader } from "utils/proxy/cookie-jar";
|
import { addCookieToJar, setCookieHeader } from "utils/proxy/cookie-jar";
|
||||||
import { getSettings } from "utils/config/config";
|
import getServiceWidget, { getPrivateWidgetOptions } from "utils/config/service-helpers";
|
||||||
import getServiceWidget from "utils/config/service-helpers";
|
|
||||||
import createLogger from "utils/logger";
|
import createLogger from "utils/logger";
|
||||||
import widgets from "widgets/widgets";
|
import widgets from "widgets/widgets";
|
||||||
|
|
||||||
@ -15,13 +14,13 @@ const logger = createLogger(proxyName);
|
|||||||
|
|
||||||
async function getWidget(req) {
|
async function getWidget(req) {
|
||||||
const { group, service, type } = req.query;
|
const { group, service, type } = req.query;
|
||||||
|
|
||||||
let widget = null;
|
let widget = null;
|
||||||
if (type === "unifi_console") {
|
if (type === "unifi_console") { // info widget
|
||||||
const settings = getSettings();
|
const index = req.query?.query ? JSON.parse(req.query.query).index : undefined;
|
||||||
widget = settings.unifi_console;
|
widget = await getPrivateWidgetOptions(type, index);
|
||||||
if (!widget) {
|
if (!widget) {
|
||||||
logger.debug("There is no unifi_console section in settings.yaml");
|
logger.debug("Error retrieving settings for this Unifi widget");
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
widget.type = "unifi";
|
widget.type = "unifi";
|
||||||
|
Loading…
x
Reference in New Issue
Block a user