14 Commits

35 changed files with 592 additions and 352 deletions

5
package-lock.json generated
View File

@ -10111,6 +10111,11 @@
"minimist": "^1.2.5" "minimist": "^1.2.5"
} }
}, },
"moment": {
"version": "2.29.1",
"resolved": "https://registry.npmjs.org/moment/-/moment-2.29.1.tgz",
"integrity": "sha512-kHmoybcPV8Sqy59DwNDY3Jefr64lK/by/da0ViFcuA4DH0vQg5Q6Ze5VimxkfQNSC+Mls/Kx53s7TjP1RhFEDQ=="
},
"move-concurrently": { "move-concurrently": {
"version": "1.0.1", "version": "1.0.1",
"resolved": "https://registry.npmjs.org/move-concurrently/-/move-concurrently-1.0.1.tgz", "resolved": "https://registry.npmjs.org/move-concurrently/-/move-concurrently-1.0.1.tgz",

View File

@ -7,6 +7,7 @@
"@testing-library/react": "^11.1.2", "@testing-library/react": "^11.1.2",
"@testing-library/user-event": "^12.2.2", "@testing-library/user-event": "^12.2.2",
"axios": "^0.21.0", "axios": "^0.21.0",
"moment": "^2.29.1",
"react": "^17.0.1", "react": "^17.0.1",
"react-axios": "^2.0.3", "react-axios": "^2.0.3",
"react-dom": "^17.0.1", "react-dom": "^17.0.1",

View File

@ -1,29 +1,53 @@
{ {
"DepartureBoard": { "DepartureBoard": {
"noNamespaceSchemaLocation": "http://api.vasttrafik.se/v1/hafasRestDepartureBoard.xsd", "noNamespaceSchemaLocation": "http://api.vasttrafik.se/v1/hafasRestDepartureBoard.xsd",
"servertime": "10:09", "servertime": "09:38",
"serverdate": "2020-12-10", "serverdate": "2020-12-11",
"Departure": { "Departures": [
{
"name": "Buss MEXP", "name": "Buss MEXP",
"sname": "MEXP", "sname": "MEXP",
"journeyNumber": "24", "journeyNumber": "22",
"type": "BUS", "type": "BUS",
"stopid": "9022014014754002", "stopid": "9022014014751002",
"stop": "Bollestadsvägen, Kungälv", "stop": "Guddeby, Kungälv",
"time": "10:09", "time": "09:40",
"date": "2020-12-10", "date": "2020-12-11",
"journeyid": "9015014621000024", "journeyid": "9015014621000022",
"direction": "Marstrand", "direction": "Marstrand",
"track": "B", "track": "B",
"rtTime": "10:11", "rtTime": "09:44",
"rtDate": "2020-12-10", "rtDate": "2020-12-11",
"fgColor": "#006C93", "fgColor": "#006C93",
"bgColor": "#FFFFFF", "bgColor": "#FFFFFF",
"stroke": "Solid", "stroke": "Solid",
"accessibility": "wheelChair", "accessibility": "wheelChair",
"JourneyDetailRef": { "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" "ref": "https://api.vasttrafik.se/bin/rest.exe/v2/journeyDetail?ref=715722%2F247121%2F629948%2F76401%2F80%3Fdate%3D2020-12-11%26station_evaId%3D14751002%26station_type%3Ddep%26format%3Djson%26"
}
},
{
"name": "Buss 927",
"sname": "927",
"journeyNumber": "2",
"type": "BUS",
"stopid": "9022014014751002",
"stop": "Guddeby, Kungälv",
"time": "12:29",
"date": "2020-12-11",
"journeyid": "9015014692700002",
"direction": "Tjuvkil",
"track": "B",
"rtTime": "12:30",
"rtDate": "2020-12-11",
"fgColor": "#006C93",
"bgColor": "#FFFFFF",
"stroke": "Solid",
"accessibility": "wheelChair",
"JourneyDetailRef": {
"ref": "https://api.vasttrafik.se/bin/rest.exe/v2/journeyDetail?ref=286581%2F125303%2F109682%2F40686%2F80%3Fdate%3D2020-12-11%26station_evaId%3D14751002%26station_type%3Ddep%26format%3Djson%26"
} }
} }
]
} }
} }

View File

@ -1,29 +1,53 @@
{ {
"DepartureBoard": { "DepartureBoard": {
"noNamespaceSchemaLocation": "http://api.vasttrafik.se/v1/hafasRestDepartureBoard.xsd", "noNamespaceSchemaLocation": "http://api.vasttrafik.se/v1/hafasRestDepartureBoard.xsd",
"servertime": "10:10", "servertime": "09:41",
"serverdate": "2020-12-10", "serverdate": "2020-12-11",
"Departure": { "Departures": [
{
"name": "Buss MEXP", "name": "Buss MEXP",
"sname": "MEXP", "sname": "MEXP",
"journeyNumber": "24", "journeyNumber": "22",
"type": "BUS", "type": "BUS",
"stopid": "9022014014020002", "stopid": "9022014014010002",
"stop": "Ekelöv västra, Kungälv", "stop": "Hålta kyrka, Kungälv",
"time": "10:10", "time": "09:47",
"date": "2020-12-10", "date": "2020-12-11",
"journeyid": "9015014621000024", "journeyid": "9015014621000022",
"direction": "Marstrand", "direction": "Marstrand",
"track": "B", "track": "B",
"rtTime": "10:13", "rtTime": "09:50",
"rtDate": "2020-12-10", "rtDate": "2020-12-11",
"fgColor": "#006C93", "fgColor": "#006C93",
"bgColor": "#FFFFFF", "bgColor": "#FFFFFF",
"stroke": "Solid", "stroke": "Solid",
"accessibility": "wheelChair", "accessibility": "wheelChair",
"JourneyDetailRef": { "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" "ref": "https://api.vasttrafik.se/bin/rest.exe/v2/journeyDetail?ref=514476%2F180039%2F54148%2F144419%2F80%3Fdate%3D2020-12-11%26station_evaId%3D14010002%26station_type%3Ddep%26format%3Djson%26"
}
},
{
"name": "Buss 927",
"sname": "927",
"journeyNumber": "2",
"type": "BUS",
"stopid": "9022014014010002",
"stop": "Hålta kyrka, Kungälv",
"time": "12:38",
"date": "2020-12-11",
"journeyid": "9015014692700002",
"direction": "Tjuvkil",
"track": "B",
"rtTime": "12:38",
"rtDate": "2020-12-11",
"fgColor": "#006C93",
"bgColor": "#FFFFFF",
"stroke": "Solid",
"accessibility": "wheelChair",
"JourneyDetailRef": {
"ref": "https://api.vasttrafik.se/bin/rest.exe/v2/journeyDetail?ref=667647%2F252325%2F917844%2F236373%2F80%3Fdate%3D2020-12-11%26station_evaId%3D14010002%26station_type%3Ddep%26format%3Djson%26"
} }
} }
]
} }
} }

