Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WebUi challenge 1. Created fancy wifi list. #12

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
69 changes: 52 additions & 17 deletions frontend/routes/Wifi.jsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,39 @@
import * as React from 'react';
import { exec_table, exec } from '../util/exec';

import { withStyles, makeStyles } from '@material-ui/core/styles';
import Tablee from '@material-ui/core/Table';
import TableBody from '@material-ui/core/TableBody';
import TableCell from '@material-ui/core/TableCell';
import TableContainer from '@material-ui/core/TableContainer';
import TableHead from '@material-ui/core/TableHead';
import TableRow from '@material-ui/core/TableRow';
import Paper from '@material-ui/core/Paper';

export const title = 'Wifi Configuration';
export const route = '/wifi';

const useStyles = makeStyles({
table: {
minWidth: 500,
},
});

const StyledTableCell = withStyles((theme) => ({
head: {
backgroundColor: theme.palette.common.black,
color: theme.palette.common.white,
},
}))(TableCell);

const StyledTableRow = withStyles((theme) => ({
root: {
'&:nth-of-type(odd)': {
backgroundColor: theme.palette.action.hover,
},
},
}))(TableRow);

export class Component extends React.Component {
constructor(props) {
super(props);
Expand All @@ -27,27 +57,32 @@ export class Component extends React.Component {
}
}


function Table(props) {
const classes = useStyles()
const { data } = props;

if (data.length === 0) return <table />;
return (
<table>
<thead>
<tr>
{Object.keys(data[0]).map(s => (
<th key={s}>{s}</th>
))}
</tr>
</thead>
<tbody>
{data.map((row, i) => (
<tr key={i}>
{Object.values(row).map((s, i) => (
<td key={i}>{s}</td>
<TableContainer component={Paper}>
<Tablee className={classes.table} aria-label="simple table">
<TableHead>
<StyledTableRow>
{Object.keys(data[0]).map(s => (
<StyledTableCell key={s}>{s}</StyledTableCell>
))}
</tr>
))}
</tbody>
</table>
</StyledTableRow>
</TableHead>
<TableBody>
{data.map((row, i) => (
<StyledTableRow align="right" key={i}>
{Object.values(row).map((s, i) => (
<StyledTableCell key={i}>{s}</StyledTableCell>
))}
</StyledTableRow>
))}
</TableBody>
</Tablee>
</TableContainer>
);
}