fixed minor bug on smartplugs

This commit is contained in:
britea 2020-03-26 09:51:25 +01:00
parent e231425a94
commit 054f4ad341
4 changed files with 11 additions and 12 deletions

View file

@ -12,7 +12,7 @@ import {
editModeStyleLeft, editModeStyleLeft,
} from "./styleComponents"; } from "./styleComponents";
import Settings from "./DeviceSettings"; import Settings from "./DeviceSettings";
import { Image, Icon } from "semantic-ui-react"; import { Image } from "semantic-ui-react";
import { import {
energyConsumedStyle, energyConsumedStyle,
imageStyle, imageStyle,
@ -75,7 +75,7 @@ export default class SmartPlug extends Component {
componentDidMount() { componentDidMount() {
this.setState({ this.setState({
turnedOn: this.props.device.on, turnedOn: this.props.device.on,
energyConsumed: this.props.device.totalConsumption, energyConsumed: (this.props.device.totalConsumption / 1000).toFixed(3),
}); });
} }

View file

@ -102,7 +102,6 @@ export default class ModalWindow extends Component {
padding: "10px 10px", padding: "10px 10px",
margin: "10px 0px", margin: "10px 0px",
}; };
console.log(this.state, this.idRoom);
return ( return (
<div> <div>
<Responsive minWidth={768}> <Responsive minWidth={768}>

View file

@ -38,21 +38,21 @@ export default class Dashboard extends Component {
.getAllDevices() .getAllDevices()
.then((res) => { .then((res) => {
if (res.status === 200) { if (res.status === 200) {
console.log(res.data); //console.log(res.data);
this.setState({ this.setState({
devices: res.data, devices: res.data,
}); });
} }
}) })
.catch((err) => { .catch((err) => {
console.log(err); //console.log(err);
}); });
} else { } else {
call call
.getAllDevicesByRoom(this.state.activeItem) .getAllDevicesByRoom(this.state.activeItem)
.then((res) => { .then((res) => {
if (res.status === 200) { if (res.status === 200) {
console.log(res.data); //console.log(res.data);
this.setState({ this.setState({
devices: res.data, devices: res.data,
}); });
@ -88,7 +88,7 @@ export default class Dashboard extends Component {
} }
}) })
.catch((err) => { .catch((err) => {
console.log(err); //console.log(err);
}); });
} }
@ -107,7 +107,7 @@ export default class Dashboard extends Component {
this.handleItemClick(-1); this.handleItemClick(-1);
}) })
.catch((err) => { .catch((err) => {
console.log(err); //console.log(err);
}); });
} }
@ -139,7 +139,7 @@ export default class Dashboard extends Component {
} }
}) })
.catch((err) => { .catch((err) => {
console.log(err); //console.log(err);
}); });
} else { } else {
call call
@ -153,7 +153,7 @@ export default class Dashboard extends Component {
} }
}) })
.catch((err) => { .catch((err) => {
console.log(err); //console.log(err);
}); });
} }
this.state.rooms.forEach((item) => { this.state.rooms.forEach((item) => {

View file

@ -26,13 +26,13 @@ class Navbar extends Component {
handleClick = (e, { id, name }) => { handleClick = (e, { id, name }) => {
const room = this.props.rooms.filter((d) => d.id === id)[0]; const room = this.props.rooms.filter((d) => d.id === id)[0];
console.log(room); //console.log(room);
this.setState({ this.setState({
activeItem: id, activeItem: id,
activeItemName: name, activeItemName: name,
}); });
this.activeRoom = room; this.activeRoom = room;
console.log(this.activeRoom); //console.log(this.activeRoom);
this.forceUpdate(); this.forceUpdate();
this.props.handleItemClick(id); this.props.handleItemClick(id);
}; };