Skip to content

Commit

Permalink
feat: Add DashboardSectionsDivider component
Browse files Browse the repository at this point in the history
  • Loading branch information
pacholoamit committed Oct 15, 2024
1 parent 5ccbec9 commit da37633
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 39 deletions.
25 changes: 25 additions & 0 deletions src/components/dashboard-section-divider.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { Divider, Grid, Text } from '@mantine/core';

interface DashboardSectionsDividerProps {
label: string;
}
const DashboardSectionsDivider = ({ label }: DashboardSectionsDividerProps) => {
return (
<>
<Grid.Col span={12}>
<Divider
my="xs"
label={
<>
<Text c="dimmed" size="sm" tt="uppercase" weight={700}>
{label}
</Text>
</>
}
/>
</Grid.Col>
</>
);
};

export default DashboardSectionsDivider;
64 changes: 25 additions & 39 deletions src/features/metrics/pages/dashboard.page.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { useShallow } from 'zustand/react/shallow';

import DashboardSectionsDivider from '@/components/dashboard-section-divider';
import PageWrapper from '@/components/page-wrapper';
import SystemInformationWidget from '@/components/system-information-widget';
import CpusBarChart from '@/features/metrics/components/cpus/cpus.bar-charts';
Expand All @@ -16,26 +17,7 @@ import SwapStatsRing from '@/features/metrics/components/swap/swap.stats-ring';
import useDisksSelectors from '@/features/metrics/stores/disk.store';
import useSystemStoreSelectors from '@/features/metrics/stores/system.store';
import useRandomGreeting from '@/hooks/useRandomGreeting';
import { Divider, Grid, Text } from '@mantine/core';

// const StatsRings = () => {
// return (
// <>
// <Grid.Col sm={6} md={6} lg={3} xl={3}>
// <GlobalCpuStatsRing />
// </Grid.Col>
// <Grid.Col sm={6} md={6} lg={3} xl={3}>
// <MemoryStatsRing />
// </Grid.Col>
// <Grid.Col sm={6} md={6} lg={3} xl={3}>
// <SwapStatsRing />
// </Grid.Col>
// <Grid.Col sm={6} md={6} lg={3} xl={3}>
// <DiskStatsRing />
// </Grid.Col>
// </>
// );
// };
import { Box, Center, Divider, Grid, Text } from '@mantine/core';

const MemorySection = () => {
return (
Expand Down Expand Up @@ -79,6 +61,10 @@ const NetworksSection = () => {
const DiskSection = () => {
const disks = useDisksSelectors.use.disks();

if (disks.length === 0) {
return <DashboardNoDataAvailable message="No disk data available" />;
}

return (
<>
{disks.map((disk) => (
Expand All @@ -90,25 +76,24 @@ const DiskSection = () => {
);
};

interface DashboardSectionsDividerProps {
label: string;
const TempsSection = () => {
const temps = [];

if (temps.length === 0) {
return <DashboardNoDataAvailable message="No temperature data available" />;
}
};

interface DashboardNoDataAvailableProps {
message: string;
}
const DashboardSectionsDivider = ({ label }: DashboardSectionsDividerProps) => {
const DashboardNoDataAvailable = ({ message }: DashboardNoDataAvailableProps) => {
return (
<>
<Grid.Col span={12}>
<Divider
my="xs"
label={
<>
<Text c="dimmed" size="sm" tt="uppercase" weight={700}>
{label}
</Text>
</>
}
/>
</Grid.Col>
</>
<Center maw={400} h={190} mx="auto">
<Text c="dimmed" size="sm" tt="uppercase" fw={700}>
{message}
</Text>
</Center>
);
};

Expand All @@ -126,8 +111,9 @@ const DashboardPage = () => {
<MemorySection />
<DashboardSectionsDivider label="Disks" />
<DiskSection />
<DashboardSectionsDivider label="Networks" />
<NetworksSection />
<DashboardSectionsDivider label="Temps" />
<TempsSection />
{/* <NetworksSection /> */}
</Grid>
</PageWrapper>
);
Expand Down

0 comments on commit da37633

Please sign in to comment.