Separated kubernetes widgets from resources widgets

This commit is contained in:
James Wynn 2022-11-18 18:02:23 -06:00
parent 056e26dfd3
commit fdb143304f
9 changed files with 200 additions and 46 deletions

View file

@ -5,10 +5,10 @@ import { useTranslation } from "next-i18next";
import UsageBar from "./usage-bar";
export default function Cpu({ expanded, backend }) {
export default function Cpu({ expanded }) {
const { t } = useTranslation();
const { data, error } = useSWR(`/api/widgets/${backend || 'resources'}?type=cpu`, {
const { data, error } = useSWR(`/api/widgets/resources?type=cpu`, {
refreshInterval: 1500,
});

View file

@ -5,10 +5,10 @@ import { useTranslation } from "next-i18next";
import UsageBar from "./usage-bar";
export default function Disk({ options, expanded, backend }) {
export default function Disk({ options, expanded }) {
const { t } = useTranslation();
const { data, error } = useSWR(`/api/widgets/${backend || 'resources'}?type=disk&target=${options.disk}`, {
const { data, error } = useSWR(`/api/widgets/resources?type=disk&target=${options.disk}`, {
refreshInterval: 1500,
});

View file

@ -5,10 +5,10 @@ import { useTranslation } from "next-i18next";
import UsageBar from "./usage-bar";
export default function Memory({ expanded, backend }) {
export default function Memory({ expanded }) {
const { t } = useTranslation();
const { data, error } = useSWR(`/api/widgets/${backend || 'resources'}?type=memory`, {
const { data, error } = useSWR(`/api/widgets/resources?type=memory`, {
refreshInterval: 1500,
});

View file

@ -3,15 +3,15 @@ import Cpu from "./cpu";
import Memory from "./memory";
export default function Resources({ options }) {
const { expanded, backend } = options;
const { expanded } = options;
return (
<div className="flex flex-col max-w:full sm:basis-auto self-center grow-0 flex-wrap">
<div className="flex flex-row self-center flex-wrap justify-between">
{options.cpu && <Cpu expanded={expanded} backend={backend} />}
{options.memory && <Memory expanded={expanded} backend={backend} />}
{options.cpu && <Cpu expanded={expanded} />}
{options.memory && <Memory expanded={expanded} />}
{Array.isArray(options.disk)
? options.disk.map((disk) => <Disk key={disk} options={{ disk }} expanded={expanded} backend={backend} />)
: options.disk && <Disk options={options} expanded={expanded} backend={backend} />}
? options.disk.map((disk) => <Disk key={disk} options={{ disk }} expanded={expanded} />)
: options.disk && <Disk options={options} expanded={expanded} />}
</div>
{options.label && (
<div className="ml-6 pt-1 text-center text-theme-800 dark:text-theme-200 text-xs">{options.label}</div>