View File

@ -1,27 +1,53 @@
{ {
"DepartureBoard": { "DepartureBoard": {
"noNamespaceSchemaLocation": "http://api.vasttrafik.se/v1/hafasRestDepartureBoard.xsd", "noNamespaceSchemaLocation": "http://api.vasttrafik.se/v1/hafasRestDepartureBoard.xsd",
"servertime": "10:10", "servertime": "09:44",
"serverdate": "2020-12-10", "serverdate": "2020-12-11",
"Departure": { "Departures": [
{
"name": "Buss MEXP", "name": "Buss MEXP",
"sname": "MEXP", "sname": "MEXP",
"journeyNumber": "24", "journeyNumber": "22",
"type": "BUS", "type": "BUS",
"stopid": "9022014014751002", "stopid": "9022014014614002",
"stop": "Guddeby, Kungälv", "stop": "Stenskärsvägen, Kungälv",
"time": "10:07", "time": "09:52",
"date": "2020-12-10", "date": "2020-12-11",
"journeyid": "9015014621000024", "journeyid": "9015014621000022",
"direction": "Marstrand", "direction": "Marstrand",
"track": "B", "track": "B",
"rtTime": "09:57",
"rtDate": "2020-12-11",
"fgColor": "#006C93", "fgColor": "#006C93",
"bgColor": "#FFFFFF", "bgColor": "#FFFFFF",
"stroke": "Solid", "stroke": "Solid",
"accessibility": "wheelChair", "accessibility": "wheelChair",
"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=341064%2F122235%2F154456%2F36461%2F80%3Fdate%3D2020-12-11%26station_evaId%3D14614002%26station_type%3Ddep%26format%3Djson%26"
}
},
{
"name": "Buss 320",
"sname": "320",
"journeyNumber": "10",
"type": "BUS",
"stopid": "9022014014614002",
"stop": "Stenskärsvägen, Kungälv",
"time": "10:44",
"date": "2020-12-11",
"journeyid": "9015014632000010",
"direction": "Tjuvkil",
"track": "B",
"rtTime": "10:44",
"rtDate": "2020-12-11",
"fgColor": "#006C93",
"bgColor": "#FFFFFF",
"stroke": "Solid",
"accessibility": "wheelChair",
"JourneyDetailRef": {
"ref": "https://api.vasttrafik.se/bin/rest.exe/v2/journeyDetail?ref=931884%2F318653%2F795430%2F87087%2F80%3Fdate%3D2020-12-11%26station_evaId%3D14614002%26station_type%3Ddep%26format%3Djson%26"
} }
} }
]
} }
} }

View File

