pre-commit, organize widget params
This commit is contained in:
parent
4194b57698
commit
8c1c7f5d97
@ -336,49 +336,87 @@ export function cleanServiceGroups(groups) {
|
||||
|
||||
if (cleanedService.widget) {
|
||||
// whitelisted set of keys to pass to the frontend
|
||||
// alphabetical, grouped by widget(s)
|
||||
const {
|
||||
type, // all widgets
|
||||
// all widgets
|
||||
fields,
|
||||
hideErrors,
|
||||
server, // docker widget
|
||||
container,
|
||||
currency, // coinmarketcap widget
|
||||
symbols,
|
||||
slugs,
|
||||
defaultinterval,
|
||||
site, // unifi widget
|
||||
namespace, // kubernetes widget
|
||||
app,
|
||||
podSelector,
|
||||
wan, // opnsense widget, pfsense widget
|
||||
enableBlocks, // emby/jellyfin
|
||||
enableNowPlaying,
|
||||
volume, // diskstation widget,
|
||||
enableQueue, // sonarr/radarr
|
||||
node, // Proxmox
|
||||
snapshotHost, // kopia
|
||||
snapshotPath,
|
||||
userEmail, // azuredevops
|
||||
type,
|
||||
|
||||
// azuredevops
|
||||
repositoryId,
|
||||
metric, // glances
|
||||
chart, // glances
|
||||
pointsLimit, // glances
|
||||
stream, // mjpeg
|
||||
fit,
|
||||
method, // openmediavault widget
|
||||
mappings, // customapi widget
|
||||
refreshInterval,
|
||||
integrations, // calendar widget
|
||||
userEmail,
|
||||
|
||||
// calendar
|
||||
firstDayInWeek,
|
||||
view,
|
||||
integrations,
|
||||
maxEvents,
|
||||
src, // iframe widget
|
||||
classes,
|
||||
referrerPolicy,
|
||||
allowPolicy,
|
||||
view,
|
||||
|
||||
// coinmarketcap
|
||||
currency,
|
||||
defaultinterval,
|
||||
slugs,
|
||||
symbols,
|
||||
|
||||
// customapi
|
||||
mappings,
|
||||
|
||||
// diskstation
|
||||
volume,
|
||||
|
||||
// docker
|
||||
container,
|
||||
server,
|
||||
|
||||
// emby, jellyfin
|
||||
enableBlocks,
|
||||
enableNowPlaying,
|
||||
|
||||
// glances
|
||||
chart,
|
||||
metric,
|
||||
pointsLimit,
|
||||
|
||||
// glances, customapi
|
||||
refreshInterval,
|
||||
|
||||
// iframe
|
||||
allowFullscreen,
|
||||
loadingStrategy,
|
||||
allowPolicy,
|
||||
allowScrolling,
|
||||
classes,
|
||||
loadingStrategy,
|
||||
referrerPolicy,
|
||||
src,
|
||||
|
||||
// kopia
|
||||
snapshotHost,
|
||||
snapshotPath,
|
||||
|
||||
// kubernetes
|
||||
app,
|
||||
namespace,
|
||||
podSelector,
|
||||
|
||||
// mjpeg
|
||||
fit,
|
||||
stream,
|
||||
|
||||
// openmediavault
|
||||
method,
|
||||
|
||||
// opnsense, pfsense
|
||||
wan,
|
||||
|
||||
// proxmox
|
||||
node,
|
||||
|
||||
// sonarr, radarr
|
||||
enableQueue,
|
||||
|
||||
// unifi
|
||||
site,
|
||||
} = cleanedService.widget;
|
||||
|
||||
let fieldsList = fields;
|
||||
@ -460,10 +498,10 @@ export function cleanServiceGroups(groups) {
|
||||
} else {
|
||||
cleanedService.widget.chart = true;
|
||||
}
|
||||
if(refreshInterval && Number.isInteger(refreshInterval) && refreshInterval > 0){
|
||||
if (refreshInterval && Number.isInteger(refreshInterval) && refreshInterval > 0) {
|
||||
cleanedService.widget.refreshInterval = refreshInterval;
|
||||
}
|
||||
if(pointsLimit && Number.isInteger(pointsLimit) && pointsLimit > 0){
|
||||
if (pointsLimit && Number.isInteger(pointsLimit) && pointsLimit > 0) {
|
||||
cleanedService.widget.pointsLimit = pointsLimit;
|
||||
}
|
||||
}
|
||||
|
||||
@ -21,7 +21,7 @@ export default function Component({ service }) {
|
||||
const [dataPoints, setDataPoints] = useState(new Array(pointsLimit).fill({ value: 0 }, 0, pointsLimit));
|
||||
|
||||
const { data, error } = useWidgetAPI(service.widget, "cpu", {
|
||||
refreshInterval
|
||||
refreshInterval,
|
||||
});
|
||||
|
||||
const { data: systemData, error: systemError } = useWidgetAPI(service.widget, "system");
|
||||
|
||||
@ -11,13 +11,13 @@ import useWidgetAPI from "utils/proxy/use-widget-api";
|
||||
const ChartDual = dynamic(() => import("../components/chart_dual"), { ssr: false });
|
||||
|
||||
const defaultPointsLimit = 15;
|
||||
const defaultInterval = (isChart) => isChart ? 1000 : 5000;
|
||||
const defaultInterval = (isChart) => (isChart ? 1000 : 5000);
|
||||
|
||||
export default function Component({ service }) {
|
||||
const { t } = useTranslation();
|
||||
const { widget } = service;
|
||||
const { chart} = widget;
|
||||
const {refreshInterval = defaultInterval(chart), pointsLimit = defaultPointsLimit } = widget;
|
||||
const { chart } = widget;
|
||||
const { refreshInterval = defaultInterval(chart), pointsLimit = defaultPointsLimit } = widget;
|
||||
|
||||
const [dataPoints, setDataPoints] = useState(new Array(pointsLimit).fill({ value: 0 }, 0, pointsLimit));
|
||||
|
||||
|
||||
@ -11,13 +11,13 @@ import useWidgetAPI from "utils/proxy/use-widget-api";
|
||||
const ChartDual = dynamic(() => import("../components/chart_dual"), { ssr: false });
|
||||
|
||||
const defaultPointsLimit = 15;
|
||||
const defaultInterval = (isChart) => isChart ? 1000 : 5000;
|
||||
const defaultInterval = (isChart) => (isChart ? 1000 : 5000);
|
||||
|
||||
export default function Component({ service }) {
|
||||
const { t } = useTranslation();
|
||||
const { widget } = service;
|
||||
const { chart, metric } = widget;
|
||||
const {refreshInterval = defaultInterval(chart), pointsLimit = defaultPointsLimit } = widget;
|
||||
const { refreshInterval = defaultInterval(chart), pointsLimit = defaultPointsLimit } = widget;
|
||||
|
||||
const [, interfaceName] = metric.split(":");
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user