frontend/smart-hut/src/components/dashboard/devices/Videocam.js

72 lines
1.7 KiB
JavaScript

// vim: set ts=2 sw=2 et tw=80:
import React, { Component } from "react";
import {
StyledDiv
} from "./VideocmStyle";
import { Checkbox, Embed, Button, Grid, Responsive, Segment } from "semantic-ui-react";
import { RemoteService } from "../../../remote";
import { connect } from "react-redux";
import VideocamModal from "./VideocamModal";
class Light extends Component {
constructor(props) {
super(props);
this.state = { selectedVideo: undefined};
}
openModal = () => {
this.setState((state) => {
return {selectedVideo: true}
});
};
closeModal = () => {
this.setState((state) => {
return {selectedVideo:undefined}
})
}
render() {
const normalLightView = (
<div>
<StyledDiv>
<div onClick={this.openModal}>
<video autoPlay loop muted width= "100%" height="auto">
<source src="paranormal-activity.mp4" type='video/mp4' />
</video>
</div>
</StyledDiv>
<Grid columns="equal" divide padded>
<Grid.Row textAlign="center">
<Grid.Column>
<VideocamModal
selectedVideo = {this.state.selectedVideo}
closeModal = {this.closeModal}
/>
</Grid.Column>
</ Grid.Row>
</Grid>
</div>
);
return (
<div>
{this.props.device.kind === "dimmableLight"
? console.log('err')
: normalLightView}
</div>
);
}
}
const mapStateToProps = (state, ownProps) => ({
device: state.devices[ownProps.id],
});
const LightContainer = connect(mapStateToProps, RemoteService)(Light);
export default LightContainer;