Skip to content

Commit

Permalink
add: impl memory and disk chart
Browse files Browse the repository at this point in the history
  • Loading branch information
Nurudeen38 committed Nov 8, 2022
1 parent 25a3be0 commit 070973a
Show file tree
Hide file tree
Showing 4 changed files with 93 additions and 27 deletions.
6 changes: 3 additions & 3 deletions web/src/server/ServerDetailServicesTabPanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import ServerDetailServicesTabPanelMemory from "./ServerDetailServicesTabPanelMe
import ServerDetailServicesTabPanelProcess from "./ServerDetailServicesTabPanelProcess";
import ServerDetailServicesTabPanelTCP from "./ServerDetailServicesTabPanelTCP";
import ServerDetailServicesTabPanelUptime from "./ServerDetailServicesTabPanelUptime";
import { ServerResponseType, ServerServiceNameType } from "./ServerType";
import { DiskData, MemoryData, ServerResponseType, ServerServiceNameType } from "./ServerType";

interface ServerDetailServicesTabPanelType {
serverName: ServerServiceNameType;
Expand All @@ -31,7 +31,7 @@ export default function ServerDetailServicesTabPanel(
content: (
<ServerDetailServicesTabPanelDisk
serverName={serverName}
serverData={serverData}
serverData={serverData as ServerResponseType<Array<DiskData>>}
/>
),
},
Expand All @@ -58,7 +58,7 @@ export default function ServerDetailServicesTabPanel(
content: (
<ServerDetailServicesTabPanelMemory
serverName={serverName}
serverData={serverData}
serverData={serverData as ServerResponseType<MemoryData>}
/>
),
},
Expand Down
50 changes: 39 additions & 11 deletions web/src/server/ServerDetailServicesTabPanelDisk.tsx
Original file line number Diff line number Diff line change
@@ -1,19 +1,47 @@
import React from "react";
import styled from '@emotion/styled';
import React from 'react';
import {
BarChart,
Bar,
XAxis,
YAxis,
CartesianGrid,
Tooltip,
Legend,
} from 'recharts';
import { DiskData, ServerResponseType, ServerServiceNameType } from './ServerType';

interface ServerDetailServicesTabPanelDiskType {
serverName:
| "disk"
| "docker"
| "uptime"
| "memory"
| "process"
| "loadavg"
| "tcp";
serverData: Object | [];
serverName: ServerServiceNameType;
serverData: ServerResponseType<Array<DiskData>>;
}

const Div = styled.div`
margin-top: 2rem;
`;

export default function ServerDetailServicesTabPanelDisk(
props: ServerDetailServicesTabPanelDiskType
) {
return <div>{/* <ServicesTabPanel /> */}</div>;
const { serverData:{ Message:{ Data }}} = props;

return (
<Div>
{
/* <ServicesTabPanel /> */
// <ResponsiveContainer width='100%' height='100%'>
<BarChart width={900} height={500} data={Data}>
<CartesianGrid strokeDasharray='3 3' />
<XAxis dataKey='FileSystem' />
<YAxis />
<Tooltip />
<Legend />
<Bar dataKey='Available' fill='#8884d8' />
<Bar dataKey='Used' fill='red' />
<Bar dataKey='Size' fill='green' />
</BarChart>
// </ResponsiveContainer>
}
</Div>
);
}
60 changes: 49 additions & 11 deletions web/src/server/ServerDetailServicesTabPanelMemory.tsx
Original file line number Diff line number Diff line change
@@ -1,19 +1,57 @@
import React from "react";
import styled from '@emotion/styled';
import React from 'react';
import {
BarChart,
Bar,
XAxis,
YAxis,
CartesianGrid,
Tooltip,
Legend,
} from 'recharts';
import {
MemoryData,
ServerResponseType,
ServerServiceNameType,
} from './ServerType';

interface ServerDetailServicesTabPanelMemoryType {
serverName:
| "disk"
| "docker"
| "uptime"
| "memory"
| "process"
| "loadavg"
| "tcp";
serverData: Object | [];
serverName: ServerServiceNameType;
serverData: ServerResponseType<MemoryData>;
}


const Div = styled.div`
margin-top:2rem;
`

export default function ServerDetailServicesTabPanelMemory(
props: ServerDetailServicesTabPanelMemoryType
) {
return <div>{/* <ServicesTabPanel /> */}</div>;
const {
serverData: {
Message: { Data },
},
} = props;
console.log({ Data });
return (
<Div>
{
/* <ServicesTabPanel /> */
// <ResponsiveContainer width='100%' height='100%'>
<BarChart width={900} height={500} data={[Data]}>
<CartesianGrid strokeDasharray='3 3' />
<XAxis dataKey='FileSystem' />
<YAxis />
<Tooltip />
<Legend />
<Bar dataKey='MemFree' fill='#003f5c' />
<Bar dataKey='MemTotal' fill='#58508d' />
<Bar dataKey='SwapFree' fill='#bc5090' />
<Bar dataKey='SwapTotal' fill='#ff6361' />
</BarChart>
// </ResponsiveContainer>
}
</Div>
);
}
4 changes: 2 additions & 2 deletions web/src/server/ServerType.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@ export type ServerServiceNameType =
| UptimeData
| ProcessData;

export interface ServerResponseType {
export interface ServerResponseType<T = ServerResponseMessageData> {
Error: boolean;
Message: {
Host: string;
Name: ServerServiceNameType;
Platform: 'Windows' | 'Linux' | 'Darwin' | 'MacOS';
Data: ServerResponseMessageData;
Data: T;
};
}

Expand Down

0 comments on commit 070973a

Please sign in to comment.