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",
"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"
}
}
}
]
}
}

View File

@ -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"
}
}
}
]
}
}

View File

@ -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"
}
}
}]
}
}

View File

@ -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"
}
}
}]
}
}

View File

@ -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",

View File

@ -2,7 +2,7 @@
"situationNumber": "RT2",
"severity":"normal",
"title":"Försening",
"time":"02:00",
"time":"00:02",
"affectedStopPoints":[
{
"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} )
.then(response => {
console.log(response);
this.token = response.data.access_token
});
}

View File

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

View File

@ -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 (
<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="" />
<span>Generera Störning</span>
</Button>

View File

@ -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 {
<Popup ref={this.popupElem}>
<h3>Välj hållplats:</h3>
<ul>
<li><DisruptionButton path={"ex1"} onClick={[]}>Störnings Scenario 1</DisruptionButton></li>
<li><DisruptionButton path={"ex2"} onClick={[]}>Störnings Scenario 2</DisruptionButton></li>
<li><DisruptionButton path={"ex1"} onClick={[this.hidePopup]}>Störnings Scenario 1</DisruptionButton></li>
<li><DisruptionButton path={"ex2"} onClick={[this.hidePopup]}>Störnings Scenario 2</DisruptionButton></li>
</ul>
</Popup>

View File

@ -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,
})

View File

@ -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 = () => {

View File

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

View File

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

View File

@ -45,7 +45,7 @@ class TrafficEntry extends Component {
<>
<div style={{display: "flex", flexDirection: "column"}}>
<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>
<img src={warningIcon} alt=""></img>
</>
@ -69,7 +69,7 @@ class TrafficEntry extends Component {
{lineInterference &&
<Link to={
{ pathname: "/travel"
, to: this.props.departure.finalStop
, to: this.props.departure.direction
}
}>Hitta annan resväg</Link>
}