diff --git a/public/locales/en-US/dashboard.json b/public/locales/en-US/dashboard.json index 29fb1cf..63cfbf8 100755 --- a/public/locales/en-US/dashboard.json +++ b/public/locales/en-US/dashboard.json @@ -61,6 +61,8 @@ "totalFilesAndFolders": "Files and Folders", "shareLinks": "Share links", "totalBlobs": "Blobs", + "storagePolicies": "Storage Policies Usage", + "noStoragePolicies": "No storage policies available", "homepage": "Homepage", "github": "GitHub", "documents": "Documents", diff --git a/public/locales/zh-CN/dashboard.json b/public/locales/zh-CN/dashboard.json index 4a8d66e..2d052a3 100755 --- a/public/locales/zh-CN/dashboard.json +++ b/public/locales/zh-CN/dashboard.json @@ -61,6 +61,8 @@ "totalFilesAndFolders": "文件与目录", "shareLinks": "分享链接", "totalBlobs": "文件 Blob", + "storagePolicies": "存储策略空间使用", + "noStoragePolicies": "暂无存储策略", "homepage": "主页", "github": "GitHub", "documents": "文档", diff --git a/src/api/dashboard.ts b/src/api/dashboard.ts index bed893f..5ea73df 100755 --- a/src/api/dashboard.ts +++ b/src/api/dashboard.ts @@ -20,10 +20,19 @@ export interface Version { commit: string; } +export interface StoragePolicySpace { + id: number; + name: string; + type: string; + used: number; + total: number; +} + export interface HomepageSummary { metrics_summary?: MetricsSummary; site_urls: string[]; version: Version; + storage_policies?: StoragePolicySpace[]; } export interface ManualRefreshLicenseService { diff --git a/src/component/Admin/Home/Home.tsx b/src/component/Admin/Home/Home.tsx index f9ae8cc..2a7f0db 100755 --- a/src/component/Admin/Home/Home.tsx +++ b/src/component/Admin/Home/Home.tsx @@ -43,9 +43,10 @@ import SparkleFilled from "../../Icons/SparkleFilled.tsx"; import Telegram from "../../Icons/Telegram.tsx"; import PageContainer from "../../Pages/PageContainer.tsx"; import PageHeader from "../../Pages/PageHeader.tsx"; -import ProDialog from "../Common/ProDialog.tsx"; +import ProDialog from "../../Admin/Common/ProDialog.tsx"; import SiteUrlWarning from "./SiteUrlWarning.tsx"; import CommentMultiple from "../../Icons/CommentMultiple.tsx"; +import LinearProgress from "@mui/material/LinearProgress"; const StyledPaper = styled(Paper)(({ theme }) => ({ padding: theme.spacing(3), @@ -306,6 +307,67 @@ const Home = () => { + + + + {t("summary.storagePolicies")} + + + + {summary?.storage_policies && summary.storage_policies.length > 0 ? ( + + {summary.storage_policies.map((policy) => { + const percentage = policy.total > 0 ? (policy.used / policy.total) * 100 : 0; + const formatSize = (bytes: number) => { + if (bytes === 0) return "0 B"; + const k = 1024; + const sizes = ["B", "KB", "MB", "GB", "TB", "PB"]; + const i = Math.floor(Math.log(bytes) / Math.log(k)); + return parseFloat((bytes / Math.pow(k, i)).toFixed(2)) + " " + sizes[i]; + }; + + return ( + + + {policy.name} + + {formatSize(policy.used)} / {formatSize(policy.total)} + + + + + {policy.type} + + + {percentage.toFixed(1)}% + + + 90 ? red[500] : percentage > 70 ? yellow[500] : green[500], + }, + }} + /> + + ); + })} + + ) : ( + + {t("summary.noStoragePolicies")} + + )} + + +