Compare commits
8 Commits
we-json-ex
...
we-select-
Author | SHA1 | Date | |
---|---|---|---|
2d2ec96533 | |||
3c0fc6fe1f | |||
c7517f185c | |||
d39f114d5c | |||
a0ff50ab23 | |||
ca1ca3884d | |||
ea2a18f3ad | |||
75b4ecc4ed |
@ -1,5 +1,5 @@
|
|||||||
{
|
{
|
||||||
"name":"1",
|
"name":"1",
|
||||||
"deviceId":"1",
|
"deviceId":"1",
|
||||||
"location":"9022014014754001"
|
"stoppointgid":"9022014014754001"
|
||||||
}
|
}
|
@ -1,5 +1,5 @@
|
|||||||
{
|
{
|
||||||
"name":"2",
|
"name":"2",
|
||||||
"deviceId":"2",
|
"deviceId":"2",
|
||||||
"location":"9022014014020001"
|
"stoppointgid":"9022014014020001"
|
||||||
}
|
}
|
@ -1,5 +1,5 @@
|
|||||||
{
|
{
|
||||||
"name":"3",
|
"name":"3",
|
||||||
"deviceId":"3",
|
"deviceId":"3",
|
||||||
"location":"9022014014751001"
|
"stoppointgid":"9022014014751001"
|
||||||
}
|
}
|
@ -1,5 +1,5 @@
|
|||||||
{
|
{
|
||||||
"name":"4",
|
"name":"4",
|
||||||
"deviceId":"4",
|
"deviceId":"4",
|
||||||
"location":"9021014014225000"
|
"stoppointgid":"9021014014225000"
|
||||||
}
|
}
|
@ -21,8 +21,6 @@ class App extends Component {
|
|||||||
return (
|
return (
|
||||||
<Router>
|
<Router>
|
||||||
<div className="App">
|
<div className="App">
|
||||||
<NearbyStation/>
|
|
||||||
<Disruption/>
|
|
||||||
<Route path="/" exact component={TicketsBuy} />
|
<Route path="/" exact component={TicketsBuy} />
|
||||||
<Route path="/tickets" exact component={Tickets} />
|
<Route path="/tickets" exact component={Tickets} />
|
||||||
<Route path="/ticketsBuy" exact component={TicketsBuy} />
|
<Route path="/ticketsBuy" exact component={TicketsBuy} />
|
||||||
|
@ -1,11 +1,15 @@
|
|||||||
import User from './classes/User.js';
|
import User from './classes/User.js';
|
||||||
|
import Disruption from './classes/Disruption.js'
|
||||||
import Coordinates from "./classes/Coordinates.js";
|
import Coordinates from "./classes/Coordinates.js";
|
||||||
|
|
||||||
let globalData = {
|
let globalData = {
|
||||||
user: new User(
|
user: new User(
|
||||||
"test",
|
"test",
|
||||||
"123",
|
"123",
|
||||||
new Coordinates()
|
new Coordinates(),
|
||||||
|
"9022014014020001"
|
||||||
|
),
|
||||||
|
disruption: new Disruption(
|
||||||
)
|
)
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -1,24 +1,11 @@
|
|||||||
/*
|
|
||||||
Denna klass är en modell för störningar.
|
|
||||||
*/
|
|
||||||
|
|
||||||
class Disruption {
|
class Disruption {
|
||||||
constructor(startTime, locations, departures) {
|
constructor(situationNumber, severity, title, affectedStopPoints) {
|
||||||
this.startTime = startTime;
|
this.situationNumber = situationNumber;
|
||||||
this.affectedLines = affectedLines;
|
this.severity = severity;
|
||||||
this.departures = departures;
|
this.title = title;
|
||||||
|
this.affectedStopPoints = affectedStopPoints;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
Från västtrafiks api ett element i listan av hållplatser ser ut som följande
|
|
||||||
"id": "string",
|
|
||||||
"lon": "string",
|
|
||||||
"idx": "string",
|
|
||||||
"weight": "string",
|
|
||||||
"name": "string",
|
|
||||||
"track": "string",
|
|
||||||
"lat": "string"
|
|
||||||
*/
|
|
||||||
|
|
||||||
export default Disruption;
|
export default Disruption;
|
@ -7,7 +7,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
class User {
|
class User {
|
||||||
constructor(name, deviceId, location) {
|
constructor(name, deviceId, location, stoppointgid) {
|
||||||
this.name = name;
|
this.name = name;
|
||||||
this.deviceId = deviceId;
|
this.deviceId = deviceId;
|
||||||
this.location = location;
|
this.location = location;
|
||||||
|
@ -1,11 +0,0 @@
|
|||||||
|
|
||||||
class Disruption {
|
|
||||||
constructor(situationNumber, severity, title, affectedStopPoints) {
|
|
||||||
this.situationNumber = situationNumber;
|
|
||||||
this.severity = severity;
|
|
||||||
this.title = title;
|
|
||||||
this.affectedStopPoints = affectedStopPoints;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
export default User;
|
|
@ -1,11 +1,39 @@
|
|||||||
import addNotification from "react-push-notification";
|
import addNotification from "react-push-notification";
|
||||||
|
|
||||||
|
import globData from '../GlobalData.js';
|
||||||
|
|
||||||
|
import ex1 from '../APIexamples/disruption1.json'
|
||||||
|
import ex2 from '../APIexamples/disruption2.json'
|
||||||
|
|
||||||
import Button from './Button.js';
|
import Button from './Button.js';
|
||||||
import disruptIcon from '../img/flash.svg';
|
import disruptIcon from '../img/flash.svg';
|
||||||
|
|
||||||
|
|
||||||
class DisruptionButton extends Button {
|
class DisruptionButton extends Button {
|
||||||
|
state = {
|
||||||
|
jsonLocation: this.props.path,
|
||||||
|
disruption: ""
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
genDisrupt = () => {
|
genDisrupt = () => {
|
||||||
|
this.state.disruption = ""
|
||||||
|
if(this.state.jsonLocation === "ex1"){
|
||||||
|
for (let stopPoint of ex1.affectedStopPoints) {
|
||||||
|
if(stopPoint.gid === globData.user.stoppointgid){
|
||||||
|
this.state.disruption = ex1
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else if (this.state.jsonLocation === "ex2"){
|
||||||
|
for (let stopPoint of ex2.affectedStopPoints) {
|
||||||
|
if(stopPoint.gid === globData.user.stoppointgid){
|
||||||
|
this.state.disruption = ex2
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log(this.state.disruption)
|
||||||
|
globData.disruption = this.state.disruption
|
||||||
|
|
||||||
addNotification({
|
addNotification({
|
||||||
title: "Warning",
|
title: "Warning",
|
||||||
subtitle: "This is a subtitle",
|
subtitle: "This is a subtitle",
|
||||||
|
@ -2,6 +2,7 @@ import React, { Component } from 'react';
|
|||||||
|
|
||||||
import globalData from '../GlobalData.js';
|
import globalData from '../GlobalData.js';
|
||||||
import DisruptionButton from "./DisruptionButton.js";
|
import DisruptionButton from "./DisruptionButton.js";
|
||||||
|
import SelectUserButton from "./SelectUserButton.js"
|
||||||
import Popup from './Popup.js';
|
import Popup from './Popup.js';
|
||||||
import Button from './Button.js';
|
import Button from './Button.js';
|
||||||
|
|
||||||
@ -63,7 +64,12 @@ class NavigationDrawer extends Component {
|
|||||||
<span>example@gmail.com</span>
|
<span>example@gmail.com</span>
|
||||||
</header>
|
</header>
|
||||||
<div id="navList">
|
<div id="navList">
|
||||||
<DisruptionButton onClick={[this.showPopup, this.close]} />
|
<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]} />
|
||||||
|
<DisruptionButton path={"ex2"} onClick={[this.showPopup, this.close]} />
|
||||||
</div>
|
</div>
|
||||||
<hr />
|
<hr />
|
||||||
<span id="version">Projektgrupp 3 - Utmaning 7</span>
|
<span id="version">Projektgrupp 3 - Utmaning 7</span>
|
||||||
|
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;
|
Reference in New Issue
Block a user