@ -1,10 +1,9 @@
{ {
"DepartureBoard": { "DepartureBoard": {
"noNamespaceSchemaLocation": "http://api.vasttrafik.se/v1/hafasRestDepartureBoard.xsd", "noNamespaceSchemaLocation": "http://api.vasttrafik.se/v1/hafasRestDepartureBoard.xsd",
"servertime": "10:11", "servertime": "09:45",
"serverdate": "2020-12-10", "serverdate": "2020-12-11",
"Departure": [ "Departures": [{
{
"name": "Buss 928", "name": "Buss 928",
"sname": "928", "sname": "928",
"journeyNumber": "10", "journeyNumber": "10",
@ -12,20 +11,19 @@
"stopid": "9022014014225001", "stopid": "9022014014225001",
"stop": "Skrämmenborg, Kungälv", "stop": "Skrämmenborg, Kungälv",
"time": "15:19", "time": "15:19",
"date": "2020-12-10", "date": "2020-12-11",
"journeyid": "9015014692800010", "journeyid": "9015014692800010",
"direction": "Kärna", "direction": "Kärna",
"track": "A", "track": "A",
"rtTime": "15:19", "rtTime": "15:19",
"rtDate": "2020-12-10", "rtDate": "2020-12-11",
"fgColor": "#006C93", "fgColor": "#006C93",
"bgColor": "#FFFFFF", "bgColor": "#FFFFFF",
"stroke": "Solid", "stroke": "Solid",
"accessibility": "wheelChair", "accessibility": "wheelChair",
"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=110424%2F37130%2F997492%2F461938%2F80%3Fdate%3D2020-12-11%26station_evaId%3D14225001%26station_type%3Ddep%26format%3Djson%26"
} }
} }]
]
} }
} }

View File

@ -1,15 +1,16 @@
{ {
"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":"00:07",
"affectedStopPoints":[ "affectedStopPoints":[
{ {
"gid": "9022014014020001", "gid": "9022014014010001",
"name": "Ekelöv västra, Kungälv" "name": "Hålta kyrka, Kungälv"
}, },
{ {
"gid": "9022014014751001", "gid": "9022014014614001",
"name": "Guddeby, Kungälv" "name": "Stenskärsvägen, Kungälv"
} }
] ]
} }

View File

@ -1,11 +1,12 @@
{ {
"situationNumber": "RT2", "situationNumber": "RT2",
"severity":"normal", "severity":"normal",
"title":"Försening", "title":"På grund av renovation av Nordreälvsbron i Kungälv från 10 november, 2019 till sommaren 2022 är det risk för förseningar på vissa Västtrafik bussar.",
"time":"00:09",
"affectedStopPoints":[ "affectedStopPoints":[
{ {
"gid": "9021014014225000", "gid": "9022014014762001",
"name": "Skrämmenborg, Kungälv" "name": "Kuröd, Kungälv"
} }
] ]
} }

View File

