-
Notifications
You must be signed in to change notification settings - Fork 387
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Some info cards in dashboard (#873)
Add a clock and some more cards to the dashboard home
- Loading branch information
Victor Castell
authored
Dec 20, 2020
1 parent
b6432e8
commit 0b27010
Showing
14 changed files
with
340 additions
and
87 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
import * as React from 'react'; | ||
import { FC, createElement } from 'react'; | ||
import { Card, Box, Typography, Divider } from '@material-ui/core'; | ||
import { makeStyles } from '@material-ui/core/styles'; | ||
import { Link } from 'react-router-dom'; | ||
|
||
import cartouche from './cartouche.png'; | ||
import cartoucheDark from './cartoucheDark.png'; | ||
|
||
interface Props { | ||
icon: FC<any>; | ||
to: string; | ||
title?: string; | ||
subtitle?: string | number; | ||
} | ||
|
||
const useStyles = makeStyles(theme => ({ | ||
card: { | ||
minHeight: 52, | ||
display: 'flex', | ||
flexDirection: 'column', | ||
flex: '1', | ||
'& a': { | ||
textDecoration: 'none', | ||
color: 'inherit', | ||
}, | ||
}, | ||
main: (props: Props) => ({ | ||
overflow: 'inherit', | ||
padding: 16, | ||
background: `url(${ | ||
theme.palette.type === 'dark' ? cartoucheDark : cartouche | ||
}) no-repeat`, | ||
display: 'flex', | ||
justifyContent: 'space-between', | ||
alignItems: 'center', | ||
'& .icon': { | ||
color: theme.palette.type === 'dark' ? 'inherit' : '#dc2440', | ||
}, | ||
}), | ||
title: {}, | ||
})); | ||
|
||
const CardWithIcon: FC<Props> = props => { | ||
const { icon, title, subtitle, to, children } = props; | ||
const classes = useStyles(props); | ||
return ( | ||
<Card className={classes.card}> | ||
<Link to={to}> | ||
<div className={classes.main}> | ||
<Box width="3em" className="icon"> | ||
{createElement(icon, { fontSize: 'large' })} | ||
</Box> | ||
<Box textAlign="right"> | ||
<Typography | ||
className={classes.title} | ||
color="textSecondary" | ||
> | ||
{title} | ||
</Typography> | ||
<Typography variant="h5" component="h2"> | ||
{subtitle || ' '} | ||
</Typography> | ||
</Box> | ||
</div> | ||
</Link> | ||
{children && <Divider />} | ||
{children} | ||
</Card> | ||
); | ||
}; | ||
|
||
export default CardWithIcon; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import * as React from 'react'; | ||
import { FC } from 'react'; | ||
import Icon from '@material-ui/icons/ThumbDown'; | ||
|
||
import CardWithIcon from './CardWithIcon'; | ||
|
||
interface Props { | ||
value?: string; | ||
} | ||
|
||
const FailedJobs: FC<Props> = ({ value }) => { | ||
return ( | ||
<CardWithIcon | ||
to='/jobs?filter={"status":"failed"}' | ||
icon={Icon} | ||
title='Failed Jobs' | ||
subtitle={value} | ||
/> | ||
); | ||
}; | ||
|
||
export default FailedJobs; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import * as React from 'react'; | ||
import { FC } from 'react'; | ||
import Icon from '@material-ui/icons/DeviceHub'; | ||
|
||
import CardWithIcon from './CardWithIcon'; | ||
|
||
interface Props { | ||
value?: string; | ||
} | ||
|
||
const Leader: FC<Props> = ({ value }) => { | ||
return ( | ||
<CardWithIcon | ||
to="/jobs" | ||
icon={Icon} | ||
title='Leader' | ||
subtitle={value} | ||
/> | ||
); | ||
}; | ||
|
||
export default Leader; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import * as React from 'react'; | ||
import { FC } from 'react'; | ||
import Icon from '@material-ui/icons/ThumbUp'; | ||
|
||
import CardWithIcon from './CardWithIcon'; | ||
|
||
interface Props { | ||
value?: string; | ||
} | ||
|
||
const SuccessfulJobs: FC<Props> = ({ value }) => { | ||
return ( | ||
<CardWithIcon | ||
to='/jobs?filter={"status":"success"}' | ||
icon={Icon} | ||
title='Successful Jobs' | ||
subtitle={value} | ||
/> | ||
); | ||
}; | ||
|
||
export default SuccessfulJobs; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import * as React from 'react'; | ||
import { FC } from 'react'; | ||
import Icon from '@material-ui/icons/Update'; | ||
|
||
import CardWithIcon from './CardWithIcon'; | ||
|
||
interface Props { | ||
value?: string; | ||
} | ||
|
||
const TotalJobs: FC<Props> = ({ value }) => { | ||
return ( | ||
<CardWithIcon | ||
to="/jobs" | ||
icon={Icon} | ||
title='Total Jobs' | ||
subtitle={value} | ||
/> | ||
); | ||
}; | ||
|
||
export default TotalJobs; |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import React, {Component} from 'react'; | ||
|
||
class Clock extends Component<{}, { date: Date }> { | ||
timer: any; | ||
|
||
constructor(props: any){ | ||
super(props); | ||
this.state = {date: new Date()}; | ||
} | ||
|
||
componentDidMount() { | ||
this.timer = setInterval( | ||
() => this.setState({date: new Date()}), | ||
1000 | ||
); | ||
} | ||
|
||
componentWillUnmount() { | ||
clearInterval(this.timer); | ||
} | ||
|
||
render(){ | ||
return( | ||
<div> | ||
<div>{this.state.date.toLocaleTimeString()}</div> | ||
</div> | ||
) | ||
} | ||
} | ||
export default Clock |