fixed minor bugs

This commit is contained in:
britea 2020-03-25 13:55:52 +01:00
parent cee6e3ce59
commit 7f70aeb828
6 changed files with 268 additions and 243 deletions

View file

@ -27,6 +27,7 @@ class App extends Component {
super(props); super(props);
let loggedIn = false; let loggedIn = false;
let token = undefined;
try { try {
let userJsonString = localStorage.getItem("token"); let userJsonString = localStorage.getItem("token");
@ -34,6 +35,7 @@ class App extends Component {
let date = new Date().getTime(); let date = new Date().getTime();
if (userJsonString && exp && date < exp) { if (userJsonString && exp && date < exp) {
loggedIn = true; loggedIn = true;
token = userJsonString;
} else { } else {
localStorage.removeItem("token"); localStorage.removeItem("token");
localStorage.removeItem("exp"); localStorage.removeItem("exp");
@ -42,6 +44,7 @@ class App extends Component {
this.state = { this.state = {
loggedIn: loggedIn, loggedIn: loggedIn,
token: token,
}; };
this.auth = this.auth.bind(this); this.auth = this.auth.bind(this);

View file

@ -144,11 +144,17 @@ export default class NewDevice extends Component {
image: { avatar: true, src: "/img/switchOn.svg" }, image: { avatar: true, src: "/img/switchOn.svg" },
}, },
{ {
key: "dimmer", key: "buttonDimmer",
text: "Dimmer", text: "Button Dimmer",
value: "buttonDimmer", value: "buttonDimmer",
image: { avatar: true, src: "/img/dimmer.svg" }, image: { avatar: true, src: "/img/dimmer.svg" },
}, },
{
key: "knobDimmer",
text: "Knob Dimmer",
value: "knobDimmer",
image: { avatar: true, src: "/img/dimmer.svg" },
},
]; ];
const sensorOptions = [ const sensorOptions = [
{ {
@ -176,13 +182,27 @@ export default class NewDevice extends Component {
image: { avatar: true, src: "/img/sensorOn.svg" }, image: { avatar: true, src: "/img/sensorOn.svg" },
}, },
]; ];
const availableLights = []; const availableSwitchDevices = [];
const availableDimmerDevices = [];
this.props.devices.forEach((d) => { this.props.devices.forEach((d) => {
availableLights.push({ if (
d.kind === "regularLight" ||
d.kind === "dimmableLight" ||
d.kind === "smartPlug"
) {
availableSwitchDevices.push({
key: d.id, key: d.id,
text: d.name, text: d.name,
value: d.id, value: d.id,
}); });
}
if (d.kind === "dimmableLight") {
availableDimmerDevices.push({
key: d.id,
text: d.name,
value: d.id,
});
}
}); });
const step1 = ( const step1 = (
<Dropdown <Dropdown
@ -222,7 +242,7 @@ export default class NewDevice extends Component {
/> />
</Form.Field> </Form.Field>
); );
const switchDimmerOptions = ( const switchOptions = (
<Form.Field style={{ marginTop: "1rem" }}> <Form.Field style={{ marginTop: "1rem" }}>
<label>Select the Lights You Want to Attach: </label> <label>Select the Lights You Want to Attach: </label>
<Dropdown <Dropdown
@ -231,7 +251,20 @@ export default class NewDevice extends Component {
fluid fluid
multiple multiple
onChange={this.setLightsDimmerSwitch} onChange={this.setLightsDimmerSwitch}
options={availableLights} options={availableSwitchDevices}
/>
</Form.Field>
);
const dimmerOptions = (
<Form.Field style={{ marginTop: "1rem" }}>
<label>Select the Lights You Want to Attach: </label>
<Dropdown
name="typeOfDevice"
placeholder="Select Lights"
fluid
multiple
onChange={this.setLightsDimmerSwitch}
options={availableDimmerDevices}
/> />
</Form.Field> </Form.Field>
); );
@ -239,9 +272,10 @@ export default class NewDevice extends Component {
<Form> <Form>
{deviceName} {deviceName}
{this.state.typeOfDevice === "sensor" ? sensorForm : ""} {this.state.typeOfDevice === "sensor" ? sensorForm : ""}
{this.state.typeOfDevice === "switch" || {this.state.typeOfDevice === "switch" ? switchOptions : ""}
this.state.typeOfDevice === "dimmer" {this.state.typeOfDevice === "buttonDimmer" ||
? switchDimmerOptions this.state.typeOfDevice === "knobDimmer"
? dimmerOptions
: ""} : ""}
</Form> </Form>
); );

View file

@ -22,7 +22,7 @@ export default class ModalWindow extends Component {
this.state = { this.state = {
id: "", id: "",
selectedIcon: "", selectedIcon: "",
name: this.props.type === "new" ? "" : this.props.idRoom.name, name: this.props.type === "new" ? "Device" : this.props.idRoom.name,
img: this.props.type === "new" ? null : this.props.idRoom.image, img: this.props.type === "new" ? null : this.props.idRoom.image,
openModal: false, openModal: false,
}; };

View file

@ -20,8 +20,7 @@ class Paragraph extends Component {
<Message.Header> <Message.Header>
Congratulation<ins>s</ins>! Congratulation<ins>s</ins>!
</Message.Header> </Message.Header>
Your password has been <del>succesffuly</del> Your password has been successfully reset
<ins>successfully</ins> reset
</Message> </Message>
); );
} }

View file

@ -29,9 +29,8 @@ export default class FourOhFour extends Component {
render() { render() {
return ( return (
<Segment.Group>
<Responsive as={Segment} minWidth={768}>
<div style={{ height: "110vh", background: "#1b1c1d" }}> <div style={{ height: "110vh", background: "#1b1c1d" }}>
<Responsive minWidth={768}>
<Grid> <Grid>
<Grid.Row color="black"> <Grid.Row color="black">
<Grid.Column> <Grid.Column>
@ -53,12 +52,11 @@ export default class FourOhFour extends Component {
</Grid.Column> </Grid.Column>
<Grid.Column width={8}> <Grid.Column width={8}>
<p> <p>
Hey what are you doing here? Looks like you are Hey what are you doing here? Looks like you are lost,
lost, this room does not exist. Maybe you were this room does not exist. Maybe you were looking for
looking for the kitchen, or the garage, or the the kitchen, or the garage, or the bedroom, or your
bedroom, or your love room... so don't wait here and love room... so don't wait here and let's go back to
let's go back to our main room! ...or refresh this our main room! ...or refresh this page some times...
page some times...
</p> </p>
<Button fluid inverted color="white"> <Button fluid inverted color="white">
<Link style={{ color: "black" }} to="/"> <Link style={{ color: "black" }} to="/">
@ -72,11 +70,9 @@ export default class FourOhFour extends Component {
</Grid.Column> </Grid.Column>
</Grid.Row> </Grid.Row>
</Grid> </Grid>
</div>
</Responsive> </Responsive>
<Responsive as={Segment} maxWidth={768}> <Responsive maxWidth={768}>
<div style={{ background: "#1b1c1d" }}>
<Grid> <Grid>
<Grid.Row color="black"> <Grid.Row color="black">
<Grid.Column> <Grid.Column>
@ -100,12 +96,11 @@ export default class FourOhFour extends Component {
<Grid.Row> <Grid.Row>
<Grid.Column width={16}> <Grid.Column width={16}>
<p> <p>
Hey what are you doing here? Looks like you are Hey what are you doing here? Looks like you are lost,
lost, this room does not exist. Maybe you were this room does not exist. Maybe you were looking for
looking for the kitchen, or the garage, or the the kitchen, or the garage, or the bedroom, or your
bedroom, or your love room... so don't wait here and love room... so don't wait here and let's go back to
let's go back to our main room! ...or refresh this our main room! ...or refresh this page some times...
page some times...
</p> </p>
<Button fluid inverted color="white"> <Button fluid inverted color="white">
<Link style={{ color: "black" }} to="/"> <Link style={{ color: "black" }} to="/">
@ -119,9 +114,8 @@ export default class FourOhFour extends Component {
</Grid.Column> </Grid.Column>
</Grid.Row> </Grid.Row>
</Grid> </Grid>
</div>
</Responsive> </Responsive>
</Segment.Group> </div>
); );
} }
} }

View file

@ -49,19 +49,15 @@ class Navbar extends Component {
render() { render() {
//const { activeItem } = this.state //const { activeItem } = this.state
return ( return (
<div style={{ background: "#1b1c1d!important" }}> <div style={{ background: "#1b1c1d!important", padding: "0 20px" }}>
<Segment.Group> <Responsive minWidth={768}>
<Responsive as={Segment} minWidth={768}>
<Grid> <Grid>
<Grid.Row color="black"> <Grid.Row color="black">
<button <button style={editButtonStyle} onClick={this.editModeController}>
style={editButtonStyle}
onClick={this.editModeController}
>
Edit Edit
</button> </button>
</Grid.Row> </Grid.Row>
<Grid.Row color="black"> <Grid.Row>
<Menu inverted fluid vertical> <Menu inverted fluid vertical>
<Menu.Item <Menu.Item
key={-1} key={-1}
@ -128,8 +124,8 @@ class Navbar extends Component {
</Grid> </Grid>
</Responsive> </Responsive>
<Responsive as={Segment} maxWidth={768}> <Responsive maxWidth={768}>
<Menu inverted> <Menu>
<Dropdown item fluid text={this.state.activeItemName}> <Dropdown item fluid text={this.state.activeItemName}>
<Dropdown.Menu> <Dropdown.Menu>
<Dropdown.Item <Dropdown.Item
@ -192,7 +188,6 @@ class Navbar extends Component {
</Grid.Row> </Grid.Row>
</Grid> </Grid>
</Responsive> </Responsive>
</Segment.Group>
</div> </div>
); );
} }