video component is finished and ready for those who want to be tested in the file light.js; tomorrow I will move everything back in Videocam.js (in devices) and with Andrea we will perform the connection with the backend. If you test it, enjoy the video I put in loop ;)
This commit is contained in:
parent
3443bc8530
commit
509335a061
3 changed files with 94 additions and 38 deletions
|
@ -10,44 +10,39 @@
|
|||
|
||||
import React, { Component } from "react";
|
||||
import {
|
||||
StyledDiv,hAbRNe
|
||||
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 = { intensity: this.props.device.intensity, timeout: null };
|
||||
|
||||
this.iconOn = "/img/lightOn.svg";
|
||||
this.iconOff = "/img/lightOff.svg";
|
||||
this.state = { selectedVideo: undefined};
|
||||
}
|
||||
|
||||
get turnedOn() {
|
||||
return this.props.device.on;
|
||||
openModal = () => {
|
||||
this.setState((state) => {
|
||||
return {selectedVideo: true}
|
||||
|
||||
});
|
||||
};
|
||||
|
||||
closeModal = () => {
|
||||
this.setState((state) => {
|
||||
return {selectedVideo:undefined}
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
onClickDevice = () => {
|
||||
const on = !this.turnedOn;
|
||||
this.props
|
||||
.saveDevice({ ...this.props.device, on })
|
||||
.catch((err) => console.error("regular light update error", err));
|
||||
};
|
||||
|
||||
getIcon = () => {
|
||||
return this.turnedOn ? this.iconOn : this.iconOff;
|
||||
};
|
||||
|
||||
|
||||
render() {
|
||||
|
||||
const normalLightView = (
|
||||
<div>
|
||||
<StyledDiv>
|
||||
<div onClick={this.onClickDevice}>
|
||||
<div onClick={this.openModal}>
|
||||
<video autoPlay loop muted width= "100%" height="auto">
|
||||
<source src="paranormal-activity.mp4" type='video/mp4' />
|
||||
</video>
|
||||
|
@ -55,27 +50,14 @@ class Light extends Component {
|
|||
</StyledDiv>
|
||||
<Grid columns="equal" divide padded>
|
||||
<Grid.Row textAlign="center">
|
||||
<Grid.Column width={2} height={0.5}>
|
||||
</Grid.Column>
|
||||
<Grid.Column width={2} height={0.5}>
|
||||
<Checkbox toggle
|
||||
padding = '0.5rem'
|
||||
margin-left = '5rem'
|
||||
defaultChecked
|
||||
/>
|
||||
</Grid.Column>
|
||||
<Grid.Column width={3} height={0.5}>
|
||||
</Grid.Column>
|
||||
<Grid.Column>
|
||||
<Button size='mini' color='blue'>
|
||||
Enlarge
|
||||
</Button>
|
||||
</Grid.Column>
|
||||
<Grid.Column width={4} height={0.5}>
|
||||
<VideocamModal
|
||||
selectedVideo = {this.state.selectedVideo}
|
||||
closeModal = {this.closeModal}
|
||||
/>
|
||||
</Grid.Column>
|
||||
</ Grid.Row>
|
||||
</Grid>
|
||||
|
||||
</div>
|
||||
);
|
||||
|
||||
|
|
|
@ -0,0 +1,33 @@
|
|||
|
||||
|
||||
|
||||
.ReactModalPortal > div {
|
||||
opacity: 0;
|
||||
}
|
||||
|
||||
.ReactModalPortal .ReactModal__Overlay {
|
||||
align-items: center;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
transition: opacity 200ms ease-in-out;
|
||||
}
|
||||
|
||||
.ReactModalPortal .ReactModal__Overlay--after-open {
|
||||
opacity: 1;
|
||||
}
|
||||
|
||||
|
||||
.ReactModalPortal .ReactModal__Overlay--before-close {
|
||||
opacity: 0;
|
||||
}
|
||||
|
||||
.modal {
|
||||
color: white;
|
||||
max-width: 30rem;
|
||||
outline: none;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.modal__body {
|
||||
margin: 0 0 0 0;
|
||||
}
|
41
smart-hut/src/components/dashboard/devices/VideocamModal.js
Normal file
41
smart-hut/src/components/dashboard/devices/VideocamModal.js
Normal file
|
@ -0,0 +1,41 @@
|
|||
import React from 'react';
|
||||
import Modal from 'react-modal';
|
||||
import { Button } from "semantic-ui-react";
|
||||
|
||||
const customStyles = {
|
||||
content: {
|
||||
top: '35%',
|
||||
left: '50%',
|
||||
right: 'auto',
|
||||
bottom: 'auto',
|
||||
marginRight: '-50%',
|
||||
width: '60%',
|
||||
transform: 'translate(-40%, -10%)',
|
||||
},
|
||||
};
|
||||
|
||||
|
||||
const VideocamModal = (props) => (
|
||||
<Modal
|
||||
isOpen={!!props.selectedVideo}
|
||||
contentLabel="Live Cam"
|
||||
onRequestClose={props.closeModal}
|
||||
style={customStyles}
|
||||
>
|
||||
{props.selectedVideo &&
|
||||
<video autoPlay loop muted width= "100%" height="auto">
|
||||
<source src="paranormal-activity.mp4" type='video/mp4' />
|
||||
</video>
|
||||
}
|
||||
<Button
|
||||
fluid
|
||||
primary
|
||||
onClick={props.closeModal}
|
||||
>
|
||||
Close
|
||||
</Button>
|
||||
</Modal>
|
||||
);
|
||||
|
||||
|
||||
export default VideocamModal;
|
Loading…
Reference in a new issue