-
Notifications
You must be signed in to change notification settings - Fork 92
feat(new-webui): Add card to Ingestion page showing time range, file count, and message count. #830
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
a1171e4
bbda9e4
90230c2
e1bee56
0aca620
4d04da3
0ff2bc8
760d8b2
eab5bdb
7a8ebfc
fb55972
bd2a4fc
f6b4e31
7d62a72
ed297a5
45dddf5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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; | ||
| } |
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
| @@ -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 ( | ||||||||||
| <Card | ||||||||||
| className={styles["card"] || ""} | ||||||||||
| hoverable={true} | ||||||||||
|
Comment on lines
+31
to
+32
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Improve fallback pattern for CSS class names The current fallback pattern using logical OR ( - className={styles["card"] || ""}
+ className={styles.card ?? ""}📝 Committable suggestion
Suggested change
|
||||||||||
| style={{backgroundColor}} | ||||||||||
| > | ||||||||||
| <div className={styles["cardContent"]}> | ||||||||||
| <Text | ||||||||||
| className={styles["title"] || ""} | ||||||||||
| style={{color: titleColor}} | ||||||||||
|
Comment on lines
+37
to
+38
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Improve fallback pattern for CSS class names Same issue as with the card class - the logical OR fallback may not work as expected with CSS modules. - className={styles["title"] || ""}
+ className={styles.title ?? ""}📝 Committable suggestion
Suggested change
|
||||||||||
| > | ||||||||||
| {title} | ||||||||||
| </Text> | ||||||||||
| {children} | ||||||||||
| </div> | ||||||||||
| </Card> | ||||||||||
| ); | ||||||||||
| }; | ||||||||||
|
|
||||||||||
| export {DashboardCard}; | ||||||||||
|
|
||||||||||
| export type {DashboardCardProps}; | ||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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; | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,53 +1,58 @@ | ||
| import { | ||
| Card, | ||
| Typography, | ||
| } from "antd"; | ||
| import {Typography} from "antd"; | ||
|
|
||
| import styles from "./index.module.css"; | ||
| import { | ||
| DashboardCard, | ||
| DashboardCardProps, | ||
| } from "../DashboardCard/index"; | ||
|
|
||
|
|
||
| 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 ( | ||
| <Card | ||
| className={styles["card"] || ""} | ||
| hoverable={true} | ||
| style={{backgroundColor}} | ||
| > | ||
| <div className={styles["cardContent"]}> | ||
| <Text | ||
| className={styles["title"] || ""} | ||
| style={{color: textColor}} | ||
| > | ||
| {title} | ||
| </Text> | ||
| <Text | ||
| className={styles["statistic"] || ""} | ||
| style={{color: textColor}} | ||
| > | ||
| {stat} | ||
| </Text> | ||
| </div> | ||
| </Card> | ||
| <DashboardCard {...props}> | ||
| <Text style={{color: statColor, fontSize: statSize}}> | ||
| {stat} | ||
| </Text> | ||
| </DashboardCard> | ||
| ); | ||
| }; | ||
|
|
||
| export default StatCard; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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 ( | ||
| <StatCard | ||
| stat={stat} | ||
| statColor={token.colorTextSecondary} | ||
| statSize={"1.3rem"} | ||
| title={title}/> | ||
| ); | ||
| }; | ||
|
|
||
| export default DetailsCard; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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 ( | ||
| <DetailsCard | ||
| stat={DUMMY_FILES.toString()} | ||
| title={"Files"}/> | ||
| ); | ||
| }; | ||
|
|
||
| export default Files; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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 ( | ||
| <DetailsCard | ||
| stat={DUMMY_MESSAGES.toString()} | ||
| title={"Messages"}/> | ||
| ); | ||
| }; | ||
|
|
||
| export default Messages; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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 ( | ||
| <DetailsCard | ||
| stat={formattedStat} | ||
| title={"Time Range"}/> | ||
| ); | ||
| }; | ||
|
|
||
| export default TimeRange; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| .detailsGrid { | ||
| display: grid; | ||
| grid-template-columns: repeat(2, 200px); | ||
| gap: 8px; | ||
| } | ||
|
|
||
| .timeRange { | ||
| grid-column: span 2; | ||
| } | ||
|
|
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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 ( | ||
| <div className={styles["detailsGrid"]}> | ||
| <div className={styles["timeRange"]}> | ||
| <TimeRange/> | ||
| </div> | ||
| <Messages/> | ||
| <Files/> | ||
| </div> | ||
| ); | ||
| }; | ||
|
|
||
| export default Details; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's the reason we want to extract this component from the
StatCardcomponent?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We might have cards with a graph instead of a statistic. I thought having an empty card component was better, and then anything we want for content added as children
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
right, right