diff --git a/frontend/components/TotalAssetsDetails.js b/frontend/components/TotalAssetsDetails.js new file mode 100644 index 000000000..48a6fec55 --- /dev/null +++ b/frontend/components/TotalAssetsDetails.js @@ -0,0 +1,81 @@ +import React from 'react'; +import CardContent from "@material-ui/core/CardContent"; +import Card from "@material-ui/core/Card"; +import {makeStyles} from "@material-ui/core/styles"; +import List from '@material-ui/core/List'; +import ListItem from '@material-ui/core/ListItem'; +import ListItemText from '@material-ui/core/ListItemText'; +import ListItemAvatar from '@material-ui/core/ListItemAvatar'; +import Avatar from '@material-ui/core/Avatar'; + +const useStyles = makeStyles((theme) => ({ + root: { + margin: theme.spacing(1), + }, + cardContent: {} +})); + +const logoCurrencies = { + "BTC": true, + "ETH": true, + "BCH": true, + "LTC": true, + "USDT": true, + "BNB": true, + "COMP": true, + "XRP": true, + "LINK": true, + "DOT": true, + "SXP": true, + "DAI": true, +} + +export default function TotalAssetsDetails({assets}) { + const classes = useStyles(); + + const sortedAssets = []; + for (let k in assets) { + sortedAssets.push(assets[k]); + } + sortedAssets.sort((a, b) => { + if (a.inUSD > b.inUSD) { + return -1 + } + + if (a.inUSD < b.inUSD) { + return 1 + } + + return 0; + }) + + const items = sortedAssets.map((a) => { + return ( + + { + (a.currency in logoCurrencies) ? ( + + + + ) : ( + + + + ) + } + + + ) + }) + + return ( + + + + {items} + + + + ); + +} diff --git a/frontend/components/TotalAssetsPie.js b/frontend/components/TotalAssetsPie.js index 13059ae43..48f58bbb5 100644 --- a/frontend/components/TotalAssetsPie.js +++ b/frontend/components/TotalAssetsPie.js @@ -3,6 +3,9 @@ import React, {useEffect, useState} from 'react'; import {ResponsivePie} from '@nivo/pie'; import {queryAssets} from '../api/bbgo'; import {currencyColor} from '../src/utils'; +import CardContent from "@material-ui/core/CardContent"; +import Card from "@material-ui/core/Card"; +import {makeStyles} from "@material-ui/core/styles"; function reduceAssetsBy(assets, field, minimum) { let as = [] @@ -29,55 +32,64 @@ function reduceAssetsBy(assets, field, minimum) { return as } -export default function TotalAssetsPie() { - const [assets, setAssets] = useState({}) +const useStyles = makeStyles((theme) => ({ + root: { + margin: theme.spacing(1), + }, + cardContent: { + height: 350, + } +})); - useEffect(() => { - queryAssets((assets) => { - setAssets(assets) - }) - }, []) - - return + + + ]} + /> + + + ); + } diff --git a/frontend/components/TotalAssetsSummary.js b/frontend/components/TotalAssetsSummary.js index 59179ef8e..6ddf14230 100644 --- a/frontend/components/TotalAssetsSummary.js +++ b/frontend/components/TotalAssetsSummary.js @@ -1,5 +1,4 @@ import {useEffect, useState} from "react"; -import {queryAssets} from "../api/bbgo"; import Card from '@material-ui/core/Card'; import CardContent from '@material-ui/core/CardContent'; import Typography from '@material-ui/core/Typography'; @@ -19,18 +18,8 @@ function aggregateAssetsBy(assets, field) { } const useStyles = makeStyles((theme) => ({ - paper: { - marginTop: theme.spacing(3), - marginBottom: theme.spacing(3), - padding: theme.spacing(2), - }, root: { - minWidth: 275, - }, - bullet: { - display: 'inline-block', - margin: '0 2px', - transform: 'scale(0.8)', + margin: theme.spacing(1), }, title: { fontSize: 14, @@ -40,16 +29,8 @@ const useStyles = makeStyles((theme) => ({ }, })); -export default function TotalAssetSummary() { +export default function TotalAssetSummary({ assets }) { const classes = useStyles(); - const [assets, setAssets] = useState({}) - - useEffect(() => { - queryAssets((assets) => { - setAssets(assets) - }) - }, []) - return diff --git a/frontend/pages/index.tsx b/frontend/pages/index.tsx index 616faa460..d66344fa6 100644 --- a/frontend/pages/index.tsx +++ b/frontend/pages/index.tsx @@ -1,4 +1,4 @@ -import React from 'react'; +import React, {useState} from 'react'; import {useRouter} from 'next/router'; import {makeStyles} from '@material-ui/core/styles'; @@ -9,26 +9,23 @@ import Paper from '@material-ui/core/Paper'; import TotalAssetsPie from '../components/TotalAssetsPie'; import TotalAssetSummary from '../components/TotalAssetsSummary'; +import TotalAssetDetails from '../components/TotalAssetsDetails'; import TradingVolumePanel from '../components/TradingVolumePanel'; import ExchangeSessionTabPanel from '../components/ExchangeSessionTabPanel'; import DashboardLayout from '../layouts/DashboardLayout'; -import {querySessions} from "../api/bbgo"; +import {queryAssets, querySessions} from "../api/bbgo"; const useStyles = makeStyles((theme) => ({ - paper: { - height: 140, - width: 200, - }, - totalAssetsBox: { - height: 300, - }, totalAssetsSummary: { margin: theme.spacing(2), padding: theme.spacing(2), }, + grid: { + flexGrow: 1, + }, control: { padding: theme.spacing(2), }, @@ -40,12 +37,14 @@ export default function Home() { const classes = useStyles(); const router = useRouter(); + const [assets, setAssets] = useState({}) const [sessions, setSessions] = React.useState([]) React.useEffect(() => { querySessions((sessions) => { if (sessions && sessions.length > 0) { setSessions(sessions) + queryAssets(setAssets) } else { router.push("/setup"); } @@ -66,6 +65,8 @@ export default function Home() { ); } + console.log("index: assets", assets) + return ( @@ -73,17 +74,25 @@ export default function Home() { Total Assets - - - - +
+ + + + - - - - + + + + + + + - +
diff --git a/frontend/public/images/bch-logo.svg b/frontend/public/images/bch-logo.svg new file mode 100644 index 000000000..127da329c --- /dev/null +++ b/frontend/public/images/bch-logo.svg @@ -0,0 +1,18 @@ + + + + + + + + + diff --git a/frontend/public/images/bnb-logo.svg b/frontend/public/images/bnb-logo.svg new file mode 100644 index 000000000..91a66e05f --- /dev/null +++ b/frontend/public/images/bnb-logo.svg @@ -0,0 +1 @@ +bi \ No newline at end of file diff --git a/frontend/public/images/btc-logo.svg b/frontend/public/images/btc-logo.svg new file mode 100644 index 000000000..2b75c99bc --- /dev/null +++ b/frontend/public/images/btc-logo.svg @@ -0,0 +1,15 @@ + + + + + + + + + + + + diff --git a/frontend/public/images/comp-logo.svg b/frontend/public/images/comp-logo.svg new file mode 100644 index 000000000..0face3c9d --- /dev/null +++ b/frontend/public/images/comp-logo.svg @@ -0,0 +1,16 @@ + + + + + + + diff --git a/frontend/public/images/dai-logo.svg b/frontend/public/images/dai-logo.svg new file mode 100644 index 000000000..2ae2e32ff --- /dev/null +++ b/frontend/public/images/dai-logo.svg @@ -0,0 +1,13 @@ + + + + + + + + + + diff --git a/frontend/public/images/dot-logo.svg b/frontend/public/images/dot-logo.svg new file mode 100644 index 000000000..89d0e71a0 --- /dev/null +++ b/frontend/public/images/dot-logo.svg @@ -0,0 +1,20 @@ + + + + +polkadot + + + diff --git a/frontend/public/images/eth-logo.svg b/frontend/public/images/eth-logo.svg new file mode 100644 index 000000000..684e96873 --- /dev/null +++ b/frontend/public/images/eth-logo.svg @@ -0,0 +1,21 @@ + + + + + + + + + + + + + + + + + + diff --git a/frontend/public/images/link-logo.svg b/frontend/public/images/link-logo.svg new file mode 100644 index 000000000..bf4cd5374 --- /dev/null +++ b/frontend/public/images/link-logo.svg @@ -0,0 +1 @@ +Asset 1 \ No newline at end of file diff --git a/frontend/public/images/ltc-logo.svg b/frontend/public/images/ltc-logo.svg new file mode 100644 index 000000000..13e76a40e --- /dev/null +++ b/frontend/public/images/ltc-logo.svg @@ -0,0 +1 @@ +litecoin-ltc-logo \ No newline at end of file diff --git a/frontend/public/images/sxp-logo.svg b/frontend/public/images/sxp-logo.svg new file mode 100644 index 000000000..27a498349 --- /dev/null +++ b/frontend/public/images/sxp-logo.svg @@ -0,0 +1 @@ +Asset 2 \ No newline at end of file diff --git a/frontend/public/images/usdt-logo.svg b/frontend/public/images/usdt-logo.svg new file mode 100644 index 000000000..e53082240 --- /dev/null +++ b/frontend/public/images/usdt-logo.svg @@ -0,0 +1 @@ +tether-usdt-logo \ No newline at end of file diff --git a/frontend/public/images/xrp-logo.svg b/frontend/public/images/xrp-logo.svg new file mode 100644 index 000000000..9a2c7c632 --- /dev/null +++ b/frontend/public/images/xrp-logo.svg @@ -0,0 +1 @@ +x \ No newline at end of file