Adrien Béraud | 21c53cf | 2021-04-22 00:04:32 -0400 | [diff] [blame^] | 1 | import React from 'react' |
| 2 | import { makeStyles } from '@material-ui/core/styles' |
| 3 | import { List, ListItem, ListItemIcon, ListItemSecondaryAction, ListItemText, ListSubheader, Switch, Typography, Grid, Paper, CardContent, Card, TableContainer, Table, TableHead, TableRow, TableCell, TableBody, Toolbar, IconButton, ListItemAvatar, Input, TextField } from '@material-ui/core' |
| 4 | import { PhoneCallbackRounded, GroupRounded, DeleteRounded, AccountCircle, AddCircle } from '@material-ui/icons' |
Adrien Béraud | 6ecaa40 | 2021-04-06 17:37:25 -0400 | [diff] [blame] | 5 | |
Adrien Béraud | 21c53cf | 2021-04-22 00:04:32 -0400 | [diff] [blame^] | 6 | import Account from '../../../model/Account' |
| 7 | import JamiIdCard from './JamiIdCard' |
| 8 | import ConversationAvatar from './ConversationAvatar' |
| 9 | import ConversationsOverviewCard from './ConversationsOverviewCard' |
Adrien Béraud | 6ecaa40 | 2021-04-06 17:37:25 -0400 | [diff] [blame] | 10 | |
Adrien Béraud | 21c53cf | 2021-04-22 00:04:32 -0400 | [diff] [blame^] | 11 | const useStyles = makeStyles(theme => ({ |
Adrien Béraud | 150b478 | 2021-04-21 19:40:59 -0400 | [diff] [blame] | 12 | root: { |
| 13 | minWidth: 275, |
| 14 | }, |
Adrien Béraud | 150b478 | 2021-04-21 19:40:59 -0400 | [diff] [blame] | 15 | title: { |
| 16 | fontSize: 14, |
Adrien Béraud | 21c53cf | 2021-04-22 00:04:32 -0400 | [diff] [blame^] | 17 | flexGrow: 1 |
Adrien Béraud | 150b478 | 2021-04-21 19:40:59 -0400 | [diff] [blame] | 18 | }, |
| 19 | pos: { |
| 20 | marginBottom: 12, |
| 21 | }, |
Adrien Béraud | 21c53cf | 2021-04-22 00:04:32 -0400 | [diff] [blame^] | 22 | paper: { |
| 23 | marginTop: 24, |
| 24 | marginBottom: 24 |
Adrien Béraud | 150b478 | 2021-04-21 19:40:59 -0400 | [diff] [blame] | 25 | }, |
Adrien Béraud | 21c53cf | 2021-04-22 00:04:32 -0400 | [diff] [blame^] | 26 | textField: { |
| 27 | //marginLeft: theme.spacing(1), |
| 28 | marginRight: theme.spacing(2), |
| 29 | } |
| 30 | })) |
Adrien Béraud | 150b478 | 2021-04-21 19:40:59 -0400 | [diff] [blame] | 31 | |
| 32 | export default function AccountPreferences(props) { |
| 33 | const classes = useStyles() |
| 34 | const account = props.account |
| 35 | const isJamiAccount = account.getType() === Account.TYPE_JAMI |
| 36 | const alias = isJamiAccount ? "Jami account" : "SIP account" |
Adrien Béraud | 21c53cf | 2021-04-22 00:04:32 -0400 | [diff] [blame^] | 37 | const moderators = account.getDefaultModerators() |
Adrien Béraud | 150b478 | 2021-04-21 19:40:59 -0400 | [diff] [blame] | 38 | return ( |
| 39 | <React.Fragment> |
| 40 | <Typography variant="h2" component="h2" gutterBottom>{alias}</Typography> |
Adrien Béraud | 21c53cf | 2021-04-22 00:04:32 -0400 | [diff] [blame^] | 41 | <Grid container spacing={3} style={{ marginBottom: 16 }}> |
Adrien Béraud | 150b478 | 2021-04-21 19:40:59 -0400 | [diff] [blame] | 42 | {isJamiAccount && |
| 43 | <Grid item xs={12}><JamiIdCard account={account} /></Grid>} |
| 44 | |
| 45 | <Grid item xs={12} sm={6}> |
| 46 | <ConversationsOverviewCard accountId={account.getId()} /> |
| 47 | </Grid> |
| 48 | |
| 49 | <Grid item xs={12} sm={6}> |
| 50 | <Card> |
| 51 | <CardContent> |
| 52 | <Typography className={classes.title} color="textSecondary" gutterBottom> |
| 53 | Current calls |
| 54 | </Typography> |
| 55 | <Typography gutterBottom variant="h5" component="h2"> |
| 56 | 0 |
| 57 | </Typography> |
| 58 | </CardContent> |
| 59 | </Card> |
| 60 | </Grid> |
| 61 | </Grid> |
| 62 | |
| 63 | <List subheader={<ListSubheader>Settings</ListSubheader>}> |
| 64 | <ListItem> |
| 65 | <ListItemIcon> |
| 66 | <GroupRounded /> |
| 67 | </ListItemIcon> |
| 68 | <ListItemText id="switch-list-label-rendezvous" primary="Rendez-Vous point" /> |
| 69 | <ListItemSecondaryAction> |
| 70 | <Switch |
| 71 | edge="end" |
| 72 | /*onChange={handleToggle('wifi')}*/ |
| 73 | checked={account.isRendezVous()} |
Adrien Béraud | 21c53cf | 2021-04-22 00:04:32 -0400 | [diff] [blame^] | 74 | inputProps={{ 'aria-labelledby': 'switch-list-label-rendezvous' }} |
Adrien Béraud | 150b478 | 2021-04-21 19:40:59 -0400 | [diff] [blame] | 75 | /> |
| 76 | </ListItemSecondaryAction> |
| 77 | </ListItem> |
| 78 | <ListItem> |
| 79 | <ListItemIcon> |
| 80 | <PhoneCallbackRounded /> |
| 81 | </ListItemIcon> |
| 82 | <ListItemText id="switch-list-label-publicin" primary="Allow connection from unkown peers" /> |
| 83 | <ListItemSecondaryAction> |
| 84 | <Switch |
| 85 | edge="end" |
| 86 | /*onChange={handleToggle('bluetooth')}*/ |
| 87 | checked={account.isPublicIn()} |
Adrien Béraud | 21c53cf | 2021-04-22 00:04:32 -0400 | [diff] [blame^] | 88 | inputProps={{ 'aria-labelledby': 'switch-list-label-publicin' }} |
Adrien Béraud | 150b478 | 2021-04-21 19:40:59 -0400 | [diff] [blame] | 89 | /> |
| 90 | </ListItemSecondaryAction> |
| 91 | </ListItem> |
Adrien Béraud | 21c53cf | 2021-04-22 00:04:32 -0400 | [diff] [blame^] | 92 | |
| 93 | <Paper className={classes.paper}> |
| 94 | <Toolbar> |
| 95 | <Typography className={classes.title} variant="h6"> |
| 96 | Default moderators |
| 97 | </Typography> |
| 98 | </Toolbar> |
| 99 | <List> |
| 100 | <ListItem key="add"> |
| 101 | <TextField variant="outlined" className={classes.textField} label="Add new default moderator" placeholder="Enter new moderator name or URI" fullWidth /> |
| 102 | <ListItemSecondaryAction> |
| 103 | <IconButton><AddCircle /></IconButton> |
| 104 | </ListItemSecondaryAction> |
| 105 | </ListItem> |
| 106 | {moderators.length === 0 ? |
| 107 | <ListItem key="placeholder"> |
| 108 | <ListItemText primary="No default moderator" /></ListItem> : |
| 109 | moderators.map((moderator) => ( |
| 110 | <ListItem key={moderator.name}> |
| 111 | <ListItemAvatar> |
| 112 | <ConversationAvatar name={moderator.name} /> |
| 113 | </ListItemAvatar> |
| 114 | <ListItemText primary={moderator.name} /> |
| 115 | <ListItemSecondaryAction> |
| 116 | <IconButton><DeleteRounded /></IconButton> |
| 117 | </ListItemSecondaryAction> |
| 118 | </ListItem> |
| 119 | ))} |
| 120 | </List> |
| 121 | </Paper> |
Adrien Béraud | 150b478 | 2021-04-21 19:40:59 -0400 | [diff] [blame] | 122 | </List> |
| 123 | |
Adrien Béraud | 150b478 | 2021-04-21 19:40:59 -0400 | [diff] [blame] | 124 | </React.Fragment>) |
| 125 | } |