diff --git a/components/log-viewer-webui/client/src/components/DashboardCard/index.module.css b/components/log-viewer-webui/client/src/components/DashboardCard/index.module.css new file mode 100644 index 0000000000..0f18732b5c --- /dev/null +++ b/components/log-viewer-webui/client/src/components/DashboardCard/index.module.css @@ -0,0 +1,13 @@ +.card :global(.ant-card-head) { + border: 0px; +} + +.cardContent { + display: flex; + flex-direction: column; +} + +.title { + font-size: 1.5rem; + font-weight: 600; +} diff --git a/components/log-viewer-webui/client/src/components/DashboardCard/index.tsx b/components/log-viewer-webui/client/src/components/DashboardCard/index.tsx new file mode 100644 index 0000000000..692297f4b1 --- /dev/null +++ b/components/log-viewer-webui/client/src/components/DashboardCard/index.tsx @@ -0,0 +1,50 @@ +import { + Card, + Typography, +} from "antd"; + +import styles from "./index.module.css"; + + +const {Text} = Typography; + +interface DashboardCardProps { + title: string; + titleColor?: string; + backgroundColor?: string; + children?: React.ReactNode; +} + +/** + * Renders a card for dashboard. + * + * @param props + * @param props.title + * @param props.titleColor + * @param props.backgroundColor + * @param props.children + * @return + */ +const DashboardCard = ({title, titleColor, backgroundColor, children}: DashboardCardProps) => { + return ( + +
+ + {title} + + {children} +
+
+ ); +}; + +export {DashboardCard}; + +export type {DashboardCardProps}; diff --git a/components/log-viewer-webui/client/src/components/StatCard/index.module.css b/components/log-viewer-webui/client/src/components/StatCard/index.module.css index 1da71486d4..e69de29bb2 100644 --- a/components/log-viewer-webui/client/src/components/StatCard/index.module.css +++ b/components/log-viewer-webui/client/src/components/StatCard/index.module.css @@ -1,17 +0,0 @@ -.card :global(.ant-card-head) { - border: 0px; -} - -.cardContent { - display: flex; - flex-direction: column; -} - -.title { - font-size: 1.5rem; - font-weight: 600; -} - -.statistic { - font-size: 5rem; -} diff --git a/components/log-viewer-webui/client/src/components/StatCard/index.tsx b/components/log-viewer-webui/client/src/components/StatCard/index.tsx index 06ef738a92..4610c43946 100644 --- a/components/log-viewer-webui/client/src/components/StatCard/index.tsx +++ b/components/log-viewer-webui/client/src/components/StatCard/index.tsx @@ -1,9 +1,9 @@ -import { - Card, - Typography, -} from "antd"; +import {Typography} from "antd"; -import styles from "./index.module.css"; +import { + DashboardCard, + DashboardCardProps, +} from "../DashboardCard/index"; const {Text} = Typography; @@ -11,43 +11,48 @@ const {Text} = Typography; interface StatCardProps { title: string; stat: string; - textColor?: string; + titleColor?: string; backgroundColor?: string; + statSize?: string; + statColor?: string; } /** - * Renders a card that dislays a statistic. + * Renders a card with a statistic. * * @param props * @param props.title * @param props.stat - * @param props.textColor + * @param props.titleColor * @param props.backgroundColor + * @param props.statSize + * @param props.statColor * @return */ -const StatCard = ({title, stat, textColor, backgroundColor}: StatCardProps) => { +const StatCard = ({ + title, + stat, + titleColor, + backgroundColor, + statSize, + statColor, +}: StatCardProps) => { + const props: DashboardCardProps = { + title, + ...(titleColor ? + {titleColor} : + {}), + ...(backgroundColor ? + {backgroundColor} : + {}), + }; + return ( - -
- - {title} - - - {stat} - -
-
+ + + {stat} + + ); }; - export default StatCard; diff --git a/components/log-viewer-webui/client/src/pages/IngestPage/Details/DetailsCard.tsx b/components/log-viewer-webui/client/src/pages/IngestPage/Details/DetailsCard.tsx new file mode 100644 index 0000000000..d178639b96 --- /dev/null +++ b/components/log-viewer-webui/client/src/pages/IngestPage/Details/DetailsCard.tsx @@ -0,0 +1,30 @@ +import {theme} from "antd"; + +import StatCard from "../../../components/StatCard"; + + +interface DetailsCardProps { + title: string; + stat: string; +} + +/** + * A stat card in the details grid. + * + * @param props + * @param props.title + * @param props.stat + * @return + */ +const DetailsCard = ({title, stat}: DetailsCardProps) => { + const {token} = theme.useToken(); + return ( + + ); +}; + +export default DetailsCard; diff --git a/components/log-viewer-webui/client/src/pages/IngestPage/Details/Files.tsx b/components/log-viewer-webui/client/src/pages/IngestPage/Details/Files.tsx new file mode 100644 index 0000000000..a40662014e --- /dev/null +++ b/components/log-viewer-webui/client/src/pages/IngestPage/Details/Files.tsx @@ -0,0 +1,21 @@ +import DetailsCard from "./DetailsCard"; + + +// eslint-disable-next-line no-warning-comments +// TODO: Replace with values from database once api implemented. +const DUMMY_FILES = 124; + +/** + * Renders the files statistic. + * + * @return + */ +const Files = () => { + return ( + + ); +}; + +export default Files; diff --git a/components/log-viewer-webui/client/src/pages/IngestPage/Details/Messages.tsx b/components/log-viewer-webui/client/src/pages/IngestPage/Details/Messages.tsx new file mode 100644 index 0000000000..ebf4885807 --- /dev/null +++ b/components/log-viewer-webui/client/src/pages/IngestPage/Details/Messages.tsx @@ -0,0 +1,21 @@ +import DetailsCard from "./DetailsCard"; + + +// eslint-disable-next-line no-warning-comments +// TODO: Replace with values from database once api implemented. +const DUMMY_MESSAGES = 1235844; + +/** + * Renders the messages statistic. + * + * @return + */ +const Messages = () => { + return ( + + ); +}; + +export default Messages; diff --git a/components/log-viewer-webui/client/src/pages/IngestPage/Details/TimeRange.tsx b/components/log-viewer-webui/client/src/pages/IngestPage/Details/TimeRange.tsx new file mode 100644 index 0000000000..7609d27b56 --- /dev/null +++ b/components/log-viewer-webui/client/src/pages/IngestPage/Details/TimeRange.tsx @@ -0,0 +1,29 @@ +import dayjs from "dayjs"; + +import DetailsCard from "./DetailsCard"; + + +// eslint-disable-next-line no-warning-comments +// TODO: Replace with values from database once api implemented. +const DUMMY_START_DATE = "2021-12-14"; +const DUMMY_END_DATE = "2025-04-16"; + +const DATE_FORMAT = "MMMM D, YYYY"; + +/** + * Renders the time range statistic. + * + * @return + */ +const TimeRange = () => { + const formattedStat = `${dayjs(DUMMY_START_DATE).format(DATE_FORMAT)} - + ${dayjs(DUMMY_END_DATE).format(DATE_FORMAT)}`; + + return ( + + ); +}; + +export default TimeRange; diff --git a/components/log-viewer-webui/client/src/pages/IngestPage/Details/index.module.css b/components/log-viewer-webui/client/src/pages/IngestPage/Details/index.module.css new file mode 100644 index 0000000000..c27ccf933c --- /dev/null +++ b/components/log-viewer-webui/client/src/pages/IngestPage/Details/index.module.css @@ -0,0 +1,10 @@ +.detailsGrid { + display: grid; + grid-template-columns: repeat(2, 200px); + gap: 8px; +} + +.timeRange { + grid-column: span 2; +} + diff --git a/components/log-viewer-webui/client/src/pages/IngestPage/Details/index.tsx b/components/log-viewer-webui/client/src/pages/IngestPage/Details/index.tsx new file mode 100644 index 0000000000..18d7eb8ad7 --- /dev/null +++ b/components/log-viewer-webui/client/src/pages/IngestPage/Details/index.tsx @@ -0,0 +1,24 @@ +import Files from "./Files"; +import styles from "./index.module.css"; +import Messages from "./Messages"; +import TimeRange from "./TimeRange"; + + +/** + * Renders grid with compression details. + * + * @return + */ +const Details = () => { + return ( +
+
+ +
+ + +
+ ); +}; + +export default Details; diff --git a/components/log-viewer-webui/client/src/pages/IngestPage/SpaceSavings/index.tsx b/components/log-viewer-webui/client/src/pages/IngestPage/SpaceSavings/index.tsx index 18836148e7..9d959820a4 100644 --- a/components/log-viewer-webui/client/src/pages/IngestPage/SpaceSavings/index.tsx +++ b/components/log-viewer-webui/client/src/pages/IngestPage/SpaceSavings/index.tsx @@ -9,7 +9,7 @@ const DUMMY_COMPRESSED_SIZE = 1004023; const DUMMY_UNCOMPRESSED_SIZE = 110300010; /** - * Presents space savings or compression ratio from the given statistics. + * Renders space savings card. * * @return */ @@ -18,7 +18,7 @@ const SpaceSavings = () => { const compressedSize = DUMMY_COMPRESSED_SIZE as number; const uncompressedSize = DUMMY_UNCOMPRESSED_SIZE as number; - const spaceSavingsPercent = (0 === uncompressedSize) ? + const spaceSavingsPercent = (0 !== uncompressedSize) ? 100 * (1 - (compressedSize / uncompressedSize)) : 0; @@ -28,10 +28,11 @@ const SpaceSavings = () => { + statColor={token.colorWhite} + statSize={"6rem"} + title={"Space Savings"} + titleColor={token.colorWhite}/> ); }; - export default SpaceSavings; diff --git a/components/log-viewer-webui/client/src/pages/IngestPage/index.tsx b/components/log-viewer-webui/client/src/pages/IngestPage/index.tsx index fcda0583df..e6c84a44c8 100644 --- a/components/log-viewer-webui/client/src/pages/IngestPage/index.tsx +++ b/components/log-viewer-webui/client/src/pages/IngestPage/index.tsx @@ -1,3 +1,4 @@ +import Details from "./Details"; import styles from "./index.module.css"; import SpaceSavings from "./SpaceSavings"; @@ -11,6 +12,7 @@ const IngestPage = () => { return (
+
); };