From 953b1a609a8580fecbe0fb42f0e7b65b5b7ebfcc Mon Sep 17 00:00:00 2001 From: Nicola Brunner Date: Fri, 13 Mar 2020 15:21:33 +0100 Subject: [PATCH 1/2] navbar is starting to work --- smart-hut/icons.js | 65 ++++++++++++++ smart-hut/src/components/SelectIcons.js | 33 +++++++ smart-hut/src/components/modalform.js | 67 ++++++++++++++ smart-hut/src/views/Navbar.js | 115 ++++++++++++++++++++++++ 4 files changed, 280 insertions(+) create mode 100644 smart-hut/icons.js create mode 100644 smart-hut/src/components/SelectIcons.js create mode 100644 smart-hut/src/components/modalform.js create mode 100644 smart-hut/src/views/Navbar.js diff --git a/smart-hut/icons.js b/smart-hut/icons.js new file mode 100644 index 0000000..3bb4258 --- /dev/null +++ b/smart-hut/icons.js @@ -0,0 +1,65 @@ +1. Home +'home' + +2. Bar +'coffee', 'beer', 'glass martini' + +3. Filmroom +'film', 'video' + +4. Musicroom +'music', 'headphones' + +5. Office +'fax', 'phone', 'laptop' + +6. Bathroom +'bath', 'shower' + +7. Bedroom +'bed', 'child' + +8. Garage +'warehouse', 'car', 'bicycle', 'motorcycle' + +9. Cellar +'archive', 'boxes', 'cubes' + +10. Game Room +'chess', 'gamepad', 'futbol', 'table tennis' + +11. IT Rack +'server' + +12. Livingroom +'tv' + +13. Love Room +'heart' + +14. Hobby Room +'camera', 'trophy', 'wrench' + +15. Gallery +'image' + +16. Library +'book', 'university' + +17. Infirmary +'medkit' + +18. Petroom +'paw' + +19. Garden +'tree' + +20. Kitchen +'utensils' + +21. Toilette +'female', 'male' + +22. Swimmingpool +'life ring outline' diff --git a/smart-hut/src/components/SelectIcons.js b/smart-hut/src/components/SelectIcons.js new file mode 100644 index 0000000..e7d57a1 --- /dev/null +++ b/smart-hut/src/components/SelectIcons.js @@ -0,0 +1,33 @@ +import React, { Component } from 'react'; +import { Button, Header, Image, Modal, Checkbox, Form, Grid, Input, Icon } from 'semantic-ui-react' + +export default class SelectIcons extends Component { + render(){ + const myicons = [['home', 'coffee', 'beer', 'glass martini', 'film', 'video'], + ['music', 'headphones', 'fax', 'phone', 'laptop','bath'], + ['shower', 'bed', 'child', 'warehouse', 'car', 'bicycle'], + ['motorcycle', 'archive', 'boxes', 'cubes', 'chess', 'gamepad'], + ['futbol', 'table tennis', 'server', 'tv', 'heart', 'camera'], + ['trophy', 'wrench', 'image', 'book', 'university', 'medkit'], + ['paw', 'tree', 'utensils', 'male', 'female', 'life ring outline']]; + + var colums = 0; + return ( + + { + myicons.map((e, i) => { + return ( + + {e.map((e) => { + return( + } closeIcon> +
{this.props.type == "new" ? "Add new room" : "Modify room" }
+ +
+

Insert the name of the room:

+ + + +

Insert an image of the room:

+ + + +
+ +
+

Select an icon:

+ +
+ + + +
+ + + + + + + ) + } +} diff --git a/smart-hut/src/views/Navbar.js b/smart-hut/src/views/Navbar.js new file mode 100644 index 0000000..30a2f20 --- /dev/null +++ b/smart-hut/src/views/Navbar.js @@ -0,0 +1,115 @@ +import React, { Component } from 'react'; +import { Menu, Grid, Icon, Button, Header, Image, Modal, Responsive, Segment } from "semantic-ui-react"; +import {editButtonStyle} from "../components/dashboard/devices/styleComponents"; +import ModalWindow from "../components/modalform"; + +class Navbar extends Component { + constructor(props) { + super(props); + this.state = { + activeItem: 'Home', + edited: "" + } + } + + showForm = (event) => { + console.log(event.target.name); + if (event === "new"){ + console.log("funziona"); + return () + } + } + + handleClick = (e, { i }) => { + this.setState({ activeItem: e.name, + edited: i + }); + this.props.handleItemClick(e) + } + + render(){ + const { activeItem } = this.state + return ( +
+ + + + + + + + + + + + + + + + Home + + + + + + + {this.props.rooms ? + this.props.rooms.map((e, i) => { + return ( + + + + + + + + {e.name} + + + + + + + + + + ) + }) : null + } + + + + + + + + + + + + + + + + + //dropdown menu + + +
+ ); + } +} + +export default Navbar; From 1a55fc7804239c9e883278bef5ca0794a0adfed3 Mon Sep 17 00:00:00 2001 From: Nicola Brunner Date: Sat, 14 Mar 2020 15:25:55 +0100 Subject: [PATCH 2/2] Add room feature completed --- smart-hut/src/components/SelectIcons.js | 26 +++++++-- smart-hut/src/components/modalform.js | 72 ++++++++++++++++++++----- smart-hut/src/views/Navbar.js | 11 ++-- 3 files changed, 86 insertions(+), 23 deletions(-) diff --git a/smart-hut/src/components/SelectIcons.js b/smart-hut/src/components/SelectIcons.js index e7d57a1..e9d23f6 100644 --- a/smart-hut/src/components/SelectIcons.js +++ b/smart-hut/src/components/SelectIcons.js @@ -2,6 +2,24 @@ import React, { Component } from 'react'; import { Button, Header, Image, Modal, Checkbox, Form, Grid, Input, Icon } from 'semantic-ui-react' export default class SelectIcons extends Component { + + constructor(props) { + super(props); + this.state = { + currentIcon: this.props.currentIcon + } + } + + selectIcon = (e) => { + let el = e.target.name; + if (e.target.tagName === "I"){ + console.log(e.target.parentNode); + el = e.target.parentNode.name; + } + this.props.updateIcon(el); + this.setState({currentIcon : el}) + } + render(){ const myicons = [['home', 'coffee', 'beer', 'glass martini', 'film', 'video'], ['music', 'headphones', 'fax', 'phone', 'laptop','bath'], @@ -17,10 +35,10 @@ export default class SelectIcons extends Component { { myicons.map((e, i) => { return ( - - {e.map((e) => { - return( - } closeIcon> + +
{this.props.type == "new" ? "Add new room" : "Modify room" }

Insert the name of the room:

- +

Insert an image of the room:

- +

Select an icon:

- +
- + : null }
- -
diff --git a/smart-hut/src/views/Navbar.js b/smart-hut/src/views/Navbar.js index 30a2f20..c887f59 100644 --- a/smart-hut/src/views/Navbar.js +++ b/smart-hut/src/views/Navbar.js @@ -13,7 +13,7 @@ class Navbar extends Component { } showForm = (event) => { - console.log(event.target.name); + console.log(event); if (event === "new"){ console.log("funziona"); return () @@ -34,10 +34,10 @@ class Navbar extends Component { - + - + { return ( - + {e.name} @@ -93,7 +94,7 @@ class Navbar extends Component { - +