import DeployProgress from "@/components/certimate/DeployProgress"; import DeployState from "@/components/certimate/DeployState"; import { Alert, AlertDescription, AlertTitle } from "@/components/ui/alert"; import { Button } from "@/components/ui/button"; import { Sheet, SheetContent, SheetHeader, SheetTitle, SheetTrigger, } from "@/components/ui/sheet"; import { Deployment, DeploymentListReq, Log } from "@/domain/deployment"; import { Statistic } from "@/domain/domain"; import { convertZulu2Beijing } from "@/lib/time"; import { list } from "@/repository/deployment"; import { statistics } from "@/repository/domains"; import { Ban, CalendarX2, LoaderPinwheel, Smile, SquareSigma, } from "lucide-react"; import { useEffect, useState } from "react"; import { Link, useNavigate } from "react-router-dom"; const Dashboard = () => { const [statistic, setStatistic] = useState(); const [deployments, setDeployments] = useState(); const navigate = useNavigate(); useEffect(() => { const fetchStatistic = async () => { const data = await statistics(); setStatistic(data); }; fetchStatistic(); }, []); useEffect(() => { const fetchData = async () => { const param: DeploymentListReq = { perPage: 8, }; const data = await list(param); setDeployments(data.items); }; fetchData(); }, []); return (
控制面板
所有
{statistic?.total ? ( {statistic?.total} ) : ( 0 )}
即将过期
{statistic?.expired ? ( {statistic?.expired} ) : ( 0 )}
启用中
{statistic?.enabled ? ( {statistic?.enabled} ) : ( 0 )}
未启用
{statistic?.disabled ? ( {statistic?.disabled} ) : ( 0 )}
部署历史
{deployments?.length == 0 ? ( <> 暂无数据
{" "} 你暂未创建任何部署,请先添加域名进行部署吧!
) : ( <>
域名
状态
阶段
最近执行时间
操作
部署历史
{deployments?.map((deployment) => (
{deployment.expand.domain?.domain}
{convertZulu2Beijing(deployment.deployedAt)}
{deployment.expand.domain?.domain}-{deployment.id} 部署详情
{deployment.log.check && ( <> {deployment.log.check.map((item: Log) => { return (
[{item.time}]
{item.message}
{item.error && (
{item.error}
)}
); })} )} {deployment.log.apply && ( <> {deployment.log.apply.map((item: Log) => { return (
[{item.time}]
{item.message}
{item.info && item.info.map((info: string) => { return (
{info}
); })} {item.error && (
{item.error}
)}
); })} )} {deployment.log.deploy && ( <> {deployment.log.deploy.map((item: Log) => { return (
[{item.time}]
{item.message}
{item.error && (
{item.error}
)}
); })} )}
))} )}
); }; export default Dashboard;