diff --git a/src/APIexamples/departureuser1.json b/src/APIexamples/departureuser1.json index ab6e8a8..9238faa 100644 --- a/src/APIexamples/departureuser1.json +++ b/src/APIexamples/departureuser1.json @@ -3,27 +3,51 @@ "noNamespaceSchemaLocation": "http://api.vasttrafik.se/v1/hafasRestDepartureBoard.xsd", "servertime": "10:09", "serverdate": "2020-12-10", - "Departure": { - "name": "Buss MEXP", - "sname": "MEXP", - "journeyNumber": "24", - "type": "BUS", - "stopid": "9022014014754002", - "stop": "Bollestadsvägen, Kungälv", - "time": "10:09", - "date": "2020-12-10", - "journeyid": "9015014621000024", - "direction": "Marstrand", - "track": "B", - "rtTime": "10:11", - "rtDate": "2020-12-10", - "fgColor": "#006C93", - "bgColor": "#FFFFFF", - "stroke": "Solid", - "accessibility": "wheelChair", - "JourneyDetailRef": { - "ref": "https://api.vasttrafik.se/bin/rest.exe/v2/journeyDetail?ref=347217%2F124275%2F19874%2F105802%2F80%3Fdate%3D2020-12-10%26station_evaId%3D14754002%26station_type%3Ddep%26format%3Djson%26" + "Departures": [ + { + "name": "Buss MEXP", + "sname": "MEXP", + "journeyNumber": "24", + "type": "BUS", + "stopid": "9022014014754002", + "stop": "Bollestadsvägen, Kungälv", + "time": "10:09", + "date": "2020-12-10", + "journeyid": "9015014621000024", + "direction": "Marstrand", + "track": "B", + "rtTime": "10:11", + "rtDate": "2020-12-10", + "fgColor": "#006C93", + "bgColor": "#FFFFFF", + "stroke": "Solid", + "accessibility": "wheelChair", + "JourneyDetailRef": { + "ref": "https://api.vasttrafik.se/bin/rest.exe/v2/journeyDetail?ref=347217%2F124275%2F19874%2F105802%2F80%3Fdate%3D2020-12-10%26station_evaId%3D14754002%26station_type%3Ddep%26format%3Djson%26" + } + }, + { + "name": "Buss 123", + "sname": "123", + "journeyNumber": "24", + "type": "BUS", + "stopid": "9022014014754002", + "stop": "Bollestadsvägen, Kungälv", + "time": "10:20", + "date": "2020-12-10", + "journeyid": "9015014621000024", + "direction": "Ingenstans", + "track": "B", + "rtTime": "10:11", + "rtDate": "2020-12-10", + "fgColor": "#006C93", + "bgColor": "#FFFFFF", + "stroke": "Solid", + "accessibility": "wheelChair", + "JourneyDetailRef": { + "ref": "https://api.vasttrafik.se/bin/rest.exe/v2/journeyDetail?ref=347217%2F124275%2F19874%2F105802%2F80%3Fdate%3D2020-12-10%26station_evaId%3D14754002%26station_type%3Ddep%26format%3Djson%26" + } } - } + ] } } \ No newline at end of file diff --git a/src/APIexamples/departureuser2.json b/src/APIexamples/departureuser2.json index 6081681..af9889d 100644 --- a/src/APIexamples/departureuser2.json +++ b/src/APIexamples/departureuser2.json @@ -3,27 +3,51 @@ "noNamespaceSchemaLocation": "http://api.vasttrafik.se/v1/hafasRestDepartureBoard.xsd", "servertime": "10:10", "serverdate": "2020-12-10", - "Departure": { - "name": "Buss MEXP", - "sname": "MEXP", - "journeyNumber": "24", - "type": "BUS", - "stopid": "9022014014020002", - "stop": "Ekelöv västra, Kungälv", - "time": "10:10", - "date": "2020-12-10", - "journeyid": "9015014621000024", - "direction": "Marstrand", - "track": "B", - "rtTime": "10:13", - "rtDate": "2020-12-10", - "fgColor": "#006C93", - "bgColor": "#FFFFFF", - "stroke": "Solid", - "accessibility": "wheelChair", - "JourneyDetailRef": { - "ref": "https://api.vasttrafik.se/bin/rest.exe/v2/journeyDetail?ref=740262%2F255290%2F59460%2F217024%2F80%3Fdate%3D2020-12-10%26station_evaId%3D14020002%26station_type%3Ddep%26format%3Djson%26" + "Departures": [ + { + "name": "Buss MEXP", + "sname": "MEXP", + "journeyNumber": "24", + "type": "BUS", + "stopid": "9022014014020002", + "stop": "Ekelöv västra, Kungälv", + "time": "10:10", + "date": "2020-12-10", + "journeyid": "9015014621000024", + "direction": "Marstrand", + "track": "B", + "rtTime": "10:13", + "rtDate": "2020-12-10", + "fgColor": "#006C93", + "bgColor": "#FFFFFF", + "stroke": "Solid", + "accessibility": "wheelChair", + "JourneyDetailRef": { + "ref": "https://api.vasttrafik.se/bin/rest.exe/v2/journeyDetail?ref=740262%2F255290%2F59460%2F217024%2F80%3Fdate%3D2020-12-10%26station_evaId%3D14020002%26station_type%3Ddep%26format%3Djson%26" + } + }, + { + "name": "Buss 123", + "sname": "123", + "journeyNumber": "24", + "type": "BUS", + "stopid": "9022014014754002", + "stop": "Bollestadsvägen, Kungälv", + "time": "10:20", + "date": "2020-12-10", + "journeyid": "9015014621000024", + "direction": "Ingenstans", + "track": "B", + "rtTime": "10:11", + "rtDate": "2020-12-10", + "fgColor": "#006C93", + "bgColor": "#FFFFFF", + "stroke": "Solid", + "accessibility": "wheelChair", + "JourneyDetailRef": { + "ref": "https://api.vasttrafik.se/bin/rest.exe/v2/journeyDetail?ref=347217%2F124275%2F19874%2F105802%2F80%3Fdate%3D2020-12-10%26station_evaId%3D14754002%26station_type%3Ddep%26format%3Djson%26" + } } - } + ] } } \ No newline at end of file diff --git a/src/APIexamples/departureuser3.json b/src/APIexamples/departureuser3.json index 7531f53..96194d8 100644 --- a/src/APIexamples/departureuser3.json +++ b/src/APIexamples/departureuser3.json @@ -3,7 +3,7 @@ "noNamespaceSchemaLocation": "http://api.vasttrafik.se/v1/hafasRestDepartureBoard.xsd", "servertime": "10:10", "serverdate": "2020-12-10", - "Departure": { + "Departures": [{ "name": "Buss MEXP", "sname": "MEXP", "journeyNumber": "24", @@ -22,6 +22,6 @@ "JourneyDetailRef": { "ref": "https://api.vasttrafik.se/bin/rest.exe/v2/journeyDetail?ref=473190%2F166266%2F666560%2F175550%2F80%3Fdate%3D2020-12-10%26station_evaId%3D14751002%26station_type%3Ddep%26format%3Djson%26" } - } + }] } } \ No newline at end of file diff --git a/src/APIexamples/departureuser4.json b/src/APIexamples/departureuser4.json index 4b43472..bb9fab3 100644 --- a/src/APIexamples/departureuser4.json +++ b/src/APIexamples/departureuser4.json @@ -3,8 +3,8 @@ "noNamespaceSchemaLocation": "http://api.vasttrafik.se/v1/hafasRestDepartureBoard.xsd", "servertime": "10:11", "serverdate": "2020-12-10", - "Departure": - { + "Departures": + [{ "name": "Buss 928", "sname": "928", "journeyNumber": "10", @@ -25,6 +25,6 @@ "JourneyDetailRef": { "ref": "https://api.vasttrafik.se/bin/rest.exe/v2/journeyDetail?ref=261732%2F87569%2F149176%2F12656%2F80%3Fdate%3D2020-12-10%26station_evaId%3D14225001%26station_type%3Ddep%26format%3Djson%26" } - } + }] } } \ No newline at end of file diff --git a/src/APIexamples/disruption1.json b/src/APIexamples/disruption1.json index 7aaba41..0a97099 100644 --- a/src/APIexamples/disruption1.json +++ b/src/APIexamples/disruption1.json @@ -1,8 +1,8 @@ { "situationNumber": "RT1", "severity":"normal", - "title":"Stannar inte på dessa hållplatser", - "time":"01:00", + "title":"Nabbensbergsvägen närmast Edsvägen helt avstängd och trafiken hänvisas istället via Korsebergsvägen. Samtidigt tas den tillfälliga förbifarten bort på Edsvägen och trafiken kommer att ledas förbi den nya cirkulationsplatsen i de två västra körfälten tills arbetet på Nabbensbergsvägen är klart Hastighet: 50km/h", + "time":"00:01", "affectedStopPoints":[ { "gid": "9022014014020001", diff --git a/src/APIexamples/disruption2.json b/src/APIexamples/disruption2.json index 3b3c207..5cdea81 100644 --- a/src/APIexamples/disruption2.json +++ b/src/APIexamples/disruption2.json @@ -2,7 +2,7 @@ "situationNumber": "RT2", "severity":"normal", "title":"Försening", - "time":"02:00", + "time":"00:02", "affectedStopPoints":[ { "gid": "9021014014225000", diff --git a/src/classes/AccessToken.js b/src/classes/AccessToken.js index 0537ec3..300800a 100644 --- a/src/classes/AccessToken.js +++ b/src/classes/AccessToken.js @@ -12,7 +12,6 @@ class AccessToken { axios.post('https://api.vasttrafik.se/token','grant_type=client_credentials&scope=device_'+this.device, {headers} ) .then(response => { - console.log(response); this.token = response.data.access_token }); } diff --git a/src/components/Disruption.js b/src/components/Disruption.js index 6cb7fd6..7fd34b7 100644 --- a/src/components/Disruption.js +++ b/src/components/Disruption.js @@ -21,12 +21,9 @@ class Diruption extends React.Component { 'Authorization': 'Bearer ' + this.state.tokenClass.token }; - console.log('Attempted connection') - axios.get('https://api.vasttrafik.se/ts/v1/traffic-situations/stoppoint/'+this.state.gid, { headers }) //axios.get('https://api.vasttrafik.se/ts/v1/traffic-situations/stoppoint/9022014005700002', { headers }) .then(response => { - console.log(response) this.setState({ disruptions: response.data }) diff --git a/src/components/DisruptionButton.js b/src/components/DisruptionButton.js index 34eeec1..924e032 100644 --- a/src/components/DisruptionButton.js +++ b/src/components/DisruptionButton.js @@ -8,12 +8,17 @@ import ex2 from '../APIexamples/disruption2.json' import Button from './Button.js'; import disruptIcon from '../img/flash.svg'; +import globalData from '../GlobalData.js' + class DisruptionButton extends Button { state = { jsonLocation: this.props.path, disruption: "" } - + + updatePage = () => { + globalData.currentPage.forceUpdate(); + } genDisrupt = () => { this.state.disruption = undefined @@ -21,22 +26,20 @@ class DisruptionButton extends Button { for (let stopPoint of ex1.affectedStopPoints) { if(stopPoint.gid === globData.user.stoppointgid){ this.state.disruption = ex1; - console.log(globData.stop.departures[0]) - globData.stop.departures[0].newTime = ex1.time + globData.stop.departures[0].newTime = ex1.time; globData.stop.departures[0].trafficInfo = ex1.title; } } } else if (this.state.jsonLocation === "ex2"){ for (let stopPoint of ex2.affectedStopPoints) { if(stopPoint.gid === globData.user.stoppointgid){ - this.state.disruption = ex2 - globData.stop.departures[0].newTime = ex2.time + this.state.disruption = ex2; + globData.stop.departures[0].newTime = ex2.time; globData.stop.departures[0].trafficInfo = ex2.title; } } } - console.log(this.state.disruption) globData.disruption = this.state.disruption addNotification({ @@ -50,7 +53,7 @@ class DisruptionButton extends Button { render() { return ( - diff --git a/src/components/NavigationDrawer.js b/src/components/NavigationDrawer.js index 84b242b..c154a1a 100644 --- a/src/components/NavigationDrawer.js +++ b/src/components/NavigationDrawer.js @@ -44,6 +44,10 @@ class NavigationDrawer extends Component { showPopup = () => { this.popupElem.current.show(); }; + + hidePopup = () => { + this.popupElem.current.hide(); + }; updatePage = () => { globalData.currentPage.render(); @@ -55,8 +59,8 @@ class NavigationDrawer extends Component {

Välj hållplats:

diff --git a/src/components/NearbyStation.js b/src/components/NearbyStation.js index 5ed2a2a..5e240a9 100644 --- a/src/components/NearbyStation.js +++ b/src/components/NearbyStation.js @@ -28,11 +28,8 @@ class NearbyStation extends React.Component { 'Authorization': 'Bearer ' + this.state.tokenClass.token }; - console.log('Attempted connection') - axios.get('https://api.vasttrafik.se/bin/rest.exe/v2/location.nearbystops?originCoordLat='+this.state.lat+'&originCoordLong='+this.state.long+'&maxNo=5&format=json', { headers }) .then(response => { - console.log(response.data.LocationList.StopLocation) this.setState({ stops: response.data.LocationList.StopLocation, }) diff --git a/src/components/SelectUserButton.js b/src/components/SelectUserButton.js index ab3a1f3..6924d3c 100644 --- a/src/components/SelectUserButton.js +++ b/src/components/SelectUserButton.js @@ -25,21 +25,20 @@ class SelectUserButton extends Button { if(this.props.path === "user1"){ globData.user = user1 globData.stop = locationuser1.LocationList.StopLocation[0] - globData.stop.departures = [departureuser1.DepartureBoard.Departure] + globData.stop.departures = departureuser1.DepartureBoard.Departures }else if (this.props.path === "user2"){ globData.user = user2 globData.stop = locationuser2.LocationList.StopLocation[0] - globData.stop.departures = [departureuser2.DepartureBoard.Departure] + globData.stop.departures = departureuser2.DepartureBoard.Departures }else if (this.props.path === "user3"){ globData.user = user3 globData.stop = locationuser3.LocationList.StopLocation[0] - globData.stop.departures = [departureuser3.DepartureBoard.Departure] + globData.stop.departures = departureuser3.DepartureBoard.Departures }else if (this.props.path === "user4"){ globData.user = user4 globData.stop = locationuser4.LocationList.StopLocation[0] - globData.stop.departures = [departureuser4.DepartureBoard.Departure] + globData.stop.departures = departureuser4.DepartureBoard.Departures } - console.log(globData.stop) } updatePage = () => { diff --git a/src/components/StationDisruption.js b/src/components/StationDisruption.js index fb76620..e266d4c 100644 --- a/src/components/StationDisruption.js +++ b/src/components/StationDisruption.js @@ -23,14 +23,11 @@ class StationDisruption extends React.Component { 'Authorization': 'Bearer ' + this.state.tokenClass.token }; - console.log('Attempted connection') axios.get('https://api.vasttrafik.se/bin/rest.exe/v2/location.nearbystops?originCoordLat='+this.state.lat+'&originCoordLong='+this.state.long+'&maxNo=5&format=json', { headers }) .then(response => { - console.log(response.data.LocationList.StopLocation) }) axios.get('https://api.vasttrafik.se/ts/v1/traffic-situations/stoppoint/'+this.state.gid, { headers }) .then(response => { - console.log(response) this.setState({ disruptions: response.data }) diff --git a/src/components/StopTitle.js b/src/components/StopTitle.js index 872fa7b..81656d0 100644 --- a/src/components/StopTitle.js +++ b/src/components/StopTitle.js @@ -4,7 +4,6 @@ import './css/StopTitle.css'; class StopTitle extends Component { render() { - console.log(this.props.stop); return (
@@ -13,10 +12,10 @@ class StopTitle extends Component { : "Hållplats saknas" } - {this.props.stop.name !== undefined && this.props.stop.locations !== undefined ? + {this.props.stop.name !== undefined && this.props.stop.track !== undefined ?

- {this.props.stop.locations[0]} + {this.props.stop.track}

diff --git a/src/components/TrafficEntry.js b/src/components/TrafficEntry.js index 4fde4a7..3b6e82a 100644 --- a/src/components/TrafficEntry.js +++ b/src/components/TrafficEntry.js @@ -45,7 +45,7 @@ class TrafficEntry extends Component { <>
{this.props.departure.newTime} - {this.props.departure.originalTime} + {this.props.departure.time}
@@ -69,7 +69,7 @@ class TrafficEntry extends Component { {lineInterference && Hitta annan resväg }