videocam connected to back end

This commit is contained in:
Fil Cesana 2020-04-22 14:25:24 +02:00
parent 840d5ab6a2
commit f9d1d9d678
3 changed files with 17 additions and 8 deletions

View File

@ -4,6 +4,7 @@ import SmartPlug from "./SmartPlug";
import Sensor from "./Sensor";
import { ButtonDimmer, KnobDimmer } from "./Dimmer";
import Switcher from "./Switch";
import Videocam from "./Videocam";
import { Segment, Grid, Header, Button, Icon } from "semantic-ui-react";
import { RemoteService } from "../../../remote";
import { connect } from "react-redux";
@ -30,6 +31,7 @@ class Device extends React.Component {
}
renderDeviceComponent() {
console.log(this.props.device)
switch (this.props.device.kind) {
case "regularLight":
return <Light id={this.props.id} />;
@ -47,6 +49,8 @@ class Device extends React.Component {
return <Switcher id={this.props.id} />;
case "dimmableLight":
return <Light id={this.props.id} />;
case "securityCamera":
return <Videocam id={this.props.id} />;
default:
throw new Error("Device type unknown");
}

View File

@ -106,6 +106,7 @@ class NewDevice extends Component {
switch: "New switch",
buttonDimmer: "New button dimmer",
knobDimmer: "New knob dimmer",
securityCamera: "New security camera"
};
if (this.state.deviceName === "") {
@ -186,6 +187,12 @@ class NewDevice extends Component {
value: "buttonDimmer",
image: { avatar: true, src: "/img/plusMinus.svg" },
},
{
key: "securityCamera",
text: "Security Camera",
value: "securityCamera",
image: { avatar: true, src: "/img/plusMinus.svg" },
}
];
const sensorOptions = [
{

View File

@ -5,13 +5,13 @@ import React, { Component } from "react";
import {
StyledDiv
} from "./VideocmStyle";
import { Checkbox, Embed, Button, Grid, Responsive, Segment } from "semantic-ui-react";
import {Grid } from "semantic-ui-react";
import { RemoteService } from "../../../remote";
import { connect } from "react-redux";
import VideocamModal from "./VideocamModal";
class Light extends Component {
class Videocam extends Component {
constructor(props) {
super(props);
this.state = { selectedVideo: undefined};
@ -32,7 +32,7 @@ class Light extends Component {
render() {
const normalLightView = (
const VideocamView = (
<div>
<StyledDiv>
<div onClick={this.openModal}>
@ -56,9 +56,7 @@ class Light extends Component {
return (
<div>
{this.props.device.kind === "dimmableLight"
? console.log('err')
: normalLightView}
{VideocamView}
</div>
);
}
@ -67,5 +65,5 @@ class Light extends Component {
const mapStateToProps = (state, ownProps) => ({
device: state.devices[ownProps.id],
});
const LightContainer = connect(mapStateToProps, RemoteService)(Light);
export default LightContainer;
const VideocamContainer = connect(mapStateToProps, RemoteService)(Videocam);
export default VideocamContainer;