added update for dimmableLights

This commit is contained in:
britea 2020-03-23 13:22:30 +01:00
parent 950908ef07
commit 045742d68e
4 changed files with 15 additions and 19 deletions

View File

@ -31,7 +31,6 @@ class App extends Component {
let userJsonString = localStorage.getItem("token"); let userJsonString = localStorage.getItem("token");
let exp = localStorage.getItem("exp"); let exp = localStorage.getItem("exp");
let date = new Date().getTime(); let date = new Date().getTime();
console.log(exp > date, date)
if (userJsonString && exp && date < exp) { if (userJsonString && exp && date < exp) {
loggedIn = true; loggedIn = true;
} else { } else {
@ -53,7 +52,6 @@ class App extends Component {
componentDidMount() { componentDidMount() {
if (window.location) { if (window.location) {
const values = queryString.parse(window.location.search); const values = queryString.parse(window.location.search);
console.log(values);
this.setState({ this.setState({
query : values query : values
}); });

View File

@ -36,7 +36,6 @@ export default class Light extends Component {
setIntensity = (newValue) => { setIntensity = (newValue) => {
this.props.device.intensity = Math.round(newValue * 100) <= 1 ? 1 : Math.round(newValue * 100); this.props.device.intensity = Math.round(newValue * 100) <= 1 ? 1 : Math.round(newValue * 100);
console.log(this.props.device.intensity)
call.deviceUpdate(this.props.device, 'dimmableLight') call.deviceUpdate(this.props.device, 'dimmableLight')
.then(res => { .then(res => {
if (res.status === 200 ) { if (res.status === 200 ) {
@ -69,7 +68,7 @@ export default class Light extends Component {
render() { render() {
const intensityLightView = ( const intensityLightView = (
<CircularInput <CircularInput
value={Math.round(this.props.device.intensity/100)} value={+(Math.round(this.props.device.intensity/100 + "e+2") + "e-2")}
onChange={this.setIntensity} onChange={this.setIntensity}
style={style} style={style}
> >

View File

@ -108,12 +108,12 @@ export default class ModalWindow extends Component {
<p>Insert the name of the room:</p> <p>Insert the name of the room:</p>
<Form.Field> <Form.Field>
<Input label='Room name' placeholder='Room Name' name="name" type='text' onChange={this.changeSomething} <Input label='Room name' placeholder='Room Name' name="name" type='text' onChange={this.changeSomething}
value={this.props.type === "new" && this.props.idRoom !== -1 ? "" : "" }/> value={this.props.type === "new" ? "" : this.props.idRoom.name }/>
</Form.Field> </Form.Field>
<p>Insert an image of the room:</p> <p>Insert an image of the room:</p>
<Form.Field> <Form.Field>
<Input label='Room image' type='file' name="img" onChange={this.changeSomething} <Input label='Room image' type='file' name="img" onChange={this.changeSomething}
value={this.props.type === "new" && this.props.idRoom !== -1 ? "" : this.props.idRoom.images }/> value={this.props.type === "new" ? "" : this.props.idRoom.images }/>
</Form.Field> </Form.Field>
</Form> </Form>
@ -126,7 +126,7 @@ export default class ModalWindow extends Component {
<Button icon labelPosition='left' inverted color='red' onClick={this.deleteRoom}> <Button icon labelPosition='left' inverted color='red' onClick={this.deleteRoom}>
<Icon name='trash alternate' /> <Icon name='trash alternate' />
Delete room Delete room
</Button> : "" } </Button> : null }
</Modal.Content> </Modal.Content>
<Modal.Actions> <Modal.Actions>

View File

@ -36,7 +36,7 @@ class Navbar extends Component {
render(){ render(){
//const { activeItem } = this.state //const { activeItem } = this.state
return ( return (
<div style={{background: '#1b1c1d'}}> <div style={{background: '#1b1c1d!important'}}>
<Segment.Group> <Segment.Group>
<Responsive as={Segment} minWidth={768}> <Responsive as={Segment} minWidth={768}>
<Grid> <Grid>
@ -163,22 +163,21 @@ class Navbar extends Component {
</Dropdown.Menu> </Dropdown.Menu>
</Dropdown> </Dropdown>
</Menu> </Menu >
{ <Grid inverted>
this.state.activeItem !== -1 ?
<Grid>
<Grid.Row> <Grid.Row>
<Grid.Column width={8}> <Grid.Column width={8}>
<ModalWindow type="new" idRoom={this.state.activeRoom} updateRoom={this.props.updateRoom} deleteRoom={this.props.deleteRoom}/> <ModalWindow type="new" addRoom={this.props.addRoom} />
</Grid.Column>
<Grid.Column width={8}>
<ModalWindow type="modify" idRoom={this.state.activeRoom} updateRoom={this.props.updateRoom} deleteRoom={this.props.deleteRoom}/>
</Grid.Column> </Grid.Column>
{
this.state.activeItem !== -1 ?
<Grid.Column width={8}>
<ModalWindow type="modify" idRoom={this.state.activeRoom} updateRoom={this.props.updateRoom} deleteRoom={this.props.deleteRoom}/>
</Grid.Column>
: null
}
</Grid.Row> </Grid.Row>
</Grid> </Grid>
:
null
}
</Responsive> </Responsive>
</Segment.Group> </Segment.Group>