diff --git a/smart-hut/public/img/refresh.svg b/smart-hut/public/img/refresh.svg
new file mode 100644
index 0000000..2901972
--- /dev/null
+++ b/smart-hut/public/img/refresh.svg
@@ -0,0 +1,42 @@
+
+
+
diff --git a/smart-hut/src/client_server.js b/smart-hut/src/client_server.js
index 46cc06f..2598b53 100644
--- a/smart-hut/src/client_server.js
+++ b/smart-hut/src/client_server.js
@@ -277,4 +277,9 @@ export var call = {
deviceGetAll: function (data, headers) {
return axios.get(config + data.device);
},
+ smartPlugReset: function (id) {
+ return axios.delete(config + "smartPlug/" + id + "/meter", {
+ headers: { Authorization: "Bearer " + tkn },
+ });
+ },
};
diff --git a/smart-hut/src/components/HeaderController.js b/smart-hut/src/components/HeaderController.js
index cbcbadb..d5a5e19 100644
--- a/smart-hut/src/components/HeaderController.js
+++ b/smart-hut/src/components/HeaderController.js
@@ -1,21 +1,8 @@
import React from "react";
-import {
- Dropdown,
- Icon,
- Grid,
- Divider,
- Button,
- Label,
- Responsive,
-} from "semantic-ui-react";
+import { Grid, Divider, Button, Label, Responsive } from "semantic-ui-react";
import { Segment, Image } from "semantic-ui-react";
-import { BrowserView, MobileView } from "react-device-detect";
import { call } from "../client_server";
-const AvatarImage = () => (
-
-);
-
const IconHomeImage = () => (
{
+ call.smartPlugReset(this.props.device.id).then((res) => {
+ if (res.status === 200) {
+ this.setState({
+ energyConsumed: (res.data.totalConsumption / 1000).toFixed(3),
+ });
+ }
+ });
+ };
+
getIcon = () => {
if (this.state.turnedOn) {
return this.iconOn;
@@ -60,7 +75,7 @@ export default class SmartPlug extends Component {
componentDidMount() {
this.setState({
turnedOn: this.props.device.on,
- energyConsumed: this.props.device.totalConsumption,
+ energyConsumed: (this.props.device.totalConsumption / 1000).toFixed(3),
});
}
@@ -74,6 +89,13 @@ export default class SmartPlug extends Component {
this.props.onChangeData(id, newSettings)
}
/>
+ {this.props.edit.mode ? (
+
+
+
+ ) : (
+ ""
+ )}
{this.props.device.name} ({this.props.device.id})
diff --git a/smart-hut/src/components/dashboard/devices/styleComponents.js b/smart-hut/src/components/dashboard/devices/styleComponents.js
index 1b6c788..9c052f7 100644
--- a/smart-hut/src/components/dashboard/devices/styleComponents.js
+++ b/smart-hut/src/components/dashboard/devices/styleComponents.js
@@ -37,6 +37,18 @@ export const editModeStyle = {
cursor: "pointer",
};
+export const editModeStyleLeft = {
+ position: "absolute",
+ top: "15%",
+ left: "0",
+ width: "1.5rem",
+ height: "1.5rem",
+ backgroundColor: "white",
+ borderRadius: "100%",
+ zIndex: "1000",
+ cursor: "pointer",
+};
+
export const editModeIconStyle = {
position: "absolute",
top: "50%",
diff --git a/smart-hut/src/views/Dashboard.js b/smart-hut/src/views/Dashboard.js
index 144f089..2f75f32 100644
--- a/smart-hut/src/views/Dashboard.js
+++ b/smart-hut/src/views/Dashboard.js
@@ -38,21 +38,21 @@ export default class Dashboard extends Component {
.getAllDevices()
.then((res) => {
if (res.status === 200) {
- console.log(res.data);
+ //console.log(res.data);
this.setState({
devices: res.data,
});
}
})
.catch((err) => {
- console.log(err);
+ //console.log(err);
});
} else {
call
.getAllDevicesByRoom(this.state.activeItem)
.then((res) => {
if (res.status === 200) {
- console.log(res.data);
+ //console.log(res.data);
this.setState({
devices: res.data,
});
@@ -88,7 +88,7 @@ export default class Dashboard extends Component {
}
})
.catch((err) => {
- console.log(err);
+ //console.log(err);
});
}
@@ -107,7 +107,7 @@ export default class Dashboard extends Component {
this.handleItemClick(-1);
})
.catch((err) => {
- console.log(err);
+ //console.log(err);
});
}
@@ -139,7 +139,7 @@ export default class Dashboard extends Component {
}
})
.catch((err) => {
- console.log(err);
+ //console.log(err);
});
} else {
call
@@ -153,7 +153,7 @@ export default class Dashboard extends Component {
}
})
.catch((err) => {
- console.log(err);
+ //console.log(err);
});
}
this.state.rooms.forEach((item) => {
diff --git a/smart-hut/src/views/Forgot-pass-reset.js b/smart-hut/src/views/Forgot-pass-reset.js
index 01d4560..0380465 100644
--- a/smart-hut/src/views/Forgot-pass-reset.js
+++ b/smart-hut/src/views/Forgot-pass-reset.js
@@ -20,6 +20,7 @@ export default class ChangePass extends Component {
state: false,
message: "",
},
+ success: false,
};
this.handleChangePassword = this.handleChangePassword.bind(this);
}
@@ -30,8 +31,12 @@ export default class ChangePass extends Component {
this.setState({ [nam]: val });
};
- checkpassword = (e) => {
- if (e.target.value !== this.state.password) {
+ handleChangePassword = (e) => {
+ const params = {
+ confirmationToken: this.props.query.token,
+ password: this.state.password,
+ };
+ if (this.state.confirmPassword !== this.state.password) {
this.setState({
error: {
state: true,
@@ -39,22 +44,15 @@ export default class ChangePass extends Component {
},
});
}
- };
- handleChangePassword = (e) => {
- const params = {
- confirmationToken: this.props.query.token,
- password: this.state.password,
- };
call
.resetPassword(params)
.then((res) => {
- if (res.status !== 200) {
- this.setState({ error: { state: true, message: "Errore" } });
+ if (res.status === 200) {
+ this.setState({ success: true });
} else {
- return ;
+ this.setState({ error: { state: true, message: "Errore" } });
}
- // else set a message that an email has been sent
})
.catch((err) => {
console.log(err);
@@ -62,6 +60,9 @@ export default class ChangePass extends Component {
};
render() {
+ if (this.state.success) {
+ return ;
+ }
return (