Almost done, final touches needed

This commit is contained in:
williameriksson126 2020-12-10 11:47:46 +01:00
parent 1b3f5abd25
commit cf977ccb1f
15 changed files with 122 additions and 79 deletions

View File

@ -3,27 +3,51 @@
"noNamespaceSchemaLocation": "http://api.vasttrafik.se/v1/hafasRestDepartureBoard.xsd", "noNamespaceSchemaLocation": "http://api.vasttrafik.se/v1/hafasRestDepartureBoard.xsd",
"servertime": "10:09", "servertime": "10:09",
"serverdate": "2020-12-10", "serverdate": "2020-12-10",
"Departure": { "Departures": [
"name": "Buss MEXP", {
"sname": "MEXP", "name": "Buss MEXP",
"journeyNumber": "24", "sname": "MEXP",
"type": "BUS", "journeyNumber": "24",
"stopid": "9022014014754002", "type": "BUS",
"stop": "Bollestadsvägen, Kungälv", "stopid": "9022014014754002",
"time": "10:09", "stop": "Bollestadsvägen, Kungälv",
"date": "2020-12-10", "time": "10:09",
"journeyid": "9015014621000024", "date": "2020-12-10",
"direction": "Marstrand", "journeyid": "9015014621000024",
"track": "B", "direction": "Marstrand",
"rtTime": "10:11", "track": "B",
"rtDate": "2020-12-10", "rtTime": "10:11",
"fgColor": "#006C93", "rtDate": "2020-12-10",
"bgColor": "#FFFFFF", "fgColor": "#006C93",
"stroke": "Solid", "bgColor": "#FFFFFF",
"accessibility": "wheelChair", "stroke": "Solid",
"JourneyDetailRef": { "accessibility": "wheelChair",
"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" "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"
}
} }
} ]
} }
} }

View File

@ -3,27 +3,51 @@
"noNamespaceSchemaLocation": "http://api.vasttrafik.se/v1/hafasRestDepartureBoard.xsd", "noNamespaceSchemaLocation": "http://api.vasttrafik.se/v1/hafasRestDepartureBoard.xsd",
"servertime": "10:10", "servertime": "10:10",
"serverdate": "2020-12-10", "serverdate": "2020-12-10",
"Departure": { "Departures": [
"name": "Buss MEXP", {
"sname": "MEXP", "name": "Buss MEXP",
"journeyNumber": "24", "sname": "MEXP",
"type": "BUS", "journeyNumber": "24",
"stopid": "9022014014020002", "type": "BUS",
"stop": "Ekelöv västra, Kungälv", "stopid": "9022014014020002",
"time": "10:10", "stop": "Ekelöv västra, Kungälv",
"date": "2020-12-10", "time": "10:10",
"journeyid": "9015014621000024", "date": "2020-12-10",
"direction": "Marstrand", "journeyid": "9015014621000024",
"track": "B", "direction": "Marstrand",
"rtTime": "10:13", "track": "B",
"rtDate": "2020-12-10", "rtTime": "10:13",
"fgColor": "#006C93", "rtDate": "2020-12-10",
"bgColor": "#FFFFFF", "fgColor": "#006C93",
"stroke": "Solid", "bgColor": "#FFFFFF",
"accessibility": "wheelChair", "stroke": "Solid",
"JourneyDetailRef": { "accessibility": "wheelChair",
"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" "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"
}
} }
} ]
} }
} }

View File

@ -3,7 +3,7 @@
"noNamespaceSchemaLocation": "http://api.vasttrafik.se/v1/hafasRestDepartureBoard.xsd", "noNamespaceSchemaLocation": "http://api.vasttrafik.se/v1/hafasRestDepartureBoard.xsd",
"servertime": "10:10", "servertime": "10:10",
"serverdate": "2020-12-10", "serverdate": "2020-12-10",
"Departure": { "Departures": [{
"name": "Buss MEXP", "name": "Buss MEXP",
"sname": "MEXP", "sname": "MEXP",
"journeyNumber": "24", "journeyNumber": "24",
@ -22,6 +22,6 @@
"JourneyDetailRef": { "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" "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"
} }
} }]
} }
} }

View File

@ -3,8 +3,8 @@
"noNamespaceSchemaLocation": "http://api.vasttrafik.se/v1/hafasRestDepartureBoard.xsd", "noNamespaceSchemaLocation": "http://api.vasttrafik.se/v1/hafasRestDepartureBoard.xsd",
"servertime": "10:11", "servertime": "10:11",
"serverdate": "2020-12-10", "serverdate": "2020-12-10",
"Departure": "Departures":
{ [{
"name": "Buss 928", "name": "Buss 928",
"sname": "928", "sname": "928",
"journeyNumber": "10", "journeyNumber": "10",
@ -25,6 +25,6 @@
"JourneyDetailRef": { "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" "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"
} }
} }]
} }
} }