@ -1,35 +1,35 @@
{ {
"LocationList": { "LocationList": {
"noNamespaceSchemaLocation": "http://api.vasttrafik.se/v1/hafasRestLocation.xsd", "noNamespaceSchemaLocation": "http://api.vasttrafik.se/v1/hafasRestLocation.xsd",
"servertime": "16:48", "servertime": "09:34",
"serverdate": "2020-12-09", "serverdate": "2020-12-11",
"StopLocation": [ "StopLocation": [
{ {
"name": "Bollestadsvägen, Kungälv", "name": "Guddeby, Kungälv",
"id": "9022014014754001", "id": "9022014014751001",
"lat": "57.888940", "lat": "57.874665",
"lon": "11.885663", "lon": "11.903884",
"track": "A" "track": "A"
}, },
{ {
"name": "Bollestadsvägen, Kungälv", "name": "Guddeby, Kungälv",
"id": "9021014014754000", "id": "9021014014751000",
"lat": "57.889030", "lat": "57.874710",
"lon": "11.885708" "lon": "11.903929"
}, },
{ {
"name": "Bollestadsvägen, Kungälv", "name": "Guddeby, Kungälv",
"id": "9022014014754002", "id": "9022014014751002",
"lat": "57.889111", "lat": "57.874746",
"lon": "11.885753", "lon": "11.903965",
"track": "B" "track": "B"
}, },
{ {
"name": "Bredsten, Kungälv", "name": "Stället, Kungälv",
"id": "9022014014753002", "id": "9022014014744001",
"lat": "57.886450", "lat": "57.869784",
"lon": "11.889529", "lon": "11.904172",
"track": "B" "track": "A"
} }
] ]
} }

View File

@ -1,35 +1,35 @@
{ {
"LocationList": { "LocationList": {
"noNamespaceSchemaLocation": "http://api.vasttrafik.se/v1/hafasRestLocation.xsd", "noNamespaceSchemaLocation": "http://api.vasttrafik.se/v1/hafasRestLocation.xsd",
"servertime": "16:47", "servertime": "09:35",
"serverdate": "2020-12-09", "serverdate": "2020-12-11",
"StopLocation": [ "StopLocation": [
{ {
"name": "Ekelöv västra, Kungälv", "name": "Hålta kyrka, Kungälv",
"id": "9022014014020001", "id": "9022014014010001",
"lat": "57.892527", "lat": "57.895125",
"lon": "11.865321", "lon": "11.827854",
"track": "A" "track": "A"
}, },
{ {
"name": "Ekelöv västra, Kungälv", "name": "Hålta kyrka, Kungälv",
"id": "9021014014020000", "id": "9021014014010000",
"lat": "57.892608", "lat": "57.895206",
"lon": "11.865312" "lon": "11.827647"
}, },
{ {
"name": "Ekelöv västra, Kungälv", "name": "Hålta kyrka, Kungälv",
"id": "9022014014020002", "id": "9022014014010002",
"lat": "57.892689", "lat": "57.895278",
"lon": "11.865285", "lon": "11.827440",
"track": "B" "track": "B"
}, },
{ {
"name": "Ekelöv östra, Kungälv", "name": "Hålta skola, Kungälv",
"id": "9022014014021002", "id": "9022014014015001",
"lat": "57.892994", "lat": "57.896015",
"lon": "11.873923", "lon": "11.824555",
"track": "B" "track": "A"
} }
] ]
} }

View File

@ -1,35 +1,35 @@
{ {
"LocationList": { "LocationList": {
"noNamespaceSchemaLocation": "http://api.vasttrafik.se/v1/hafasRestLocation.xsd", "noNamespaceSchemaLocation": "http://api.vasttrafik.se/v1/hafasRestLocation.xsd",
"servertime": "16:45", "servertime": "09:36",
"serverdate": "2020-12-09", "serverdate": "2020-12-11",
"StopLocation": [ "StopLocation": [
{ {
"name": "Guddeby, Kungälv", "name": "Stenskärsvägen, Kungälv",
"id": "9022014014751001", "id": "9022014014614001",
"lat": "57.874665", "lat": "57.894594",
"lon": "11.903884", "lon": "11.740128",
"track": "A" "track": "A"
}, },
{ {
"name": "Guddeby, Kungälv", "name": "Stenskärsvägen, Kungälv",
"id": "9021014014751000", "id": "9022014014614002",
"lat": "57.874710", "lat": "57.894729",
"lon": "11.903929" "lon": "11.739984",
},
{
"name": "Guddeby, Kungälv",
"id": "9022014014751002",
"lat": "57.874746",
"lon": "11.903965",
"track": "B" "track": "B"
}, },
{ {
"name": "Stället, Kungälv", "name": "Stenskärsvägen, Kungälv",
"id": "9022014014744001", "id": "9021014014614000",
"lat": "57.869784", "lat": "57.894738",
"lon": "11.904172", "lon": "11.739858"
"track": "A" },
{
"name": "Tjuvkilsboden, Kungälv",
"id": "9022014014615002",
"lat": "57.892743",
"lon": "11.743490",
"track": "B"
} }
] ]
} }

View File

@ -1,21 +1,21 @@
{ {
"LocationList": { "LocationList": {
"noNamespaceSchemaLocation": "http://api.vasttrafik.se/v1/hafasRestLocation.xsd", "noNamespaceSchemaLocation": "http://api.vasttrafik.se/v1/hafasRestLocation.xsd",
"servertime": "16:44", "servertime": "09:37",
"serverdate": "2020-12-09", "serverdate": "2020-12-11",
"StopLocation": [ "StopLocation": [
{ {
"name": "Skrämmenborg, Kungälv", "name": "Kuröd, Kungälv",
"id": "9021014014225000", "id": "9022014014762001",
"lat": "57.863528", "lat": "57.856687",
"lon": "11.867406" "lon": "11.864727",
"track": "A"
}, },
{ {
"name": "Skrämmenborg, Kungälv", "name": "Kuröd, Kungälv",
"id": "9022014014225001", "id": "9021014014762000",
"lat": "57.863528", "lat": "57.856831",
"lon": "11.867406", "lon": "11.864260"
"track": "A"
}, },
{ {
"name": "Kuröd, Kungälv", "name": "Kuröd, Kungälv",
@ -25,10 +25,10 @@
"track": "B" "track": "B"
}, },
{ {
"name": "Kuröd, Kungälv", "name": "Skrämmenborg, Kungälv",
"id": "9021014014762000", "id": "9021014014225000",
"lat": "57.856831", "lat": "57.863528",
"lon": "11.864260" "lon": "11.867406"
} }
] ]
} }

View File

@ -1,5 +1,5 @@
{ {
"name":"1", "name": "Användare 1",
"deviceId": "1", "deviceId": "1",
"stoppointgid":"9022014014754001" "stoppointgid": "9022014014751001"
} }

View File

@ -1,5 +1,5 @@
{ {
"name":"2", "name": "Användare 2",
"deviceId": "2", "deviceId": "2",
"stoppointgid":"9022014014020001" "stoppointgid": "9022014014010001"
} }

View File

@ -1,5 +1,5 @@
{ {
"name":"3", "name": "Användare 3",
"deviceId": "3", "deviceId": "3",
"stoppointgid":"9022014014751001" "stoppointgid": "9022014014614001"
} }

View File

@ -1,5 +1,5 @@
{ {
"name":"4", "name": "Användare 4",
"deviceId": "4", "deviceId": "4",
"stoppointgid":"9021014014225000" "stoppointgid": "9022014014762001"
} }

View File

@ -2,14 +2,14 @@ import User from './classes/User.js';
import Disruption from './classes/Disruption.js' import Disruption from './classes/Disruption.js'
import Coordinates from './classes/Coordinates.js'; import Coordinates from './classes/Coordinates.js';
import Stop from './classes/Stop.js' import Stop from './classes/Stop.js'
import Departure from './classes/Departure.js';
let globalData = { let globalData = {
users : [],
user: new User( user: new User(
"test", "Exempelanvändare",
"123", "123",
new Coordinates(), new Coordinates(),
"9022014014020001" "123"
), ),
disruption: new Disruption( disruption: new Disruption(
), ),

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

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

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

@ -1,53 +1,116 @@
import addNotification from "react-push-notification"; import moment from "moment";
import globData from '../GlobalData.js'; import globalData from '../GlobalData.js';
import Button from './Button.js';
import user1 from '../APIexamples/user1.json'
import user2 from '../APIexamples/user2.json'
import user3 from '../APIexamples/user3.json'
import user4 from '../APIexamples/user4.json'
import locationuser1 from '../APIexamples/locationuser1.json'
import locationuser2 from '../APIexamples/locationuser2.json'
import locationuser3 from '../APIexamples/locationuser3.json'
import locationuser4 from '../APIexamples/locationuser4.json'
import departureuser1 from '../APIexamples/departureuser1.json'
import departureuser2 from '../APIexamples/departureuser2.json'
import departureuser3 from '../APIexamples/departureuser3.json'
import departureuser4 from '../APIexamples/departureuser4.json'
import ex1 from '../APIexamples/disruption1.json' import ex1 from '../APIexamples/disruption1.json'
import ex2 from '../APIexamples/disruption2.json' import ex2 from '../APIexamples/disruption2.json'
import Button from './Button.js';
import disruptIcon from '../img/flash.svg';
class DisruptionButton extends Button { class DisruptionButton extends Button {
state = { state = {
jsonLocation: this.props.path, jsonLocation: this.props.path,
disruption: "" disruption: "",
u1 : user1,
u2 : user2,
u3 : user3,
u4 : user4,
} }
updatePage = () => {
globalData.currentPage.forceUpdate();
}
showMomentTime = (time) => {
return(time.format("HH:mm"))
}
genUsers = () => {
if(globalData.users.length < 2){
this.state.first = true;
this.state.u1.stop = locationuser1.LocationList.StopLocation[0];
this.state.u1.stop.departures = departureuser1.DepartureBoard.Departures;
this.state.u2.stop = locationuser2.LocationList.StopLocation[0];
this.state.u2.stop.departures = departureuser2.DepartureBoard.Departures;
this.state.u3.stop = locationuser3.LocationList.StopLocation[0];
this.state.u3.stop.departures = departureuser3.DepartureBoard.Departures;
this.state.u4.stop = locationuser4.LocationList.StopLocation[0];
this.state.u4.stop.departures = departureuser4.DepartureBoard.Departures;
globalData.users = [
this.state.u1,
this.state.u2,
this.state.u3,
this.state.u4
]
}
}
genDisrupt = () => { genDisrupt = () => {
this.state.disruption = "" this.genUsers()
this.state.disruption = undefined
if(this.state.jsonLocation === "ex1"){ if(this.state.jsonLocation === "ex1"){
for (let stopPoint of ex1.affectedStopPoints) { for (let stopPoint of ex1.affectedStopPoints) {
if(stopPoint.gid === globData.user.stoppointgid){ for (let user of globalData.users){
this.state.disruption = ex1 if(stopPoint.gid === user.stoppointgid){
this.state.disruption = ex1;
var old1t = moment(user.stop.departures[0].time,"HH:mm");
old1t.add(ex1.time, "HH:mm");
user.stop.departures[0].newTime = this.showMomentTime(old1t);
user.stop.departures[0].trafficInfo = ex1.title;
}
}
if(stopPoint.gid === globalData.user.stoppointgid){
this.state.disruption = ex1;
var old2t = moment(globalData.stop.departures[0].time,"HH:mm");
old2t.add(ex1.time, "HH:mm");
globalData.stop.departures[0].newTime = this.showMomentTime(old2t);
globalData.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){ for (let user of globalData.users){
this.state.disruption = ex2 if(stopPoint.gid === user.stoppointgid){
this.state.disruption = ex2;
var old3t = moment(user.stop.departures[0].time,"HH:mm");
old3t.add(ex2.time, "HH:mm");
user.stop.departures[0].newTime = this.showMomentTime(old3t);
user.stop.departures[0].trafficInfo = ex2.title;
}
}
if(stopPoint.gid === globalData.user.stoppointgid){
this.state.disruption = ex2;
var old4t = moment(globalData.stop.departures[0].time,"HH:mm");
old4t.add(ex2.time, "HH:mm");
globalData.stop.departures[0].newTime = this.showMomentTime(old4t);
globalData.stop.departures[0].trafficInfo = ex2.title;
} }
} }
} }
console.log(this.state.disruption) globalData.disruption = this.state.disruption
globData.disruption = this.state.disruption
addNotification({
title: "Warning",
subtitle: "This is a subtitle",
message: "This is a very long message",
theme: "blue",
native: true, // when using native, your OS will handle theming.
});
} }
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="" /> {this.props.children}
<span>Generera Störning</span>
</Button> </Button>
); );
} }

View File

@ -1,5 +1,5 @@
import globData from '../GlobalData.js'; import globalData from '../GlobalData.js';
import locationuser1 from '../APIexamples/locationuser1.json' import locationuser1 from '../APIexamples/locationuser1.json'
import locationuser2 from '../APIexamples/locationuser2.json' import locationuser2 from '../APIexamples/locationuser2.json'
@ -15,13 +15,13 @@ class FindStops extends Button {
locations : [] locations : []
} }
findStops = () => { findStops = () => {
if(globData.user.deviceId === "1"){ if(globalData.user.deviceId === "1"){
this.state.locations = locationuser1.LocationList.StopLocation this.state.locations = locationuser1.LocationList.StopLocation
}else if (globData.user.deviceId === "2"){ }else if (globalData.user.deviceId === "2"){
this.state.locations = locationuser2.LocationList.StopLocation this.state.locations = locationuser2.LocationList.StopLocation
}else if (globData.user.deviceId === "3"){ }else if (globalData.user.deviceId === "3"){
this.state.locations = locationuser3.LocationList.StopLocation this.state.locations = locationuser3.LocationList.StopLocation
}else if (globData.user.deviceId === "4"){ }else if (globalData.user.deviceId === "4"){
this.state.locations = locationuser4.LocationList.StopLocation this.state.locations = locationuser4.LocationList.StopLocation
} }
} }

View File

@ -5,14 +5,14 @@ class MenuButton extends Button {
render() { render() {
if (this.props.childOrderReverse) { if (this.props.childOrderReverse) {
return ( return (
<Button> <Button className="menuButton">
<span>{this.props.label}</span> <span>{this.props.label}</span>
<img src={this.props.icon} alt="" /> <img src={this.props.icon} alt="" />
</Button> </Button>
); );
} else { } else {
return ( return (
<Button> <Button className="menuButton">
<img src={this.props.icon} alt="" /> <img src={this.props.icon} alt="" />
<span>{this.props.label}</span> <span>{this.props.label}</span>
</Button> </Button>

View File

@ -9,7 +9,7 @@ import Button from './Button.js';
import './css/NavigationDrawer.css'; import './css/NavigationDrawer.css';
import userIcon from '../img/user.svg'; import userIcon from '../img/user.svg';
import FindStops from './FindStops.js'; import disruptIcon from '../img/flash.svg';
class NavigationDrawer extends Component { class NavigationDrawer extends Component {
@ -45,16 +45,22 @@ class NavigationDrawer extends Component {
this.popupElem.current.show(); this.popupElem.current.show();
}; };
hidePopup = () => {
this.popupElem.current.hide();
};
updatePage = () => {
globalData.currentPage.render();
}
render() { render() {
return ( return (
<> <>
<Popup ref={this.popupElem}> <Popup ref={this.popupElem}>
<h3>Välj hållplats:</h3> <h3>Välj scenario:</h3>
<ul> <ul>
<li><Button>Hållplats 1</Button></li> <li><DisruptionButton path={"ex1"} onClick={[this.hidePopup]}>Störningsscenario 1</DisruptionButton></li>
<li><Button>Hållplats 2</Button></li> <li><DisruptionButton path={"ex2"} onClick={[this.hidePopup]}>Störningsscenario 2</DisruptionButton></li>
<li><Button>Hållplats 3</Button></li>
<li><Button>Hållplats 4</Button></li>
</ul> </ul>
</Popup> </Popup>
@ -65,13 +71,11 @@ class NavigationDrawer extends Component {
<span>example@gmail.com</span> <span>example@gmail.com</span>
</header> </header>
<div id="navList"> <div id="navList">
<SelectUserButton path={"user1"} username="user1"/> <SelectUserButton path={"user1"} username="Användare 1"/>
<SelectUserButton path={"user2"} username="user2"/> <SelectUserButton path={"user2"} username="Användare 2"/>
<SelectUserButton path={"user3"} username="user3"/> <SelectUserButton path={"user3"} username="Användare 3"/>
<SelectUserButton path={"user4"} username="user4"/> <SelectUserButton path={"user4"} username="Användare 4"/>
<FindStops/> <Button onClick={[this.showPopup, this.close]} className="disruptBtn"><img src={disruptIcon} alt="" />Generera Störning</Button>
<DisruptionButton path={"ex1"} onClick={[this.showPopup, this.close]} />
<DisruptionButton path={"ex2"} 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>

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

@ -1,5 +1,4 @@
import globalData from '../GlobalData.js';
import globData from '../GlobalData.js';
import user1 from '../APIexamples/user1.json' import user1 from '../APIexamples/user1.json'
import user2 from '../APIexamples/user2.json' import user2 from '../APIexamples/user2.json'
@ -17,44 +16,75 @@ 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';
class SelectUserButton extends Button { class SelectUserButton extends Button {
selectUser = () => { state = {
if(this.props.path === "user1"){ first: false,
globData.user = user1 u1: user1,
globData.stop = locationuser1.LocationList.StopLocation[0] u2: user2,
globData.stop.departures = [departureuser1.DepartureBoard.Departure] u3: user3,
}else if (this.props.path === "user2"){ u4: user4,
globData.user = user2 }
globData.stop = locationuser2.LocationList.StopLocation[0]
globData.stop.departures = [departureuser2.DepartureBoard.Departure] genUsers = () => {
}else if (this.props.path === "user3"){ if (globalData.users.length < 2) {
globData.user = user3 this.state.first = true;
globData.stop = locationuser3.LocationList.StopLocation[0] this.state.u1.stop = locationuser1.LocationList.StopLocation[0];
globData.stop.departures = [departureuser3.DepartureBoard.Departure] this.state.u1.stop.departures = departureuser1.DepartureBoard.Departures;
}else if (this.props.path === "user4"){ this.state.u2.stop = locationuser2.LocationList.StopLocation[0];
globData.user = user4 this.state.u2.stop.departures = departureuser2.DepartureBoard.Departures;
globData.stop = locationuser4.LocationList.StopLocation[0] this.state.u3.stop = locationuser3.LocationList.StopLocation[0];
globData.stop.departures = [departureuser4.DepartureBoard.Departure] this.state.u3.stop.departures = departureuser3.DepartureBoard.Departures;
this.state.u4.stop = locationuser4.LocationList.StopLocation[0];
this.state.u4.stop.departures = departureuser4.DepartureBoard.Departures;
globalData.users = [
this.state.u1,
this.state.u2,
this.state.u3,
this.state.u4
]
}
}
selectUser = () => {
this.genUsers()
if(this.props.path === "user1"){
globalData.user = user1
globalData.user.track = locationuser1.LocationList.StopLocation[0].track
globalData.stop = locationuser1.LocationList.StopLocation[0]
globalData.stop.departures = departureuser1.DepartureBoard.Departures
}else if (this.props.path === "user2"){
globalData.user = user2
globalData.user.track = locationuser2.LocationList.StopLocation[0].track
globalData.stop = locationuser2.LocationList.StopLocation[0]
globalData.stop.departures = departureuser2.DepartureBoard.Departures
}else if (this.props.path === "user3"){
globalData.user = user3
globalData.user.track = locationuser3.LocationList.StopLocation[0].track
globalData.stop = locationuser3.LocationList.StopLocation[0]
globalData.stop.departures = departureuser3.DepartureBoard.Departures
}else if (this.props.path === "user4"){
globalData.user = user4
globalData.user.track = locationuser4.LocationList.StopLocation[0].track
globalData.stop = locationuser4.LocationList.StopLocation[0]
globalData.stop.departures = departureuser4.DepartureBoard.Departures
} }
console.log(globData.stop)
} }
updatePage = () => { updatePage = () => {
globalData.currentPage.render(); globalData.currentPage.forceUpdate();
} }
render() { render() {
return ( return (
<Button onClick={[this.selectUser, this.updatePage]} className="disruptBtn"> <Button onClick={[this.selectUser, this.updatePage]} className="disruptBtn">
<img src={disruptIcon} alt="" /> <img src={userIcon} alt="" />
<span>{this.props.username}</span> {this.props.username}
</Button> </Button>
); );
} }
} }
export default SelectUserButton; export default SelectUserButton;

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

@ -1,27 +1,69 @@
import React, { Component } from 'react'; import React, { Component } from 'react';
import Button from './Button.js';
import Popup from './Popup.js';
import globalData from '../GlobalData.js';
import './css/StopTitle.css'; import './css/StopTitle.css';
class StopTitle extends Component { class StopTitle extends Component {
constructor(props) {
super(props);
this.popupElem = React.createRef();
}
showPopup = () => {
this.popupElem.current.show();
};
hidePopup = () => {
this.popupElem.current.hide();
};
setTrackA = () => {
globalData.user.track = "A";
};
setTrackB = () => {
globalData.user.track = "B";
};
updatePage = () => {
globalData.currentPage.forceUpdate();
}
render() { 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.setTrackA, this.updatePage, this.hidePopup]}>{"Läge A"}</Button></li>
<li><Button onClick={[this.setTrackB, this.updatePage, 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"
}</h1> }</h1>
{this.props.stop.name !== undefined && this.props.stop.track !== undefined ?
<div> <div>
{this.props.stop.locations !== undefined ?
<>
<h3> <h3>
<span>{this.props.stop.locations[0]}</span> <span>{"Läge " + globalData.user.track}</span>
</h3> </h3>
<button>Byt Läge</button> <Button className="changeTrackBtn" onClick={[this.showPopup]}>Byt Läge</Button>
</>
:
<h3>Vänligen aktivera platsåtkomst</h3>
}
</div> </div>
:
(this.props.stop.name !== undefined ?
<></>
: <h3>Vänligen aktivera platsåtkomst</h3>
)
}
</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>
} }

View File

@ -5,6 +5,8 @@
transform: translate(-50%, -50%) scale(0); transform: translate(-50%, -50%) scale(0);
transform-origin: center; transform-origin: center;
background: white; background: white;
display: flex !important;
flex-direction: column !important;
width: 55vw; width: 55vw;
height: 39vh; height: 39vh;
padding: 3vh 5vw; padding: 3vh 5vw;
@ -21,16 +23,26 @@
.popup h3 { .popup h3 {
margin-bottom: 20px; margin-bottom: 20px;
display: block;
font-size: 1.17em;
font-weight: bold !important;
text-align: center;
color: black !important;
} }
.popup ul { .popup ul {
list-style: none; list-style: none;
width: 100%;
} }
.popup li button { .popup li button {
width: 100%; width: 100% !important;
padding: 8% 0; height: 50px;
font-size: 16px; padding: 8% 0 !important;
font-size: 16px !important;
display: flex;
align-items: center;
justify-content: center;
} }
.popupClose { .popupClose {

View File

@ -8,6 +8,7 @@
justify-content: space-evenly; justify-content: space-evenly;
padding: 0 5vw; padding: 0 5vw;
z-index: 4; z-index: 4;
max-width: 80vw;
} }
#stopTitle h1, #stopTitle h3 { #stopTitle h1, #stopTitle h3 {
@ -23,7 +24,7 @@
color: var(--colorDiscrete); color: var(--colorDiscrete);
} }
@media screen and (min-width: 350px) { @media screen and (min-width: 400px) {
#stopTitle h1 { #stopTitle h1 {
font-size: 35px; font-size: 35px;
} }
@ -37,9 +38,10 @@
#stopTitle div { #stopTitle div {
display: flex; display: flex;
flex-direction: row; flex-direction: row;
align-items: center;
} }
#stopTitle button { .changeTrackBtn {
width: auto; width: auto;
height: 100%; height: 100%;
box-shadow: none; box-shadow: none;
@ -51,6 +53,6 @@
border-radius: calc(var(--topMenuHeight) / 15); border-radius: calc(var(--topMenuHeight) / 15);
} }
#stopTitle button:active { .changeTrackBtn:active {
background: rgba(0, 0, 0, 0.3); background: rgba(0, 0, 0, 0.3);
} }

View File

@ -6,7 +6,7 @@
justify-content: space-evenly; justify-content: space-evenly;
} }
#topMenu button { #topMenu .menuButton {
width: var(--topMenuHeight); width: var(--topMenuHeight);
height: calc(var(--topMenuHeight) / 1.3); height: calc(var(--topMenuHeight) / 1.3);
display: flex; display: flex;
@ -17,7 +17,7 @@
box-shadow: var(--boxShadow); box-shadow: var(--boxShadow);
} }
#topMenu button:active { #topMenu .menuButton:active {
background: rgb(235, 235, 235); background: rgb(235, 235, 235);
} }

View File

@ -89,7 +89,7 @@
flex-grow: 1; flex-grow: 1;
display: block; display: block;
white-space: nowrap; white-space: nowrap;
max-height: 3.5vw; max-height: 4.5vw;
} }
.infoWrapper span { .infoWrapper span {

View File

@ -10,10 +10,6 @@ import globalData from '../../GlobalData.js';
class TrafficInfo extends Component { class TrafficInfo extends Component {
state = {
stop: globalData.stop
};
render() { render() {
globalData.currentPage = this; globalData.currentPage = this;
@ -21,10 +17,10 @@ class TrafficInfo extends Component {
<> <>
<Header title="Trafikinfo" /> <Header title="Trafikinfo" />
<TopMenu> <TopMenu>
<StopTitle stop={this.state.stop} /> <StopTitle stop={globalData.stop} />
</TopMenu> </TopMenu>
<MainArea> <MainArea>
<TrafficList departures={this.state.stop.departures} /> <TrafficList departures={globalData.stop.departures} />
</MainArea> </MainArea>
</> </>
); );

19
src/img/userDark.svg Normal file
View File

@ -0,0 +1,19 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Generator: Adobe Illustrator 24.0.1, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
<svg version="1.1" id="Capa_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
viewBox="0 0 460.8 460.8" style="enable-background:new 0 0 460.8 460.8;" xml:space="preserve">
<g>
<g>
<path d="M230.4,0c-65.8,0-119.6,53.8-119.6,119.6s53.8,119.6,119.6,119.6S350,185.4,350,119.6S296.3,0,230.4,0z"/>
</g>
</g>
<g>
<g>
<path d="M435.8,334.9c-3.1-7.8-7.3-15.2-12-21.9c-24-35.5-61.1-59-102.9-64.8c-5.2-0.5-11,0.5-15.2,3.7
c-21.9,16.2-48.1,24.6-75.2,24.6s-53.3-8.4-75.2-24.6c-4.2-3.1-9.9-4.7-15.2-3.7c-41.8,5.7-79.4,29.3-102.9,64.8
c-4.7,6.8-8.9,14.6-12,21.9c-1.6,3.1-1,6.8,0.5,9.9c4.2,7.3,9.4,14.6,14.1,20.9c7.3,9.9,15.2,18.8,24,27.2
c7.3,7.3,15.7,14.1,24,20.9c41.3,30.8,90.9,47,142.1,47s100.8-16.2,142.1-47c8.4-6.3,16.7-13.6,24-20.9c8.4-8.4,16.7-17.2,24-27.2
c5.2-6.8,9.9-13.6,14.1-20.9C436.8,341.7,437.3,338,435.8,334.9z"/>
</g>
</g>
</svg>

After

Width:  |  Height:  |  Size: 1.0 KiB