mirror of
https://github.com/Termix-SSH/Termix.git
synced 2026-07-15 21:03:47 +00:00
Filter dashboard status hosts (#997)
This commit is contained in:
@@ -531,6 +531,10 @@ function HostStatusCard({
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function isStatusCheckEnabled(host: Host): boolean {
|
||||||
|
return host.statsConfig?.statusCheckEnabled !== false;
|
||||||
|
}
|
||||||
|
|
||||||
function RecentActivityCard({
|
function RecentActivityCard({
|
||||||
activity,
|
activity,
|
||||||
hosts,
|
hosts,
|
||||||
@@ -1283,6 +1287,7 @@ export function DashboardTab({
|
|||||||
Map<string, { cpu: number | null; ram: number | null; disk: number | null }>
|
Map<string, { cpu: number | null; ram: number | null; disk: number | null }>
|
||||||
>(new Map());
|
>(new Map());
|
||||||
const viewerSessionsRef = useRef<Map<number, string>>(new Map());
|
const viewerSessionsRef = useRef<Map<number, string>>(new Map());
|
||||||
|
const statusCheckHosts = hosts.filter(isStatusCheckEnabled);
|
||||||
|
|
||||||
const fetchMetrics = useCallback(async (hostList: Host[]) => {
|
const fetchMetrics = useCallback(async (hostList: Host[]) => {
|
||||||
let statuses: Record<number, { status?: string }> = {};
|
let statuses: Record<number, { status?: string }> = {};
|
||||||
@@ -1342,8 +1347,9 @@ export function DashboardTab({
|
|||||||
const load = async () => {
|
const load = async () => {
|
||||||
const raw = await getSSHHosts().catch(() => []);
|
const raw = await getSSHHosts().catch(() => []);
|
||||||
const mapped = raw.map(sshHostToHost);
|
const mapped = raw.map(sshHostToHost);
|
||||||
|
const statusHosts = mapped.filter(isStatusCheckEnabled);
|
||||||
if (mounted) setHosts(mapped);
|
if (mounted) setHosts(mapped);
|
||||||
fetchMetrics(mapped).catch(() => {});
|
fetchMetrics(statusHosts).catch(() => {});
|
||||||
};
|
};
|
||||||
load();
|
load();
|
||||||
|
|
||||||
@@ -1396,8 +1402,9 @@ export function DashboardTab({
|
|||||||
const metricsInterval = setInterval(async () => {
|
const metricsInterval = setInterval(async () => {
|
||||||
const raw = await getSSHHosts().catch(() => []);
|
const raw = await getSSHHosts().catch(() => []);
|
||||||
const mapped = raw.map(sshHostToHost);
|
const mapped = raw.map(sshHostToHost);
|
||||||
|
const statusHosts = mapped.filter(isStatusCheckEnabled);
|
||||||
if (mounted) setHosts(mapped);
|
if (mounted) setHosts(mapped);
|
||||||
fetchMetrics(mapped).catch(() => {});
|
fetchMetrics(statusHosts).catch(() => {});
|
||||||
}, 30000);
|
}, 30000);
|
||||||
|
|
||||||
return () => {
|
return () => {
|
||||||
@@ -1707,7 +1714,7 @@ export function DashboardTab({
|
|||||||
)}
|
)}
|
||||||
{slot.id === "host_status" && (
|
{slot.id === "host_status" && (
|
||||||
<HostStatusCard
|
<HostStatusCard
|
||||||
hosts={hosts}
|
hosts={statusCheckHosts}
|
||||||
hostMetrics={hostMetrics}
|
hostMetrics={hostMetrics}
|
||||||
onOpenTab={onOpenTab}
|
onOpenTab={onOpenTab}
|
||||||
isAdmin={isAdmin}
|
isAdmin={isAdmin}
|
||||||
|
|||||||
Reference in New Issue
Block a user