mirror of
https://github.com/khairul169/garage-webui.git
synced 2025-10-14 23:09:32 +07:00

- Add GitHub Actions workflow for automated releases - Add comprehensive style guide documentation - Improve bucket management with detailed hooks and components - Add Docker development environment setup - Enhance cluster management with improved TypeScript types - Update API documentation and alignment tasks - Add share dialog functionality for bucket objects - Improve UI components and layouts
90 lines
2.3 KiB
TypeScript
90 lines
2.3 KiB
TypeScript
import Page from "@/context/page-context";
|
|
import { useNodesHealth } from "./hooks";
|
|
import StatsCard from "./components/stats-card";
|
|
import {
|
|
Database,
|
|
DatabaseZap,
|
|
FileBox,
|
|
FileCheck,
|
|
FileClock,
|
|
HardDrive,
|
|
HardDriveUpload,
|
|
Leaf,
|
|
PieChart,
|
|
} from "lucide-react";
|
|
import { cn, readableBytes, ucfirst } from "@/lib/utils";
|
|
import { useBucketsWithDetails } from "../buckets/hooks";
|
|
import { useMemo } from "react";
|
|
|
|
const HomePage = () => {
|
|
const { data: health } = useNodesHealth();
|
|
const bucketDetailsQueries = useBucketsWithDetails();
|
|
|
|
const totalUsage = useMemo(() => {
|
|
return bucketDetailsQueries
|
|
.map(query => query.data?.bytes)
|
|
.filter(bytes => bytes != null)
|
|
.reduce((acc, bytes) => acc + bytes, 0);
|
|
}, [bucketDetailsQueries]);
|
|
|
|
return (
|
|
<div className="container">
|
|
<Page title="Dashboard" />
|
|
|
|
<section className="grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-4 md:gap-6">
|
|
<StatsCard
|
|
title="Status"
|
|
icon={Leaf}
|
|
value={ucfirst(health?.status)}
|
|
valueClassName={cn(
|
|
"text-lg",
|
|
health?.status === "healthy"
|
|
? "text-success"
|
|
: health?.status === "degraded"
|
|
? "text-warning"
|
|
: "text-error"
|
|
)}
|
|
/>
|
|
<StatsCard title="Nodes" icon={HardDrive} value={health?.knownNodes} />
|
|
<StatsCard
|
|
title="Connected Nodes"
|
|
icon={HardDriveUpload}
|
|
value={health?.connectedNodes}
|
|
/>
|
|
<StatsCard
|
|
title="Storage Nodes"
|
|
icon={Database}
|
|
value={health?.storageNodes}
|
|
/>
|
|
<StatsCard
|
|
title="Active Storage Nodes"
|
|
icon={DatabaseZap}
|
|
value={health?.storageNodesUp}
|
|
/>
|
|
<StatsCard
|
|
title="Partitions"
|
|
icon={FileBox}
|
|
value={health?.partitions}
|
|
/>
|
|
<StatsCard
|
|
title="Partitions Quorum"
|
|
icon={FileClock}
|
|
value={health?.partitionsQuorum}
|
|
/>
|
|
<StatsCard
|
|
title="Active Partitions"
|
|
icon={FileCheck}
|
|
value={health?.partitionsAllOk}
|
|
/>
|
|
<StatsCard
|
|
title="Total Usage"
|
|
icon={PieChart}
|
|
value={readableBytes(totalUsage)}
|
|
/>
|
|
</section>
|
|
</div>
|
|
);
|
|
};
|
|
|
|
export default HomePage;
|