Present correct information about track in traffic info

This commit is contained in:
André Wahlberg 2020-12-10 12:48:36 +01:00
parent 28d549de28
commit 5cafe99946
3 changed files with 42 additions and 9 deletions

View File

@ -4,14 +4,16 @@
name : String (Användarnamn) name : String (Användarnamn)
deviceId : Int (Enhetens ID) deviceId : Int (Enhetens ID)
location : Coordinates (Användarens koordinater) location : Coordinates (Användarens koordinater)
track : String (Nuvarande hållplatsläge)
*/ */
class User { class User {
constructor(name, deviceId, location, stoppointgid) { constructor(name, deviceId, location, stoppointgid, track) {
this.name = name; this.name = name;
this.deviceId = deviceId; this.deviceId = deviceId;
this.location = location; this.location = location;
this.stoppointgid = stoppointgid; this.stoppointgid = stoppointgid;
this.track = track;
} }
} }

View File

@ -16,25 +16,30 @@ import departureuser3 from '../APIexamples/departureuser3.json'
import departureuser4 from '../APIexamples/departureuser4.json' import departureuser4 from '../APIexamples/departureuser4.json'
import Button from './Button.js'; import Button from './Button.js';
import disruptIcon from '../img/flash.svg'; import userIcon from '../img/userDark.svg';
import globalData from '../GlobalData.js'; import globalData from '../GlobalData.js';
class SelectUserButton extends Button { class SelectUserButton extends Button {
selectUser = () => { selectUser = () => {
if(this.props.path === "user1"){ if(this.props.path === "user1"){
globData.user = user1 globData.user = user1
globData.user.track = locationuser1.LocationList.StopLocation[0].track
globData.stop = locationuser1.LocationList.StopLocation[0] globData.stop = locationuser1.LocationList.StopLocation[0]
globData.stop.departures = departureuser1.DepartureBoard.Departures globData.stop.departures = departureuser1.DepartureBoard.Departures
}else if (this.props.path === "user2"){ }else if (this.props.path === "user2"){
globData.user = user2 globData.user = user2
globData.user.track = locationuser2.LocationList.StopLocation[0].track
globData.stop = locationuser2.LocationList.StopLocation[0] globData.stop = locationuser2.LocationList.StopLocation[0]
globData.stop.departures = departureuser2.DepartureBoard.Departures globData.stop.departures = departureuser2.DepartureBoard.Departures
}else if (this.props.path === "user3"){ }else if (this.props.path === "user3"){
globData.user = user3 globData.user = user3
globData.user.track = locationuser3.LocationList.StopLocation[0].track
globData.stop = locationuser3.LocationList.StopLocation[0] globData.stop = locationuser3.LocationList.StopLocation[0]
globData.stop.departures = departureuser3.DepartureBoard.Departures globData.stop.departures = departureuser3.DepartureBoard.Departures
}else if (this.props.path === "user4"){ }else if (this.props.path === "user4"){
globData.user = user4 globData.user = user4
globData.user.track = locationuser4.LocationList.StopLocation[0].track
globData.stop = locationuser4.LocationList.StopLocation[0] globData.stop = locationuser4.LocationList.StopLocation[0]
globData.stop.departures = departureuser4.DepartureBoard.Departures globData.stop.departures = departureuser4.DepartureBoard.Departures
} }

View File

@ -1,12 +1,38 @@
import React, { Component } from 'react'; import React, { Component } from 'react';
import Button from './Button.js';
import Popup from './Popup.js';
import './css/StopTitle.css'; import './css/StopTitle.css';
class StopTitle extends Component {
render() {
class StopTitle extends Component {
constructor(props) {
super(props);
this.popupElem = React.createRef();
}
showPopup = () => {
this.popupElem.current.show();
};
hidePopup = () => {
this.popupElem.current.hide();
};
render() {
return ( return (
<div id="stopTitle"> <div id="stopTitle">
<Popup ref={this.popupElem} className="">
<h3>Välj läge:</h3>
<ul>
<>
<li><Button onClick={[this.hidePopup]}>{"Läge A"}</Button></li>
<li><Button onClick={[this.hidePopup]}>{"Läge B"}</Button></li>
</>
</ul>
</Popup>
<h1>{this.props.stop.name !== undefined ? <h1>{this.props.stop.name !== undefined ?
this.props.stop.name this.props.stop.name
: "Hållplats saknas" : "Hållplats saknas"
@ -15,9 +41,9 @@ class StopTitle extends Component {
{this.props.stop.name !== undefined && this.props.stop.track !== undefined ? {this.props.stop.name !== undefined && this.props.stop.track !== undefined ?
<div> <div>
<h3> <h3>
<span>{this.props.stop.track}</span> <span>{"Läge " + this.props.stop.track}</span>
</h3> </h3>
<button>Byt Läge</button> <Button onclick={this.showPopup}>Byt Läge</Button>
</div> </div>
: :
(this.props.stop.name !== undefined ? (this.props.stop.name !== undefined ?