Merge branch 'dev' into add-more-openapi
This commit is contained in:
155 files changed
+8504
-3050
No files matched your search
@@ -151,21 +151,26 @@ export const SystemHealthMonitoring = ({
|
||||
<List.Item className="health-monitoring-information-uptime" icon={<IconClock size={30} />}>
|
||||
{formatUptime(healthInfo.uptime, t)}
|
||||
</List.Item>
|
||||
<List.Item className="health-monitoring-information-load-average" icon={<IconCpu size={30} />}>
|
||||
{t("widget.healthMonitoring.popover.loadAverage")}
|
||||
</List.Item>
|
||||
<List m="xs" withPadding center spacing="xs" icon={<IconCpu size={30} />}>
|
||||
<List.Item className="health-monitoring-information-load-average-1min">
|
||||
{t("widget.healthMonitoring.popover.minute")} {healthInfo.loadAverage["1min"]}%
|
||||
</List.Item>
|
||||
<List.Item className="health-monitoring-information-load-average-5min">
|
||||
{t("widget.healthMonitoring.popover.minutes", { count: "5" })} {healthInfo.loadAverage["5min"]}%
|
||||
</List.Item>
|
||||
<List.Item className="health-monitoring-information-load-average-15min">
|
||||
{t("widget.healthMonitoring.popover.minutes", { count: "15" })}{" "}
|
||||
{healthInfo.loadAverage["15min"]}%
|
||||
</List.Item>
|
||||
</List>
|
||||
{healthInfo.loadAverage && (
|
||||
<>
|
||||
<List.Item className="health-monitoring-information-load-average" icon={<IconCpu size={30} />}>
|
||||
{t("widget.healthMonitoring.popover.loadAverage")}
|
||||
</List.Item>
|
||||
<List m="xs" withPadding center spacing="xs" icon={<IconCpu size={30} />}>
|
||||
<List.Item className="health-monitoring-information-load-average-1min">
|
||||
{t("widget.healthMonitoring.popover.minute")} {healthInfo.loadAverage["1min"]}%
|
||||
</List.Item>
|
||||
<List.Item className="health-monitoring-information-load-average-5min">
|
||||
{t("widget.healthMonitoring.popover.minutes", { count: "5" })}{" "}
|
||||
{healthInfo.loadAverage["5min"]}%
|
||||
</List.Item>
|
||||
<List.Item className="health-monitoring-information-load-average-15min">
|
||||
{t("widget.healthMonitoring.popover.minutes", { count: "15" })}{" "}
|
||||
{healthInfo.loadAverage["15min"]}%
|
||||
</List.Item>
|
||||
</List>
|
||||
</>
|
||||
)}
|
||||
</List>
|
||||
</Stack>
|
||||
</Modal>
|
||||
|
||||
@@ -27,6 +27,7 @@ export default function IFrameWidget({ options, isEditMode }: WidgetComponentPro
|
||||
src={embedUrl}
|
||||
title="widget iframe"
|
||||
allow={allowedPermissions.join(" ")}
|
||||
scrolling={options.allowScrolling ? "yes" : "no"}
|
||||
>
|
||||
<Text>{t("widget.iframe.error.noBrowerSupport")}</Text>
|
||||
</iframe>
|
||||
@@ -71,7 +72,9 @@ const UnsupportedProtocol = () => {
|
||||
);
|
||||
};
|
||||
|
||||
const getAllowedPermissions = (permissions: Omit<WidgetComponentProps<"iframe">["options"], "embedUrl">) => {
|
||||
const getAllowedPermissions = (
|
||||
permissions: Omit<WidgetComponentProps<"iframe">["options"], "embedUrl" | "allowScrolling">,
|
||||
) => {
|
||||
return objectEntries(permissions)
|
||||
.filter(([_key, value]) => value)
|
||||
.map(([key]) => permissionMapping[key]);
|
||||
@@ -84,6 +87,4 @@ const permissionMapping = {
|
||||
allowGeolocation: "geolocation",
|
||||
allowMicrophone: "microphone",
|
||||
allowPayment: "payment",
|
||||
allowScrolling: "scrolling",
|
||||
allowTransparency: "transparency",
|
||||
} satisfies Record<keyof Omit<WidgetComponentProps<"iframe">["options"], "embedUrl">, string>;
|
||||
} satisfies Record<keyof Omit<WidgetComponentProps<"iframe">["options"], "embedUrl" | "allowScrolling">, string>;
|
||||
@@ -12,7 +12,6 @@ export const { definition, componentLoader } = createWidgetDefinition("iframe",
|
||||
allowScrolling: factory.switch({
|
||||
defaultValue: true,
|
||||
}),
|
||||
allowTransparency: factory.switch(),
|
||||
allowPayment: factory.switch(),
|
||||
allowAutoPlay: factory.switch(),
|
||||
allowMicrophone: factory.switch(),
|
||||
|
||||
@@ -72,6 +72,7 @@ import "./notebook.css";
|
||||
import { useSession } from "@homarr/auth/client";
|
||||
import { constructBoardPermissions } from "@homarr/auth/shared";
|
||||
import { useRequiredBoard } from "@homarr/boards/context";
|
||||
import { useConfirmModal } from "@homarr/modals";
|
||||
|
||||
const iconProps = {
|
||||
size: 30,
|
||||
@@ -240,9 +241,20 @@ export function Notebook({ options, setOptions, isEditMode, boardId, itemId }: W
|
||||
return false;
|
||||
}, [editor]);
|
||||
|
||||
const { openConfirmModal } = useConfirmModal();
|
||||
const handleEditCancel = useCallback(() => {
|
||||
setIsEditing(handleEditCancelCallback);
|
||||
}, [setIsEditing, handleEditCancelCallback]);
|
||||
openConfirmModal({
|
||||
title: t("widget.notebook.dismiss.title"),
|
||||
children: t("widget.notebook.dismiss.message"),
|
||||
labels: {
|
||||
confirm: t("widget.notebook.dismiss.action.discard"),
|
||||
cancel: t("widget.notebook.dismiss.action.keepEditing"),
|
||||
},
|
||||
onConfirm: () => {
|
||||
setIsEditing(handleEditCancelCallback);
|
||||
},
|
||||
});
|
||||
}, [setIsEditing, handleEditCancelCallback, openConfirmModal, t]);
|
||||
|
||||
const handleEditToggle = useCallback(() => {
|
||||
setIsEditing(handleEditToggleCallback);
|
||||
|
||||
@@ -49,7 +49,7 @@ export default function RssFeed({ options }: WidgetComponentProps<"rssFeed">) {
|
||||
<Text dir={languageDir} fz="sm" lh="sm" lineClamp={2}>
|
||||
{feedEntry.title}
|
||||
</Text>
|
||||
{feedEntry.description && (
|
||||
{!options.hideDescription && feedEntry.description && (
|
||||
<Text
|
||||
className={feedEntry.description}
|
||||
dir={languageDir}
|
||||
|
||||
@@ -29,6 +29,9 @@ export const { definition, componentLoader } = createWidgetDefinition("rssFeed",
|
||||
defaultValue: 100,
|
||||
validate: z.number().min(1).max(9999),
|
||||
}),
|
||||
hideDescription: factory.switch({
|
||||
defaultValue: false,
|
||||
}),
|
||||
}));
|
||||
},
|
||||
}).withDynamicImport(() => import("./component"));
|
||||
@@ -1,14 +0,0 @@
|
||||
.grid {
|
||||
display: grid;
|
||||
grid-template-rows: repeat(3, 1fr);
|
||||
grid-template-columns: repeat(2, 1fr);
|
||||
gap: 8px;
|
||||
padding: 8px;
|
||||
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
.colSpanWide {
|
||||
grid-column-start: 1;
|
||||
grid-column-end: 3;
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
"use client";
|
||||
|
||||
import { useState } from "react";
|
||||
import { Box, Group, Stack } from "@mantine/core";
|
||||
import { useElementSize } from "@mantine/hooks";
|
||||
|
||||
import { clientApi } from "@homarr/api/client";
|
||||
@@ -10,11 +11,10 @@ import { CombinedNetworkTrafficChart } from "./chart/combined-network-traffic";
|
||||
import { SystemResourceCPUChart } from "./chart/cpu-chart";
|
||||
import { SystemResourceMemoryChart } from "./chart/memory-chart";
|
||||
import { NetworkTrafficChart } from "./chart/network-traffic";
|
||||
import classes from "./component.module.css";
|
||||
|
||||
const MAX_QUEUE_SIZE = 15;
|
||||
|
||||
export default function SystemResources({ integrationIds }: WidgetComponentProps<"systemResources">) {
|
||||
export default function SystemResources({ integrationIds, options }: WidgetComponentProps<"systemResources">) {
|
||||
const { ref, width } = useElementSize();
|
||||
|
||||
const [data] = clientApi.widget.healthMonitoring.getSystemHealthStatus.useSuspenseQuery({
|
||||
@@ -49,34 +49,40 @@ export default function SystemResources({ integrationIds }: WidgetComponentProps
|
||||
},
|
||||
);
|
||||
|
||||
const showNetwork = items.length === 0 || items.every((item) => item.network !== null);
|
||||
const showNetwork =
|
||||
items.length === 0 || (items.every((item) => item.network !== null) && options.visibleCharts.includes("network"));
|
||||
const rowHeight = `calc((100% - ${(options.visibleCharts.length - 1) * 8}px) / ${options.visibleCharts.length})`;
|
||||
|
||||
return (
|
||||
<div ref={ref} className={classes.grid}>
|
||||
<div className={classes.colSpanWide}>
|
||||
<SystemResourceCPUChart cpuUsageOverTime={items.map((item) => item.cpu)} />
|
||||
</div>
|
||||
<div className={classes.colSpanWide}>
|
||||
<SystemResourceMemoryChart
|
||||
memoryUsageOverTime={items.map((item) => item.memory)}
|
||||
totalCapacityInBytes={memoryCapacityInBytes}
|
||||
/>
|
||||
</div>
|
||||
<Stack gap="xs" p="xs" ref={ref} h="100%">
|
||||
{options.visibleCharts.includes("cpu") && (
|
||||
<Box h={rowHeight}>
|
||||
<SystemResourceCPUChart cpuUsageOverTime={items.map((item) => item.cpu)} />
|
||||
</Box>
|
||||
)}
|
||||
{options.visibleCharts.includes("memory") && (
|
||||
<Box h={rowHeight}>
|
||||
<SystemResourceMemoryChart
|
||||
memoryUsageOverTime={items.map((item) => item.memory)}
|
||||
totalCapacityInBytes={memoryCapacityInBytes}
|
||||
/>
|
||||
</Box>
|
||||
)}
|
||||
{showNetwork &&
|
||||
(width > 200 ? (
|
||||
<>
|
||||
(width > 256 ? (
|
||||
<Group h={rowHeight} gap="xs" grow>
|
||||
{/* eslint-disable-next-line @typescript-eslint/no-non-null-assertion */}
|
||||
<NetworkTrafficChart usageOverTime={items.map((item) => item.network!.down)} isUp={false} />
|
||||
|
||||
{/* eslint-disable-next-line @typescript-eslint/no-non-null-assertion */}
|
||||
<NetworkTrafficChart usageOverTime={items.map((item) => item.network!.up)} isUp />
|
||||
</>
|
||||
</Group>
|
||||
) : (
|
||||
<div className={classes.colSpanWide}>
|
||||
<Box h={rowHeight}>
|
||||
{/* eslint-disable-next-line @typescript-eslint/no-non-null-assertion */}
|
||||
<CombinedNetworkTrafficChart usageOverTime={items.map((item) => item.network!)} />
|
||||
</div>
|
||||
</Box>
|
||||
))}
|
||||
</div>
|
||||
</Stack>
|
||||
);
|
||||
}
|
||||
@@ -5,8 +5,17 @@ import { optionsBuilder } from "../options";
|
||||
|
||||
export const { definition, componentLoader } = createWidgetDefinition("systemResources", {
|
||||
icon: IconGraphFilled,
|
||||
supportedIntegrations: ["dashDot", "openmediavault"],
|
||||
supportedIntegrations: ["dashDot", "openmediavault", "truenas"],
|
||||
createOptions() {
|
||||
return optionsBuilder.from(() => ({}));
|
||||
return optionsBuilder.from((factory) => ({
|
||||
visibleCharts: factory.multiSelect({
|
||||
options: (["cpu", "memory", "network"] as const).map((key) => ({
|
||||
value: key,
|
||||
label: (t) => t(`widget.systemResources.option.visibleCharts.option.${key}`),
|
||||
})),
|
||||
defaultValue: ["cpu", "memory", "network"],
|
||||
withDescription: true,
|
||||
}),
|
||||
}));
|
||||
},
|
||||
}).withDynamicImport(() => import("./component"));
|
||||
@@ -1,9 +1,8 @@
|
||||
"use client";
|
||||
|
||||
import { useEffect, useRef } from "react";
|
||||
import { Anchor, Center, Group, Stack, Title } from "@mantine/core";
|
||||
import { Anchor, Box, Center, Group, Stack, Title } from "@mantine/core";
|
||||
import { IconBrandYoutube, IconDeviceCctvOff } from "@tabler/icons-react";
|
||||
import combineClasses from "clsx";
|
||||
import videojs from "video.js";
|
||||
|
||||
import { useI18n } from "@homarr/translation/client";
|
||||
@@ -13,6 +12,8 @@ import classes from "./component.module.css";
|
||||
|
||||
import "video.js/dist/video-js.css";
|
||||
|
||||
import type Player from "video.js/dist/types/player";
|
||||
|
||||
import { createDocumentationLink } from "@homarr/definitions";
|
||||
|
||||
export default function VideoWidget({ options }: WidgetComponentProps<"video">) {
|
||||
@@ -55,32 +56,66 @@ const ForYoutubeUseIframe = () => {
|
||||
};
|
||||
|
||||
const Feed = ({ options }: Pick<WidgetComponentProps<"video">, "options">) => {
|
||||
const videoRef = useRef<HTMLVideoElement>(null);
|
||||
const videoRef = useRef<HTMLDivElement>(null);
|
||||
const playerRef = useRef<Player>(null);
|
||||
|
||||
useEffect(() => {
|
||||
if (!videoRef.current) {
|
||||
return;
|
||||
if (playerRef.current) return;
|
||||
const videoElement = document.createElement("video-js");
|
||||
videoElement.classList.add("vjs-big-play-centered");
|
||||
if (classes.video) {
|
||||
videoElement.classList.add(classes.video);
|
||||
}
|
||||
videoRef.current?.appendChild(videoElement);
|
||||
|
||||
// Initialize Video.js player if it's not already initialized
|
||||
if (!("player" in videoRef.current)) {
|
||||
videojs(
|
||||
videoRef.current,
|
||||
playerRef.current = videojs(videoElement, {
|
||||
autoplay: options.hasAutoPlay,
|
||||
muted: options.isMuted,
|
||||
controls: options.hasControls,
|
||||
sources: [
|
||||
{
|
||||
autoplay: options.hasAutoPlay,
|
||||
muted: options.isMuted,
|
||||
controls: options.hasControls,
|
||||
src: options.feedUrl,
|
||||
},
|
||||
() => undefined,
|
||||
);
|
||||
}
|
||||
}, [options.hasAutoPlay, options.hasControls, options.isMuted, videoRef]);
|
||||
],
|
||||
});
|
||||
// All other properties are updated with other useEffect
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
}, [videoRef]);
|
||||
|
||||
useEffect(() => {
|
||||
if (!playerRef.current) return;
|
||||
playerRef.current.src(options.feedUrl);
|
||||
}, [options.feedUrl]);
|
||||
|
||||
useEffect(() => {
|
||||
if (!playerRef.current) return;
|
||||
playerRef.current.autoplay(options.hasAutoPlay);
|
||||
}, [options.hasAutoPlay]);
|
||||
|
||||
useEffect(() => {
|
||||
if (!playerRef.current) return;
|
||||
playerRef.current.muted(options.isMuted);
|
||||
}, [options.isMuted]);
|
||||
|
||||
useEffect(() => {
|
||||
if (!playerRef.current) return;
|
||||
playerRef.current.controls(options.hasControls);
|
||||
}, [options.hasControls]);
|
||||
|
||||
useEffect(() => {
|
||||
const player = playerRef.current;
|
||||
|
||||
return () => {
|
||||
if (player && !player.isDisposed()) {
|
||||
player.dispose();
|
||||
playerRef.current = null;
|
||||
}
|
||||
};
|
||||
}, [playerRef]);
|
||||
|
||||
return (
|
||||
<Group justify="center" w="100%" h="100%" pos="relative">
|
||||
<video className={combineClasses("video-js", classes.video)} ref={videoRef}>
|
||||
<source src={options.feedUrl} />
|
||||
</video>
|
||||
<Box w="100%" h="100%" ref={videoRef} />
|
||||
</Group>
|
||||
);
|
||||
};
|
||||
@@ -100,7 +100,7 @@ export const WidgetIntegrationSelect = ({
|
||||
});
|
||||
|
||||
return (
|
||||
<Combobox store={combobox} onOptionSubmit={handleValueSelect} withinPortal={false}>
|
||||
<Combobox store={combobox} onOptionSubmit={handleValueSelect}>
|
||||
<Combobox.DropdownTarget>
|
||||
<PillsInput
|
||||
inputWrapperOrder={["label", "input", "description", "error"]}
|
||||
|
||||
Reference in new issue
Block a user