View File

@ -1,8 +1,8 @@
{ {
"situationNumber": "RT1", "situationNumber": "RT1",
"severity":"normal", "severity":"normal",
"title":"Stannar inte på dessa hållplatser", "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":"01:00", "time":"00:01",
"affectedStopPoints":[ "affectedStopPoints":[
{ {
"gid": "9022014014020001", "gid": "9022014014020001",

View File

@ -2,7 +2,7 @@
"situationNumber": "RT2", "situationNumber": "RT2",
"severity":"normal", "severity":"normal",
"title":"Försening", "title":"Försening",
"time":"02:00", "time":"00:02",
"affectedStopPoints":[ "affectedStopPoints":[
{ {
"gid": "9021014014225000", "gid": "9021014014225000",

View File

@ -12,7 +12,6 @@ class AccessToken {
axios.post('https://api.vasttrafik.se/token','grant_type=client_credentials&scope=device_'+this.device, {headers} ) axios.post('https://api.vasttrafik.se/token','grant_type=client_credentials&scope=device_'+this.device, {headers} )
.then(response => { .then(response => {
console.log(response);
this.token = response.data.access_token this.token = response.data.access_token
}); });
} }

View File

@ -21,12 +21,9 @@ class Diruption extends React.Component {
'Authorization': 'Bearer ' + this.state.tokenClass.token '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/'+this.state.gid, { headers })
//axios.get('https://api.vasttrafik.se/ts/v1/traffic-situations/stoppoint/9022014005700002', { headers }) //axios.get('https://api.vasttrafik.se/ts/v1/traffic-situations/stoppoint/9022014005700002', { headers })
.then(response => { .then(response => {
console.log(response)
this.setState({ this.setState({
disruptions: response.data disruptions: response.data
}) })

View File

@ -8,12 +8,17 @@ 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';
import globalData from '../GlobalData.js'
class DisruptionButton extends Button { class DisruptionButton extends Button {
state = { state = {
jsonLocation: this.props.path, jsonLocation: this.props.path,
disruption: "" disruption: ""
} }
updatePage = () => {
globalData.currentPage.forceUpdate();
}
genDisrupt = () => { genDisrupt = () => {
this.state.disruption = undefined this.state.disruption = undefined
@ -21,22 +26,20 @@ class DisruptionButton extends Button {
for (let stopPoint of ex1.affectedStopPoints) { for (let stopPoint of ex1.affectedStopPoints) {
if(stopPoint.gid === globData.user.stoppointgid){ if(stopPoint.gid === globData.user.stoppointgid){
this.state.disruption = ex1; 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; globData.stop.departures[0].trafficInfo = ex1.title;
} }
} }
} else if (this.state.jsonLocation === "ex2"){ } else if (this.state.jsonLocation === "ex2"){
for (let stopPoint of ex2.affectedStopPoints) { for (let stopPoint of ex2.affectedStopPoints) {
if(stopPoint.gid === globData.user.stoppointgid){ if(stopPoint.gid === globData.user.stoppointgid){
this.state.disruption = ex2 this.state.disruption = ex2;
globData.stop.departures[0].newTime = ex2.time globData.stop.departures[0].newTime = ex2.time;
globData.stop.departures[0].trafficInfo = ex2.title; globData.stop.departures[0].trafficInfo = ex2.title;
} }
} }
} }
console.log(this.state.disruption)
globData.disruption = this.state.disruption globData.disruption = this.state.disruption
addNotification({ addNotification({
@ -50,7 +53,7 @@ class DisruptionButton extends Button {
render() { render() {
return ( return (
<Button onClick={this.props.onClick.concat([this.genDisrupt])} className="disruptBtn"> <Button onClick={this.props.onClick.concat([this.genDisrupt,this.updatePage])} className="disruptBtn">
<img src={disruptIcon} alt="" /> <img src={disruptIcon} alt="" />
<span>Generera Störning</span> <span>Generera Störning</span>
</Button> </Button>

View File

@ -45,6 +45,10 @@ class NavigationDrawer extends Component {
this.popupElem.current.show(); this.popupElem.current.show();
}; };
hidePopup = () => {
this.popupElem.current.hide();
};
updatePage = () => { updatePage = () => {
globalData.currentPage.render(); globalData.currentPage.render();
} }
@ -55,8 +59,8 @@ class NavigationDrawer extends Component {
<Popup ref={this.popupElem}> <Popup ref={this.popupElem}>
<h3>Välj hållplats:</h3> <h3>Välj hållplats:</h3>
<ul> <ul>
<li><DisruptionButton path={"ex1"} onClick={[]}>Störnings Scenario 1</DisruptionButton></li> <li><DisruptionButton path={"ex1"} onClick={[this.hidePopup]}>Störnings Scenario 1</DisruptionButton></li>
<li><DisruptionButton path={"ex2"} onClick={[]}>Störnings Scenario 2</DisruptionButton></li> <li><DisruptionButton path={"ex2"} onClick={[this.hidePopup]}>Störnings Scenario 2</DisruptionButton></li>
</ul> </ul>
</Popup> </Popup>

View File

@ -28,11 +28,8 @@ class NearbyStation extends React.Component {
'Authorization': 'Bearer ' + this.state.tokenClass.token '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 }) 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 => { .then(response => {
console.log(response.data.LocationList.StopLocation)
this.setState({ this.setState({
stops: response.data.LocationList.StopLocation, stops: response.data.LocationList.StopLocation,
}) })

View File

@ -25,21 +25,20 @@ class SelectUserButton extends Button {
if(this.props.path === "user1"){ if(this.props.path === "user1"){
globData.user = user1 globData.user = user1
globData.stop = locationuser1.LocationList.StopLocation[0] globData.stop = locationuser1.LocationList.StopLocation[0]
globData.stop.departures = [departureuser1.DepartureBoard.Departure] 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.stop = locationuser2.LocationList.StopLocation[0] globData.stop = locationuser2.LocationList.StopLocation[0]
globData.stop.departures = [departureuser2.DepartureBoard.Departure] 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.stop = locationuser3.LocationList.StopLocation[0] globData.stop = locationuser3.LocationList.StopLocation[0]
globData.stop.departures = [departureuser3.DepartureBoard.Departure] 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.stop = locationuser4.LocationList.StopLocation[0] globData.stop = locationuser4.LocationList.StopLocation[0]
globData.stop.departures = [departureuser4.DepartureBoard.Departure] globData.stop.departures = departureuser4.DepartureBoard.Departures
} }
console.log(globData.stop)
} }
updatePage = () => { updatePage = () => {

View File

@ -23,14 +23,11 @@ class StationDisruption extends React.Component {
'Authorization': 'Bearer ' + this.state.tokenClass.token '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 }) 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 => { .then(response => {
console.log(response.data.LocationList.StopLocation)
}) })
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/'+this.state.gid, { headers })
.then(response => { .then(response => {
console.log(response)
this.setState({ this.setState({
disruptions: response.data disruptions: response.data
}) })

View File

@ -4,7 +4,6 @@ import './css/StopTitle.css';
class StopTitle extends Component { class StopTitle extends Component {
render() { render() {
console.log(this.props.stop);
return ( return (
<div id="stopTitle"> <div id="stopTitle">
@ -13,10 +12,10 @@ class StopTitle extends Component {
: "Hållplats saknas" : "Hållplats saknas"
}</h1> }</h1>
{this.props.stop.name !== undefined && this.props.stop.locations !== undefined ? {this.props.stop.name !== undefined && this.props.stop.track !== undefined ?
<div> <div>
<h3> <h3>
<span>{this.props.stop.locations[0]}</span> <span>{this.props.stop.track}</span>
</h3> </h3>
<button>Byt Läge</button> <button>Byt Läge</button>
</div> </div>

View File

@ -45,7 +45,7 @@ class TrafficEntry extends Component {
<> <>
<div style={{display: "flex", flexDirection: "column"}}> <div style={{display: "flex", flexDirection: "column"}}>
<span style={{color: "red", fontWeight: "bold"}}>{this.props.departure.newTime}</span> <span style={{color: "red", fontWeight: "bold"}}>{this.props.departure.newTime}</span>
<span style={{textDecoration: "line-through"}}>{this.props.departure.originalTime}</span> <span style={{textDecoration: "line-through"}}>{this.props.departure.time}</span>
</div> </div>
<img src={warningIcon} alt=""></img> <img src={warningIcon} alt=""></img>
</> </>
@ -69,7 +69,7 @@ class TrafficEntry extends Component {
{lineInterference && {lineInterference &&
<Link to={ <Link to={
{ pathname: "/travel" { pathname: "/travel"
, to: this.props.departure.finalStop , to: this.props.departure.direction
} }
}>Hitta annan resväg</Link> }>Hitta annan resväg</Link>
} }