From b35abca622ac2c596c3217b85be86f37e3ddc2b3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9rgio=20Salgado?= Date: Thu, 2 Dec 2021 17:30:50 +0000 Subject: [PATCH] feat: add dashboard states for empty transactions and empty machine list --- .../src/components/table/EmptyTable.js | 5 +- .../src/pages/Dashboard/Dashboard.js | 117 +++++++++++++----- .../src/pages/Dashboard/Dashboard.styles.js | 33 ++++- .../pages/Dashboard/SystemPerformance/Nav.js | 36 +++--- .../SystemPerformance/SystemPerformance.js | 14 ++- .../SystemPerformance.styles.js | 3 + 6 files changed, 155 insertions(+), 53 deletions(-) diff --git a/new-lamassu-admin/src/components/table/EmptyTable.js b/new-lamassu-admin/src/components/table/EmptyTable.js index 270bbc7b..a7d991de 100644 --- a/new-lamassu-admin/src/components/table/EmptyTable.js +++ b/new-lamassu-admin/src/components/table/EmptyTable.js @@ -1,4 +1,5 @@ import { makeStyles } from '@material-ui/core' +import classNames from 'classnames' import React, { memo } from 'react' import { H4 } from 'src/components/typography' @@ -16,11 +17,11 @@ const styles = { const useStyles = makeStyles(styles) -const EmptyTable = memo(({ message }) => { +const EmptyTable = memo(({ message, className }) => { const classes = useStyles() return ( -
+

{message}

diff --git a/new-lamassu-admin/src/pages/Dashboard/Dashboard.js b/new-lamassu-admin/src/pages/Dashboard/Dashboard.js index 5d4997de..d446593c 100644 --- a/new-lamassu-admin/src/pages/Dashboard/Dashboard.js +++ b/new-lamassu-admin/src/pages/Dashboard/Dashboard.js @@ -1,9 +1,16 @@ +import { useQuery } from '@apollo/react-hooks' import Grid from '@material-ui/core/Grid' import { makeStyles } from '@material-ui/core/styles' import classnames from 'classnames' -import React from 'react' +import gql from 'graphql-tag' +import * as R from 'ramda' +import React, { useState } from 'react' +import { useHistory } from 'react-router-dom' +import { Button } from 'src/components/buttons' import TitleSection from 'src/components/layout/TitleSection' +import { H1, Info2, TL2, Label1 } from 'src/components/typography' +import AddMachine from 'src/pages/AddMachine' import { ReactComponent as TxInIcon } from 'src/styling/icons/direction/cash-in.svg' import { ReactComponent as TxOutIcon } from 'src/styling/icons/direction/cash-out.svg' @@ -13,40 +20,88 @@ import LeftSide from './LeftSide' import RightSide from './RightSide' const useStyles = makeStyles(styles) -const Dashboard = () => { - const classes = useStyles() +const GET_DATA = gql` + query getData { + machines { + name + } + serverVersion + } +` - return ( - <> - -
-
- - Cash-out +const Dashboard = () => { + const history = useHistory() + const classes = useStyles() + const [open, setOpen] = useState(false) + + const { data, loading } = useQuery(GET_DATA) + + const onPaired = machine => { + setOpen(false) + history.push('/maintenance/machine-status', { id: machine.deviceId }) + } + + return !loading ? ( + !R.isEmpty(data.machines) ? ( + <> + +
+ <> +
+ + Cash-out +
+
+ + Cash-in +
+
-
- - Cash-in + +
+ + + + + + + + +
+
+ + ) : ( + <> + {open && ( + setOpen(false)} onPaired={onPaired} /> + )} + +
+ + {data?.serverVersion}{' '} + server version + +
+
+
+
+

No machines on your system yet

+ + To fully take advantage of Lamassu Admin, add a new machine to + your system + +
- - -
- - - - - - - - -
-
- +
+ + ) + ) : ( + <> ) } diff --git a/new-lamassu-admin/src/pages/Dashboard/Dashboard.styles.js b/new-lamassu-admin/src/pages/Dashboard/Dashboard.styles.js index f83fc58c..6526c4a4 100644 --- a/new-lamassu-admin/src/pages/Dashboard/Dashboard.styles.js +++ b/new-lamassu-admin/src/pages/Dashboard/Dashboard.styles.js @@ -1,5 +1,12 @@ import typographyStyles from 'src/components/typography/styles' -import { spacer, white, primaryColor } from 'src/styling/variables' +import { + spacer, + white, + primaryColor, + zircon, + zircon2, + offDarkColor +} from 'src/styling/variables' const { label1 } = typographyStyles const styles = { @@ -23,6 +30,11 @@ const styles = { display: 'flex', marginBottom: 120 }, + emptyMachinesRoot: { + height: 300, + backgroundColor: zircon, + border: `solid 2px ${zircon2}` + }, card: { wordWrap: 'break-word', boxShadow: '0 0 4px 0 rgba(0, 0, 0, 0.08)', @@ -75,6 +87,25 @@ const styles = { displayFlex: { display: 'flex', flexDirection: 'column' + }, + inline: { + display: 'inline' + }, + emptyMachinesContent: { + display: 'flex', + flexDirection: 'column', + height: '100%', + justifyContent: 'center', + alignItems: 'center', + '& > :first-child': { + marginTop: 0 + }, + '& > *': { + marginTop: 25 + } + }, + offColor: { + color: offDarkColor } } diff --git a/new-lamassu-admin/src/pages/Dashboard/SystemPerformance/Nav.js b/new-lamassu-admin/src/pages/Dashboard/SystemPerformance/Nav.js index 04c9bd7a..07f76fe4 100644 --- a/new-lamassu-admin/src/pages/Dashboard/SystemPerformance/Nav.js +++ b/new-lamassu-admin/src/pages/Dashboard/SystemPerformance/Nav.js @@ -10,7 +10,7 @@ import styles from './SystemPerformance.styles' const useStyles = makeStyles(styles) const ranges = ['Month', 'Week', 'Day'] -const Nav = ({ handleSetRange }) => { +const Nav = ({ handleSetRange, showPicker }) => { const classes = useStyles() const [clickedItem, setClickedItem] = useState('Day') @@ -25,22 +25,24 @@ const Nav = ({ handleSetRange }) => {

{'System performance'}

-
- {ranges.map((it, idx) => { - return ( -
handleClick(e.target.innerText)} - className={ - isSelected(it) - ? classnames(classes.newHighlightedLabel, classes.navButton) - : classnames(classes.label, classes.navButton) - }> - {it} -
- ) - })} -
+ {showPicker && ( +
+ {ranges.map((it, idx) => { + return ( +
handleClick(e.target.innerText)} + className={ + isSelected(it) + ? classnames(classes.newHighlightedLabel, classes.navButton) + : classnames(classes.label, classes.navButton) + }> + {it} +
+ ) + })} +
+ )}
) } diff --git a/new-lamassu-admin/src/pages/Dashboard/SystemPerformance/SystemPerformance.js b/new-lamassu-admin/src/pages/Dashboard/SystemPerformance/SystemPerformance.js index 21610885..500c1bd8 100644 --- a/new-lamassu-admin/src/pages/Dashboard/SystemPerformance/SystemPerformance.js +++ b/new-lamassu-admin/src/pages/Dashboard/SystemPerformance/SystemPerformance.js @@ -8,6 +8,7 @@ import gql from 'graphql-tag' import * as R from 'ramda' import React, { useState } from 'react' +import { EmptyTable } from 'src/components/table' import { Label1, Label2 } from 'src/components/typography/index' import { ReactComponent as PercentDownIcon } from 'src/styling/icons/dashboard/down.svg' import { ReactComponent as PercentNeutralIcon } from 'src/styling/icons/dashboard/equal.svg' @@ -171,8 +172,17 @@ const SystemPerformance = () => { return ( <> -