Feat: cards same height in Dashboard
Fix: merge alerts.new.styles into alerts.styles
This commit is contained in:
parent
eb5693d42b
commit
3f042410f7
11 changed files with 168 additions and 159 deletions
|
|
@ -1,5 +1,6 @@
|
||||||
import Grid from '@material-ui/core/Grid'
|
import Grid from '@material-ui/core/Grid'
|
||||||
import { makeStyles } from '@material-ui/core/styles'
|
import { makeStyles } from '@material-ui/core/styles'
|
||||||
|
import classnames from 'classnames'
|
||||||
import PropTypes from 'prop-types'
|
import PropTypes from 'prop-types'
|
||||||
import React from 'react'
|
import React from 'react'
|
||||||
|
|
||||||
|
|
@ -26,13 +27,9 @@ const useStyles = makeStyles(styles)
|
||||||
const CollapsibleCard = ({ className, state, shrunkComponent, children }) => {
|
const CollapsibleCard = ({ className, state, shrunkComponent, children }) => {
|
||||||
const classes = useStyles()
|
const classes = useStyles()
|
||||||
return (
|
return (
|
||||||
<div className={className}>
|
<Grid item className={classnames(className, classes.card)}>
|
||||||
<Grid item>
|
{state === cardState.SHRUNK ? shrunkComponent : children}
|
||||||
<div className={classes.card}>
|
</Grid>
|
||||||
{state === cardState.SHRUNK ? shrunkComponent : children}
|
|
||||||
</div>
|
|
||||||
</Grid>
|
|
||||||
</div>
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -7,11 +7,10 @@ import gql from 'graphql-tag'
|
||||||
import * as R from 'ramda'
|
import * as R from 'ramda'
|
||||||
import React from 'react'
|
import React from 'react'
|
||||||
|
|
||||||
import { cardState as cardState_ } from 'src/components/CollapsibleCard'
|
import { cardState } from 'src/components/CollapsibleCard'
|
||||||
import { Label1, H4 } from 'src/components/typography'
|
import { Label1, H4 } from 'src/components/typography'
|
||||||
|
|
||||||
import styles from '../Dashboard.styles'
|
import styles from './Alerts.styles'
|
||||||
|
|
||||||
import AlertsTable from './AlertsTable'
|
import AlertsTable from './AlertsTable'
|
||||||
|
|
||||||
const NUM_TO_RENDER = 3
|
const NUM_TO_RENDER = 3
|
||||||
|
|
@ -38,7 +37,7 @@ const useStyles = makeStyles(styles)
|
||||||
|
|
||||||
const Alerts = ({ onReset, onExpand, size }) => {
|
const Alerts = ({ onReset, onExpand, size }) => {
|
||||||
const classes = useStyles()
|
const classes = useStyles()
|
||||||
const showAllItems = size === cardState_.EXPANDED
|
const showAllItems = size === cardState.EXPANDED
|
||||||
const { data } = useQuery(GET_ALERTS)
|
const { data } = useQuery(GET_ALERTS)
|
||||||
const alerts = R.path(['alerts'])(data) ?? []
|
const alerts = R.path(['alerts'])(data) ?? []
|
||||||
const machines = R.compose(
|
const machines = R.compose(
|
||||||
|
|
@ -73,9 +72,9 @@ const Alerts = ({ onReset, onExpand, size }) => {
|
||||||
className={classnames(alertsTableContainerClasses)}
|
className={classnames(alertsTableContainerClasses)}
|
||||||
container
|
container
|
||||||
spacing={1}>
|
spacing={1}>
|
||||||
<Grid item xs={12} className={classes.alertsTableMargin}>
|
<Grid item xs={12}>
|
||||||
{!alerts.length && (
|
{!alerts.length && (
|
||||||
<Label1 className={classes.notAlertsLabel}>
|
<Label1 className={classes.noAlertsLabel}>
|
||||||
No new alerts. Your system is running smoothly.
|
No new alerts. Your system is running smoothly.
|
||||||
</Label1>
|
</Label1>
|
||||||
)}
|
)}
|
||||||
|
|
@ -84,20 +83,22 @@ const Alerts = ({ onReset, onExpand, size }) => {
|
||||||
alerts={alerts}
|
alerts={alerts}
|
||||||
machines={machines}
|
machines={machines}
|
||||||
/>
|
/>
|
||||||
{!showAllItems && alertsLength > NUM_TO_RENDER && (
|
|
||||||
<Label1 className={classes.centerLabel}>
|
|
||||||
<Button
|
|
||||||
onClick={() => onExpand('alerts')}
|
|
||||||
size="small"
|
|
||||||
disableRipple
|
|
||||||
disableFocusRipple
|
|
||||||
className={classes.button}>
|
|
||||||
{`Show all (${alerts.length})`}
|
|
||||||
</Button>
|
|
||||||
</Label1>
|
|
||||||
)}
|
|
||||||
</Grid>
|
</Grid>
|
||||||
</Grid>
|
</Grid>
|
||||||
|
{!showAllItems && alertsLength > NUM_TO_RENDER && (
|
||||||
|
<Grid item xs={12}>
|
||||||
|
<Label1 className={classes.centerLabel}>
|
||||||
|
<Button
|
||||||
|
onClick={() => onExpand('alerts')}
|
||||||
|
size="small"
|
||||||
|
disableRipple
|
||||||
|
disableFocusRipple
|
||||||
|
className={classes.button}>
|
||||||
|
{`Show all (${alerts.length})`}
|
||||||
|
</Button>
|
||||||
|
</Label1>
|
||||||
|
</Grid>
|
||||||
|
)}
|
||||||
</>
|
</>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,39 +1,26 @@
|
||||||
import {
|
import { primaryColor, comet } from 'src/styling/variables'
|
||||||
backgroundColor,
|
|
||||||
offColor,
|
|
||||||
errorColor,
|
|
||||||
primaryColor,
|
|
||||||
spacer
|
|
||||||
} from 'src/styling/variables'
|
|
||||||
|
|
||||||
const styles = {
|
const styles = {
|
||||||
container: {
|
container: {
|
||||||
display: 'flex',
|
display: 'flex',
|
||||||
justifyContent: 'space-between'
|
justifyContent: 'space-between'
|
||||||
},
|
},
|
||||||
centerLabel: {
|
h4: {
|
||||||
textAlign: 'center',
|
|
||||||
marginBottom: 0,
|
|
||||||
marginTop: 0
|
|
||||||
},
|
|
||||||
label: {
|
|
||||||
margin: 0,
|
margin: 0,
|
||||||
color: offColor
|
marginBottom: 10
|
||||||
},
|
},
|
||||||
row: {
|
centerLabel: {
|
||||||
backgroundColor: backgroundColor,
|
marginBottom: 0,
|
||||||
borderBottom: 'none'
|
padding: 0,
|
||||||
|
textAlign: 'center'
|
||||||
},
|
},
|
||||||
header: {
|
upperButtonLabel: {
|
||||||
display: 'flex',
|
marginTop: -3,
|
||||||
alignItems: 'center',
|
marginBottom: 24
|
||||||
whiteSpace: 'pre'
|
|
||||||
},
|
|
||||||
error: {
|
|
||||||
color: errorColor
|
|
||||||
},
|
},
|
||||||
button: {
|
button: {
|
||||||
color: primaryColor,
|
color: primaryColor,
|
||||||
|
marginTop: 0,
|
||||||
minHeight: 0,
|
minHeight: 0,
|
||||||
minWidth: 0,
|
minWidth: 0,
|
||||||
padding: 0,
|
padding: 0,
|
||||||
|
|
@ -42,24 +29,21 @@ const styles = {
|
||||||
backgroundColor: 'transparent'
|
backgroundColor: 'transparent'
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
statusHeader: {
|
alertsTableContainer: {
|
||||||
marginLeft: 2
|
margin: 0
|
||||||
|
},
|
||||||
|
expandedAlertsTableContainer: {
|
||||||
|
margin: 0,
|
||||||
|
maxHeight: 460
|
||||||
|
},
|
||||||
|
noAlertsLabel: {
|
||||||
|
color: comet,
|
||||||
|
marginLeft: -5
|
||||||
},
|
},
|
||||||
table: {
|
table: {
|
||||||
marginTop: spacer * 4,
|
|
||||||
maxHeight: 465,
|
maxHeight: 465,
|
||||||
overflow: 'auto'
|
overflowX: 'hidden',
|
||||||
},
|
overflowY: 'auto'
|
||||||
tableBody: {
|
|
||||||
overflow: 'auto'
|
|
||||||
},
|
|
||||||
h4: {
|
|
||||||
marginTop: 0
|
|
||||||
},
|
|
||||||
buttonLabel: {
|
|
||||||
textAlign: 'center',
|
|
||||||
marginBottom: 0,
|
|
||||||
marginTop: 0
|
|
||||||
},
|
},
|
||||||
listItemText: {
|
listItemText: {
|
||||||
margin: '8px 0 8px 0'
|
margin: '8px 0 8px 0'
|
||||||
|
|
|
||||||
|
|
@ -34,10 +34,15 @@ const Dashboard = () => {
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</TitleSection>
|
</TitleSection>
|
||||||
|
|
||||||
<div className={classes.root}>
|
<div className={classes.root}>
|
||||||
<Grid container>
|
<Grid container>
|
||||||
<LeftSide />
|
<Grid container direction="column" item xs={6}>
|
||||||
<RightSide />
|
<LeftSide />
|
||||||
|
</Grid>
|
||||||
|
<Grid container direction="column" item xs={6}>
|
||||||
|
<RightSide />
|
||||||
|
</Grid>
|
||||||
</Grid>
|
</Grid>
|
||||||
</div>
|
</div>
|
||||||
<Footer />
|
<Footer />
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,7 @@ const styles = {
|
||||||
},
|
},
|
||||||
root: {
|
root: {
|
||||||
flexGrow: 1,
|
flexGrow: 1,
|
||||||
marginBottom: 108
|
display: 'flex'
|
||||||
},
|
},
|
||||||
footer: {
|
footer: {
|
||||||
margin: [['auto', 0, spacer * 3, 'auto']]
|
margin: [['auto', 0, spacer * 3, 'auto']]
|
||||||
|
|
@ -30,9 +30,8 @@ const styles = {
|
||||||
boxShadow: '0 0 4px 0 rgba(0, 0, 0, 0.08)',
|
boxShadow: '0 0 4px 0 rgba(0, 0, 0, 0.08)',
|
||||||
borderRadius: 12,
|
borderRadius: 12,
|
||||||
padding: 24,
|
padding: 24,
|
||||||
backgroundColor: white
|
backgroundColor: white,
|
||||||
},
|
flex: 1,
|
||||||
leftSideMargin: {
|
|
||||||
marginRight: 24
|
marginRight: 24
|
||||||
},
|
},
|
||||||
container: {
|
container: {
|
||||||
|
|
@ -56,24 +55,11 @@ const styles = {
|
||||||
marginLeft: spacer
|
marginLeft: spacer
|
||||||
},
|
},
|
||||||
alertsCard: {
|
alertsCard: {
|
||||||
marginBottom: 16
|
marginBottom: spacer
|
||||||
},
|
},
|
||||||
h4: {
|
h4: {
|
||||||
marginTop: 0
|
marginTop: 0
|
||||||
},
|
},
|
||||||
alertsTableMargin: {
|
|
||||||
marginTop: -30
|
|
||||||
},
|
|
||||||
alertsTableContainer: {
|
|
||||||
height: 220,
|
|
||||||
overflowX: 'hidden',
|
|
||||||
overflowY: 'auto'
|
|
||||||
},
|
|
||||||
expandedAlertsTableContainer: {
|
|
||||||
minHeight: 476,
|
|
||||||
overflowX: 'hidden',
|
|
||||||
overflowY: 'auto'
|
|
||||||
},
|
|
||||||
centerLabel: {
|
centerLabel: {
|
||||||
marginTop: 40,
|
marginTop: 40,
|
||||||
marginBottom: 0
|
marginBottom: 0
|
||||||
|
|
@ -81,6 +67,21 @@ const styles = {
|
||||||
notAlertsLabel: {
|
notAlertsLabel: {
|
||||||
marginTop: 40,
|
marginTop: 40,
|
||||||
color: comet
|
color: comet
|
||||||
|
},
|
||||||
|
systemStatusCard: {
|
||||||
|
flex: 1,
|
||||||
|
marginTop: spacer
|
||||||
|
},
|
||||||
|
expandedCard: {
|
||||||
|
flex: 0.9
|
||||||
|
},
|
||||||
|
shrunkCard: {
|
||||||
|
flex: 0.1
|
||||||
|
},
|
||||||
|
displayFlex: {
|
||||||
|
display: 'flex',
|
||||||
|
flex: 0.85,
|
||||||
|
flexDirection: 'column'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -39,7 +39,10 @@ const styles = {
|
||||||
content: {
|
content: {
|
||||||
width: 1200,
|
width: 1200,
|
||||||
backgroundColor: white,
|
backgroundColor: white,
|
||||||
zIndex: 1
|
zIndex: 1,
|
||||||
|
position: 'fixed',
|
||||||
|
bottom: -spacer,
|
||||||
|
transform: 'translateY(-100%)'
|
||||||
},
|
},
|
||||||
footerContainer: ({ expanded, bigFooter }) => ({
|
footerContainer: ({ expanded, bigFooter }) => ({
|
||||||
marginLeft: spacer * 5,
|
marginLeft: spacer * 5,
|
||||||
|
|
|
||||||
|
|
@ -11,12 +11,10 @@ const LeftSide = () => {
|
||||||
const classes = useStyles()
|
const classes = useStyles()
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Grid item xs={6}>
|
<Grid item xs={12} className={classes.displayFlex}>
|
||||||
<Grid item className={classes.leftSideMargin}>
|
<div className={classes.card}>
|
||||||
<div className={classes.card}>
|
<SystemPerformance />
|
||||||
<SystemPerformance />
|
</div>
|
||||||
</div>
|
|
||||||
</Grid>
|
|
||||||
</Grid>
|
</Grid>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
import Button from '@material-ui/core/Button'
|
import Button from '@material-ui/core/Button'
|
||||||
import Grid from '@material-ui/core/Grid'
|
import Grid from '@material-ui/core/Grid'
|
||||||
import { makeStyles } from '@material-ui/core/styles'
|
import { makeStyles } from '@material-ui/core/styles'
|
||||||
|
import classnames from 'classnames'
|
||||||
import React, { useState } from 'react'
|
import React, { useState } from 'react'
|
||||||
|
|
||||||
import CollapsibleCard, { cardState } from 'src/components/CollapsibleCard'
|
import CollapsibleCard, { cardState } from 'src/components/CollapsibleCard'
|
||||||
|
|
@ -17,18 +18,16 @@ const ShrunkCard = ({ title, buttonName, onUnshrink }) => {
|
||||||
return (
|
return (
|
||||||
<div className={classes.container}>
|
<div className={classes.container}>
|
||||||
<H4 className={classes.h4}>{title}</H4>
|
<H4 className={classes.h4}>{title}</H4>
|
||||||
<>
|
<Label1 className={classes.upperButtonLabel}>
|
||||||
<Label1 className={classes.upperButtonLabel}>
|
<Button
|
||||||
<Button
|
onClick={onUnshrink}
|
||||||
onClick={onUnshrink}
|
size="small"
|
||||||
size="small"
|
disableRipple
|
||||||
disableRipple
|
disableFocusRipple
|
||||||
disableFocusRipple
|
className={classes.button}>
|
||||||
className={classes.button}>
|
{buttonName}
|
||||||
{buttonName}
|
</Button>
|
||||||
</Button>
|
</Label1>
|
||||||
</Label1>
|
|
||||||
</>
|
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
@ -43,44 +42,57 @@ const RightSide = () => {
|
||||||
setSystemStatusSize(cardState.DEFAULT)
|
setSystemStatusSize(cardState.DEFAULT)
|
||||||
}
|
}
|
||||||
return (
|
return (
|
||||||
<Grid item xs={6}>
|
<Grid item xs={12} className={classes.displayFlex}>
|
||||||
<CollapsibleCard
|
<div style={{ flex: 1, display: 'flex', flexDirection: 'column' }}>
|
||||||
className={classes.alertsCard}
|
<>
|
||||||
state={alertsSize}
|
<CollapsibleCard
|
||||||
shrunkComponent={
|
className={classnames({
|
||||||
<ShrunkCard
|
[classes.alertsCard]: alertsSize !== cardState.SHRUNK,
|
||||||
title={'Alerts'}
|
[classes.shrunkCard]: alertsSize === cardState.SHRUNK,
|
||||||
buttonName={'Show alerts'}
|
[classes.expandedCard]: alertsSize === cardState.EXPANDED
|
||||||
onUnshrink={onReset}
|
})}
|
||||||
/>
|
state={alertsSize}
|
||||||
}>
|
shrunkComponent={
|
||||||
<Alerts
|
<ShrunkCard
|
||||||
onExpand={() => {
|
title={'Alerts'}
|
||||||
setAlertsSize(cardState.EXPANDED)
|
buttonName={'Show alerts'}
|
||||||
setSystemStatusSize(cardState.SHRUNK)
|
onUnshrink={onReset}
|
||||||
}}
|
/>
|
||||||
onReset={onReset}
|
}>
|
||||||
size={alertsSize}
|
<Alerts
|
||||||
/>
|
onExpand={() => {
|
||||||
</CollapsibleCard>
|
setAlertsSize(cardState.EXPANDED)
|
||||||
<CollapsibleCard
|
setSystemStatusSize(cardState.SHRUNK)
|
||||||
state={systemStatusSize}
|
}}
|
||||||
shrunkComponent={
|
onReset={onReset}
|
||||||
<ShrunkCard
|
size={alertsSize}
|
||||||
title={'System status'}
|
/>
|
||||||
buttonName={'Show machines'}
|
</CollapsibleCard>
|
||||||
onUnshrink={onReset}
|
<CollapsibleCard
|
||||||
/>
|
className={classnames({
|
||||||
}>
|
[classes.shrunkCard]: systemStatusSize === cardState.SHRUNK,
|
||||||
<SystemStatus
|
[classes.systemStatusCard]: systemStatusSize !== cardState.SHRUNK,
|
||||||
onExpand={() => {
|
[classes.expandedCard]: alertsSize === cardState.EXPANDED
|
||||||
setSystemStatusSize(cardState.EXPANDED)
|
})}
|
||||||
setAlertsSize(cardState.SHRUNK)
|
state={systemStatusSize}
|
||||||
}}
|
shrunkComponent={
|
||||||
onReset={onReset}
|
<ShrunkCard
|
||||||
size={systemStatusSize}
|
title={'System status'}
|
||||||
/>
|
buttonName={'Show machines'}
|
||||||
</CollapsibleCard>
|
onUnshrink={onReset}
|
||||||
|
/>
|
||||||
|
}>
|
||||||
|
<SystemStatus
|
||||||
|
onExpand={() => {
|
||||||
|
setSystemStatusSize(cardState.EXPANDED)
|
||||||
|
setAlertsSize(cardState.SHRUNK)
|
||||||
|
}}
|
||||||
|
onReset={onReset}
|
||||||
|
size={systemStatusSize}
|
||||||
|
/>
|
||||||
|
</CollapsibleCard>
|
||||||
|
</>
|
||||||
|
</div>
|
||||||
</Grid>
|
</Grid>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -48,6 +48,8 @@ const styles = {
|
||||||
},
|
},
|
||||||
newHighlightedLabel: {
|
newHighlightedLabel: {
|
||||||
cursor: 'pointer',
|
cursor: 'pointer',
|
||||||
|
color: primaryColor,
|
||||||
|
fontWeight: 700,
|
||||||
borderRadius: 0,
|
borderRadius: 0,
|
||||||
minHeight: 0,
|
minHeight: 0,
|
||||||
minWidth: 0,
|
minWidth: 0,
|
||||||
|
|
|
||||||
|
|
@ -37,7 +37,8 @@ const styles = {
|
||||||
textTransform: 'none',
|
textTransform: 'none',
|
||||||
'&:hover': {
|
'&:hover': {
|
||||||
backgroundColor: 'transparent'
|
backgroundColor: 'transparent'
|
||||||
}
|
},
|
||||||
|
marginBottom: -40
|
||||||
},
|
},
|
||||||
buttonLabel: {
|
buttonLabel: {
|
||||||
position: 'absolute',
|
position: 'absolute',
|
||||||
|
|
@ -76,11 +77,16 @@ const styles = {
|
||||||
},
|
},
|
||||||
machinesTableContainer: {
|
machinesTableContainer: {
|
||||||
marginTop: 10,
|
marginTop: 10,
|
||||||
height: 230
|
height: 220
|
||||||
},
|
},
|
||||||
expandedMachinesTableContainer: {
|
expandedMachinesTableContainer: {
|
||||||
marginTop: 10,
|
marginTop: 10,
|
||||||
height: 442
|
height: 414
|
||||||
|
},
|
||||||
|
centerLabel: {
|
||||||
|
marginBottom: 0,
|
||||||
|
padding: 0,
|
||||||
|
textAlign: 'center'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,7 @@ import styles from './MachinesTable.styles'
|
||||||
const useStyles = makeStyles(styles)
|
const useStyles = makeStyles(styles)
|
||||||
|
|
||||||
// number of machines in the table to render on page load
|
// number of machines in the table to render on page load
|
||||||
const NUM_TO_RENDER = 3
|
const NUM_TO_RENDER = 4
|
||||||
|
|
||||||
const GET_DATA = gql`
|
const GET_DATA = gql`
|
||||||
query getData {
|
query getData {
|
||||||
|
|
@ -112,22 +112,22 @@ const SystemStatus = ({ onReset, onExpand, size }) => {
|
||||||
numToRender={showAllItems ? Infinity : NUM_TO_RENDER}
|
numToRender={showAllItems ? Infinity : NUM_TO_RENDER}
|
||||||
machines={machines}
|
machines={machines}
|
||||||
/>
|
/>
|
||||||
{!showAllItems && machines.length > NUM_TO_RENDER && (
|
|
||||||
<>
|
|
||||||
<Label1 className={classes.buttonLabel}>
|
|
||||||
<Button
|
|
||||||
onClick={() => onExpand()}
|
|
||||||
size="small"
|
|
||||||
disableRipple
|
|
||||||
disableFocusRipple
|
|
||||||
className={classes.button}>
|
|
||||||
{`Show all (${machines.length})`}
|
|
||||||
</Button>
|
|
||||||
</Label1>
|
|
||||||
</>
|
|
||||||
)}
|
|
||||||
</Grid>
|
</Grid>
|
||||||
</Grid>
|
</Grid>
|
||||||
|
{!showAllItems && machines.length > NUM_TO_RENDER && (
|
||||||
|
<Grid item xs={12}>
|
||||||
|
<Label1 className={classes.centerLabel}>
|
||||||
|
<Button
|
||||||
|
onClick={() => onExpand()}
|
||||||
|
size="small"
|
||||||
|
disableRipple
|
||||||
|
disableFocusRipple
|
||||||
|
className={classes.button}>
|
||||||
|
{`Show all (${machines.length})`}
|
||||||
|
</Button>
|
||||||
|
</Label1>
|
||||||
|
</Grid>
|
||||||
|
)}
|
||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
</>
|
</>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue