2020-03-13 14:21:33 +00:00
|
|
|
import React, { Component } from 'react';
|
2020-03-18 16:12:29 +00:00
|
|
|
import { Menu, Grid, Icon, Button, Header, Image, Modal, Responsive, Segment, Dropdown } from "semantic-ui-react";
|
2020-03-13 14:21:33 +00:00
|
|
|
import {editButtonStyle} from "../components/dashboard/devices/styleComponents";
|
|
|
|
import ModalWindow from "../components/modalform";
|
|
|
|
|
|
|
|
class Navbar extends Component {
|
|
|
|
constructor(props) {
|
|
|
|
super(props);
|
|
|
|
this.state = {
|
|
|
|
activeItem: 'Home',
|
2020-03-17 15:39:21 +00:00
|
|
|
edited: "",
|
|
|
|
editMode : false
|
2020-03-13 14:21:33 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-03-18 16:12:29 +00:00
|
|
|
editModeController = (e) => this.setState((prevState) => ({ editMode: !prevState.editMode }));
|
2020-03-13 14:21:33 +00:00
|
|
|
|
2020-03-18 11:46:28 +00:00
|
|
|
handleClick = (e, {id}) => {
|
|
|
|
console.log(id);
|
|
|
|
this.setState({ activeItem: id,
|
2020-03-13 14:21:33 +00:00
|
|
|
});
|
2020-03-18 11:46:28 +00:00
|
|
|
this.props.handleItemClick(id)
|
2020-03-13 14:21:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
render(){
|
2020-03-18 11:46:28 +00:00
|
|
|
//const { activeItem } = this.state
|
2020-03-13 14:21:33 +00:00
|
|
|
return (
|
|
|
|
<div>
|
|
|
|
<Segment.Group>
|
2020-03-18 16:12:29 +00:00
|
|
|
<Responsive as={Segment} minWidth={768}>
|
2020-03-13 14:21:33 +00:00
|
|
|
<Grid>
|
2020-03-14 14:25:55 +00:00
|
|
|
<Grid.Row color='black'>
|
2020-03-13 14:21:33 +00:00
|
|
|
<button style={editButtonStyle} onClick={this.editModeController}>Edit</button>
|
|
|
|
</Grid.Row>
|
2020-03-14 14:25:55 +00:00
|
|
|
<Grid.Row color='black'>
|
2020-03-13 14:21:33 +00:00
|
|
|
<Menu inverted fluid vertical>
|
|
|
|
<Menu.Item
|
2020-03-18 11:46:28 +00:00
|
|
|
key={-1}
|
2020-03-13 14:21:33 +00:00
|
|
|
name='Home'
|
2020-03-18 11:46:28 +00:00
|
|
|
active={this.state.activeItem === 'Home'}
|
2020-03-13 14:21:33 +00:00
|
|
|
onClick={this.handleClick}
|
|
|
|
>
|
|
|
|
<Grid>
|
|
|
|
<Grid.Row>
|
|
|
|
<Grid.Column>
|
|
|
|
<Icon name="home" size="small"/>
|
|
|
|
</Grid.Column>
|
|
|
|
<Grid.Column>
|
2020-03-17 15:39:21 +00:00
|
|
|
HOME
|
2020-03-13 14:21:33 +00:00
|
|
|
</Grid.Column>
|
|
|
|
</Grid.Row>
|
|
|
|
</Grid>
|
|
|
|
|
|
|
|
</ Menu.Item>
|
|
|
|
|
|
|
|
{this.props.rooms ?
|
|
|
|
this.props.rooms.map((e, i) => {
|
|
|
|
return (
|
|
|
|
<Menu.Item
|
2020-03-14 14:25:55 +00:00
|
|
|
id={e.id}
|
2020-03-13 14:21:33 +00:00
|
|
|
key={i}
|
|
|
|
name={e.name}
|
2020-03-18 11:46:28 +00:00
|
|
|
active={this.state.activeItem === e.id}
|
2020-03-13 14:21:33 +00:00
|
|
|
onClick={this.handleClick}
|
|
|
|
>
|
|
|
|
<Grid>
|
|
|
|
<Grid.Row>
|
2020-03-17 15:39:21 +00:00
|
|
|
<Grid.Column>
|
2020-03-14 14:25:55 +00:00
|
|
|
<Icon name={e.icon} size="small"/>
|
2020-03-13 14:21:33 +00:00
|
|
|
</Grid.Column>
|
2020-03-17 15:39:21 +00:00
|
|
|
<Grid.Column width={8}>
|
2020-03-13 14:21:33 +00:00
|
|
|
{e.name}
|
|
|
|
</Grid.Column>
|
2020-03-17 15:39:21 +00:00
|
|
|
<Grid.Column floated="right">
|
2020-03-18 16:12:29 +00:00
|
|
|
{this.state.editMode ?
|
2020-03-17 15:39:21 +00:00
|
|
|
<ModalWindow type="modify" idRoom={e} modifyRoom={this.props.updateRoom} deleteRoom={this.props.deleteRoom}/>
|
|
|
|
: null
|
|
|
|
}
|
2020-03-13 14:21:33 +00:00
|
|
|
</Grid.Column>
|
|
|
|
</Grid.Row>
|
|
|
|
</Grid>
|
|
|
|
</ Menu.Item>
|
|
|
|
)
|
|
|
|
}) : null
|
|
|
|
}
|
|
|
|
|
|
|
|
<Menu.Item
|
|
|
|
name='newM'
|
2020-03-18 11:46:28 +00:00
|
|
|
active={this.state.activeItem === 'newM'}
|
2020-03-13 14:21:33 +00:00
|
|
|
>
|
|
|
|
|
2020-03-17 15:39:21 +00:00
|
|
|
<Grid>
|
|
|
|
<Grid.Row centered name='new'>
|
2020-03-14 14:25:55 +00:00
|
|
|
<ModalWindow type="new" addRoom={this.props.addRoom}/>
|
2020-03-13 14:21:33 +00:00
|
|
|
</Grid.Row>
|
|
|
|
</Grid>
|
|
|
|
|
|
|
|
</ Menu.Item>
|
|
|
|
</Menu>
|
|
|
|
</Grid.Row>
|
|
|
|
</Grid>
|
|
|
|
</Responsive>
|
2020-03-18 16:12:29 +00:00
|
|
|
|
2020-03-13 14:21:33 +00:00
|
|
|
<Responsive as={Segment} maxWidth={768}>
|
2020-03-18 16:12:29 +00:00
|
|
|
|
|
|
|
<Menu inverted>
|
|
|
|
<Dropdown item fluid text='Select Room'>
|
|
|
|
<Dropdown.Menu>
|
|
|
|
|
|
|
|
<Dropdown.Item
|
|
|
|
key={-1}
|
|
|
|
name='Home'
|
|
|
|
active={this.state.activeItem === 'Home'}
|
|
|
|
onClick={this.handleClick}>
|
|
|
|
<Grid>
|
|
|
|
<Grid.Row>
|
|
|
|
<Grid.Column>
|
|
|
|
<Icon name="home" size="small"/>
|
|
|
|
</Grid.Column>
|
|
|
|
<Grid.Column>
|
|
|
|
Home
|
|
|
|
</Grid.Column>
|
|
|
|
</Grid.Row>
|
|
|
|
</Grid>
|
|
|
|
</Dropdown.Item>
|
|
|
|
|
|
|
|
{this.props.rooms ?
|
|
|
|
this.props.rooms.map((e, i) => {
|
|
|
|
return (
|
|
|
|
<Dropdown.Item
|
|
|
|
id={e.id}
|
|
|
|
key={i}
|
|
|
|
name={e.name}
|
|
|
|
active={this.state.activeItem === e.id}
|
|
|
|
onClick={this.handleClick}
|
|
|
|
>
|
|
|
|
<Grid>
|
|
|
|
<Grid.Row>
|
|
|
|
<Grid.Column width={1}>
|
|
|
|
<Icon name={e.icon} size="small"/>
|
|
|
|
</Grid.Column>
|
|
|
|
<Grid.Column>
|
|
|
|
{e.name}
|
|
|
|
</Grid.Column>
|
|
|
|
</Grid.Row>
|
|
|
|
</Grid>
|
|
|
|
</ Dropdown.Item>
|
|
|
|
)
|
|
|
|
}) : null
|
|
|
|
}
|
|
|
|
|
|
|
|
</Dropdown.Menu>
|
|
|
|
</Dropdown>
|
|
|
|
</Menu>
|
|
|
|
|
|
|
|
<Grid>
|
|
|
|
<Grid.Row>
|
|
|
|
<Grid.Column width={8}>
|
|
|
|
<Button icon fluid labelPosition='left'>
|
|
|
|
<Icon name='plus' size='small'/>
|
|
|
|
ADD ROOM
|
|
|
|
</Button>
|
|
|
|
</Grid.Column>
|
|
|
|
<Grid.Column width={8}>
|
|
|
|
<Button icon fluid labelPosition='left'>
|
|
|
|
<Icon name='pencil' size='small'/>
|
|
|
|
EDIT ROOM
|
|
|
|
</Button>
|
|
|
|
</Grid.Column>
|
|
|
|
</Grid.Row>
|
|
|
|
</Grid>
|
|
|
|
|
|
|
|
|
2020-03-13 14:21:33 +00:00
|
|
|
</Responsive>
|
2020-03-18 16:12:29 +00:00
|
|
|
|
2020-03-13 14:21:33 +00:00
|
|
|
</Segment.Group>
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export default Navbar;
|