Added background color, Added Accordion onChange handler
This commit is contained in:
parent
0e3eb8720f
commit
3f267cb009
@ -1,9 +1,6 @@
|
|||||||
import { Box, Container, IconButton, Menu, MenuItem, MenuList, Paper, Grow, Popper } from '@material-ui/core';
|
import { Box, Container, IconButton, Menu, MenuItem, MenuList, Paper, Grow, Popper } from '@material-ui/core';
|
||||||
import AccountCircle from '@material-ui/icons/AccountCircle';
|
import AccountCircle from '@material-ui/icons/AccountCircle';
|
||||||
import AppBar from '@material-ui/core/AppBar';
|
import AppBar from '@material-ui/core/AppBar';
|
||||||
import blue from '@material-ui/core/colors/blue';
|
|
||||||
import orange from '@material-ui/core/colors/orange';
|
|
||||||
import grey from '@material-ui/core/colors/grey';
|
|
||||||
import { positions } from '@material-ui/system';
|
import { positions } from '@material-ui/system';
|
||||||
import { createMuiTheme, createStyles, makeStyles, Theme } from '@material-ui/core/styles';
|
import { createMuiTheme, createStyles, makeStyles, Theme } from '@material-ui/core/styles';
|
||||||
import Toolbar from '@material-ui/core/Toolbar';
|
import Toolbar from '@material-ui/core/Toolbar';
|
||||||
@ -17,17 +14,18 @@ import AuthService from './components/auth/AuthService';
|
|||||||
import { ClickAwayListener } from '@material-ui/core';
|
import { ClickAwayListener } from '@material-ui/core';
|
||||||
import MapContainer from './components/heatmap/Heatmap';
|
import MapContainer from './components/heatmap/Heatmap';
|
||||||
import Devices from './components/devices/Devices';
|
import Devices from './components/devices/Devices';
|
||||||
|
import { blueGrey, blue, orange, grey } from '@material-ui/core/colors';
|
||||||
|
|
||||||
|
|
||||||
const theme = createMuiTheme({
|
const theme = createMuiTheme({
|
||||||
palette: {
|
palette: {
|
||||||
primary: {
|
primary: {
|
||||||
main: blue[900],
|
main: blue[900],
|
||||||
dark: grey[400],
|
dark: blueGrey[50],
|
||||||
},
|
},
|
||||||
secondary: {
|
secondary: {
|
||||||
main: orange[200],
|
main: orange[200],
|
||||||
dark: grey[400],
|
dark: blueGrey[50],
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
@ -6,6 +6,7 @@ import AccordionDetails from '@material-ui/core/AccordionDetails';
|
|||||||
import ExpandMoreIcon from '@material-ui/icons/ExpandMore';
|
import ExpandMoreIcon from '@material-ui/icons/ExpandMore';
|
||||||
import { Grid, Typography, Paper } from '@material-ui/core';
|
import { Grid, Typography, Paper } from '@material-ui/core';
|
||||||
import { withStyles } from '@material-ui/styles';
|
import { withStyles } from '@material-ui/styles';
|
||||||
|
import { withRouter } from "react-router";
|
||||||
|
|
||||||
const styles = theme => ({
|
const styles = theme => ({
|
||||||
grid_typo: {
|
grid_typo: {
|
||||||
@ -37,6 +38,10 @@ const styles = theme => ({
|
|||||||
class DeviceComponent extends Component {
|
class DeviceComponent extends Component {
|
||||||
constructor(props) {
|
constructor(props) {
|
||||||
super(props);
|
super(props);
|
||||||
|
|
||||||
|
this.state = {
|
||||||
|
expanded: "",
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
getColor(status) {
|
getColor(status) {
|
||||||
@ -49,17 +54,26 @@ class DeviceComponent extends Component {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
componentDidMount() {
|
||||||
|
const id = this.props.match.params.id;
|
||||||
|
this.setState({ expanded: id });
|
||||||
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const { classes } = this.props;
|
const { classes } = this.props;
|
||||||
const Sensors = this.props.device.sensors.map((sensor, index) => (
|
const Sensors = this.props.device.sensors.map((sensor, index) => (
|
||||||
<Grid item className={classes.grid_item} key={sensor.id}>
|
<Grid item className={classes.grid_item} key={sensor.id}>
|
||||||
<Typography className={classes.grid_item_typo}>Sensor {index}</Typography>
|
<Typography className={classes.grid_item_typo}>Sensor {index}</Typography>
|
||||||
<Typography className={classes.grid_item_typo_2}>S{sensor.id}</Typography>
|
<Typography className={classes.grid_item_typo_2}>{sensor.id}</Typography>
|
||||||
</Grid>
|
</Grid>
|
||||||
));
|
));
|
||||||
|
|
||||||
|
const handleChange = (panel) => (event, isExpanded) => {
|
||||||
|
this.setState({ expanded: isExpanded ? panel : "" });
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Accordion>
|
<Accordion expanded={this.state.expanded === this.props.device.id} onChange={handleChange(this.props.device.id)}>
|
||||||
<AccordionSummary
|
<AccordionSummary
|
||||||
expandIcon={<ExpandMoreIcon />}
|
expandIcon={<ExpandMoreIcon />}
|
||||||
aria-controls={"device-panel-/" + this.props.device.id}
|
aria-controls={"device-panel-/" + this.props.device.id}
|
||||||
@ -82,4 +96,4 @@ class DeviceComponent extends Component {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export default withStyles(styles)(DeviceComponent);
|
export default withRouter(withStyles(styles)(DeviceComponent));
|
@ -10,7 +10,7 @@ import { grey } from '@material-ui/core/colors';
|
|||||||
const styles = theme => ({
|
const styles = theme => ({
|
||||||
root: {
|
root: {
|
||||||
padding: '64px',
|
padding: '64px',
|
||||||
color: theme.palette.primary.main,
|
backgroundColor: theme.palette.primary.dark,
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -8,14 +8,8 @@ export default class SensorComponent extends Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const Sensors = this.props.device.sensors.map((sensor, index) => (
|
|
||||||
<Typography>Sensor {this.props.index}</Typography>
|
|
||||||
));
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<AccordionDetails>
|
|
||||||
{Sensors}
|
|
||||||
</AccordionDetails>
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user