Fixing the join dialog.

master
Håvar Aambø Fosstveit 2019-11-01 14:22:29 +01:00
parent 10228a9f8c
commit 5d1a38d978
2 changed files with 169 additions and 89 deletions

View File

@ -1,19 +1,22 @@
import React from 'react'; import React, { useState, useEffect } from 'react';
import { connect } from 'react-redux'; import { connect } from 'react-redux';
import { withStyles } from '@material-ui/core/styles'; import { withStyles } from '@material-ui/core/styles';
import { withRoomContext } from '../RoomContext'; import { withRoomContext } from '../RoomContext';
import * as stateActions from '../actions/stateActions'; import * as stateActions from '../actions/stateActions';
import PropTypes from 'prop-types'; import PropTypes from 'prop-types';
import Dialog from '@material-ui/core/Dialog'; import Dialog from '@material-ui/core/Dialog';
import DialogTitle from '@material-ui/core/DialogTitle'; import DialogContentText from '@material-ui/core/DialogContentText';
import IconButton from '@material-ui/core/IconButton'; import IconButton from '@material-ui/core/IconButton';
import AccountCircle from '@material-ui/icons/AccountCircle'; import AccountCircle from '@material-ui/icons/AccountCircle';
import Avatar from '@material-ui/core/Avatar'; import Avatar from '@material-ui/core/Avatar';
import Typography from '@material-ui/core/Typography'; import Typography from '@material-ui/core/Typography';
import DialogActions from '@material-ui/core/DialogActions';
import Button from '@material-ui/core/Button'; import Button from '@material-ui/core/Button';
import TextField from '@material-ui/core/TextField'; import TextField from '@material-ui/core/TextField';
import Tooltip from '@material-ui/core/Tooltip';
import CookieConsent from 'react-cookie-consent'; import CookieConsent from 'react-cookie-consent';
import MuiDialogTitle from '@material-ui/core/DialogTitle';
import MuiDialogContent from '@material-ui/core/DialogContent';
import MuiDialogActions from '@material-ui/core/DialogActions';
const styles = (theme) => const styles = (theme) =>
({ ({
@ -29,54 +32,134 @@ const styles = (theme) =>
backgroundSize : 'cover', backgroundSize : 'cover',
backgroundRepeat : 'no-repeat' backgroundRepeat : 'no-repeat'
}, },
dialogTitle :
{
},
dialogPaper : dialogPaper :
{ {
width : '20vw', width : '30vw',
padding : theme.spacing(2), padding : theme.spacing(2),
[theme.breakpoints.down('lg')] : [theme.breakpoints.down('lg')] :
{ {
width : '30vw' width : '40vw'
}, },
[theme.breakpoints.down('md')] : [theme.breakpoints.down('md')] :
{ {
width : '40vw' width : '50vw'
}, },
[theme.breakpoints.down('sm')] : [theme.breakpoints.down('sm')] :
{ {
width : '60vw' width : '70vw'
}, },
[theme.breakpoints.down('xs')] : [theme.breakpoints.down('xs')] :
{ {
width : '80vw' width : '90vw'
} }
}, },
title :
{
position : 'relative',
alignItems : 'center',
display : 'flex',
marginLeft : 0
},
actionButtons :
{
right : 0,
position : 'absolute'
},
logo : logo :
{ {
display : 'block' display : 'block',
paddingBottom : '1vh'
},
loginButton :
{
position : 'absolute',
right : theme.spacing(2),
top : theme.spacing(2),
padding : 0
},
largeIcon :
{
fontSize : '2em'
},
largeAvatar :
{
width : 50,
height : 50
}, },
green : green :
{ {
color : 'rgba(0,255,0,1)' color : 'rgba(0, 153, 0, 1)'
} }
}); });
const DialogTitle = withStyles(styles)((props) =>
{
const [ open, setOpen ] = useState(false);
useEffect(() =>
{
const openTimer = setTimeout(() => setOpen(true), 1000);
const closeTimer = setTimeout(() => setOpen(false), 4000);
return () =>
{
clearTimeout(openTimer);
clearTimeout(closeTimer);
};
}, []);
const { children, classes, myPicture, onLogin, ...other } = props;
const handleTooltipClose = () =>
{
setOpen(false);
};
const handleTooltipOpen = () =>
{
setOpen(true);
};
return (
<MuiDialogTitle disableTypography className={classes.dialogTitle} {...other}>
{ window.config.logo && <img alt='Logo' className={classes.logo} src={window.config.logo} /> }
<Typography variant='h5'>{children}</Typography>
{ window.config.loginEnabled &&
<Tooltip
onClose={handleTooltipClose}
onOpen={handleTooltipOpen}
open={open}
title='Click to log in'
placement='left'
>
<IconButton
aria-label='Account'
className={classes.loginButton}
color='inherit'
onClick={onLogin}
>
{ myPicture ?
<Avatar src={myPicture} className={classes.largeAvatar} />
:
<AccountCircle className={classes.largeIcon} />
}
</IconButton>
</Tooltip>
}
</MuiDialogTitle>
);
});
const DialogContent = withStyles((theme) => ({
root :
{
padding : theme.spacing(2)
}
}))(MuiDialogContent);
const DialogActions = withStyles((theme) => ({
root :
{
margin : 0,
padding : theme.spacing(1)
}
}))(MuiDialogActions);
const JoinDialog = ({ const JoinDialog = ({
roomClient, roomClient,
room, room,
displayName, displayName,
loginEnabled,
loggedIn, loggedIn,
myPicture, myPicture,
changeDisplayName, changeDisplayName,
@ -109,53 +192,36 @@ const JoinDialog = ({
paper : classes.dialogPaper paper : classes.dialogPaper
}} }}
> >
<DialogTitle disableTypography className={classes.title}> <DialogTitle
{ window.config.logo && <img alt='Logo' className={classes.logo} src={window.config.logo} /> } myPicture={myPicture}
<div className={classes.title}> onLogin={() =>
<Typography variant='h4'>
{ window.config.title }
</Typography>
</div>
<div className={classes.grow} />
<div className={classes.actionButtons}>
{ loginEnabled &&
<IconButton
aria-label='Account'
className={classes.actionButton}
color='inherit'
onClick={() =>
{ {
loggedIn ? roomClient.logout() : roomClient.login(); loggedIn ? roomClient.logout() : roomClient.login();
}} }}
> >
{ myPicture ? { window.config.title }
<Avatar src={myPicture} /> <hr />
:
<AccountCircle />
}
</IconButton>
}
</div>
</DialogTitle> </DialogTitle>
{ window.config.logo && <DialogContent>
<img alt='Logo' className={classes.logo} src={window.config.logo} /> <DialogContentText gutterBottom>
}
<Typography variant='h6'>
You are about to join a meeting. You are about to join a meeting.
</Typography> </DialogContentText>
<Typography variant='h5'>
<center> Room ID: { room.name } </center> <DialogContentText variant='h6' gutterBottom align='center'>
</Typography> Room ID: { room.name }
<Typography variant='h6'> </DialogContentText>
<DialogContentText gutterBottom>
Set your name for participation, Set your name for participation,
and choose how you want to join: and choose how you want to join:
</Typography> </DialogContentText>
<TextField <TextField
id='displayname' id='displayname'
label='Your name' label='Your name'
className={classes.textField}
value={displayName} value={displayName}
variant='outlined'
margin='normal'
onChange={(event) => onChange={(event) =>
{ {
const { value } = event.target; const { value } = event.target;
@ -169,9 +235,11 @@ const JoinDialog = ({
changeDisplayName('Guest'); changeDisplayName('Guest');
if (room.inLobby) roomClient.changeDisplayName(displayName); if (room.inLobby) roomClient.changeDisplayName(displayName);
}} }}
margin='normal' fullWidth
/> />
</DialogContent>
{ !room.inLobby ? { !room.inLobby ?
<DialogActions> <DialogActions>
<Button <Button
@ -196,19 +264,26 @@ const JoinDialog = ({
</Button> </Button>
</DialogActions> </DialogActions>
: :
<Typography variant='h6'> <DialogContent>
<div className={classes.green}> Ok, you are ready</div> <DialogContentText
className={classes.green}
gutterBottom
variant='h6'
align='center'
>
Ok, you are ready
</DialogContentText>
{ room.signInRequired ? { room.signInRequired ?
<div> <DialogContentText gutterBottom>
The room is empty! The room is empty!
You can Log In to start the meeting or wait until the host joins. You can Log In to start the meeting or wait until the host joins.
</div> </DialogContentText>
: :
<div> <DialogContentText gutterBottom>
The room is locked - hang on until somebody lets you in ... The room is locked - hang on until somebody lets you in ...
</div> </DialogContentText>
} }
</Typography> </DialogContent>
} }
<CookieConsent> <CookieConsent>

View File

@ -18,6 +18,11 @@ html
font-family: 'Roboto'; font-family: 'Roboto';
font-weight: 300; font-weight: 300;
margin : 0; margin : 0;
box-sizing: border-box;
}
*, *:before, *:after {
box-sizing: inherit;
} }
body body