Skip to content

Commit

Permalink
Merge pull request #6 from SIT-DigiCre/enhance/table-view
Browse files Browse the repository at this point in the history
テーブル機能を実装
  • Loading branch information
ymd1138 committed May 2, 2023
2 parents 608e6a3 + e5a5021 commit c1b4f78
Show file tree
Hide file tree
Showing 4 changed files with 270 additions and 171 deletions.
2 changes: 1 addition & 1 deletion pages/_app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export default function App({ Component, pageProps }: AppProps) {
return (
<>
<Header />
<Component {...pageProps} />;
<Component {...pageProps} />
</>
);
}
43 changes: 30 additions & 13 deletions pages/serverinfo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,18 @@ import { Container, Row, Table } from "react-bootstrap";
type Props = {
dbMbSizes: { name: string; mbSize: number }[];
storageMbSize: number;
error?: string;
};

const ServerInfoPage = ({ dbMbSizes }: Props) => {
const ServerInfoPage = ({ dbMbSizes, error }: Props) => {
if (error)
return (
<Container>
<Row>
<p style={{ color: "red" }}>{error}</p>
</Row>
</Container>
);
return (
<Container>
<Row>
Expand Down Expand Up @@ -36,24 +45,32 @@ const ServerInfoPage = ({ dbMbSizes }: Props) => {
export default ServerInfoPage;

export const getServerSideProps: GetServerSideProps = async (context) => {
const rows = await queryDb(`SELECT
try {
const rows = await queryDb(`SELECT
table_schema, sum(data_length+index_length) /1024 /1024 AS MB
FROM
information_schema.tables
GROUP BY
table_schema
ORDER BY
sum(data_length+index_length) DESC;`);
const dbMbSizes = rows.map((r) => {
return { name: r.TABLE_SCHEMA, mbSize: r.MB };
});
console.log(dbMbSizes);
const props: Props = {
dbMbSizes,
storageMbSize: 0,
};
const dbMbSizes = rows.map((r) => {
return { name: r.TABLE_SCHEMA, mbSize: r.MB };
});
console.log(dbMbSizes);
const props: Props = {
dbMbSizes,
storageMbSize: 0,
};

return {
props: props,
};
return {
props: props,
};
} catch (e: any) {
return {
props: {
error: e.message,
},
};
}
};
Loading

0 comments on commit c1b4f78

Please sign in to comment.