Merge pull request #8 from thefeli73/we-select-user
Add: Select user buttons
This commit is contained in:
commit
359c0a8192
@ -1,5 +1,5 @@
|
||||
{
|
||||
"name":"1",
|
||||
"deviceId":"1",
|
||||
"location":"9022014014754001"
|
||||
"stoppointgid":"9022014014754001"
|
||||
}
|
@ -1,5 +1,5 @@
|
||||
{
|
||||
"name":"2",
|
||||
"deviceId":"2",
|
||||
"location":"9022014014020001"
|
||||
"stoppointgid":"9022014014020001"
|
||||
}
|
@ -1,5 +1,5 @@
|
||||
{
|
||||
"name":"3",
|
||||
"deviceId":"3",
|
||||
"location":"9022014014751001"
|
||||
"stoppointgid":"9022014014751001"
|
||||
}
|
@ -1,5 +1,5 @@
|
||||
{
|
||||
"name":"4",
|
||||
"deviceId":"4",
|
||||
"location":"9021014014225000"
|
||||
"stoppointgid":"9021014014225000"
|
||||
}
|
@ -11,23 +11,21 @@ import disruptIcon from '../img/flash.svg';
|
||||
class DisruptionButton extends Button {
|
||||
state = {
|
||||
jsonLocation: this.props.path,
|
||||
user: globData.user,
|
||||
disruption: ""
|
||||
}
|
||||
|
||||
|
||||
genDisrupt = () => {
|
||||
console.log(globData.disruption)
|
||||
this.state.disruption = ""
|
||||
for (let stopPoint of ex1.affectedStopPoints) {
|
||||
if(stopPoint.gid === this.state.user.stoppointgid){
|
||||
if(stopPoint.gid === globData.user.stoppointgid){
|
||||
this.state.disruption = ex1
|
||||
}
|
||||
}
|
||||
|
||||
console.log(this.state.disruption)
|
||||
globData.disruption = this.state.disruption
|
||||
|
||||
console.log(globData.disruption)
|
||||
|
||||
addNotification({
|
||||
title: "Warning",
|
||||
subtitle: "This is a subtitle",
|
||||
|
@ -2,6 +2,7 @@ import React, { Component } from 'react';
|
||||
|
||||
import globalData from '../GlobalData.js';
|
||||
import DisruptionButton from "./DisruptionButton.js";
|
||||
import SelectUserButton from "./SelectUserButton.js"
|
||||
import Popup from './Popup.js';
|
||||
import Button from './Button.js';
|
||||
|
||||
@ -63,6 +64,10 @@ class NavigationDrawer extends Component {
|
||||
<span>example@gmail.com</span>
|
||||
</header>
|
||||
<div id="navList">
|
||||
<SelectUserButton path={"user1"} username="user1"/>
|
||||
<SelectUserButton path={"user2"} username="user2"/>
|
||||
<SelectUserButton path={"user3"} username="user3"/>
|
||||
<SelectUserButton path={"user4"} username="user4"/>
|
||||
<DisruptionButton path={"ex1"} onClick={[this.showPopup, this.close]} />
|
||||
</div>
|
||||
<hr />
|
||||
|
36
src/components/SelectUserButton.js
Normal file
36
src/components/SelectUserButton.js
Normal file
@ -0,0 +1,36 @@
|
||||
|
||||
import globData from '../GlobalData.js';
|
||||
|
||||
import user1 from '../APIexamples/user1.json'
|
||||
import user2 from '../APIexamples/user2.json'
|
||||
import user3 from '../APIexamples/user3.json'
|
||||
import user4 from '../APIexamples/user4.json'
|
||||
|
||||
import Button from './Button.js';
|
||||
import disruptIcon from '../img/flash.svg';
|
||||
|
||||
class SelectUserButton extends Button {
|
||||
selectUser = () => {
|
||||
if(this.props.path === "user1"){
|
||||
globData.user = user1
|
||||
}else if (this.props.path === "user2"){
|
||||
globData.user = user2
|
||||
}else if (this.props.path === "user3"){
|
||||
globData.user = user3
|
||||
}else if (this.props.path === "user4"){
|
||||
globData.user = user4
|
||||
}
|
||||
}
|
||||
|
||||
render() {
|
||||
return (
|
||||
<Button onClick={[this.selectUser]} className="disruptBtn">
|
||||
<img src={disruptIcon} alt="" />
|
||||
<span>{this.props.username}</span>
|
||||
</Button>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
export default SelectUserButton;
|
Loading…
Reference in New Issue
Block a user