Merge branch '103-temperature-sensor-color-circle-change-with-temperature-value' into 'dev'
Resolve "temperature sensor - color circle change with temperature value" Closes #103 See merge request sa4-2020/the-sanmarinoes/frontend!131
This commit is contained in:
commit
3132204872
6 changed files with 85 additions and 12170 deletions
|
@ -94,12 +94,12 @@ class RoomModal extends Component {
|
||||||
};
|
};
|
||||||
|
|
||||||
setSureTrue = () => {
|
setSureTrue = () => {
|
||||||
this.setState({sure: true})
|
this.setState({ sure: true });
|
||||||
}
|
};
|
||||||
|
|
||||||
setSureFalse= () => {
|
setSureFalse = () => {
|
||||||
this.setState({sure: false})
|
this.setState({ sure: false });
|
||||||
}
|
};
|
||||||
|
|
||||||
changeSomething = (event) => {
|
changeSomething = (event) => {
|
||||||
let nam = event.target.name;
|
let nam = event.target.name;
|
||||||
|
@ -239,13 +239,14 @@ class RoomModal extends Component {
|
||||||
onClick={this.setSureTrue}
|
onClick={this.setSureTrue}
|
||||||
>
|
>
|
||||||
<Icon name="trash alternate" />
|
<Icon name="trash alternate" />
|
||||||
Delete Room </Button>
|
Delete Room{" "}
|
||||||
|
</Button>
|
||||||
<Confirm
|
<Confirm
|
||||||
open={this.state.sure}
|
open={this.state.sure}
|
||||||
onCancel={this.setSureFalse}
|
onCancel={this.setSureFalse}
|
||||||
onConfirm={this.deleteRoom}/>
|
onConfirm={this.deleteRoom}
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
) : null}
|
) : null}
|
||||||
</Modal.Content>
|
</Modal.Content>
|
||||||
<Modal.Actions>
|
<Modal.Actions>
|
||||||
|
|
|
@ -141,9 +141,13 @@ class NewDevice extends Component {
|
||||||
case "buttonDimmer":
|
case "buttonDimmer":
|
||||||
case "knobDimmer":
|
case "knobDimmer":
|
||||||
outputs = this.state.lightsAttached;
|
outputs = this.state.lightsAttached;
|
||||||
if (this.state.lightsAttached === undefined ||
|
if (
|
||||||
this.state.lightsAttached.length === 0) {
|
this.state.lightsAttached === undefined ||
|
||||||
alert("No lights attached to this switch! Please, add a light a first.");
|
this.state.lightsAttached.length === 0
|
||||||
|
) {
|
||||||
|
alert(
|
||||||
|
"No lights attached to this switch! Please, add a light a first."
|
||||||
|
);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -165,11 +169,17 @@ class NewDevice extends Component {
|
||||||
render() {
|
render() {
|
||||||
const deviceOptions = [
|
const deviceOptions = [
|
||||||
//stuff
|
//stuff
|
||||||
{ key: "thermostat", text: "Thermostat", value: "thermostat",
|
{
|
||||||
image: {avatar: true, src: "/img/thermostat-icon.png"}
|
key: "thermostat",
|
||||||
|
text: "Thermostat",
|
||||||
|
value: "thermostat",
|
||||||
|
image: { avatar: true, src: "/img/thermostat-icon.png" },
|
||||||
},
|
},
|
||||||
{ key: "curtains", text: "Curtain", value: "curtains",
|
{
|
||||||
image: {avatar: true, src: "/img/curtains-icon.png"}
|
key: "curtains",
|
||||||
|
text: "Curtain",
|
||||||
|
value: "curtains",
|
||||||
|
image: { avatar: true, src: "/img/curtains-icon.png" },
|
||||||
},
|
},
|
||||||
//stuff ends
|
//stuff ends
|
||||||
{
|
{
|
||||||
|
|
|
@ -123,6 +123,18 @@ class Sensor extends Component {
|
||||||
return this.iconOff;
|
return this.iconOff;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
temperatureColor = (value) => {
|
||||||
|
let hue = 100;
|
||||||
|
const min = 16;
|
||||||
|
const max = 20;
|
||||||
|
if (value >= min && value < max) {
|
||||||
|
hue = 100 - ((value - min) * 100) / (max - min);
|
||||||
|
} else if (value >= max) {
|
||||||
|
hue = 0;
|
||||||
|
}
|
||||||
|
return `hsl(${hue}, 100%, 50%)`;
|
||||||
|
};
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const MotionSensor = (props) => {
|
const MotionSensor = (props) => {
|
||||||
return (
|
return (
|
||||||
|
@ -161,11 +173,18 @@ class Sensor extends Component {
|
||||||
>
|
>
|
||||||
<CircularProgress
|
<CircularProgress
|
||||||
strokeWidth="2rem"
|
strokeWidth="2rem"
|
||||||
stroke={this.colors.progress}
|
stroke={
|
||||||
|
this.props.stateOrDevice.sensor === "TEMPERATURE"
|
||||||
|
? this.temperatureColor(this.state.value)
|
||||||
|
: this.colors.progress
|
||||||
|
}
|
||||||
fill={this.colors.circle}
|
fill={this.colors.circle}
|
||||||
/>
|
/>
|
||||||
<text
|
<text
|
||||||
style={{ ...valueStyle, fill: this.colors.text }}
|
style={{
|
||||||
|
...valueStyle,
|
||||||
|
fill: this.colors.text,
|
||||||
|
}}
|
||||||
x={100}
|
x={100}
|
||||||
y={110}
|
y={110}
|
||||||
textAnchor="middle"
|
textAnchor="middle"
|
||||||
|
@ -177,7 +196,10 @@ class Sensor extends Component {
|
||||||
{this.units}
|
{this.units}
|
||||||
</text>
|
</text>
|
||||||
<text
|
<text
|
||||||
style={{ ...sensorText, fill: this.colors.text }}
|
style={{
|
||||||
|
...sensorText,
|
||||||
|
fill: this.colors.text,
|
||||||
|
}}
|
||||||
x={100}
|
x={100}
|
||||||
y={150}
|
y={150}
|
||||||
textAnchor="middle"
|
textAnchor="middle"
|
||||||
|
|
|
@ -8,10 +8,7 @@ import ScenesNavbar from "./ScenesNavbar";
|
||||||
import HostsNavbar from "./HostsNavbar";
|
import HostsNavbar from "./HostsNavbar";
|
||||||
import MyHeader from "../components/HeaderController";
|
import MyHeader from "../components/HeaderController";
|
||||||
import { Grid, Responsive, Button, Menu } from "semantic-ui-react";
|
import { Grid, Responsive, Button, Menu } from "semantic-ui-react";
|
||||||
import {
|
import { mobilePanelStyle } from "../components/dashboard/devices/styleComponents";
|
||||||
panelStyle,
|
|
||||||
mobilePanelStyle,
|
|
||||||
} from "../components/dashboard/devices/styleComponents";
|
|
||||||
|
|
||||||
import { RemoteService } from "../remote";
|
import { RemoteService } from "../remote";
|
||||||
import { connect } from "react-redux";
|
import { connect } from "react-redux";
|
||||||
|
@ -84,10 +81,10 @@ class Dashboard extends Component {
|
||||||
// needed to correctly assign the background image
|
// needed to correctly assign the background image
|
||||||
//in case a room has one.
|
//in case a room has one.
|
||||||
let backgroundImageHelper;
|
let backgroundImageHelper;
|
||||||
if(this.activeTab==="Devices"){
|
if (this.activeTab === "Devices") {
|
||||||
backgroundImageHelper=this.props.allRooms;
|
backgroundImageHelper = this.props.backgroundImage;
|
||||||
}else{
|
} else {
|
||||||
backgroundImageHelper=null;
|
backgroundImageHelper = null;
|
||||||
}
|
}
|
||||||
//console.log("helper is",helper)
|
//console.log("helper is",helper)
|
||||||
return (
|
return (
|
||||||
|
@ -135,15 +132,19 @@ class Dashboard extends Component {
|
||||||
</Grid.Column>
|
</Grid.Column>
|
||||||
)}
|
)}
|
||||||
<Grid.Column width={this.hasNavbar ? 13 : 16}>
|
<Grid.Column width={this.hasNavbar ? 13 : 16}>
|
||||||
<div style={
|
<div
|
||||||
{backgroundImage:"url("+ backgroundImageHelper+")",
|
style={{
|
||||||
|
backgroundImage: "url(" + backgroundImageHelper + ")",
|
||||||
backgroundColor: "#fafafa",
|
backgroundColor: "#fafafa",
|
||||||
height: "85vh",
|
height: "85vh",
|
||||||
padding: "0rem 3rem",
|
padding: "0rem 3rem",
|
||||||
color: "#000000",
|
color: "#000000",
|
||||||
overflow: "auto",
|
overflow: "auto",
|
||||||
maxHeight: "75vh",}
|
maxHeight: "75vh",
|
||||||
}>{this.renderTab(this.activeTab)}</div>
|
}}
|
||||||
|
>
|
||||||
|
{this.renderTab(this.activeTab)}
|
||||||
|
</div>
|
||||||
</Grid.Column>
|
</Grid.Column>
|
||||||
</Grid.Row>
|
</Grid.Row>
|
||||||
</Grid>
|
</Grid>
|
||||||
|
@ -216,26 +217,16 @@ class Dashboard extends Component {
|
||||||
|
|
||||||
const mapStateToProps = (state, _) => ({
|
const mapStateToProps = (state, _) => ({
|
||||||
activeTab: state.active.activeTab,
|
activeTab: state.active.activeTab,
|
||||||
get currentRoom(){
|
get currentRoom() {
|
||||||
return state.active.activeRoom;
|
return state.active.activeRoom;
|
||||||
},
|
},
|
||||||
//this took me way longer to figure out than it should have
|
get backgroundImage() {
|
||||||
get allRooms(){
|
if (state.active.activeRoom === -1) {
|
||||||
if(state.active.activeRoom==-1){
|
|
||||||
return null;
|
return null;
|
||||||
}
|
} else {
|
||||||
for(let i in state.rooms){
|
return state.rooms[state.active.activeRoom].image;
|
||||||
if(i==state.active.activeRoom){
|
|
||||||
//console.log("check",state.rooms[i].image)
|
|
||||||
if(state.rooms[i].image===undefined){
|
|
||||||
return null;
|
|
||||||
}else{
|
|
||||||
return state.rooms[i].image;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
const setActiveTab = (activeTab) => {
|
const setActiveTab = (activeTab) => {
|
||||||
|
|
12113
smart-hut/yarn.lock
12113
smart-hut/yarn.lock
File diff suppressed because it is too large
Load diff
4
yarn.lock
Normal file
4
yarn.lock
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
|
||||||
|
# yarn lockfile v1
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue