import React from "react"; import { GetServer, GetAllServers } from "../Server/AllServers"; import { Modal } from "../ui/React/Modal"; import { formatBigNumber } from "../ui/formatNumber"; import Table from "@mui/material/Table"; import TableBody from "@mui/material/TableBody"; import TableCell from "@mui/material/TableCell"; import TableContainer from "@mui/material/TableContainer"; import TableHead from "@mui/material/TableHead"; import TableRow from "@mui/material/TableRow"; import Typography from "@mui/material/Typography"; import Paper from "@mui/material/Paper"; import Accordion from "@mui/material/Accordion"; import AccordionSummary from "@mui/material/AccordionSummary"; import AccordionDetails from "@mui/material/AccordionDetails"; import ExpandMoreIcon from "@mui/icons-material/ExpandMore"; import { ServerName } from "../Types/strings"; import { allContentFiles } from "../Paths/ContentFile"; interface File { name: string; size: number; } function ServerAccordion(props: { hostname: ServerName }): React.ReactElement { const server = GetServer(props.hostname); if (server === null) throw new Error(`server '${props.hostname}' should not be null`); let totalSize = 0; const files: File[] = []; for (const [path, file] of allContentFiles(server)) { totalSize += file.content.length; files.push({ name: path, size: file.content.length }); } if (totalSize === 0) return <>; files.sort((a: File, b: File): number => b.size - a.size); return ( }> {server.hostname} ({formatBigNumber(totalSize)}b) Filename Size {files.map((file: File) => ( {file.name} {formatBigNumber(file.size)}b ))}
); } interface IProps { open: boolean; onClose: () => void; } export function FileDiagnosticModal(props: IProps): React.ReactElement { const keys: string[] = []; for (const key of GetAllServers()) { keys.push(key.hostname); } return ( <> Welcome to the file diagnostic! If your save file is really big it's likely because you have too many text/scripts. This tool can help you narrow down where they are. {keys.map((hostname: string) => ( ))} ); }