refactor widget api design

this passes all widget API calls through the backend, with a pluggable design and reusable API handlers
This commit is contained in:
Ben Phelps
2022-09-04 21:58:42 +03:00
parent 975f79f6cc
commit 97bf174b78
27 changed files with 370 additions and 252 deletions

View File

@@ -1,24 +1,24 @@
import useSWR from "swr";
import { calculateCPUPercent, formatBytes } from "utils/stats-helpers";
import Widget from "../widget";
import Block from "../block";
import { calculateCPUPercent, formatBytes } from "utils/stats-helpers";
export default function Docker({ service }) {
const config = service.widget;
const { data: statusData, error: statusError } = useSWR(
`/api/docker/status/${config.container}/${config.server || ""}`,
{
refreshInterval: 1500,
refreshInterval: 5000,
}
);
const { data: statsData, error: statsError } = useSWR(
`/api/docker/stats/${config.container}/${config.server || ""}`,
{
refreshInterval: 1500,
refreshInterval: 5000,
}
);