5 Commits

Author SHA1 Message Date
d39f114d5c Fix 2of2 2020-12-08 10:42:50 +01:00
a0ff50ab23 Fix 1of2 2020-12-08 10:41:31 +01:00
ca1ca3884d Merge pull request #6 from thefeli73/we-demo-disruption-first
Add: code to fetch disruption data and see if it is relevant
2020-12-08 10:30:41 +01:00
ea2a18f3ad Add: code to fetch disruption data and see if it is relevant 2020-12-08 10:29:03 +01:00
75b4ecc4ed Merge pull request #5 from thefeli73/we-json-examples
Add: json files for scenarios
2020-12-08 09:38:22 +01:00
7 changed files with 35 additions and 35 deletions

View File

@ -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} />

View File

@ -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(
) )
}; };

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -1,11 +1,33 @@
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/disruption1.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,
user: globData.user,
disruption: ""
}
genDisrupt = () => { genDisrupt = () => {
console.log(globData.disruption)
for (let stopPoint of ex1.affectedStopPoints) {
if(stopPoint.gid === this.state.user.stoppointgid){
this.state.disruption = ex1
}
}
globData.disruption = this.state.disruption
console.log(globData.disruption)
addNotification({ addNotification({
title: "Warning", title: "Warning",
subtitle: "This is a subtitle", subtitle: "This is a subtitle",

View File

@ -63,7 +63,7 @@ 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]} /> <DisruptionButton path={"ex1"} 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>