2020-04-22 11:34:10 +00:00
|
|
|
// vim: set ts=2 sw=2 et tw=80:
|
|
|
|
|
|
|
|
import React, { Component } from "react";
|
2020-04-22 18:14:18 +00:00
|
|
|
import { StyledDivCamera } from "./styleComponents";
|
|
|
|
import { Grid } from "semantic-ui-react";
|
2020-04-22 11:34:10 +00:00
|
|
|
import { RemoteService } from "../../../remote";
|
2020-04-23 15:18:43 +00:00
|
|
|
import { endpointURL } from "../../../endpoint";
|
2020-04-22 11:34:10 +00:00
|
|
|
import { connect } from "react-redux";
|
2020-04-22 18:14:18 +00:00
|
|
|
import VideocamModal from "./VideocamModal";
|
2020-05-03 16:09:53 +00:00
|
|
|
import mapStateToProps from "../../../deviceProps";
|
2020-04-22 11:34:10 +00:00
|
|
|
|
2020-04-22 12:25:24 +00:00
|
|
|
class Videocam extends Component {
|
2020-04-22 11:34:10 +00:00
|
|
|
constructor(props) {
|
|
|
|
super(props);
|
2020-04-22 18:14:18 +00:00
|
|
|
this.state = { selectedVideo: undefined };
|
2020-04-22 11:34:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
openModal = () => {
|
|
|
|
this.setState((state) => {
|
2020-04-22 18:14:18 +00:00
|
|
|
return { selectedVideo: true };
|
2020-04-22 11:34:10 +00:00
|
|
|
});
|
|
|
|
};
|
|
|
|
|
|
|
|
closeModal = () => {
|
|
|
|
this.setState((state) => {
|
2020-04-22 18:14:18 +00:00
|
|
|
return { selectedVideo: undefined };
|
|
|
|
});
|
|
|
|
};
|
2020-04-22 11:34:10 +00:00
|
|
|
|
2020-04-23 15:18:43 +00:00
|
|
|
get url() {
|
|
|
|
return endpointURL() + this.props.device.path;
|
|
|
|
}
|
|
|
|
|
2020-04-22 11:34:10 +00:00
|
|
|
render() {
|
2020-04-22 12:25:24 +00:00
|
|
|
const VideocamView = (
|
2020-04-22 11:34:10 +00:00
|
|
|
<div>
|
2020-04-22 18:14:18 +00:00
|
|
|
<StyledDivCamera>
|
|
|
|
<div onClick={this.openModal}>
|
|
|
|
<video autoPlay loop muted width="100%" height="auto">
|
2020-04-23 15:18:43 +00:00
|
|
|
<source src={this.url} type="video/mp4" />
|
2020-04-22 11:34:10 +00:00
|
|
|
</video>
|
|
|
|
</div>
|
2020-04-22 18:14:18 +00:00
|
|
|
</StyledDivCamera>
|
2020-04-26 11:38:54 +00:00
|
|
|
<Grid columns="equal" padded>
|
2020-04-22 18:14:18 +00:00
|
|
|
<Grid.Row textAlign="center">
|
|
|
|
<Grid.Column>
|
|
|
|
<VideocamModal
|
|
|
|
selectedVideo={this.state.selectedVideo}
|
|
|
|
closeModal={this.closeModal}
|
2020-04-23 15:18:43 +00:00
|
|
|
url={this.url}
|
2020-04-22 18:14:18 +00:00
|
|
|
/>
|
|
|
|
</Grid.Column>
|
|
|
|
</Grid.Row>
|
|
|
|
</Grid>
|
2020-04-22 11:34:10 +00:00
|
|
|
</div>
|
|
|
|
);
|
2020-04-22 18:14:18 +00:00
|
|
|
|
|
|
|
return <div>{VideocamView}</div>;
|
2020-04-22 11:34:10 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-04-22 12:25:24 +00:00
|
|
|
const VideocamContainer = connect(mapStateToProps, RemoteService)(Videocam);
|
|
|
|
export default VideocamContainer;
|