Adrien Béraud | 6ecaa40 | 2021-04-06 17:37:25 -0400 | [diff] [blame] | 1 | import React from 'react'; |
Adrien Béraud | 150b478 | 2021-04-21 19:40:59 -0400 | [diff] [blame^] | 2 | import { makeStyles } from '@material-ui/core/styles'; |
| 3 | import { List, ListItem, ListItemIcon, ListItemSecondaryAction, ListItemText, ListSubheader, Switch, Typography, Grid, Paper, CardContent, Card } from '@material-ui/core'; |
| 4 | import { PhoneCallbackRounded, GroupRounded } from '@material-ui/icons'; |
Adrien Béraud | 6ecaa40 | 2021-04-06 17:37:25 -0400 | [diff] [blame] | 5 | |
| 6 | import JamiIdCard from './JamiIdCard'; |
Adrien Béraud | 6ecaa40 | 2021-04-06 17:37:25 -0400 | [diff] [blame] | 7 | import Account from '../../../model/Account'; |
Adrien Béraud | 150b478 | 2021-04-21 19:40:59 -0400 | [diff] [blame^] | 8 | import ConversationsOverviewCard from './ConversationsOverviewCard'; |
Adrien Béraud | 6ecaa40 | 2021-04-06 17:37:25 -0400 | [diff] [blame] | 9 | |
Adrien Béraud | 150b478 | 2021-04-21 19:40:59 -0400 | [diff] [blame^] | 10 | const useStyles = makeStyles({ |
| 11 | root: { |
| 12 | minWidth: 275, |
| 13 | }, |
| 14 | bullet: { |
| 15 | display: 'inline-block', |
| 16 | margin: '0 2px', |
| 17 | transform: 'scale(0.8)', |
| 18 | }, |
| 19 | title: { |
| 20 | fontSize: 14, |
| 21 | }, |
| 22 | pos: { |
| 23 | marginBottom: 12, |
| 24 | }, |
| 25 | }); |
Adrien Béraud | 6ecaa40 | 2021-04-06 17:37:25 -0400 | [diff] [blame] | 26 | |
Adrien Béraud | 150b478 | 2021-04-21 19:40:59 -0400 | [diff] [blame^] | 27 | const columns = [ |
| 28 | { id: 'name', label: 'Name', minWidth: 170 }, |
| 29 | { id: 'code', label: 'ISO\u00a0Code', minWidth: 100 }, |
| 30 | { |
| 31 | id: 'population', |
| 32 | label: 'Population', |
| 33 | minWidth: 170, |
| 34 | align: 'right', |
| 35 | format: (value) => value.toLocaleString('en-US'), |
| 36 | }, |
| 37 | { |
| 38 | id: 'size', |
| 39 | label: 'Size\u00a0(km\u00b2)', |
| 40 | minWidth: 170, |
| 41 | align: 'right', |
| 42 | format: (value) => value.toLocaleString('en-US'), |
| 43 | }, |
| 44 | { |
| 45 | id: 'density', |
| 46 | label: 'Density', |
| 47 | minWidth: 170, |
| 48 | align: 'right', |
| 49 | format: (value) => value.toFixed(2), |
| 50 | }, |
| 51 | ]; |
Adrien Béraud | 6ecaa40 | 2021-04-06 17:37:25 -0400 | [diff] [blame] | 52 | |
Adrien Béraud | 150b478 | 2021-04-21 19:40:59 -0400 | [diff] [blame^] | 53 | function createData(name, code, population, size) { |
| 54 | const density = population / size; |
| 55 | return { name, code, population, size, density }; |
Adrien Béraud | 6ecaa40 | 2021-04-06 17:37:25 -0400 | [diff] [blame] | 56 | } |
| 57 | |
Adrien Béraud | 150b478 | 2021-04-21 19:40:59 -0400 | [diff] [blame^] | 58 | const rows = [ |
| 59 | createData('India', 'IN', 1324171354, 3287263), |
| 60 | createData('China', 'CN', 1403500365, 9596961), |
| 61 | createData('Italy', 'IT', 60483973, 301340), |
| 62 | createData('United States', 'US', 327167434, 9833520), |
| 63 | createData('Canada', 'CA', 37602103, 9984670), |
| 64 | createData('Australia', 'AU', 25475400, 7692024), |
| 65 | createData('Germany', 'DE', 83019200, 357578), |
| 66 | createData('Ireland', 'IE', 4857000, 70273), |
| 67 | createData('Mexico', 'MX', 126577691, 1972550), |
| 68 | createData('Japan', 'JP', 126317000, 377973), |
| 69 | createData('France', 'FR', 67022000, 640679), |
| 70 | createData('United Kingdom', 'GB', 67545757, 242495), |
| 71 | createData('Russia', 'RU', 146793744, 17098246), |
| 72 | createData('Nigeria', 'NG', 200962417, 923768), |
| 73 | createData('Brazil', 'BR', 210147125, 8515767), |
| 74 | ]; |
| 75 | |
| 76 | export default function AccountPreferences(props) { |
| 77 | const classes = useStyles() |
| 78 | const account = props.account |
| 79 | const isJamiAccount = account.getType() === Account.TYPE_JAMI |
| 80 | const alias = isJamiAccount ? "Jami account" : "SIP account" |
| 81 | return ( |
| 82 | <React.Fragment> |
| 83 | <Typography variant="h2" component="h2" gutterBottom>{alias}</Typography> |
| 84 | <Grid container spacing={3} style={{marginBottom: 16}}> |
| 85 | {isJamiAccount && |
| 86 | <Grid item xs={12}><JamiIdCard account={account} /></Grid>} |
| 87 | |
| 88 | <Grid item xs={12} sm={6}> |
| 89 | <ConversationsOverviewCard accountId={account.getId()} /> |
| 90 | </Grid> |
| 91 | |
| 92 | <Grid item xs={12} sm={6}> |
| 93 | <Card> |
| 94 | <CardContent> |
| 95 | <Typography className={classes.title} color="textSecondary" gutterBottom> |
| 96 | Current calls |
| 97 | </Typography> |
| 98 | <Typography gutterBottom variant="h5" component="h2"> |
| 99 | 0 |
| 100 | </Typography> |
| 101 | </CardContent> |
| 102 | </Card> |
| 103 | </Grid> |
| 104 | </Grid> |
| 105 | |
| 106 | <List subheader={<ListSubheader>Settings</ListSubheader>}> |
| 107 | <ListItem> |
| 108 | <ListItemIcon> |
| 109 | <GroupRounded /> |
| 110 | </ListItemIcon> |
| 111 | <ListItemText id="switch-list-label-rendezvous" primary="Rendez-Vous point" /> |
| 112 | <ListItemSecondaryAction> |
| 113 | <Switch |
| 114 | edge="end" |
| 115 | /*onChange={handleToggle('wifi')}*/ |
| 116 | checked={account.isRendezVous()} |
| 117 | inputProps={{ 'aria-labelledby': 'switch-list-label-wifi' }} |
| 118 | /> |
| 119 | </ListItemSecondaryAction> |
| 120 | </ListItem> |
| 121 | <ListItem> |
| 122 | <ListItemIcon> |
| 123 | <PhoneCallbackRounded /> |
| 124 | </ListItemIcon> |
| 125 | <ListItemText id="switch-list-label-publicin" primary="Allow connection from unkown peers" /> |
| 126 | <ListItemSecondaryAction> |
| 127 | <Switch |
| 128 | edge="end" |
| 129 | /*onChange={handleToggle('bluetooth')}*/ |
| 130 | checked={account.isPublicIn()} |
| 131 | inputProps={{ 'aria-labelledby': 'switch-list-label-bluetooth' }} |
| 132 | /> |
| 133 | </ListItemSecondaryAction> |
| 134 | </ListItem> |
| 135 | </List> |
| 136 | |
| 137 | |
| 138 | |
| 139 | |
| 140 | |
| 141 | </React.Fragment>) |
| 142 | } |