forwards table in active session card

master
Tudor Stanciu 2020-05-19 01:33:52 +03:00
parent adc282511c
commit dcc91dbf3a
6 changed files with 99 additions and 28 deletions

View File

@ -44,6 +44,6 @@
}, },
"Server": { "Server": {
"ActiveSession": "Sesiune activă", "ActiveSession": "Sesiune activă",
"ActiveSessionSubtitle": "Extindeţi pentru a vedea redirecţionările" "ActiveSessionSubtitle": "Extindeţi pentru a vedea redirectările"
} }
} }

View File

@ -9,23 +9,25 @@ import CardActions from "@material-ui/core/CardActions";
import Collapse from "@material-ui/core/Collapse"; import Collapse from "@material-ui/core/Collapse";
import Avatar from "@material-ui/core/Avatar"; import Avatar from "@material-ui/core/Avatar";
import IconButton from "@material-ui/core/IconButton"; import IconButton from "@material-ui/core/IconButton";
import Typography from "@material-ui/core/Typography";
import ExpandMoreIcon from "@material-ui/icons/ExpandMore"; import ExpandMoreIcon from "@material-ui/icons/ExpandMore";
import SurroundSoundRoundedIcon from "@material-ui/icons/SurroundSoundRounded"; import SurroundSoundRoundedIcon from "@material-ui/icons/SurroundSoundRounded";
import ActiveSessionSummary from "./ActiveSessionSummary"; import ActiveSessionSummary from "./ActiveSessionSummary";
import styles from "../../../components/common/styles/expandableCardStyles"; import styles from "../../../components/common/styles/expandableCardStyles";
import { useTranslation } from "react-i18next"; import { useTranslation } from "react-i18next";
import SessionForwardsComponent from "../../session/components/SessionForwardsComponent";
import Spinner from "../../../components/common/Spinner";
const useStyles = makeStyles(styles); const useStyles = makeStyles(styles);
const ActiveSessionComponent = ({ session }) => { const ActiveSessionComponent = ({
session,
expanded,
handleExpandClick,
forwards,
openOptionsDialog
}) => {
const classes = useStyles(); const classes = useStyles();
const { t } = useTranslation(); const { t } = useTranslation();
const [expanded, setExpanded] = React.useState(false);
const handleExpandClick = () => {
setExpanded(!expanded);
};
return ( return (
<Card> <Card>
@ -56,11 +58,18 @@ const ActiveSessionComponent = ({ session }) => {
<CardActions disableSpacing></CardActions> <CardActions disableSpacing></CardActions>
<Collapse in={expanded} timeout="auto" unmountOnExit> <Collapse in={expanded} timeout="auto" unmountOnExit>
<CardContent> <CardContent>
<Typography paragraph>Method:</Typography> {!forwards || forwards.loading ? (
<Typography paragraph> <Spinner />
Tabel ca cel de pana acum cu redirectarile. From va fi link si la ) : (
click va deschide in tab nou aplicatia forwards.loaded && (
</Typography> <SessionForwardsComponent
session={session}
forwards={forwards}
openOptionsDialog={openOptionsDialog}
showSessionInfo={false}
/>
)
)}
</CardContent> </CardContent>
</Collapse> </Collapse>
</Card> </Card>
@ -68,7 +77,11 @@ const ActiveSessionComponent = ({ session }) => {
}; };
ActiveSessionComponent.propTypes = { ActiveSessionComponent.propTypes = {
session: PropTypes.object.isRequired session: PropTypes.object.isRequired,
expanded: PropTypes.bool.isRequired,
handleExpandClick: PropTypes.func.isRequired,
forwards: PropTypes.array,
openOptionsDialog: PropTypes.func.isRequired
}; };
export default ActiveSessionComponent; export default ActiveSessionComponent;

View File

@ -1,32 +1,75 @@
import React, { useEffect } from "react"; import React, { useEffect, useState } from "react";
import { connect } from "react-redux"; import { connect } from "react-redux";
import { bindActionCreators } from "redux"; import { bindActionCreators } from "redux";
import PropTypes from "prop-types"; import PropTypes from "prop-types";
import { loadActiveSession } from "../actionCreators"; import { loadActiveSession } from "../actionCreators";
import { loadSessionForwards } from "../../session/actionCreators";
import { getActiveForwards } from "../selectors";
import ActiveSessionComponent from "./ActiveSessionComponent"; import ActiveSessionComponent from "./ActiveSessionComponent";
import ForwardOptionsDialog from "../../session/components/ForwardOptionsDialog";
const ActiveSessionContainer = ({ actions, session, forwards }) => {
const [expanded, setExpanded] = useState(false);
const [optionsDialogOpen, setOptionsDialogOpen] = useState(false);
const [forwardOptions, setForwardOptions] = useState(null);
const ActiveSessionContainer = ({ actions, session }) => {
useEffect(() => { useEffect(() => {
actions.loadActiveSession(); actions.loadActiveSession();
}, []); }, []);
return <ActiveSessionComponent session={session} />; const handleExpandClick = () => {
const expand = !expanded;
setExpanded(expand);
if (expand) actions.loadSessionForwards(session.sessionId);
};
const handleOptionsDialogOpen = (options) => () => {
setForwardOptions(options);
setOptionsDialogOpen(true);
};
const handleOptionsDialogClose = () => {
setOptionsDialogOpen(false);
setForwardOptions(null);
};
return (
<>
<ActiveSessionComponent
session={session}
expanded={expanded}
handleExpandClick={handleExpandClick}
forwards={forwards}
openOptionsDialog={handleOptionsDialogOpen}
/>
<ForwardOptionsDialog
open={optionsDialogOpen}
handleClose={handleOptionsDialogClose}
options={forwardOptions}
/>
</>
);
}; };
ActiveSessionContainer.propTypes = { ActiveSessionContainer.propTypes = {
actions: PropTypes.object.isRequired, actions: PropTypes.object.isRequired,
session: PropTypes.object.isRequired session: PropTypes.object.isRequired,
forwards: PropTypes.array
}; };
function mapStateToProps(state) { function mapStateToProps(state) {
return { return {
session: state.server.activeSession session: state.server.activeSession,
forwards: getActiveForwards(state)
}; };
} }
function mapDispatchToProps(dispatch) { function mapDispatchToProps(dispatch) {
return { return {
actions: bindActionCreators({ loadActiveSession }, dispatch) actions: bindActionCreators(
{ loadActiveSession, loadSessionForwards },
dispatch
)
}; };
} }

View File

@ -0,0 +1,4 @@
export const getActiveForwards = (state) => {
const { sessionId } = state.server.activeSession;
return state.forwards[sessionId];
};

View File

@ -23,7 +23,12 @@ import {
const useStyles = makeStyles(styles); const useStyles = makeStyles(styles);
const SessionForwardsComponent = ({ session, forwards, openOptionsDialog }) => { const SessionForwardsComponent = ({
session,
forwards,
openOptionsDialog,
showSessionInfo
}) => {
const classes = useStyles(); const classes = useStyles();
const { t } = useTranslation(); const { t } = useTranslation();
@ -91,12 +96,16 @@ const SessionForwardsComponent = ({ session, forwards, openOptionsDialog }) => {
) )
)} )}
</Grid> </Grid>
<Grid item xs={12} sm={12} md={12}> {showSessionInfo && (
<br /> <>
</Grid> <Grid item xs={12} sm={12} md={12}>
<Grid item xs={12} sm={12} md={12}> <br />
<SessionForwardsHeaderComponent session={session} /> </Grid>
</Grid> <Grid item xs={12} sm={12} md={12}>
<SessionForwardsHeaderComponent session={session} />
</Grid>
</>
)}
</Grid> </Grid>
); );
}; };
@ -104,7 +113,8 @@ const SessionForwardsComponent = ({ session, forwards, openOptionsDialog }) => {
SessionForwardsComponent.propTypes = { SessionForwardsComponent.propTypes = {
session: PropTypes.object.isRequired, session: PropTypes.object.isRequired,
forwards: PropTypes.array, forwards: PropTypes.array,
openOptionsDialog: PropTypes.func.isRequired openOptionsDialog: PropTypes.func.isRequired,
showSessionInfo: PropTypes.bool.isRequired
}; };
export default SessionForwardsComponent; export default SessionForwardsComponent;

View File

@ -47,6 +47,7 @@ const SessionListComponent = ({
session={session} session={session}
forwards={forwards[session.sessionId]} forwards={forwards[session.sessionId]}
openOptionsDialog={openOptionsDialog} openOptionsDialog={openOptionsDialog}
showSessionInfo={true}
/> />
</ExpansionPanelDetails> </ExpansionPanelDetails>
</ExpansionPanel> </ExpansionPanel>