frontend: run prettier

This commit is contained in:
ycdesu 2022-06-14 15:33:22 +08:00
parent 258675b93a
commit 19dfd6d219
3 changed files with 25 additions and 28 deletions

View File

@ -16,15 +16,17 @@ export function queryOutboundIP(cb) {
} }
const triggerSync = async () => { const triggerSync = async () => {
return axios.post<any>(baseURL + '/api/environment/sync') return axios.post<any>(baseURL + '/api/environment/sync');
} };
export { triggerSync }; export { triggerSync };
export function querySyncStatus(cb) { export function querySyncStatus(cb) {
return axios.get<any>(baseURL + '/api/environment/syncing').then((response) => { return axios
cb(response.data.syncing); .get<any>(baseURL + '/api/environment/syncing')
}); .then((response) => {
cb(response.data.syncing);
});
} }
export function testDatabaseConnection(params, cb) { export function testDatabaseConnection(params, cb) {
@ -99,9 +101,11 @@ export function querySessionSymbols(sessionName, cb) {
} }
export function queryTrades(params, cb) { export function queryTrades(params, cb) {
axios.get<any>(baseURL + '/api/trades', { params: params }).then((response) => { axios
cb(response.data.trades || []); .get<any>(baseURL + '/api/trades', { params: params })
}); .then((response) => {
cb(response.data.trades || []);
});
} }
export function queryClosedOrders(params, cb) { export function queryClosedOrders(params, cb) {

View File

@ -9,9 +9,9 @@ import Container from '@mui/material/Container';
import SideBar from '../components/SideBar'; import SideBar from '../components/SideBar';
import ConnectWallet from '../components/ConnectWallet'; import ConnectWallet from '../components/ConnectWallet';
import { Box } from "@mui/material"; import { Box } from '@mui/material';
import {throttle} from "../src/utils"; import { throttle } from '../src/utils';
import {triggerSync} from "../api/bbgo"; import { triggerSync } from '../api/bbgo';
const useStyles = makeStyles((theme) => ({ const useStyles = makeStyles((theme) => ({
root: { root: {
@ -30,26 +30,19 @@ const useStyles = makeStyles((theme) => ({
container: {}, container: {},
toolbar: { toolbar: {
justifyContent: 'space-between', justifyContent: 'space-between',
} },
})); }));
const ToolbarButton = styled('button')(({ theme }) => ({ const ToolbarButton = styled('button')(({ theme }) => ({
padding: theme.spacing(1) padding: theme.spacing(1),
}) }));
)
function SyncButton() { function SyncButton() {
const handleClick = throttle(async () => { const handleClick = throttle(async () => {
await triggerSync() await triggerSync();
}, 2000) }, 2000);
return ( return <ToolbarButton onClick={handleClick}>Sync</ToolbarButton>;
<ToolbarButton
onClick={handleClick}
>
Sync
</ToolbarButton>
);
} }
export default function DashboardLayout({ children }) { export default function DashboardLayout({ children }) {

View File

@ -29,9 +29,9 @@ export function throttle(fn, delayMillis) {
let permitted = true; let permitted = true;
return () => { return () => {
if (permitted) { if (permitted) {
fn.apply(this, arguments) fn.apply(this, arguments);
permitted = false permitted = false;
setTimeout(() => permitted = true, delayMillis) setTimeout(() => (permitted = true), delayMillis);
} }
} };
} }