diff --git a/frontend/src/basic/Main.tsx b/frontend/src/basic/Main.tsx index f9c4eeeb..725da394 100644 --- a/frontend/src/basic/Main.tsx +++ b/frontend/src/basic/Main.tsx @@ -112,19 +112,21 @@ const Main = ({ settings, setSettings }: MainProps): JSX.Element => { coordinatorVersion: versionInfo.coordinatorVersion, clientVersion: versionInfo.clientVersion, }); - setRobot({ - ...robot, - nickname: data.nickname, - loading: false, - activeOrderId: data.active_order_id ?? null, - lastOrderId: data.last_order_id ?? null, - referralCode: data.referral_code, - tgEnabled: data.tg_enabled, - tgBotName: data.tg_bot_name, - tgToken: data.tg_token, - earnedRewards: data.earned_rewards ?? 0, - stealthInvoices: data.wants_stealth, - }); + if (!robot.nickname) { + setRobot({ + ...robot, + nickname: data.nickname, + loading: false, + activeOrderId: data.active_order_id ?? null, + lastOrderId: data.last_order_id ?? null, + referralCode: data.referral_code, + tgEnabled: data.tg_enabled, + tgBotName: data.tg_bot_name, + tgToken: data.tg_token, + earnedRewards: data.earned_rewards ?? 0, + stealthInvoices: data.wants_stealth, + }); + } }); }; @@ -168,7 +170,7 @@ const Main = ({ settings, setSettings }: MainProps): JSX.Element => { path='/make' render={() => ( void; - orders: Order[]; + book: Book; fav: Favorites; maker: Maker; setFav: (state: Favorites) => void; @@ -24,7 +24,7 @@ interface MakerPageProps { const MakerPage = ({ limits, fetchLimits, - orders, + book, fav, maker, setFav, @@ -38,7 +38,7 @@ const MakerPage = ({ const [showMatches, setShowMatches] = useState(false); const matches = filterOrders({ - orders, + orders: book.orders, baseFilter: { currency: fav.currency === 0 ? 1 : fav.currency, type: fav.type }, paymentMethods: maker.paymentMethods, amountFilter: { @@ -59,15 +59,13 @@ const MakerPage = ({ 4 ? 4 : matches.length), - loading: false, - }} + book={book} maxWidth={Math.min(windowSize.width, 60)} // EM units - maxHeight={Math.min(matches.length * 3.25 + 3.575, 16.575)} // EM units + maxHeight={Math.min(matches.length * 3.25 + 3.25, 16)} // EM units defaultFullscreen={false} showControls={false} showFooter={false} + showNoResults={false} /> diff --git a/frontend/src/components/BookTable/index.tsx b/frontend/src/components/BookTable/index.tsx index 49310352..538f7bc3 100644 --- a/frontend/src/components/BookTable/index.tsx +++ b/frontend/src/components/BookTable/index.tsx @@ -45,6 +45,7 @@ interface Props { fillContainer?: boolean; showControls?: boolean; showFooter?: boolean; + showNoResults?: boolean; onCurrencyChange?: (e: any) => void; onTypeChange?: (mouseEvent: any, val: number) => void; } @@ -62,6 +63,7 @@ const BookTable = ({ fillContainer = false, showControls = true, showFooter = true, + showNoResults = true, onCurrencyChange, onTypeChange, }: Props): JSX.Element => { @@ -706,10 +708,12 @@ const BookTable = ({ const gridComponents = function () { const components: GridComponentProps = { LoadingOverlay: LinearProgress, - NoResultsOverlay, - NoRowsOverlay: NoResultsOverlay, }; + if (showNoResults) { + components.NoResultsOverlay = NoResultsOverlay; + components.NoRowsOverlay = NoResultsOverlay; + } if (showFooter) { components.Footer = Footer; } diff --git a/frontend/src/pro/Main.tsx b/frontend/src/pro/Main.tsx index bf9d2f87..065eddd3 100644 --- a/frontend/src/pro/Main.tsx +++ b/frontend/src/pro/Main.tsx @@ -1,6 +1,6 @@ import React, { useEffect, useRef, useState } from 'react'; import GridLayout, { Layout } from 'react-grid-layout'; -import { Grid, useTheme } from '@mui/material'; +import { Grid, styled, useTheme } from '@mui/material'; import { apiClient } from '../services/api'; import checkVer from '../utils/checkVer'; @@ -34,20 +34,36 @@ interface MainProps { setSettings: (state: Settings) => void; } +// To Do. Add dotted grid when layout is not frozen +// ${freeze ? +// `background: radial-gradient(${theme.palette.text.disabled} 1px, transparent 0px); +// background-size: ${gridCellSize}em ${gridCellSize}em; +// background-position: left 1em bottom 1.5em;` +// :''} + +const StyledRGL = styled(GridLayout)( + ({ theme, gridCellSize, height, width, freeze }) => ` + height: ${height}em; + width: ${width}px; + max-height: ${height}em; + `, +); + const Main = ({ settings, setSettings }: MainProps): JSX.Element => { const theme = useTheme(); - const em = theme.typography.fontSize; - const toolbarHeight = 3; + const em: number = theme.typography.fontSize; + const toolbarHeight: number = 3; + const gridCellSize: number = 2; const defaultLayout: Layout = [ - { i: 'Maker', w: 6, h: 13, x: 42, y: 0, minW: 6, maxW: 12, minH: 9, maxH: 18 }, - { i: 'Book', w: 27, h: 13, x: 21, y: 13, minW: 6, maxW: 40, minH: 9, maxH: 15 }, - { i: 'DepthChart', w: 8, h: 9, x: 13, y: 13, minW: 6, maxW: 12, minH: 9, maxH: 15 }, - { i: 'robots', w: 33, h: 13, x: 0, y: 0, minW: 15, maxW: 48, minH: 8, maxH: 20 }, - { i: 'history', w: 7, h: 9, x: 6, y: 13, minW: 6, maxW: 12, minH: 9, maxH: 15 }, - { i: 'trade', w: 9, h: 13, x: 33, y: 0, minW: 6, maxW: 12, minH: 9, maxH: 15 }, - { i: 'settings', w: 6, h: 13, x: 0, y: 13, minW: 6, maxW: 12, minH: 9, maxH: 15 }, - { i: 'other', w: 15, h: 4, x: 6, y: 22, minW: 2, maxW: 30, minH: 4, maxH: 15 }, + { i: 'Maker', w: 10, h: 16, x: 67, y: 0, minW: 8, maxW: 22, minH: 10, maxH: 28 }, + { i: 'Book', w: 43, h: 15, x: 34, y: 16, minW: 6, maxW: 70, minH: 9, maxH: 25 }, + { i: 'DepthChart', w: 15, h: 10, x: 19, y: 16, minW: 6, maxW: 22, minH: 9, maxH: 25 }, + { i: 'Garage', w: 52, h: 16, x: 0, y: 0, minW: 15, maxW: 78, minH: 8, maxH: 30 }, + { i: 'History', w: 10, h: 10, x: 9, y: 16, minW: 6, maxW: 22, minH: 9, maxH: 25 }, + { i: 'Trade', w: 15, h: 16, x: 52, y: 0, minW: 6, maxW: 22, minH: 9, maxH: 25 }, + { i: 'Settings', w: 9, h: 15, x: 0, y: 16, minW: 6, maxW: 22, minH: 9, maxH: 25 }, + { i: 'Other', w: 25, h: 5, x: 9, y: 26, minW: 2, maxW: 50, minH: 4, maxH: 25 }, ]; // All app data structured @@ -115,7 +131,8 @@ const Main = ({ settings, setSettings }: MainProps): JSX.Element => { }); }); }; - console.log(windowSize); + + console.log(layout); return ( @@ -124,15 +141,19 @@ const Main = ({ settings, setSettings }: MainProps): JSX.Element => { - setLayout(layout)} > @@ -150,6 +171,7 @@ const Main = ({ settings, setSettings }: MainProps): JSX.Element => { {
-
+
-
+
-
+
-
+
-
+
- + ); diff --git a/frontend/src/pro/Widgets/Book.tsx b/frontend/src/pro/Widgets/Book.tsx index 1ff6b1f4..dfe99e60 100644 --- a/frontend/src/pro/Widgets/Book.tsx +++ b/frontend/src/pro/Widgets/Book.tsx @@ -6,6 +6,7 @@ import BookTable from '../../components/BookTable'; interface BookWidgetProps { layout: any; + gridCellSize?: number; book: Book; fetchBook: () => void; fav: Favorites; @@ -22,6 +23,7 @@ const BookWidget = React.forwardRef( ( { layout, + gridCellSize = 2, book, fetchBook, fav, @@ -45,8 +47,8 @@ const BookWidget = React.forwardRef( book={book} fav={fav} fillContainer={true} - maxWidth={(windowSize.width / 48) * layout.w} // EM units - maxHeight={(layout.h * theme.typography.fontSize * 2.5) / theme.typography.fontSize} // EM units + maxWidth={layout.w * gridCellSize} // EM units + maxHeight={layout.h * gridCellSize} // EM units fullWidth={windowSize.width} // EM units fullHeight={windowSize.height} // EM units defaultFullscreen={false} diff --git a/frontend/src/pro/Widgets/Depth.tsx b/frontend/src/pro/Widgets/Depth.tsx index 59b834cd..c65afdee 100644 --- a/frontend/src/pro/Widgets/Depth.tsx +++ b/frontend/src/pro/Widgets/Depth.tsx @@ -6,6 +6,7 @@ import DepthChart from '../../components/Charts/DepthChart'; interface DepthChartWidgetProps { layout: any; + gridCellSize: number; orders: Order[]; currency: number; limitList: LimitList; @@ -21,6 +22,7 @@ const DepthChartWidget = React.forwardRef( ( { layout, + gridCellSize, limitList, orders, currency, @@ -42,8 +44,8 @@ const DepthChartWidget = React.forwardRef( orders={orders} currency={currency} limits={limitList} - maxWidth={(windowSize.width / 48) * layout.w} // EM units - maxHeight={(layout.h * theme.typography.fontSize * 2.5) / theme.typography.fontSize} // EM units + maxWidth={layout.w * gridCellSize} // EM units + maxHeight={layout.h * gridCellSize} // EM units fillContainer={true} />