robosats/frontend/src/components/BottomBar.js

191 lines
7.6 KiB
JavaScript
Raw Normal View History

2022-01-14 16:21:42 +00:00
import React, { Component } from 'react'
2022-01-15 00:28:19 +00:00
import {Paper, Grid, IconButton, Typography, Select, MenuItem, List, ListItemText, ListItem, ListItemIcon, Divider, Dialog, DialogContent} from "@mui/material";
2022-01-14 16:21:42 +00:00
// Icons
import SettingsIcon from '@mui/icons-material/Settings';
import SupportAgentIcon from '@mui/icons-material/SupportAgent';
import InventoryIcon from '@mui/icons-material/Inventory';
import SellIcon from '@mui/icons-material/Sell';
import SmartToyIcon from '@mui/icons-material/SmartToy';
import PercentIcon from '@mui/icons-material/Percent';
2022-01-14 17:35:27 +00:00
import PriceChangeIcon from '@mui/icons-material/PriceChange';
2022-01-15 00:28:19 +00:00
import BoltIcon from '@mui/icons-material/Bolt';
import GitHubIcon from '@mui/icons-material/GitHub';
import EqualizerIcon from '@mui/icons-material/Equalizer';
2022-01-14 16:21:42 +00:00
export default class BottomBar extends Component {
constructor(props) {
super(props);
this.state = {
2022-01-15 00:28:19 +00:00
openStatsForNerds: false,
2022-01-14 17:35:27 +00:00
num_public_buy_orders: null,
num_active_robotsats: null,
num_public_sell_orders: null,
fee: null,
today_avg_nonkyc_btc_premium: null,
today_volume: null,
2022-01-14 16:21:42 +00:00
};
this.getInfo();
}
handleClickSuppport = () => {
window.open("https://t.me/robosats");
};
getInfo() {
this.setState(null)
fetch('/api/info/')
.then((response) => response.json())
.then((data) => {console.log(data) &
this.setState(data)
});
}
2022-01-15 00:28:19 +00:00
handleClickOpenStatsForNerds = () => {
this.setState({openStatsForNerds: true});
};
handleClickCloseStatsForNerds = () => {
this.setState({openStatsForNerds: false});
};
StatsDialog =() =>{
return(
<Dialog
open={this.state.openStatsForNerds}
onClose={this.handleClickCloseStatsForNerds}
aria-labelledby="stats-for-nerds-dialog-title"
aria-describedby="stats-for-nerds-description"
>
<DialogContent>
<Typography component="h5" variant="h5">Stats For Nerds</Typography>
<List>
<Divider/>
<ListItem>
<ListItemIcon><BoltIcon/></ListItemIcon>
<ListItemText primary={this.state.lnd_version} secondary="LND version"/>
</ListItem>
<Divider/>
<ListItem>
<ListItemIcon><GitHubIcon/></ListItemIcon>
<ListItemText secondary="Currently running commit height">
<a href={"https://github.com/Reckless-Satoshi/robosats/tree/"
+ this.state.robosats_running_commit_hash}>{this.state.robosats_running_commit_hash}
</a>
</ListItemText>
</ListItem>
<Divider/>
<ListItem>
<ListItemIcon><EqualizerIcon/></ListItemIcon>
<ListItemText primary={this.state.today_volume} secondary="Today traded volume"/>
</ListItem>
</List>
</DialogContent>
</Dialog>
)
}
2022-01-14 16:21:42 +00:00
render() {
return (
<Paper elevation={6} style={{height:40}}>
2022-01-15 00:28:19 +00:00
<this.StatsDialog/>
2022-01-14 16:21:42 +00:00
<Grid container xs={12}>
2022-01-14 17:35:27 +00:00
2022-01-14 16:21:42 +00:00
<Grid item xs={1}>
2022-01-15 00:28:19 +00:00
<IconButton color="primary"
aria-label="Stats for Nerds"
onClick={this.handleClickOpenStatsForNerds} >
2022-01-14 16:21:42 +00:00
<SettingsIcon />
</IconButton>
</Grid>
2022-01-14 17:35:27 +00:00
2022-01-14 16:21:42 +00:00
<Grid item xs={2}>
<ListItem className="bottomItem">
<ListItemIcon size="small">
<InventoryIcon/>
</ListItemIcon>
<ListItemText
primaryTypographyProps={{fontSize: '14px'}}
secondaryTypographyProps={{fontSize: '12px'}}
primary={this.state.num_public_buy_orders}
secondary="Public Buy Orders" />
</ListItem>
</Grid>
2022-01-14 17:35:27 +00:00
2022-01-14 16:21:42 +00:00
<Grid item xs={2}>
<ListItem className="bottomItem">
<ListItemIcon size="small">
<SellIcon/>
</ListItemIcon>
<ListItemText
primaryTypographyProps={{fontSize: '14px'}}
secondaryTypographyProps={{fontSize: '12px'}}
primary={this.state.num_public_sell_orders}
secondary="Public Sell Orders" />
</ListItem>
</Grid>
2022-01-14 17:35:27 +00:00
2022-01-14 16:21:42 +00:00
<Grid item xs={2}>
<ListItem className="bottomItem">
<ListItemIcon size="small">
<SmartToyIcon/>
</ListItemIcon>
<ListItemText
primaryTypographyProps={{fontSize: '14px'}}
secondaryTypographyProps={{fontSize: '12px'}}
primary={this.state.num_active_robotsats}
secondary="Num Active RoboSats" />
</ListItem>
</Grid>
2022-01-14 17:35:27 +00:00
2022-01-14 16:21:42 +00:00
<Grid item xs={2}>
<ListItem className="bottomItem">
<ListItemIcon size="small">
2022-01-14 17:35:27 +00:00
<PriceChangeIcon/>
2022-01-14 16:21:42 +00:00
</ListItemIcon>
<ListItemText
primaryTypographyProps={{fontSize: '14px'}}
secondaryTypographyProps={{fontSize: '12px'}}
primary={this.state.today_avg_nonkyc_btc_premium}
secondary="Today Avg Premium" />
</ListItem>
</Grid>
2022-01-14 17:35:27 +00:00
<Grid item xs={2}>
<ListItem className="bottomItem">
<ListItemIcon size="small">
<PercentIcon/>
</ListItemIcon>
<ListItemText
primaryTypographyProps={{fontSize: '14px'}}
secondaryTypographyProps={{fontSize: '12px'}}
primary={this.state.fee*100}
secondary="Trading Fee" />
</ListItem>
</Grid>
2022-01-14 16:21:42 +00:00
<Grid container item xs={1}>
<Grid item xs={2}/>
<Grid item xs={6}>
<Select
size = 'small'
defaultValue={1}
inputProps={{
style: {textAlign:"center"}
}}>
<MenuItem value={1}>EN</MenuItem>
</Select>
</Grid>
<Grid item xs={4}>
<IconButton color="primary" aria-label="Telegram" onClick={this.handleClickSuppport}>
<SupportAgentIcon />
</IconButton>
</Grid>
2022-01-14 17:35:27 +00:00
2022-01-14 16:21:42 +00:00
</Grid>
</Grid>
</Paper>
)
}
}