Merge branch 'dev-copy' into 'dev'
Dev copy See merge request sa4-2020/the-sanmarinoes/frontend!106
This commit is contained in:
commit
c2f646d29a
14 changed files with 192 additions and 162 deletions
|
@ -24,7 +24,12 @@ class DevicePanel extends Component {
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
return (
|
return (
|
||||||
<Grid doubling columns={2} divided="vertically">
|
<Grid
|
||||||
|
doubling
|
||||||
|
columns={3}
|
||||||
|
divided="vertically"
|
||||||
|
style={{ paddingTop: "3rem" }}
|
||||||
|
>
|
||||||
{this.props.devices.map((e, i) => {
|
{this.props.devices.map((e, i) => {
|
||||||
return (
|
return (
|
||||||
<Grid.Column key={i}>
|
<Grid.Column key={i}>
|
||||||
|
|
|
@ -7,11 +7,18 @@ import Switcher from "./Switch";
|
||||||
import Videocam from "./Videocam";
|
import Videocam from "./Videocam";
|
||||||
import Curtains from "./Curtain";
|
import Curtains from "./Curtain";
|
||||||
import Thermostat from "./Thermostats";
|
import Thermostat from "./Thermostats";
|
||||||
import { Segment, Grid, Header, Button, Icon } from "semantic-ui-react";
|
import { Segment, Grid, Header, Button, Icon, Card } from "semantic-ui-react";
|
||||||
import { RemoteService } from "../../../remote";
|
import { RemoteService } from "../../../remote";
|
||||||
import { connect } from "react-redux";
|
import { connect } from "react-redux";
|
||||||
import DeviceSettingsModal from "./DeviceSettingsModal";
|
import DeviceSettingsModal from "./DeviceSettingsModal";
|
||||||
|
|
||||||
|
const centerComponent = {
|
||||||
|
marginLeft: "50%",
|
||||||
|
transform: "translateX(-50%)",
|
||||||
|
marginTop: "10%",
|
||||||
|
marginBottom: "10%",
|
||||||
|
};
|
||||||
|
|
||||||
class Device extends React.Component {
|
class Device extends React.Component {
|
||||||
constructor(props) {
|
constructor(props) {
|
||||||
super(props);
|
super(props);
|
||||||
|
@ -101,27 +108,14 @@ class Device extends React.Component {
|
||||||
<Videocam id={this.props.stateOrDevice.id} tab={this.props.tab} />
|
<Videocam id={this.props.stateOrDevice.id} tab={this.props.tab} />
|
||||||
);
|
);
|
||||||
default:
|
default:
|
||||||
//throw new Error("Device type unknown");
|
throw new Error("Device type unknown");
|
||||||
return undefined;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
deviceDescription() {
|
||||||
{
|
|
||||||
if (this.props.type !== "") {
|
|
||||||
return (
|
return (
|
||||||
<Segment>
|
<div className="ui two buttons">
|
||||||
<Grid columns={2}>
|
<Button color="blue" icon onClick={this.edit} labelPosition="left">
|
||||||
<Grid.Column>{this.renderDeviceComponent()}</Grid.Column>
|
|
||||||
{this.props.tab === "Devices" ? (
|
|
||||||
<Grid.Column textAlign="center">
|
|
||||||
<Header as="h3">{this.props.stateOrDevice.name}</Header>
|
|
||||||
<Button
|
|
||||||
color="blue"
|
|
||||||
icon
|
|
||||||
onClick={this.edit}
|
|
||||||
labelPosition="left"
|
|
||||||
>
|
|
||||||
<Icon name="pencil" />
|
<Icon name="pencil" />
|
||||||
Edit
|
Edit
|
||||||
</Button>
|
</Button>
|
||||||
|
@ -136,15 +130,13 @@ class Device extends React.Component {
|
||||||
Reset
|
Reset
|
||||||
</Button>
|
</Button>
|
||||||
) : null}
|
) : null}
|
||||||
</Grid.Column>
|
</div>
|
||||||
) : (
|
);
|
||||||
<Grid.Column textAlign="center">
|
}
|
||||||
<Header as="h3">{this.props.device.name}</Header>
|
|
||||||
{this.props.tab === "Scenes" ? (
|
stateDescription() {
|
||||||
<Header as="h4">{this.props.roomName}</Header>
|
return (
|
||||||
) : (
|
<div class="ui one button">
|
||||||
""
|
|
||||||
)}
|
|
||||||
<Button
|
<Button
|
||||||
color="red"
|
color="red"
|
||||||
icon
|
icon
|
||||||
|
@ -154,35 +146,49 @@ class Device extends React.Component {
|
||||||
<Icon name="undo" />
|
<Icon name="undo" />
|
||||||
Delete
|
Delete
|
||||||
</Button>
|
</Button>
|
||||||
</Grid.Column>
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
get deviceName() {
|
||||||
|
return this.props.tab === "Devices"
|
||||||
|
? this.props.stateOrDevice.name
|
||||||
|
: this.props.device.name;
|
||||||
|
}
|
||||||
|
|
||||||
|
render() {
|
||||||
|
{
|
||||||
|
return (
|
||||||
|
<Card>
|
||||||
|
<Card.Content>
|
||||||
|
<Card.Header textAlign="center">
|
||||||
|
<Header as="h3">{this.deviceName}</Header>
|
||||||
|
{this.props.tab === "Scenes" ? (
|
||||||
|
<Header as="h4">{this.props.roomName}</Header>
|
||||||
|
) : (
|
||||||
|
""
|
||||||
)}
|
)}
|
||||||
</Grid>
|
</Card.Header>
|
||||||
{this.props.stateOrDevice && this.props.tab === "Devices" ? (
|
|
||||||
|
<Card.Description style={centerComponent}>
|
||||||
|
{this.renderDeviceComponent()}
|
||||||
|
</Card.Description>
|
||||||
|
</Card.Content>
|
||||||
|
<Card.Content extra>
|
||||||
|
{this.props.tab === "Devices"
|
||||||
|
? this.deviceDescription()
|
||||||
|
: this.stateDescription()}
|
||||||
|
</Card.Content>
|
||||||
<DeviceSettingsModal
|
<DeviceSettingsModal
|
||||||
ref={this.modalRef}
|
ref={this.modalRef}
|
||||||
id={this.props.stateOrDevice.id}
|
id={this.props.stateOrDevice.id}
|
||||||
/>
|
/>
|
||||||
) : (
|
</Card>
|
||||||
""
|
|
||||||
)}
|
|
||||||
</Segment>
|
|
||||||
);
|
);
|
||||||
} else {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/*
|
|
||||||
|
|
||||||
{this.props.stateOrDevice ?
|
|
||||||
<DeviceSettingsModal
|
|
||||||
ref={this.modalRef}
|
|
||||||
id={this.props.stateOrDevice.id}
|
|
||||||
/> :
|
|
||||||
""
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
const mapStateToProps = (state, ownProps) => ({
|
const mapStateToProps = (state, ownProps) => ({
|
||||||
get stateOrDevice() {
|
get stateOrDevice() {
|
||||||
if (state.active.activeTab === "Devices") {
|
if (state.active.activeTab === "Devices") {
|
||||||
|
@ -207,7 +213,6 @@ const mapStateToProps = (state, ownProps) => ({
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
get type() {
|
get type() {
|
||||||
console.log("ALPACA", state, ownProps);
|
|
||||||
if (state.active.activeTab === "Scenes") {
|
if (state.active.activeTab === "Scenes") {
|
||||||
if (state.sceneStates[ownProps.id]) {
|
if (state.sceneStates[ownProps.id]) {
|
||||||
//console.log(state.sceneStates[ownProps.id], ownProps.id);
|
//console.log(state.sceneStates[ownProps.id], ownProps.id);
|
||||||
|
|
|
@ -33,6 +33,8 @@ const SettingsForm = (props) => {
|
||||||
|
|
||||||
const [values, setValues] = useState({ name: "" });
|
const [values, setValues] = useState({ name: "" });
|
||||||
|
|
||||||
|
console.log(props);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Form>
|
<Form>
|
||||||
<Form.Field>
|
<Form.Field>
|
||||||
|
@ -42,7 +44,6 @@ const SettingsForm = (props) => {
|
||||||
name="name"
|
name="name"
|
||||||
onChange={handleInputChange}
|
onChange={handleInputChange}
|
||||||
placeholder={props.name}
|
placeholder={props.name}
|
||||||
// {this.props.device.name}
|
|
||||||
/>
|
/>
|
||||||
</Form.Field>
|
</Form.Field>
|
||||||
|
|
||||||
|
@ -106,20 +107,25 @@ class DeviceSettingsModal extends Component {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
_editForm = null;
|
||||||
const SettingsModal = () => (
|
get editForm() {
|
||||||
<Modal closeIcon onClose={this.closeModal} open={this.state.openModal}>
|
this._editForm = this._editForm || (
|
||||||
<Modal.Header>Settings of {this.props.device.name}</Modal.Header>
|
|
||||||
<Modal.Content>
|
|
||||||
<SettingsForm
|
<SettingsForm
|
||||||
name={this.state.name}
|
name={this.state.name}
|
||||||
removeDevice={this.deleteDevice}
|
removeDevice={this.deleteDevice}
|
||||||
saveFunction={this.updateDevice}
|
saveFunction={this.updateDevice}
|
||||||
/>
|
/>
|
||||||
</Modal.Content>
|
);
|
||||||
|
return this._editForm;
|
||||||
|
}
|
||||||
|
|
||||||
|
render() {
|
||||||
|
return (
|
||||||
|
<Modal closeIcon onClose={this.closeModal} open={this.state.openModal}>
|
||||||
|
<Modal.Header>Settings of {this.props.device.name}</Modal.Header>
|
||||||
|
<Modal.Content>{this.editForm}</Modal.Content>
|
||||||
</Modal>
|
</Modal>
|
||||||
);
|
);
|
||||||
return <SettingsModal />;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -129,10 +129,10 @@ export class KnobDimmerComponent extends Component {
|
||||||
}
|
}
|
||||||
|
|
||||||
const mapStateToProps = (state, ownProps) => ({
|
const mapStateToProps = (state, ownProps) => ({
|
||||||
get stateOrDevice(){
|
get stateOrDevice() {
|
||||||
if(state.active.activeTab==="Devices"){
|
if (state.active.activeTab === "Devices") {
|
||||||
return state.devices[ownProps.id];
|
return state.devices[ownProps.id];
|
||||||
}else{
|
} else {
|
||||||
return state.sceneStates[ownProps.id];
|
return state.sceneStates[ownProps.id];
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
|
@ -35,6 +35,7 @@ export const ValueStyle = {
|
||||||
fontSize: "1.3rem",
|
fontSize: "1.3rem",
|
||||||
fontFamily: "Lato",
|
fontFamily: "Lato",
|
||||||
textAnchor: "middle",
|
textAnchor: "middle",
|
||||||
|
userSelect: "none",
|
||||||
};
|
};
|
||||||
|
|
||||||
export const CircularThumbStyle = {
|
export const CircularThumbStyle = {
|
||||||
|
@ -52,6 +53,7 @@ export const textStyle = {
|
||||||
overflow: "hidden",
|
overflow: "hidden",
|
||||||
whiteSpace: "nowrap",
|
whiteSpace: "nowrap",
|
||||||
textOverflow: "ellipsis",
|
textOverflow: "ellipsis",
|
||||||
|
userSelect: "none",
|
||||||
};
|
};
|
||||||
|
|
||||||
export const knobIcon = {
|
export const knobIcon = {
|
||||||
|
|
|
@ -164,8 +164,8 @@ class Light extends Component {
|
||||||
);
|
);
|
||||||
|
|
||||||
const normalLightView = (
|
const normalLightView = (
|
||||||
<StyledDiv>
|
<StyledDiv onClick={this.onClickDevice}>
|
||||||
<div onClick={this.onClickDevice}>
|
<div>
|
||||||
<Image src={this.getIcon()} style={iconStyle} />
|
<Image src={this.getIcon()} style={iconStyle} />
|
||||||
<BottomPanel style={{ backgroundColor: "#ffa41b" }}>
|
<BottomPanel style={{ backgroundColor: "#ffa41b" }}>
|
||||||
<h5 style={nameStyle}>Light</h5>
|
<h5 style={nameStyle}>Light</h5>
|
||||||
|
|
|
@ -20,6 +20,7 @@ export const textStyle = {
|
||||||
overflow: "hidden",
|
overflow: "hidden",
|
||||||
whiteSpace: "nowrap",
|
whiteSpace: "nowrap",
|
||||||
textOverflow: "ellipsis",
|
textOverflow: "ellipsis",
|
||||||
|
userSelect: "none",
|
||||||
};
|
};
|
||||||
|
|
||||||
export const nameStyle = {
|
export const nameStyle = {
|
||||||
|
@ -29,6 +30,7 @@ export const nameStyle = {
|
||||||
left: "50%",
|
left: "50%",
|
||||||
transform: "translateX(-50%)",
|
transform: "translateX(-50%)",
|
||||||
color: "white",
|
color: "white",
|
||||||
|
userSelect: "none",
|
||||||
};
|
};
|
||||||
|
|
||||||
export const LightDimmerStyle = {
|
export const LightDimmerStyle = {
|
||||||
|
|
|
@ -21,12 +21,14 @@ export const sensorText = {
|
||||||
overflow: "hidden",
|
overflow: "hidden",
|
||||||
whiteSpace: "nowrap",
|
whiteSpace: "nowrap",
|
||||||
textOverflow: "ellipsis",
|
textOverflow: "ellipsis",
|
||||||
|
userSelect: "none",
|
||||||
};
|
};
|
||||||
|
|
||||||
export const valueStyle = {
|
export const valueStyle = {
|
||||||
fill: "#3e99ff",
|
fill: "#3e99ff",
|
||||||
fontSize: "2.4rem",
|
fontSize: "2.4rem",
|
||||||
fontFamily: "Lato",
|
fontFamily: "Lato",
|
||||||
|
userSelect: "none",
|
||||||
};
|
};
|
||||||
|
|
||||||
export const errorStyle = {
|
export const errorStyle = {
|
||||||
|
@ -34,6 +36,7 @@ export const errorStyle = {
|
||||||
fontSize: "1.5rem",
|
fontSize: "1.5rem",
|
||||||
fontFamily: "Lato",
|
fontFamily: "Lato",
|
||||||
textShadow: "1px 1px 0.5px rgba(0, 0, 0, .2)",
|
textShadow: "1px 1px 0.5px rgba(0, 0, 0, .2)",
|
||||||
|
userSelect: "none",
|
||||||
};
|
};
|
||||||
|
|
||||||
export const motionSensorInnerCircle = {
|
export const motionSensorInnerCircle = {
|
||||||
|
|
|
@ -5,6 +5,7 @@ export const energyConsumedStyle = {
|
||||||
top: "20%",
|
top: "20%",
|
||||||
left: "50%",
|
left: "50%",
|
||||||
transform: "translateX(-50%)",
|
transform: "translateX(-50%)",
|
||||||
|
userSelect: "none",
|
||||||
};
|
};
|
||||||
|
|
||||||
export const kwhStyle = {
|
export const kwhStyle = {
|
||||||
|
@ -14,6 +15,7 @@ export const kwhStyle = {
|
||||||
top: "50%",
|
top: "50%",
|
||||||
left: "50%",
|
left: "50%",
|
||||||
transform: "translateX(-50%)",
|
transform: "translateX(-50%)",
|
||||||
|
userSelect: "none",
|
||||||
};
|
};
|
||||||
|
|
||||||
export const imageStyle = {
|
export const imageStyle = {
|
||||||
|
@ -24,6 +26,7 @@ export const imageStyle = {
|
||||||
left: "50%",
|
left: "50%",
|
||||||
transform: "translateX(-35%)",
|
transform: "translateX(-35%)",
|
||||||
filter: "drop-shadow( 1px 1px 0.5px rgba(0, 0, 0, .25))",
|
filter: "drop-shadow( 1px 1px 0.5px rgba(0, 0, 0, .25))",
|
||||||
|
userSelect: "none",
|
||||||
};
|
};
|
||||||
|
|
||||||
export const nameStyle = {
|
export const nameStyle = {
|
||||||
|
@ -35,4 +38,5 @@ export const nameStyle = {
|
||||||
overflow: "hidden",
|
overflow: "hidden",
|
||||||
whiteSpace: "nowrap",
|
whiteSpace: "nowrap",
|
||||||
textOverflow: "ellipsis",
|
textOverflow: "ellipsis",
|
||||||
|
userSelect: "none",
|
||||||
};
|
};
|
||||||
|
|
|
@ -5,6 +5,7 @@ export const imageStyle = {
|
||||||
top: "5%",
|
top: "5%",
|
||||||
left: "50%",
|
left: "50%",
|
||||||
transform: "translateX(-50%)",
|
transform: "translateX(-50%)",
|
||||||
|
userSelect: "none",
|
||||||
};
|
};
|
||||||
|
|
||||||
export const nameStyle = {
|
export const nameStyle = {
|
||||||
|
@ -16,6 +17,7 @@ export const nameStyle = {
|
||||||
overflow: "hidden",
|
overflow: "hidden",
|
||||||
whiteSpace: "nowrap",
|
whiteSpace: "nowrap",
|
||||||
textOverflow: "ellipsis",
|
textOverflow: "ellipsis",
|
||||||
|
userSelect: "none",
|
||||||
};
|
};
|
||||||
|
|
||||||
export const turnedOnStyle = {
|
export const turnedOnStyle = {
|
||||||
|
@ -25,4 +27,5 @@ export const turnedOnStyle = {
|
||||||
top: "20%",
|
top: "20%",
|
||||||
left: "50%",
|
left: "50%",
|
||||||
transform: "translateX(-50%)",
|
transform: "translateX(-50%)",
|
||||||
|
userSelect: "none",
|
||||||
};
|
};
|
||||||
|
|
|
@ -75,6 +75,7 @@ export const iconStyle = {
|
||||||
top: "10%",
|
top: "10%",
|
||||||
left: "50%",
|
left: "50%",
|
||||||
transform: "translateX(-50%)",
|
transform: "translateX(-50%)",
|
||||||
|
userSelect: "none",
|
||||||
};
|
};
|
||||||
export const nameStyle = {
|
export const nameStyle = {
|
||||||
position: "absolute",
|
position: "absolute",
|
||||||
|
|
|
@ -499,7 +499,6 @@ function reducer(previousState, action) {
|
||||||
console.warn(`Action type ${action.type} unknown`, action);
|
console.warn(`Action type ${action.type} unknown`, action);
|
||||||
return previousState;
|
return previousState;
|
||||||
}
|
}
|
||||||
console.log("THETRUEALPACA", newState, action.type, action);
|
|
||||||
return newState;
|
return newState;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue