Skip to content

Commit 23e5dc1

Browse files
committed
Adapt vue stationboard to new id based endpoint
1 parent 2ebc8b3 commit 23e5dc1

2 files changed

Lines changed: 21 additions & 7 deletions

File tree

resources/views/stationboard.blade.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,11 @@
77
<div class="row justify-content-center">
88
<div class="col-md-8 col-lg-7" id="station-board-new">
99
@if(auth()->user()->hasRole('open-beta'))
10-
<Stationboard @isset($station) station="{{$station->name}}" @endisset></Stationboard>
10+
<Stationboard
11+
@isset($station)
12+
station="{{$station->name}}"
13+
station-id="{{$station->id}}"
14+
@endisset></Stationboard>
1115
@else
1216
@include('includes.station-autocomplete')
1317
<div id="timepicker-wrapper">

resources/vue/components/Stationboard.vue

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,11 @@ export default {
1515
type: String,
1616
required: true,
1717
default: "Karlsruhe Hbf"
18+
},
19+
stationId: {
20+
type: Number,
21+
required: true,
22+
default: 0
1823
}
1924
},
2025
data() {
@@ -27,7 +32,8 @@ export default {
2732
selectedTrain: null,
2833
selectedDestination: null,
2934
loading: false,
30-
stationString: null,
35+
stationName: null,
36+
trwlStationId: null
3137
};
3238
},
3339
methods: {
@@ -39,7 +45,8 @@ export default {
3945
this.$refs.modal.show();
4046
},
4147
updateStation(station) {
42-
this.stationString = station.name;
48+
this.stationName = station.name;
49+
this.trwlStationId = station.id;
4350
this.data = [];
4451
this.fetchData();
4552
},
@@ -69,10 +76,9 @@ export default {
6976
time = this.fetchTime.minus({minutes: 5}).toString();
7077
}
7178
72-
let query = this.stationString.replace(/%2F/, " ").replace(/\//, " ");
7379
let travelType = this.travelType ? this.travelType : "";
7480
75-
fetch(`/api/v1/trains/station/${query}/departures?when=${time}&travelType=${travelType}`) //TODO: change this to the new endpoint "/station/{id}/departures"
81+
fetch(`/api/v1/station/${this.trwlStationId}/departures?when=${time}&travelType=${travelType}`)
7682
.then((response) => {
7783
this.loading = false;
7884
this.now = DateTime.now();
@@ -105,7 +111,11 @@ export default {
105111
},
106112
mounted() {
107113
this.fetchTime = DateTime.now().setZone("UTC");
108-
this.stationString = this.$props.station;
114+
115+
// These are needed for the communication with blade templates
116+
this.stationName = this.$props.station;
117+
this.trwlStationId = this.$props.stationId;
118+
109119
this.fetchData();
110120
},
111121
computed: {
@@ -123,7 +133,7 @@ export default {
123133
v-on:update:time="updateTime"
124134
v-on:update:station="updateStation"
125135
v-on:update:travel-type="updateTravelType"
126-
:station="{name: stationString}"
136+
:station="{name: stationName}"
127137
:time="now"
128138
/>
129139
<div v-if="loading" style="max-width: 200px;" class="spinner-grow text-trwl mx-auto p-2" role="status">

0 commit comments

Comments
 (0)