Merge branch 'dev' into '72-7-users-can-invite-guests'
# Conflicts: # smart-hut/src/components/dashboard/devices/Device.js
This commit is contained in:
commit
61430bb42e
3 changed files with 35 additions and 4 deletions
|
@ -126,7 +126,10 @@ class Device extends React.Component {
|
||||||
<Header as="h4">{this.props.roomName}</Header>
|
<Header as="h4">{this.props.roomName}</Header>
|
||||||
</Card.Header>
|
</Card.Header>
|
||||||
|
|
||||||
<Card.Description style={centerComponent}>
|
<Card.Description
|
||||||
|
style={
|
||||||
|
this.props.device.kind !== "curtains" ? centerComponent : null
|
||||||
|
}>
|
||||||
{this.renderDeviceComponent()}
|
{this.renderDeviceComponent()}
|
||||||
</Card.Description>
|
</Card.Description>
|
||||||
</Card.Content>
|
</Card.Content>
|
||||||
|
|
|
@ -105,7 +105,7 @@ class Thermostats extends Component {
|
||||||
? this.props.device.mode !== "OFF"
|
? this.props.device.mode !== "OFF"
|
||||||
: this.props.stateOrDevice.on
|
: this.props.stateOrDevice.on
|
||||||
}
|
}
|
||||||
slider
|
toggle
|
||||||
style={toggle}
|
style={toggle}
|
||||||
onChange={(e, val) => this.setMode(val.checked)}
|
onChange={(e, val) => this.setMode(val.checked)}
|
||||||
/>
|
/>
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
import React, { Component } from "react";
|
import React, { Component } from "react";
|
||||||
import { StyledDivCamera } from "./styleComponents";
|
import { StyledDivCamera } from "./styleComponents";
|
||||||
import { Grid } from "semantic-ui-react";
|
import { Grid, Checkbox } from "semantic-ui-react";
|
||||||
import { RemoteService } from "../../../remote";
|
import { RemoteService } from "../../../remote";
|
||||||
import { endpointURL } from "../../../endpoint";
|
import { endpointURL } from "../../../endpoint";
|
||||||
import { connect } from "react-redux";
|
import { connect } from "react-redux";
|
||||||
|
@ -13,6 +13,8 @@ class Videocam extends Component {
|
||||||
constructor(props) {
|
constructor(props) {
|
||||||
super(props);
|
super(props);
|
||||||
this.state = { selectedVideo: undefined };
|
this.state = { selectedVideo: undefined };
|
||||||
|
|
||||||
|
this.setOnOff = this.setOnOff.bind(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
openModal = () => {
|
openModal = () => {
|
||||||
|
@ -27,6 +29,23 @@ class Videocam extends Component {
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
setOnOff(onOff) {
|
||||||
|
const turn = onOff;
|
||||||
|
if (this.props.tab === "Devices") {
|
||||||
|
this.props
|
||||||
|
.saveDevice({ ...this.props.device, on: turn })
|
||||||
|
.then((res) =>
|
||||||
|
turn ? this.refs.vidRef.play() : this.refs.vidRef.pause()
|
||||||
|
)
|
||||||
|
.catch((err) => console.error("videocamera update error", err));
|
||||||
|
} else {
|
||||||
|
this.props.updateState(
|
||||||
|
{ id: this.props.state.id, on: turn },
|
||||||
|
this.props.state.kind
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
get url() {
|
get url() {
|
||||||
return endpointURL() + this.props.device.path;
|
return endpointURL() + this.props.device.path;
|
||||||
}
|
}
|
||||||
|
@ -36,7 +55,7 @@ class Videocam extends Component {
|
||||||
<div>
|
<div>
|
||||||
<StyledDivCamera>
|
<StyledDivCamera>
|
||||||
<div onClick={this.openModal}>
|
<div onClick={this.openModal}>
|
||||||
<video autoPlay loop muted width="100%" height="auto">
|
<video ref="vidRef" autoPlay loop muted width="100%" height="auto">
|
||||||
<source src={this.url} type="video/mp4" />
|
<source src={this.url} type="video/mp4" />
|
||||||
</video>
|
</video>
|
||||||
</div>
|
</div>
|
||||||
|
@ -52,6 +71,15 @@ class Videocam extends Component {
|
||||||
</Grid.Column>
|
</Grid.Column>
|
||||||
</Grid.Row>
|
</Grid.Row>
|
||||||
</Grid>
|
</Grid>
|
||||||
|
<Checkbox
|
||||||
|
checked={
|
||||||
|
this.props.tab === "Devices"
|
||||||
|
? this.props.device.on
|
||||||
|
: this.props.state.on
|
||||||
|
}
|
||||||
|
toggle
|
||||||
|
onChange={(e, val) => this.setOnOff(val.checked)}
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue