Use index instead of name, lots of code cleanup
This commit is contained in:
parent
43e8010375
commit
ec383d60bb
@ -20,14 +20,12 @@ Service widgets are used to display the status of a service, often a web service
|
||||
server: localhost
|
||||
container: plex
|
||||
widgets:
|
||||
- Tautulli:
|
||||
type: tautulli
|
||||
url: http://172.16.1.1:8181
|
||||
key: aabbccddeeffgghhiijjkkllmmnnoo
|
||||
- UptimeKuma:
|
||||
type: uptimekuma
|
||||
url: http://172.16.1.2:8080
|
||||
slug: aaaaaaabbbbb
|
||||
- type: tautulli
|
||||
url: http://172.16.1.1:8181
|
||||
key: aabbccddeeffgghhiijjkkllmmnnoo
|
||||
- type: uptimekuma
|
||||
url: http://172.16.1.2:8080
|
||||
slug: aaaaaaabbbbb
|
||||
```
|
||||
|
||||
## Info Widgets
|
||||
|
||||
@ -155,7 +155,7 @@ export default function Item({ service, group, useEqualHeights }) {
|
||||
)}
|
||||
|
||||
{service.widgets.map((widget) => (
|
||||
<Widget widget={widget} service={service} />
|
||||
<Widget widget={widget} service={service} key={widget.index} />
|
||||
))}
|
||||
</div>
|
||||
</li>
|
||||
|
||||
@ -8,7 +8,7 @@ export default function Widget({ widget, service }) {
|
||||
|
||||
const ServiceWidget = components[widget.type];
|
||||
|
||||
const fullService = service;
|
||||
const fullService = Object.apply({}, service);
|
||||
fullService.widget = widget;
|
||||
if (ServiceWidget) {
|
||||
return (
|
||||
|
||||
@ -9,8 +9,8 @@ const logger = createLogger("servicesProxy");
|
||||
|
||||
export default async function handler(req, res) {
|
||||
try {
|
||||
const { service, group, name } = req.query;
|
||||
const serviceWidget = await getServiceWidget(group, service, name);
|
||||
const { service, group, index } = req.query;
|
||||
const serviceWidget = await getServiceWidget(group, service, index);
|
||||
let type = serviceWidget?.type;
|
||||
|
||||
// exceptions
|
||||
@ -41,7 +41,7 @@ export default async function handler(req, res) {
|
||||
const endpoint = mapping?.endpoint;
|
||||
const endpointProxy = mapping?.proxyHandler || serviceProxyHandler;
|
||||
|
||||
if (mapping.method && mapping.method !== req.method) {
|
||||
if (mapping?.method && mapping.method !== req.method) {
|
||||
logger.debug("Unsupported method: %s", req.method);
|
||||
return res.status(403).json({ error: "Unsupported method" });
|
||||
}
|
||||
|
||||
@ -354,317 +354,317 @@ export function cleanServiceGroups(groups) {
|
||||
if (typeof cleanedService.weight !== "number") {
|
||||
cleanedService.weight = 0;
|
||||
}
|
||||
cleanedService.widgets = cleanedService.widgets ? cleanedService.widgets : [];
|
||||
if (cleanedService.widget != undefined) cleanedService.widgets.push(cleanedService.widget);
|
||||
if (cleanedService.widgets != []) {
|
||||
cleanedService.widgets = cleanedService.widgets.map((widget) => {
|
||||
// whitelisted set of keys to pass to the frontend
|
||||
// alphabetical, grouped by widget(s)
|
||||
const {
|
||||
// all widgets
|
||||
fields,
|
||||
hideErrors,
|
||||
type,
|
||||
|
||||
// azuredevops
|
||||
repositoryId,
|
||||
userEmail,
|
||||
|
||||
// beszel
|
||||
systemId,
|
||||
|
||||
// calendar
|
||||
firstDayInWeek,
|
||||
integrations,
|
||||
maxEvents,
|
||||
showTime,
|
||||
previousDays,
|
||||
view,
|
||||
timezone,
|
||||
|
||||
// coinmarketcap
|
||||
currency,
|
||||
defaultinterval,
|
||||
slugs,
|
||||
symbols,
|
||||
|
||||
// customapi
|
||||
mappings,
|
||||
display,
|
||||
|
||||
// diskstation
|
||||
volume,
|
||||
|
||||
// docker
|
||||
container,
|
||||
server,
|
||||
|
||||
// emby, jellyfin
|
||||
enableBlocks,
|
||||
enableNowPlaying,
|
||||
|
||||
// emby, jellyfin, tautulli
|
||||
enableUser,
|
||||
expandOneStreamToTwoRows,
|
||||
showEpisodeNumber,
|
||||
|
||||
// frigate
|
||||
enableRecentEvents,
|
||||
|
||||
// glances, immich, mealie, pihole, pfsense
|
||||
version,
|
||||
|
||||
// glances
|
||||
chart,
|
||||
metric,
|
||||
pointsLimit,
|
||||
diskUnits,
|
||||
|
||||
// glances, customapi, iframe, prometheusmetric
|
||||
refreshInterval,
|
||||
|
||||
// hdhomerun
|
||||
tuner,
|
||||
|
||||
// healthchecks
|
||||
uuid,
|
||||
|
||||
// iframe
|
||||
allowFullscreen,
|
||||
allowPolicy,
|
||||
allowScrolling,
|
||||
classes,
|
||||
loadingStrategy,
|
||||
referrerPolicy,
|
||||
src,
|
||||
|
||||
// kopia
|
||||
snapshotHost,
|
||||
snapshotPath,
|
||||
|
||||
// kubernetes
|
||||
app,
|
||||
namespace,
|
||||
podSelector,
|
||||
|
||||
// lubelogger
|
||||
vehicleID,
|
||||
|
||||
// mjpeg
|
||||
fit,
|
||||
stream,
|
||||
|
||||
// openmediavault
|
||||
method,
|
||||
|
||||
// openwrt
|
||||
interfaceName,
|
||||
|
||||
// opnsense, pfsense
|
||||
wan,
|
||||
|
||||
// prometheusmetric
|
||||
metrics,
|
||||
|
||||
// proxmox
|
||||
node,
|
||||
|
||||
// speedtest
|
||||
bitratePrecision,
|
||||
|
||||
// sonarr, radarr
|
||||
enableQueue,
|
||||
|
||||
// stocks
|
||||
watchlist,
|
||||
showUSMarketStatus,
|
||||
|
||||
// truenas
|
||||
enablePools,
|
||||
nasType,
|
||||
|
||||
// unifi
|
||||
site,
|
||||
|
||||
// vikunja
|
||||
enableTaskList,
|
||||
|
||||
// wgeasy
|
||||
threshold,
|
||||
|
||||
// technitium
|
||||
range,
|
||||
|
||||
// spoolman
|
||||
spoolIds,
|
||||
} = Object.keys(widget)[0] != "type" ? widget[Object.keys(widget)[0]] : widget;
|
||||
|
||||
let fieldsList = fields;
|
||||
if (typeof fields === "string") {
|
||||
try {
|
||||
fieldsList = JSON.parse(fields);
|
||||
} catch (e) {
|
||||
logger.error("Invalid fields list detected in config for service '%s'", service.name);
|
||||
fieldsList = null;
|
||||
}
|
||||
}
|
||||
|
||||
widget = {
|
||||
type,
|
||||
fields: fieldsList || null,
|
||||
hide_errors: hideErrors || false,
|
||||
service_name: service.name,
|
||||
service_group: serviceGroup.name,
|
||||
widget_name: Object.keys(widget)[0] != "type" ? Object.keys(widget)[0] : "",
|
||||
};
|
||||
|
||||
if (type === "azuredevops") {
|
||||
if (userEmail) widget.userEmail = userEmail;
|
||||
if (repositoryId) widget.repositoryId = repositoryId;
|
||||
}
|
||||
|
||||
if (type === "beszel") {
|
||||
if (systemId) widget.systemId = systemId;
|
||||
}
|
||||
|
||||
if (type === "coinmarketcap") {
|
||||
if (currency) widget.currency = currency;
|
||||
if (symbols) widget.symbols = symbols;
|
||||
if (slugs) widget.slugs = slugs;
|
||||
if (defaultinterval) widget.defaultinterval = defaultinterval;
|
||||
}
|
||||
|
||||
if (type === "docker") {
|
||||
if (server) widget.server = server;
|
||||
if (container) widget.container = container;
|
||||
}
|
||||
if (type === "unifi") {
|
||||
if (site) widget.site = site;
|
||||
}
|
||||
if (type === "proxmox") {
|
||||
if (node) widget.node = node;
|
||||
}
|
||||
if (type === "kubernetes") {
|
||||
if (namespace) widget.namespace = namespace;
|
||||
if (app) widget.app = app;
|
||||
if (podSelector) widget.podSelector = podSelector;
|
||||
}
|
||||
if (type === "iframe") {
|
||||
if (src) widget.src = src;
|
||||
if (classes) widget.classes = classes;
|
||||
if (referrerPolicy) widget.referrerPolicy = referrerPolicy;
|
||||
if (allowPolicy) widget.allowPolicy = allowPolicy;
|
||||
if (allowFullscreen) widget.allowFullscreen = allowFullscreen;
|
||||
if (loadingStrategy) widget.loadingStrategy = loadingStrategy;
|
||||
if (allowScrolling) widget.allowScrolling = allowScrolling;
|
||||
if (refreshInterval) widget.refreshInterval = refreshInterval;
|
||||
}
|
||||
if (["opnsense", "pfsense"].includes(type)) {
|
||||
if (wan) widget.wan = wan;
|
||||
}
|
||||
if (["emby", "jellyfin"].includes(type)) {
|
||||
if (enableBlocks !== undefined) widget.enableBlocks = JSON.parse(enableBlocks);
|
||||
if (enableNowPlaying !== undefined) widget.enableNowPlaying = JSON.parse(enableNowPlaying);
|
||||
}
|
||||
if (["emby", "jellyfin", "tautulli"].includes(type)) {
|
||||
if (expandOneStreamToTwoRows !== undefined)
|
||||
widget.expandOneStreamToTwoRows = !!JSON.parse(expandOneStreamToTwoRows);
|
||||
if (showEpisodeNumber !== undefined) widget.showEpisodeNumber = !!JSON.parse(showEpisodeNumber);
|
||||
if (enableUser !== undefined) widget.enableUser = !!JSON.parse(enableUser);
|
||||
}
|
||||
if (["sonarr", "radarr"].includes(type)) {
|
||||
if (enableQueue !== undefined) widget.enableQueue = JSON.parse(enableQueue);
|
||||
}
|
||||
if (type === "truenas") {
|
||||
if (enablePools !== undefined) widget.enablePools = JSON.parse(enablePools);
|
||||
if (nasType !== undefined) widget.nasType = nasType;
|
||||
}
|
||||
if (["diskstation", "qnap"].includes(type)) {
|
||||
if (volume) widget.volume = volume;
|
||||
}
|
||||
if (type === "kopia") {
|
||||
if (snapshotHost) widget.snapshotHost = snapshotHost;
|
||||
if (snapshotPath) widget.snapshotPath = snapshotPath;
|
||||
}
|
||||
if (["glances", "immich", "mealie", "pfsense", "pihole"].includes(type)) {
|
||||
if (version) widget.version = parseInt(version, 10);
|
||||
}
|
||||
if (type === "glances") {
|
||||
if (metric) widget.metric = metric;
|
||||
if (chart !== undefined) {
|
||||
widget.chart = chart;
|
||||
} else {
|
||||
widget.chart = true;
|
||||
}
|
||||
if (refreshInterval) widget.refreshInterval = refreshInterval;
|
||||
if (pointsLimit) widget.pointsLimit = pointsLimit;
|
||||
if (diskUnits) widget.diskUnits = diskUnits;
|
||||
}
|
||||
if (type === "mjpeg") {
|
||||
if (stream) widget.stream = stream;
|
||||
if (fit) widget.fit = fit;
|
||||
}
|
||||
if (type === "openmediavault") {
|
||||
if (method) widget.method = method;
|
||||
}
|
||||
if (type === "openwrt") {
|
||||
if (interfaceName) widget.interfaceName = interfaceName;
|
||||
}
|
||||
if (type === "customapi") {
|
||||
if (mappings) widget.mappings = mappings;
|
||||
if (display) widget.display = display;
|
||||
if (refreshInterval) widget.refreshInterval = refreshInterval;
|
||||
}
|
||||
if (type === "calendar") {
|
||||
if (integrations) widget.integrations = integrations;
|
||||
if (firstDayInWeek) widget.firstDayInWeek = firstDayInWeek;
|
||||
if (view) widget.view = view;
|
||||
if (maxEvents) widget.maxEvents = maxEvents;
|
||||
if (previousDays) widget.previousDays = previousDays;
|
||||
if (showTime) widget.showTime = showTime;
|
||||
if (timezone) widget.timezone = timezone;
|
||||
}
|
||||
if (type === "hdhomerun") {
|
||||
if (tuner !== undefined) widget.tuner = tuner;
|
||||
}
|
||||
if (type === "healthchecks") {
|
||||
if (uuid !== undefined) widget.uuid = uuid;
|
||||
}
|
||||
if (type === "speedtest") {
|
||||
if (bitratePrecision !== undefined) {
|
||||
widget.bitratePrecision = parseInt(bitratePrecision, 10);
|
||||
}
|
||||
}
|
||||
if (type === "stocks") {
|
||||
if (watchlist) widget.watchlist = watchlist;
|
||||
if (showUSMarketStatus) widget.showUSMarketStatus = showUSMarketStatus;
|
||||
}
|
||||
if (type === "wgeasy") {
|
||||
if (threshold !== undefined) widget.threshold = parseInt(threshold, 10);
|
||||
}
|
||||
if (type === "frigate") {
|
||||
if (enableRecentEvents !== undefined) widget.enableRecentEvents = enableRecentEvents;
|
||||
}
|
||||
if (type === "technitium") {
|
||||
if (range !== undefined) widget.range = range;
|
||||
}
|
||||
if (type === "lubelogger") {
|
||||
if (vehicleID !== undefined) widget.vehicleID = parseInt(vehicleID, 10);
|
||||
}
|
||||
if (type === "vikunja") {
|
||||
if (enableTaskList !== undefined) widget.enableTaskList = !!enableTaskList;
|
||||
}
|
||||
if (type === "prometheusmetric") {
|
||||
if (metrics) widget.metrics = metrics;
|
||||
if (refreshInterval) widget.refreshInterval = refreshInterval;
|
||||
}
|
||||
if (type === "spoolman") {
|
||||
if (spoolIds !== undefined) widget.spoolIds = spoolIds;
|
||||
}
|
||||
return widget;
|
||||
});
|
||||
if (!cleanedService.widgets) cleanedService.widgets = [];
|
||||
if (cleanedService.widget) {
|
||||
cleanedService.widgets.push(cleanedService.widget);
|
||||
delete cleanedService.widget;
|
||||
}
|
||||
cleanedService.widget = null;
|
||||
cleanedService.widgets = cleanedService.widgets.map((widgetData, index) => {
|
||||
// whitelisted set of keys to pass to the frontend
|
||||
// alphabetical, grouped by widget(s)
|
||||
const {
|
||||
// all widgets
|
||||
fields,
|
||||
hideErrors,
|
||||
type,
|
||||
|
||||
// azuredevops
|
||||
repositoryId,
|
||||
userEmail,
|
||||
|
||||
// beszel
|
||||
systemId,
|
||||
|
||||
// calendar
|
||||
firstDayInWeek,
|
||||
integrations,
|
||||
maxEvents,
|
||||
showTime,
|
||||
previousDays,
|
||||
view,
|
||||
timezone,
|
||||
|
||||
// coinmarketcap
|
||||
currency,
|
||||
defaultinterval,
|
||||
slugs,
|
||||
symbols,
|
||||
|
||||
// customapi
|
||||
mappings,
|
||||
display,
|
||||
|
||||
// diskstation
|
||||
volume,
|
||||
|
||||
// docker
|
||||
container,
|
||||
server,
|
||||
|
||||
// emby, jellyfin
|
||||
enableBlocks,
|
||||
enableNowPlaying,
|
||||
|
||||
// emby, jellyfin, tautulli
|
||||
enableUser,
|
||||
expandOneStreamToTwoRows,
|
||||
showEpisodeNumber,
|
||||
|
||||
// frigate
|
||||
enableRecentEvents,
|
||||
|
||||
// glances, immich, mealie, pihole, pfsense
|
||||
version,
|
||||
|
||||
// glances
|
||||
chart,
|
||||
metric,
|
||||
pointsLimit,
|
||||
diskUnits,
|
||||
|
||||
// glances, customapi, iframe, prometheusmetric
|
||||
refreshInterval,
|
||||
|
||||
// hdhomerun
|
||||
tuner,
|
||||
|
||||
// healthchecks
|
||||
uuid,
|
||||
|
||||
// iframe
|
||||
allowFullscreen,
|
||||
allowPolicy,
|
||||
allowScrolling,
|
||||
classes,
|
||||
loadingStrategy,
|
||||
referrerPolicy,
|
||||
src,
|
||||
|
||||
// kopia
|
||||
snapshotHost,
|
||||
snapshotPath,
|
||||
|
||||
// kubernetes
|
||||
app,
|
||||
namespace,
|
||||
podSelector,
|
||||
|
||||
// lubelogger
|
||||
vehicleID,
|
||||
|
||||
// mjpeg
|
||||
fit,
|
||||
stream,
|
||||
|
||||
// openmediavault
|
||||
method,
|
||||
|
||||
// openwrt
|
||||
interfaceName,
|
||||
|
||||
// opnsense, pfsense
|
||||
wan,
|
||||
|
||||
// prometheusmetric
|
||||
metrics,
|
||||
|
||||
// proxmox
|
||||
node,
|
||||
|
||||
// speedtest
|
||||
bitratePrecision,
|
||||
|
||||
// sonarr, radarr
|
||||
enableQueue,
|
||||
|
||||
// stocks
|
||||
watchlist,
|
||||
showUSMarketStatus,
|
||||
|
||||
// truenas
|
||||
enablePools,
|
||||
nasType,
|
||||
|
||||
// unifi
|
||||
site,
|
||||
|
||||
// vikunja
|
||||
enableTaskList,
|
||||
|
||||
// wgeasy
|
||||
threshold,
|
||||
|
||||
// technitium
|
||||
range,
|
||||
|
||||
// spoolman
|
||||
spoolIds,
|
||||
} = widgetData;
|
||||
|
||||
let fieldsList = fields;
|
||||
if (typeof fields === "string") {
|
||||
try {
|
||||
fieldsList = JSON.parse(fields);
|
||||
} catch (e) {
|
||||
logger.error("Invalid fields list detected in config for service '%s'", service.name);
|
||||
fieldsList = null;
|
||||
}
|
||||
}
|
||||
|
||||
const widget = {
|
||||
type,
|
||||
fields: fieldsList || null,
|
||||
hide_errors: hideErrors || false,
|
||||
service_name: service.name,
|
||||
service_group: serviceGroup.name,
|
||||
index,
|
||||
};
|
||||
|
||||
if (type === "azuredevops") {
|
||||
if (userEmail) widget.userEmail = userEmail;
|
||||
if (repositoryId) widget.repositoryId = repositoryId;
|
||||
}
|
||||
|
||||
if (type === "beszel") {
|
||||
if (systemId) widget.systemId = systemId;
|
||||
}
|
||||
|
||||
if (type === "coinmarketcap") {
|
||||
if (currency) widget.currency = currency;
|
||||
if (symbols) widget.symbols = symbols;
|
||||
if (slugs) widget.slugs = slugs;
|
||||
if (defaultinterval) widget.defaultinterval = defaultinterval;
|
||||
}
|
||||
|
||||
if (type === "docker") {
|
||||
if (server) widget.server = server;
|
||||
if (container) widget.container = container;
|
||||
}
|
||||
if (type === "unifi") {
|
||||
if (site) widget.site = site;
|
||||
}
|
||||
if (type === "proxmox") {
|
||||
if (node) widget.node = node;
|
||||
}
|
||||
if (type === "kubernetes") {
|
||||
if (namespace) widget.namespace = namespace;
|
||||
if (app) widget.app = app;
|
||||
if (podSelector) widget.podSelector = podSelector;
|
||||
}
|
||||
if (type === "iframe") {
|
||||
if (src) widget.src = src;
|
||||
if (classes) widget.classes = classes;
|
||||
if (referrerPolicy) widget.referrerPolicy = referrerPolicy;
|
||||
if (allowPolicy) widget.allowPolicy = allowPolicy;
|
||||
if (allowFullscreen) widget.allowFullscreen = allowFullscreen;
|
||||
if (loadingStrategy) widget.loadingStrategy = loadingStrategy;
|
||||
if (allowScrolling) widget.allowScrolling = allowScrolling;
|
||||
if (refreshInterval) widget.refreshInterval = refreshInterval;
|
||||
}
|
||||
if (["opnsense", "pfsense"].includes(type)) {
|
||||
if (wan) widget.wan = wan;
|
||||
}
|
||||
if (["emby", "jellyfin"].includes(type)) {
|
||||
if (enableBlocks !== undefined) widget.enableBlocks = JSON.parse(enableBlocks);
|
||||
if (enableNowPlaying !== undefined) widget.enableNowPlaying = JSON.parse(enableNowPlaying);
|
||||
}
|
||||
if (["emby", "jellyfin", "tautulli"].includes(type)) {
|
||||
if (expandOneStreamToTwoRows !== undefined)
|
||||
widget.expandOneStreamToTwoRows = !!JSON.parse(expandOneStreamToTwoRows);
|
||||
if (showEpisodeNumber !== undefined) widget.showEpisodeNumber = !!JSON.parse(showEpisodeNumber);
|
||||
if (enableUser !== undefined) widget.enableUser = !!JSON.parse(enableUser);
|
||||
}
|
||||
if (["sonarr", "radarr"].includes(type)) {
|
||||
if (enableQueue !== undefined) widget.enableQueue = JSON.parse(enableQueue);
|
||||
}
|
||||
if (type === "truenas") {
|
||||
if (enablePools !== undefined) widget.enablePools = JSON.parse(enablePools);
|
||||
if (nasType !== undefined) widget.nasType = nasType;
|
||||
}
|
||||
if (["diskstation", "qnap"].includes(type)) {
|
||||
if (volume) widget.volume = volume;
|
||||
}
|
||||
if (type === "kopia") {
|
||||
if (snapshotHost) widget.snapshotHost = snapshotHost;
|
||||
if (snapshotPath) widget.snapshotPath = snapshotPath;
|
||||
}
|
||||
if (["glances", "immich", "mealie", "pfsense", "pihole"].includes(type)) {
|
||||
if (version) widget.version = parseInt(version, 10);
|
||||
}
|
||||
if (type === "glances") {
|
||||
if (metric) widget.metric = metric;
|
||||
if (chart !== undefined) {
|
||||
widget.chart = chart;
|
||||
} else {
|
||||
widget.chart = true;
|
||||
}
|
||||
if (refreshInterval) widget.refreshInterval = refreshInterval;
|
||||
if (pointsLimit) widget.pointsLimit = pointsLimit;
|
||||
if (diskUnits) widget.diskUnits = diskUnits;
|
||||
}
|
||||
if (type === "mjpeg") {
|
||||
if (stream) widget.stream = stream;
|
||||
if (fit) widget.fit = fit;
|
||||
}
|
||||
if (type === "openmediavault") {
|
||||
if (method) widget.method = method;
|
||||
}
|
||||
if (type === "openwrt") {
|
||||
if (interfaceName) widget.interfaceName = interfaceName;
|
||||
}
|
||||
if (type === "customapi") {
|
||||
if (mappings) widget.mappings = mappings;
|
||||
if (display) widget.display = display;
|
||||
if (refreshInterval) widget.refreshInterval = refreshInterval;
|
||||
}
|
||||
if (type === "calendar") {
|
||||
if (integrations) widget.integrations = integrations;
|
||||
if (firstDayInWeek) widget.firstDayInWeek = firstDayInWeek;
|
||||
if (view) widget.view = view;
|
||||
if (maxEvents) widget.maxEvents = maxEvents;
|
||||
if (previousDays) widget.previousDays = previousDays;
|
||||
if (showTime) widget.showTime = showTime;
|
||||
if (timezone) widget.timezone = timezone;
|
||||
}
|
||||
if (type === "hdhomerun") {
|
||||
if (tuner !== undefined) widget.tuner = tuner;
|
||||
}
|
||||
if (type === "healthchecks") {
|
||||
if (uuid !== undefined) widget.uuid = uuid;
|
||||
}
|
||||
if (type === "speedtest") {
|
||||
if (bitratePrecision !== undefined) {
|
||||
widget.bitratePrecision = parseInt(bitratePrecision, 10);
|
||||
}
|
||||
}
|
||||
if (type === "stocks") {
|
||||
if (watchlist) widget.watchlist = watchlist;
|
||||
if (showUSMarketStatus) widget.showUSMarketStatus = showUSMarketStatus;
|
||||
}
|
||||
if (type === "wgeasy") {
|
||||
if (threshold !== undefined) widget.threshold = parseInt(threshold, 10);
|
||||
}
|
||||
if (type === "frigate") {
|
||||
if (enableRecentEvents !== undefined) widget.enableRecentEvents = enableRecentEvents;
|
||||
}
|
||||
if (type === "technitium") {
|
||||
if (range !== undefined) widget.range = range;
|
||||
}
|
||||
if (type === "lubelogger") {
|
||||
if (vehicleID !== undefined) widget.vehicleID = parseInt(vehicleID, 10);
|
||||
}
|
||||
if (type === "vikunja") {
|
||||
if (enableTaskList !== undefined) widget.enableTaskList = !!enableTaskList;
|
||||
}
|
||||
if (type === "prometheusmetric") {
|
||||
if (metrics) widget.metrics = metrics;
|
||||
if (refreshInterval) widget.refreshInterval = refreshInterval;
|
||||
}
|
||||
if (type === "spoolman") {
|
||||
if (spoolIds !== undefined) widget.spoolIds = spoolIds;
|
||||
}
|
||||
return widget;
|
||||
});
|
||||
return cleanedService;
|
||||
}),
|
||||
}));
|
||||
@ -697,15 +697,11 @@ export async function getServiceItem(group, service) {
|
||||
return false;
|
||||
}
|
||||
|
||||
export default async function getServiceWidget(group, service, name = null) {
|
||||
export default async function getServiceWidget(group, service, index) {
|
||||
const serviceItem = await getServiceItem(group, service);
|
||||
if (serviceItem && (name == null || name === "undefined")) {
|
||||
const { widget } = serviceItem;
|
||||
return widget;
|
||||
}
|
||||
if (serviceItem && name != null && name !== "undefined") {
|
||||
const { widgets } = serviceItem;
|
||||
return widgets.filter((widget) => Object.keys(widget)[0] == name)[0][name];
|
||||
if (serviceItem) {
|
||||
const { widget, widgets } = serviceItem;
|
||||
return index > -1 && widgets ? widgets[index] : widget;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -12,7 +12,7 @@ export function getURLSearchParams(widget, endpoint) {
|
||||
const params = new URLSearchParams({
|
||||
group: widget.service_group,
|
||||
service: widget.service_name,
|
||||
...(widget.widget_name != "" && { name: widget.widget_name }),
|
||||
index: widget.index,
|
||||
});
|
||||
if (endpoint) {
|
||||
params.append("endpoint", endpoint);
|
||||
|
||||
@ -9,10 +9,10 @@ import widgets from "widgets/widgets";
|
||||
const logger = createLogger("credentialedProxyHandler");
|
||||
|
||||
export default async function credentialedProxyHandler(req, res, map) {
|
||||
const { group, service, endpoint, name } = req.query;
|
||||
const { group, service, endpoint, index } = req.query;
|
||||
|
||||
if (group && service) {
|
||||
const widget = await getServiceWidget(group, service, name ? name : null);
|
||||
const widget = await getServiceWidget(group, service, index);
|
||||
|
||||
if (!widgets?.[widget.type]?.api) {
|
||||
return res.status(403).json({ error: "Service does not support API calls" });
|
||||
|
||||
@ -8,10 +8,10 @@ import widgets from "widgets/widgets";
|
||||
const logger = createLogger("genericProxyHandler");
|
||||
|
||||
export default async function genericProxyHandler(req, res, map) {
|
||||
const { group, service, endpoint, name } = req.query;
|
||||
const { group, service, endpoint, index } = req.query;
|
||||
|
||||
if (group && service) {
|
||||
const widget = await getServiceWidget(group, service, name ? name : null);
|
||||
const widget = await getServiceWidget(group, service, index);
|
||||
|
||||
if (!widgets?.[widget.type]?.api) {
|
||||
return res.status(403).json({ error: "Service does not support API calls" });
|
||||
|
||||
@ -65,10 +65,10 @@ export async function sendJsonRpcRequest(url, method, params, widget) {
|
||||
}
|
||||
|
||||
export default async function jsonrpcProxyHandler(req, res) {
|
||||
const { group, service, endpoint: method, name } = req.query;
|
||||
const { group, service, endpoint: method, index } = req.query;
|
||||
|
||||
if (group && service) {
|
||||
const widget = await getServiceWidget(group, service, name ? name : null);
|
||||
const widget = await getServiceWidget(group, service, index);
|
||||
const api = widgets?.[widget.type]?.api;
|
||||
|
||||
const [, mapping] = Object.entries(widgets?.[widget.type]?.mappings).find(([, value]) => value.endpoint === method);
|
||||
|
||||
@ -131,13 +131,13 @@ function toError(url, synologyError) {
|
||||
}
|
||||
|
||||
export default async function synologyProxyHandler(req, res) {
|
||||
const { group, service, endpoint, name } = req.query;
|
||||
const { group, service, endpoint, index } = req.query;
|
||||
|
||||
if (!group || !service) {
|
||||
return res.status(400).json({ error: "Invalid proxy service type" });
|
||||
}
|
||||
|
||||
const serviceWidget = await getServiceWidget(group, service, name ? name : null);
|
||||
const serviceWidget = await getServiceWidget(group, service, index);
|
||||
const widget = widgets?.[serviceWidget.type];
|
||||
const mapping = widget?.mappings?.[endpoint];
|
||||
if (!widget.api || !mapping) {
|
||||
|
||||
@ -23,14 +23,14 @@ async function retrieveFromAPI(url, key) {
|
||||
}
|
||||
|
||||
export default async function audiobookshelfProxyHandler(req, res) {
|
||||
const { group, service, endpoint, name } = req.query;
|
||||
const { group, service, endpoint, index } = req.query;
|
||||
|
||||
if (!group || !service) {
|
||||
logger.debug("Invalid or missing service '%s' or group '%s'", service, group);
|
||||
return res.status(400).json({ error: "Invalid proxy service type" });
|
||||
}
|
||||
|
||||
const widget = await getServiceWidget(group, service, name ? name : null);
|
||||
const widget = await getServiceWidget(group, service, index);
|
||||
|
||||
if (!widget) {
|
||||
logger.debug("Invalid or missing widget for service '%s' in group '%s'", service, group);
|
||||
|
||||
@ -34,10 +34,10 @@ async function login(loginUrl, username, password, service) {
|
||||
}
|
||||
|
||||
export default async function beszelProxyHandler(req, res) {
|
||||
const { group, service, endpoint, name } = req.query;
|
||||
const { group, service, endpoint, index } = req.query;
|
||||
|
||||
if (group && service) {
|
||||
const widget = await getServiceWidget(group, service, name ? name : null);
|
||||
const widget = await getServiceWidget(group, service, index);
|
||||
|
||||
if (!widgets?.[widget.type]?.api) {
|
||||
return res.status(403).json({ error: "Service does not support API calls" });
|
||||
|
||||
@ -5,10 +5,10 @@ import createLogger from "utils/logger";
|
||||
const logger = createLogger("calendarProxyHandler");
|
||||
|
||||
export default async function calendarProxyHandler(req, res) {
|
||||
const { group, service, endpoint, name } = req.query;
|
||||
const { group, service, endpoint, index } = req.query;
|
||||
|
||||
if (group && service) {
|
||||
const widget = await getServiceWidget(group, service, name ? name : null);
|
||||
const widget = await getServiceWidget(group, service, index);
|
||||
const integration = widget.integrations?.find((i) => i.name === endpoint);
|
||||
|
||||
if (integration) {
|
||||
|
||||
@ -35,14 +35,14 @@ async function login(widget, service) {
|
||||
}
|
||||
|
||||
export default async function crowdsecProxyHandler(req, res) {
|
||||
const { group, service, endpoint, name } = req.query;
|
||||
const { group, service, endpoint, index } = req.query;
|
||||
|
||||
if (!group || !service) {
|
||||
logger.error("Invalid or missing service '%s' or group '%s'", service, group);
|
||||
return res.status(400).json({ error: "Invalid proxy service type" });
|
||||
}
|
||||
|
||||
const widget = await getServiceWidget(group, service, name ? name : null);
|
||||
const widget = await getServiceWidget(group, service, index);
|
||||
if (!widget || !widgets[widget.type].api) {
|
||||
logger.error("Invalid or missing widget for service '%s' in group '%s'", service, group);
|
||||
return res.status(400).json({ error: "Invalid widget configuration" });
|
||||
|
||||
@ -40,14 +40,14 @@ function login(url, password) {
|
||||
}
|
||||
|
||||
export default async function delugeProxyHandler(req, res) {
|
||||
const { group, service, name } = req.query;
|
||||
const { group, service, index } = req.query;
|
||||
|
||||
if (!group || !service) {
|
||||
logger.debug("Invalid or missing service '%s' or group '%s'", service, group);
|
||||
return res.status(400).json({ error: "Invalid proxy service type" });
|
||||
}
|
||||
|
||||
const widget = await getServiceWidget(group, service, name ? name : null);
|
||||
const widget = await getServiceWidget(group, service, index);
|
||||
|
||||
if (!widget) {
|
||||
logger.debug("Invalid or missing widget for service '%s' in group '%s'", service, group);
|
||||
|
||||
@ -28,14 +28,14 @@ async function login(widget) {
|
||||
}
|
||||
|
||||
export default async function floodProxyHandler(req, res) {
|
||||
const { group, service, endpoint, name } = req.query;
|
||||
const { group, service, endpoint, index } = req.query;
|
||||
|
||||
if (!group || !service) {
|
||||
logger.debug("Invalid or missing service '%s' or group '%s'", service, group);
|
||||
return res.status(400).json({ error: "Invalid proxy service type" });
|
||||
}
|
||||
|
||||
const widget = await getServiceWidget(group, service, name ? name : null);
|
||||
const widget = await getServiceWidget(group, service, index);
|
||||
|
||||
if (!widget) {
|
||||
logger.debug("Invalid or missing widget for service '%s' in group '%s'", service, group);
|
||||
|
||||
@ -74,14 +74,14 @@ async function apiCall(widget, endpoint, service) {
|
||||
}
|
||||
|
||||
export default async function freshrssProxyHandler(req, res) {
|
||||
const { group, service, name } = req.query;
|
||||
const { group, service, index } = req.query;
|
||||
|
||||
if (!group || !service) {
|
||||
logger.debug("Invalid or missing service '%s' or group '%s'", service, group);
|
||||
return res.status(400).json({ error: "Invalid proxy service type" });
|
||||
}
|
||||
|
||||
const widget = await getServiceWidget(group, service, name ? name : null);
|
||||
const widget = await getServiceWidget(group, service, index);
|
||||
if (!widget) {
|
||||
logger.debug("Invalid or missing widget for service '%s' in group '%s'", service, group);
|
||||
return res.status(400).json({ error: "Invalid proxy service type" });
|
||||
|
||||
@ -46,8 +46,8 @@ async function requestEndpoint(apiBaseUrl, service, action) {
|
||||
}
|
||||
|
||||
export default async function fritzboxProxyHandler(req, res) {
|
||||
const { group, service, name } = req.query;
|
||||
const serviceWidget = await getServiceWidget(group, service, name ? name : null);
|
||||
const { group, service, index } = req.query;
|
||||
const serviceWidget = await getServiceWidget(group, service, index);
|
||||
|
||||
if (!serviceWidget) {
|
||||
res.status(500).json({ error: { message: "Service widget not found" } });
|
||||
|
||||
@ -7,8 +7,8 @@ const proxyName = "gamedigProxyHandler";
|
||||
const logger = createLogger(proxyName);
|
||||
|
||||
export default async function gamedigProxyHandler(req, res) {
|
||||
const { group, service, name } = req.query;
|
||||
const serviceWidget = await getServiceWidget(group, service, name ? name : null);
|
||||
const { group, service, index } = req.query;
|
||||
const serviceWidget = await getServiceWidget(group, service, index);
|
||||
const url = new URL(serviceWidget.url);
|
||||
|
||||
try {
|
||||
|
||||
@ -62,14 +62,14 @@ async function getQuery(query, { url, key }) {
|
||||
}
|
||||
|
||||
export default async function homeassistantProxyHandler(req, res) {
|
||||
const { group, service, name } = req.query;
|
||||
const { group, service, index } = req.query;
|
||||
|
||||
if (!group || !service) {
|
||||
logger.debug("Invalid or missing service '%s' or group '%s'", service, group);
|
||||
return res.status(400).json({ error: "Invalid proxy service type" });
|
||||
}
|
||||
|
||||
const widget = await getServiceWidget(group, service, name ? name : null);
|
||||
const widget = await getServiceWidget(group, service, index);
|
||||
if (!widget) {
|
||||
logger.debug("Invalid or missing widget for service '%s' in group '%s'", service, group);
|
||||
return res.status(400).json({ error: "Invalid proxy service type" });
|
||||
|
||||
@ -68,14 +68,14 @@ async function apiCall(widget, endpoint, service) {
|
||||
}
|
||||
|
||||
export default async function homeboxProxyHandler(req, res) {
|
||||
const { group, service, name } = req.query;
|
||||
const { group, service, index } = req.query;
|
||||
|
||||
if (!group || !service) {
|
||||
logger.debug("Invalid or missing service '%s' or group '%s'", service, group);
|
||||
return res.status(400).json({ error: "Invalid proxy service type" });
|
||||
}
|
||||
|
||||
const widget = await getServiceWidget(group, service, name ? name : null);
|
||||
const widget = await getServiceWidget(group, service, index);
|
||||
if (!widget) {
|
||||
logger.debug("Invalid or missing widget for service '%s' in group '%s'", service, group);
|
||||
return res.status(400).json({ error: "Invalid proxy service type" });
|
||||
|
||||
@ -71,14 +71,14 @@ async function apiCall(widget, endpoint, service) {
|
||||
}
|
||||
|
||||
export default async function homebridgeProxyHandler(req, res) {
|
||||
const { group, service, name } = req.query;
|
||||
const { group, service, index } = req.query;
|
||||
|
||||
if (!group || !service) {
|
||||
logger.debug("Invalid or missing service '%s' or group '%s'", service, group);
|
||||
return res.status(400).json({ error: "Invalid proxy service type" });
|
||||
}
|
||||
|
||||
const widget = await getServiceWidget(group, service, name ? name : null);
|
||||
const widget = await getServiceWidget(group, service, index);
|
||||
|
||||
if (!widget) {
|
||||
logger.debug("Invalid or missing widget for service '%s' in group '%s'", service, group);
|
||||
|
||||
@ -25,14 +25,14 @@ async function fetchJackettCookie(widget, loginURL) {
|
||||
}
|
||||
|
||||
export default async function jackettProxyHandler(req, res) {
|
||||
const { group, service, endpoint, name } = req.query;
|
||||
const { group, service, endpoint, index } = req.query;
|
||||
|
||||
if (!group || !service) {
|
||||
logger.error("Invalid or missing service '%s' or group '%s'", service, group);
|
||||
return res.status(400).json({ error: "Invalid proxy service type" });
|
||||
}
|
||||
|
||||
const widget = await getServiceWidget(group, service, name ? name : null);
|
||||
const widget = await getServiceWidget(group, service, index);
|
||||
if (!widget || !widgets[widget.type].api) {
|
||||
logger.error("Invalid or missing widget for service '%s' in group '%s'", service, group);
|
||||
return res.status(400).json({ error: "Invalid widget configuration" });
|
||||
|
||||
@ -12,12 +12,12 @@ const proxyName = "jdownloaderProxyHandler";
|
||||
const logger = createLogger(proxyName);
|
||||
|
||||
async function getWidget(req) {
|
||||
const { group, service, name } = req.query;
|
||||
const { group, service, index } = req.query;
|
||||
if (!group || !service) {
|
||||
logger.debug("Invalid or missing service '%s' or group '%s'", service, group);
|
||||
return null;
|
||||
}
|
||||
const widget = await getServiceWidget(group, service, name ? name : null);
|
||||
const widget = await getServiceWidget(group, service, index);
|
||||
if (!widget) {
|
||||
logger.debug("Invalid or missing widget for service '%s' in group '%s'", service, group);
|
||||
return null;
|
||||
|
||||
@ -70,14 +70,14 @@ async function apiCall(widget, endpoint, service) {
|
||||
}
|
||||
|
||||
export default async function KavitaProxyHandler(req, res) {
|
||||
const { group, service, name } = req.query;
|
||||
const { group, service, index } = req.query;
|
||||
|
||||
if (!group || !service) {
|
||||
logger.debug("Invalid or missing service '%s' or group '%s'", service, group);
|
||||
return res.status(400).json({ error: "Invalid proxy service type" });
|
||||
}
|
||||
|
||||
const widget = await getServiceWidget(group, service, name ? name : null);
|
||||
const widget = await getServiceWidget(group, service, index);
|
||||
if (!widget) {
|
||||
logger.debug("Invalid or missing widget for service '%s' in group '%s'", service, group);
|
||||
return res.status(400).json({ error: "Invalid proxy service type" });
|
||||
|
||||
@ -7,8 +7,8 @@ const proxyName = "minecraftProxyHandler";
|
||||
const logger = createLogger(proxyName);
|
||||
|
||||
export default async function minecraftProxyHandler(req, res) {
|
||||
const { group, service, name } = req.query;
|
||||
const serviceWidget = await getServiceWidget(group, service, name ? name : null);
|
||||
const { group, service, index } = req.query;
|
||||
const serviceWidget = await getServiceWidget(group, service, index);
|
||||
const url = new URL(serviceWidget.url);
|
||||
try {
|
||||
const pingResponse = await pingWithPromise(url.hostname, url.port || 25565);
|
||||
|
||||
@ -36,10 +36,10 @@ async function login(loginUrl, username, password, service) {
|
||||
}
|
||||
|
||||
export default async function npmProxyHandler(req, res) {
|
||||
const { group, service, endpoint, name } = req.query;
|
||||
const { group, service, endpoint, index } = req.query;
|
||||
|
||||
if (group && service) {
|
||||
const widget = await getServiceWidget(group, service, name ? name : null);
|
||||
const widget = await getServiceWidget(group, service, index);
|
||||
|
||||
if (!widgets?.[widget.type]?.api) {
|
||||
return res.status(403).json({ error: "Service does not support API calls" });
|
||||
|
||||
@ -33,10 +33,10 @@ async function login(loginUrl, username, password, controllerVersionMajor) {
|
||||
}
|
||||
|
||||
export default async function omadaProxyHandler(req, res) {
|
||||
const { group, service, name } = req.query;
|
||||
const { group, service, index } = req.query;
|
||||
|
||||
if (group && service) {
|
||||
const widget = await getServiceWidget(group, service, name ? name : null);
|
||||
const widget = await getServiceWidget(group, service, index);
|
||||
|
||||
if (widget) {
|
||||
const { url } = widget;
|
||||
|
||||
@ -12,14 +12,14 @@ const BG_POLL_PERIOD = 500;
|
||||
const logger = createLogger(PROXY_NAME);
|
||||
|
||||
async function getWidget(req) {
|
||||
const { group, service, name } = req.query;
|
||||
const { group, service, index } = req.query;
|
||||
|
||||
if (!group || !service) {
|
||||
logger.debug("Invalid or missing service '%s' or group '%s'", service, group);
|
||||
return null;
|
||||
}
|
||||
|
||||
const widget = await getServiceWidget(group, service, name ? name : null);
|
||||
const widget = await getServiceWidget(group, service, index);
|
||||
|
||||
if (!widget) {
|
||||
logger.debug("Invalid or missing widget for service '%s' in group '%s'", service, group);
|
||||
|
||||
@ -17,14 +17,14 @@ const PARAMS = {
|
||||
};
|
||||
|
||||
async function getWidget(req) {
|
||||
const { group, service, name } = req.query;
|
||||
const { group, service, index } = req.query;
|
||||
|
||||
if (!group || !service) {
|
||||
logger.debug("Invalid or missing service '%s' or group '%s'", service, group);
|
||||
return null;
|
||||
}
|
||||
|
||||
const widget = await getServiceWidget(group, service, name ? name : null);
|
||||
const widget = await getServiceWidget(group, service, index);
|
||||
|
||||
if (!widget) {
|
||||
logger.debug("Invalid or missing widget for service '%s' in group '%s'", service, group);
|
||||
|
||||
@ -6,14 +6,14 @@ import createLogger from "utils/logger";
|
||||
const logger = createLogger("photoprismProxyHandler");
|
||||
|
||||
export default async function photoprismProxyHandler(req, res) {
|
||||
const { group, service, name } = req.query;
|
||||
const { group, service, index } = req.query;
|
||||
|
||||
if (!group || !service) {
|
||||
logger.debug("Invalid or missing service '%s' or group '%s'", service, group);
|
||||
return res.status(400).json({ error: "Invalid proxy service type" });
|
||||
}
|
||||
|
||||
const widget = await getServiceWidget(group, service, name ? name : null);
|
||||
const widget = await getServiceWidget(group, service, index);
|
||||
|
||||
if (!widget) {
|
||||
logger.debug("Invalid or missing widget for service '%s' in group '%s'", service, group);
|
||||
|
||||
@ -33,7 +33,7 @@ async function login(widget, service) {
|
||||
}
|
||||
|
||||
export default async function piholeProxyHandler(req, res) {
|
||||
const { group, service, name } = req.query;
|
||||
const { group, service, index } = req.query;
|
||||
let endpoint = "stats/summary";
|
||||
|
||||
if (!group || !service) {
|
||||
@ -41,7 +41,7 @@ export default async function piholeProxyHandler(req, res) {
|
||||
return res.status(400).json({ error: "Invalid proxy service type" });
|
||||
}
|
||||
|
||||
const widget = await getServiceWidget(group, service, name ? name : null);
|
||||
const widget = await getServiceWidget(group, service, index);
|
||||
if (!widget) {
|
||||
logger.error("Invalid or missing widget for service '%s' in group '%s'", service, group);
|
||||
return res.status(400).json({ error: "Invalid widget configuration" });
|
||||
|
||||
@ -16,14 +16,14 @@ const tvCacheKey = `${proxyName}__tv`;
|
||||
const logger = createLogger(proxyName);
|
||||
|
||||
async function getWidget(req) {
|
||||
const { group, service, name } = req.query;
|
||||
const { group, service, index } = req.query;
|
||||
|
||||
if (!group || !service) {
|
||||
logger.debug("Invalid or missing service '%s' or group '%s'", service, group);
|
||||
return null;
|
||||
}
|
||||
|
||||
const widget = await getServiceWidget(group, service, name ? name : null);
|
||||
const widget = await getServiceWidget(group, service, index);
|
||||
|
||||
if (!widget) {
|
||||
logger.debug("Invalid or missing widget for service '%s' in group '%s'", service, group);
|
||||
|
||||
@ -67,11 +67,11 @@ async function login(loginUrl, service, username, password = "") {
|
||||
}
|
||||
|
||||
export default async function pyloadProxyHandler(req, res) {
|
||||
const { group, service, endpoint, name } = req.query;
|
||||
const { group, service, endpoint, index } = req.query;
|
||||
|
||||
try {
|
||||
if (group && service) {
|
||||
const widget = await getServiceWidget(group, service, name ? name : null);
|
||||
const widget = await getServiceWidget(group, service, index);
|
||||
|
||||
if (widget) {
|
||||
const url = new URL(formatApiCall(widgets[widget.type].api, { endpoint, ...widget }));
|
||||
|
||||
@ -21,14 +21,14 @@ async function login(widget) {
|
||||
}
|
||||
|
||||
export default async function qbittorrentProxyHandler(req, res) {
|
||||
const { group, service, endpoint, name } = req.query;
|
||||
const { group, service, endpoint, index } = req.query;
|
||||
|
||||
if (!group || !service) {
|
||||
logger.debug("Invalid or missing service '%s' or group '%s'", service, group);
|
||||
return res.status(400).json({ error: "Invalid proxy service type" });
|
||||
}
|
||||
|
||||
const widget = await getServiceWidget(group, service, name ? name : null);
|
||||
const widget = await getServiceWidget(group, service, index);
|
||||
|
||||
if (!widget) {
|
||||
logger.debug("Invalid or missing widget for service '%s' in group '%s'", service, group);
|
||||
|
||||
@ -77,14 +77,14 @@ async function apiCall(widget, endpoint, service) {
|
||||
}
|
||||
|
||||
export default async function qnapProxyHandler(req, res) {
|
||||
const { group, service, name } = req.query;
|
||||
const { group, service, index } = req.query;
|
||||
|
||||
if (!group || !service) {
|
||||
logger.debug("Invalid or missing service '%s' or group '%s'", service, group);
|
||||
return res.status(400).json({ error: "Invalid proxy service type" });
|
||||
}
|
||||
|
||||
const widget = await getServiceWidget(group, service, name ? name : null);
|
||||
const widget = await getServiceWidget(group, service, index);
|
||||
if (!widget) {
|
||||
logger.debug("Invalid or missing widget for service '%s' in group '%s'", service, group);
|
||||
return res.status(400).json({ error: "Invalid proxy service type" });
|
||||
|
||||
@ -45,10 +45,10 @@ const getTorrentInfo = (data) => ({
|
||||
});
|
||||
|
||||
export default async function rutorrentProxyHandler(req, res) {
|
||||
const { group, service, name } = req.query;
|
||||
const { group, service, index } = req.query;
|
||||
|
||||
if (group && service) {
|
||||
const widget = await getServiceWidget(group, service, name ? name : null);
|
||||
const widget = await getServiceWidget(group, service, index);
|
||||
|
||||
if (widget) {
|
||||
const api = widgets?.[widget.type]?.api;
|
||||
|
||||
@ -114,14 +114,14 @@ function extractCounts(responseJSON, fields) {
|
||||
}
|
||||
|
||||
export default async function suwayomiProxyHandler(req, res) {
|
||||
const { group, service, endpoint, name } = req.query;
|
||||
const { group, service, endpoint, index } = req.query;
|
||||
|
||||
if (!group || !service) {
|
||||
logger.debug("Invalid or missing service '%s' or group '%s'", service, group);
|
||||
return res.status(400).json({ error: "Invalid proxy service type" });
|
||||
}
|
||||
|
||||
const widget = await getServiceWidget(group, service, name ? name : null);
|
||||
const widget = await getServiceWidget(group, service, index);
|
||||
|
||||
if (!widget) {
|
||||
logger.debug("Invalid or missing widget for service '%s' in group '%s'", service, group);
|
||||
|
||||
@ -8,14 +8,14 @@ const proxyName = "tdarrProxyHandler";
|
||||
const logger = createLogger(proxyName);
|
||||
|
||||
export default async function tdarrProxyHandler(req, res) {
|
||||
const { group, service, name } = req.query;
|
||||
const { group, service, index } = req.query;
|
||||
|
||||
if (!group || !service) {
|
||||
logger.debug("Invalid or missing service '%s' or group '%s'", service, group);
|
||||
return res.status(400).json({ error: "Invalid proxy service type" });
|
||||
}
|
||||
|
||||
const widget = await getServiceWidget(group, service, name ? name : null);
|
||||
const widget = await getServiceWidget(group, service, index);
|
||||
|
||||
if (!widget) {
|
||||
logger.debug("Invalid or missing widget for service '%s' in group '%s'", service, group);
|
||||
|
||||
@ -11,14 +11,14 @@ const headerCacheKey = `${proxyName}__headers`;
|
||||
const logger = createLogger(proxyName);
|
||||
|
||||
export default async function transmissionProxyHandler(req, res) {
|
||||
const { group, service, name } = req.query;
|
||||
const { group, service, index } = req.query;
|
||||
|
||||
if (!group || !service) {
|
||||
logger.debug("Invalid or missing service '%s' or group '%s'", service, group);
|
||||
return res.status(400).json({ error: "Invalid proxy service type" });
|
||||
}
|
||||
|
||||
const widget = await getServiceWidget(group, service, name ? name : null);
|
||||
const widget = await getServiceWidget(group, service, index);
|
||||
|
||||
if (!widget) {
|
||||
logger.debug("Invalid or missing widget for service '%s' in group '%s'", service, group);
|
||||
|
||||
@ -14,13 +14,13 @@ const prefixCacheKey = `${proxyName}__prefix`;
|
||||
const logger = createLogger(proxyName);
|
||||
|
||||
async function getWidget(req) {
|
||||
const { group, service, name } = req.query;
|
||||
const { group, service, index } = req.query;
|
||||
|
||||
let widget = null;
|
||||
if (group === "unifi_console" && service === "unifi_console") {
|
||||
// info widget
|
||||
const index = req.query?.query ? JSON.parse(req.query.query).index : undefined;
|
||||
widget = await getPrivateWidgetOptions("unifi_console", index);
|
||||
const infowidgetIndex = req.query?.query ? JSON.parse(req.query.query).index : undefined;
|
||||
widget = await getPrivateWidgetOptions("unifi_console", infowidgetIndex);
|
||||
if (!widget) {
|
||||
logger.debug("Error retrieving settings for this Unifi widget");
|
||||
return null;
|
||||
@ -32,7 +32,7 @@ async function getWidget(req) {
|
||||
return null;
|
||||
}
|
||||
|
||||
widget = await getServiceWidget(group, service, name ? name : null);
|
||||
widget = await getServiceWidget(group, service, index);
|
||||
|
||||
if (!widget) {
|
||||
logger.debug("Invalid or missing widget for service '%s' in group '%s'", service, group);
|
||||
|
||||
@ -3,8 +3,8 @@ import { UrbackupServer } from "urbackup-server-api";
|
||||
import getServiceWidget from "utils/config/service-helpers";
|
||||
|
||||
export default async function urbackupProxyHandler(req, res) {
|
||||
const { group, service, name } = req.query;
|
||||
const serviceWidget = await getServiceWidget(group, service, name ? name : null);
|
||||
const { group, service, index } = req.query;
|
||||
const serviceWidget = await getServiceWidget(group, service, index);
|
||||
|
||||
const server = new UrbackupServer({
|
||||
url: serviceWidget.url,
|
||||
|
||||
@ -8,14 +8,14 @@ const proxyName = "watchtowerProxyHandler";
|
||||
const logger = createLogger(proxyName);
|
||||
|
||||
export default async function watchtowerProxyHandler(req, res) {
|
||||
const { group, service, endpoint, name } = req.query;
|
||||
const { group, service, endpoint, index } = req.query;
|
||||
|
||||
if (!group || !service) {
|
||||
logger.debug("Invalid or missing service '%s' or group '%s'", service, group);
|
||||
return res.status(400).json({ error: "Invalid proxy service type" });
|
||||
}
|
||||
|
||||
const widget = await getServiceWidget(group, service, name ? name : null);
|
||||
const widget = await getServiceWidget(group, service, index);
|
||||
|
||||
if (!widget) {
|
||||
logger.debug("Invalid or missing widget for service '%s' in group '%s'", service, group);
|
||||
|
||||
@ -7,13 +7,13 @@ import getServiceWidget from "utils/config/service-helpers";
|
||||
const logger = createLogger("xteveProxyHandler");
|
||||
|
||||
export default async function xteveProxyHandler(req, res) {
|
||||
const { group, service, name } = req.query;
|
||||
const { group, service, index } = req.query;
|
||||
|
||||
if (!group || !service) {
|
||||
return res.status(400).json({ error: "Invalid proxy service type" });
|
||||
}
|
||||
|
||||
const widget = await getServiceWidget(group, service, name ? name : null);
|
||||
const widget = await getServiceWidget(group, service, index);
|
||||
const api = widgets?.[widget.type]?.api;
|
||||
if (!api) {
|
||||
return res.status(403).json({ error: "Service does not support API calls" });
|
||||
|
||||
Loading…
Reference in New Issue
Block a user