session details

master
Tudor Stanciu 2020-05-14 03:01:01 +03:00
parent 6463b1acb3
commit 359acd2776
7 changed files with 132 additions and 40 deletions

View File

@ -24,6 +24,13 @@
"StartDate": "Start date", "StartDate": "Start date",
"StopDate": "Stop date", "StopDate": "Stop date",
"RunningTime": "Running time", "RunningTime": "Running time",
"Host": "Host" "Host": "Host",
"LogRows": "Log rows",
"LogSize": "Log size",
"Details": {
"From": "From",
"To": "To",
"Options": "Option"
}
} }
} }

View File

@ -15,6 +15,13 @@
"StartDate": "Dată pornire", "StartDate": "Dată pornire",
"StopDate": "Dată oprire", "StopDate": "Dată oprire",
"RunningTime": "Timp de rulare", "RunningTime": "Timp de rulare",
"Host": "Gazdă" "Host": "Gazdă",
"LogRows": "Linii log",
"LogSize": "Dimensiune log",
"Details": {
"From": "De la",
"To": "Către",
"Options": "Opțiuni"
}
} }
} }

View File

@ -9,6 +9,12 @@ import TableHead from "@material-ui/core/TableHead";
import TableRow from "@material-ui/core/TableRow"; import TableRow from "@material-ui/core/TableRow";
import Paper from "@material-ui/core/Paper"; import Paper from "@material-ui/core/Paper";
import Spinner from "../../../components/common/Spinner"; import Spinner from "../../../components/common/Spinner";
import DonutLargeRoundedIcon from "@material-ui/icons/DonutLargeRounded";
import IconButton from "@material-ui/core/IconButton";
import Tooltip from "@material-ui/core/Tooltip";
import SessionDetailsHeaderComponent from "./SessionDetailsHeaderComponent";
import { Grid } from "@material-ui/core";
import { useTranslation } from "react-i18next";
const StyledTableCell = withStyles((theme) => ({ const StyledTableCell = withStyles((theme) => ({
head: { head: {
@ -34,42 +40,74 @@ const useStyles = makeStyles({
} }
}); });
const SessionDetailsComponent = ({ forwards }) => { const SessionDetailsComponent = ({ session, forwards }) => {
const classes = useStyles(); const classes = useStyles();
const { t } = useTranslation();
return !forwards || forwards.loading ? ( return (
<Spinner /> <Grid container>
) : ( <Grid item xs={12} sm={12} md={12}>
forwards.loaded && ( {!forwards || forwards.loading ? (
<TableContainer component={Paper}> <Spinner />
<Table ) : (
className={classes.table} forwards.loaded && (
size="small" <TableContainer component={Paper}>
aria-label="customized table" <Table
> className={classes.table}
<TableHead> size="small"
<TableRow> aria-label="customized table"
<StyledTableCell /> >
<StyledTableCell>From</StyledTableCell> <TableHead>
<StyledTableCell>To</StyledTableCell> <TableRow>
</TableRow> <StyledTableCell />
</TableHead> <StyledTableCell>
<TableBody> {t("Session.Details.From")}
{forwards.map((row) => ( </StyledTableCell>
<StyledTableRow key={row.forwardId}> <StyledTableCell>{t("Session.Details.To")}</StyledTableCell>
<StyledTableCell>{forwards.indexOf(row) + 1}</StyledTableCell> <StyledTableCell align="right">
<StyledTableCell>{row.from}</StyledTableCell> {t("Session.Details.Options")}
<StyledTableCell>{row.to}</StyledTableCell> </StyledTableCell>
</StyledTableRow> </TableRow>
))} </TableHead>
</TableBody> <TableBody>
</Table> {forwards.map((row) => (
</TableContainer> <StyledTableRow key={row.forwardId}>
) <StyledTableCell component="th" scope="row">
{forwards.indexOf(row) + 1}
</StyledTableCell>
<StyledTableCell>{row.from}</StyledTableCell>
<StyledTableCell>{row.to}</StyledTableCell>
<StyledTableCell align="right">
{row.options ? (
<Tooltip title={t("Session.Details.Options")}>
<IconButton aria-label="options" size="small">
<DonutLargeRoundedIcon color="primary" />
</IconButton>
</Tooltip>
) : (
""
)}
</StyledTableCell>
</StyledTableRow>
))}
</TableBody>
</Table>
</TableContainer>
)
)}
</Grid>
<Grid item xs={12} sm={12} md={12}>
<br />
</Grid>
<Grid item xs={12} sm={12} md={12}>
<SessionDetailsHeaderComponent session={session} />
</Grid>
</Grid>
); );
}; };
SessionDetailsComponent.propTypes = { SessionDetailsComponent.propTypes = {
session: PropTypes.object.isRequired,
forwards: PropTypes.array forwards: PropTypes.array
}; };

View File

@ -0,0 +1,35 @@
import React from "react";
import PropTypes from "prop-types";
import { Grid } from "@material-ui/core";
import { makeStyles } from "@material-ui/core/styles";
import { useTranslation } from "react-i18next";
import styles from "../styles/gridStyles";
const useStyles = makeStyles(styles);
const SessionDetailsHeaderComponent = ({ session }) => {
const classes = useStyles();
const { t } = useTranslation();
return (
<Grid container className={classes.miniContainer}>
<Grid item xs={12} sm={5} md={5}>
{`${t("Session.LogRows")}: `}
<span className={classes.value}>{session.logRows || "-"}</span>
</Grid>
<Grid item xs={12} sm={5} md={5}>
{`${t("Session.LogSize")}: `}
<span className={classes.value}>{`${
session.logSizeKB || "-"
} KB`}</span>
</Grid>
</Grid>
);
};
SessionDetailsHeaderComponent.propTypes = {
session: PropTypes.object.isRequired
};
export default SessionDetailsHeaderComponent;

View File

@ -46,6 +46,7 @@ const SessionListComponent = ({ sessions, handleToggle, forwards }) => {
</ExpansionPanelSummary> </ExpansionPanelSummary>
<ExpansionPanelDetails> <ExpansionPanelDetails>
<SessionDetailsComponent <SessionDetailsComponent
session={session}
forwards={forwards[session.sessionId]} forwards={forwards[session.sessionId]}
/> />
</ExpansionPanelDetails> </ExpansionPanelDetails>

View File

@ -4,15 +4,9 @@ import { Grid } from "@material-ui/core";
import { makeStyles } from "@material-ui/core/styles"; import { makeStyles } from "@material-ui/core/styles";
import { CheckCircleOutlineRounded, RemoveRounded } from "@material-ui/icons"; import { CheckCircleOutlineRounded, RemoveRounded } from "@material-ui/icons";
import { useTranslation } from "react-i18next"; import { useTranslation } from "react-i18next";
import styles from "../styles/gridStyles";
const useStyles = makeStyles((theme) => ({ const useStyles = makeStyles(styles);
value: {
fontWeight: theme.typography.fontWeightMedium
},
miniContainer: {
paddingTop: "10px"
}
}));
const SessionSummary = ({ session }) => { const SessionSummary = ({ session }) => {
const classes = useStyles(); const classes = useStyles();

View File

@ -0,0 +1,10 @@
const styles = (theme) => ({
value: {
fontWeight: theme.typography.fontWeightMedium
},
miniContainer: {
paddingTop: "10px"
}
});
export default styles;