diff --git a/src/components/StationsView/StationCard.vue b/src/components/StationsView/StationCard.vue index da460cb..f85edba 100644 --- a/src/components/StationsView/StationCard.vue +++ b/src/components/StationsView/StationCard.vue @@ -126,17 +126,15 @@ class="user" v-for="train in computedStationTrains" :key="train.trainNo + train.driverName" - :class="{'no-timetable': !train.hasTimetable}" + :class="{'no-timetable': !train.timetableData}" > - {{train.trainNo}} | {{train.driverName}} - + -
-
-
-
{{stationInfo.stationName.toUpperCase()}}
-
AKTYWNE ROZKŁADY JAZDY
-
- -
-
- - - - - {{timetable.category}} - {{timetable.trainNo}} - - | - - {{ timetable.driverName }} - - - - - Skończył bieg - - Odprawiony - - Na stacji - - W drodze - - Postój - - - - - - ROZPOCZYNA BIEG - {{timestampToTime(timetable.arrivalTime)}} ({{timetable.arrivalDelay}}) - - - - {{timetable.stopTime}} {{timetable.stopType}} - - - - KOŃCZY BIEG - {{timestampToTime(timetable.departureTime)}} ({{timetable.departureDelay}}) - - -
-
-
-
+ @@ -238,7 +157,13 @@ import styleMixin from "@/mixins/styleMixin"; import Station from "@/scripts/interfaces/Station"; -@Component +import StationTimetable from "@/components/StationsView/StationTimetable.vue"; + +@Component({ + components: { + StationTimetable + } +}) export default class StationCard extends styleMixin { @Prop() stationInfo!: Station; @Prop() exit!: void; @@ -247,7 +172,6 @@ export default class StationCard extends styleMixin { cardMode: number = 0; get computedExp(): string { - return this.stationInfo.dispatcherExp < 2 ? "L" : `${this.stationInfo.dispatcherExp}`; @@ -256,27 +180,9 @@ export default class StationCard extends styleMixin { get computedStationTrains() { return this.stationInfo.stationTrains.map(stationTrain => ({ ...stationTrain, - hasTimetable: this.trains.find(train => train.timetableData && train.trainNo === stationTrain.trainNo) + timetableData: this.trains.find(train => train.timetableData && train.trainNo === stationTrain.trainNo) })) } - - - get computedScheduledTrains() { - return this.stationInfo.scheduledTrains.sort((a, b) => { - if (a.arrivalTime > b.arrivalTime) return 1; - else if ((a.arrivalTime < b.arrivalTime)) return -1; - - return a.departureTime > b.departureTime ? 1 : -1; - }) - - } - - timestampToTime(timestamp: number) { - return new Date(timestamp).toLocaleTimeString('pl-PL', { - hour: '2-digit', - minute: '2-digit', - }) - } } @@ -292,11 +198,17 @@ export default class StationCard extends styleMixin { .station-card { scroll-behavior: smooth; - font-size: calc(0.55rem + 0.3vw); + font-size: calc(0.5rem + 0.4vw); + max-width: 850px; @include bigScreen { font-size: 1.1rem; } + + @include smallScreen { + font-size: 0.8em; + width: 100%; + } } .card { @@ -327,7 +239,7 @@ export default class StationCard extends styleMixin { margin-top: 1rem; display: grid; - grid-template-areas: "main main" "icons icons" "dispatcher hours" "users spawns" "history history"; + grid-template-areas: "main main" "icons icons" "dispatcher hours" "users spawns"; grid-template-columns: repeat(2, minmax(0, 1fr)); min-width: 200px; max-height: 500px; @@ -369,7 +281,7 @@ export default class StationCard extends styleMixin { background: $accentCol; color: black; - font-size: 2.5em; + font-size: 3em; font-weight: 600; border-radius: 50%; @@ -512,145 +424,4 @@ export default class StationCard extends styleMixin { } } } - -.card-timetables { - position: absolute; - left: 0; - top: 0; - width: 100%; - height: 100%; - - overflow: hidden; - - transform: translateY(-100%); - -webikit-transform: translateY(-100%); - - &.show { - transform: translateY(0); - -webkit-transform: translateY(0); - } - - transition: transform 150ms ease-out; - - background: #333; -} - -.timetables { - &-content { - width: 100%; - height: 100%; - overflow: auto; - } - - &-title { - padding-top: 2rem; - padding-bottom: 0.3rem; - font-size: 1.6em; - } - - &-wrapper { - height: 100%; - - display: flex; - flex-direction: column; - } -} - -.timetable { - margin: 1em auto; - - display: grid; - grid-template-columns: repeat(auto-fit, minmax(0, 1fr)); - gap: 0 1rem; - - padding: 0 2rem; - - @include smallScreen() { - display: flex; - flex-direction: column; - align-items: center; - } - - &-general { - padding: 0.3rem 0.5rem; - border: 1px solid white; - - display: flex; - justify-content: space-between; - - @include smallScreen() { - width: 95%; - } - } - - &-schedule { - @include smallScreen() { - width: 80%; - margin: 0.7em 0; - } - - display: grid; - grid-template-columns: repeat(auto-fit, minmax(0, 1fr)); - font-size: 1.2em; - } -} - -.arrow { - border: solid white; - border-width: 0 2px 2px 0; - display: inline-block; - padding: 2px; - margin-left: 50px; - - position: relative; - - transform: rotate(-45deg); - - &::before { - content: ""; - position: absolute; - display: block; - width: 55px; - height: 3px; - top: 4px; - left: 4px; - - transform: translate(-100%, -1px) rotate(45deg); - transform-origin: right bottom; - - background: white; - } -} - -.general-info { - span { - color: $accentCol; - } -} - -.schedule { - &-arrival, - &-stop, - &-departure { - display: flex; - justify-content: center; - align-items: center; - - margin: 0 0.3rem; - } - - &-stop { - display: flex; - flex-direction: column; - - .stop-time { - font-size: 0.7em; - } - } -} - -.arrival-time.begins, -.departure-time.terminates { - font-size: 0.75em; -} \ No newline at end of file diff --git a/src/components/StationsView/StationTimetable.vue b/src/components/StationsView/StationTimetable.vue new file mode 100644 index 0000000..965fbf9 --- /dev/null +++ b/src/components/StationsView/StationTimetable.vue @@ -0,0 +1,267 @@ + + + + + \ No newline at end of file diff --git a/src/components/TrainsView/TrainSearch.vue b/src/components/TrainsView/TrainSearch.vue index 272fe87..43b7eaf 100644 --- a/src/components/TrainsView/TrainSearch.vue +++ b/src/components/TrainsView/TrainSearch.vue @@ -47,6 +47,13 @@ export default class extends Vue { this.searchedDriver = ""; } } + + mounted() { + if (this.passedSearchedTrain && this.passedSearchedTrain != "") { + this.searchedTrain = this.passedSearchedTrain; + this.searchedDriver = ""; + } + } } diff --git a/src/components/TrainsView/TrainTable.vue b/src/components/TrainsView/TrainTable.vue index 9ab0a5f..8eb1fd6 100644 --- a/src/components/TrainsView/TrainTable.vue +++ b/src/components/TrainsView/TrainTable.vue @@ -140,12 +140,10 @@ export default class TrainTable extends Vue { generateStopList(stops: any): string | undefined { if (!stops) return ""; return stops.reduce((acc, stop, i) => { - if (i < 2 || i > stops.length - 2) return acc; if (stop.stopType.includes("ph")) acc.push(`${stop.stopName}`); - if (stop.stopType == "") acc.push(`${stop.stopName}`); - if (stop.stopType == "podg.") acc.push(`${stop.stopName - }`); + else if (i > 0 && i < stops.length - 1) acc.push(`${stop.stopName}`); + // if (stop.stopType == "podg.") acc.push(`${stop.stopName}`); return acc; }, []).join(" * "); diff --git a/src/store/store.ts b/src/store/store.ts index 28de914..31c3630 100644 --- a/src/store/store.ts +++ b/src/store/store.ts @@ -22,7 +22,7 @@ const URLs = { const timetableURL = (trainNo: number) => `https://api.td2.info.pl:9640/?method=readFromSWDR&value=getTimetable%3B${trainNo}%3Beu`; const getLocoURL = (locoType: string) => `https://rj.td2.info.pl/dist/img/thumbnails/${locoType.includes('EN') ? locoType + 'rb' : locoType}.png`; -const getStationLabel = (stationStatus: any) => { +const getStatusLabel = (stationStatus: any) => { if (!stationStatus) return 'NIEZALOGOWANY'; const statusCode = stationStatus[2]; @@ -55,6 +55,29 @@ const getStationLabel = (stationStatus: any) => { return 'NIEDOSTĘPNY'; }; +const getStatusTimestamp = (stationStatus: any) => { + if (!stationStatus) return -2; + + const statusCode = stationStatus[2]; + const statusTimestamp = stationStatus[3]; + + switch (statusCode) { + case 0: + case 1: + case 3: + return statusTimestamp; + + case 2: + if (statusTimestamp == 0) return 0; + break; + + default: + break; + } + + return -1; +}; + const getOpenSpawns = (spawnString: string) => (spawnString ? spawnString.split(';').map(v => (v.split(',')[6] ? v.split(',')[6] : v.split(',')[0])) : ''); const getTimestamp = (date: string) => (date ? new Date(date).getTime() : 0); @@ -114,13 +137,19 @@ export default class Store extends VuexModule { const followingStops = timetable.stopPoints.reduce((acc, point) => { const stopObj: any = {}; + + // if (point.pointName.includes('strong') && !point.pointName.includes('Południowy')) { + // stopObj.stopName = point.pointNameRAW; + // stopObj.stopType = point.pointStopType; + // } + if (!point.pointName.includes('Południowy') && (point.pointName.includes('strong') || point.pointName.includes('podg.'))) { if (point.pointName.includes('strong')) { stopObj.stopName = point.pointNameRAW; stopObj.stopType = point.pointStopType; - } else { + } else if (JSONStationData.some(data => data.stationName.toLowerCase().includes(point.pointNameRAW.split(',')[0].toLowerCase()))) { stopObj.stopName = point.pointNameRAW.split(',')[0]; - stopObj.stopType = 'podg.'; + stopObj.stopType = 'pt podg.'; } stopObj.arrivalTime = getTimestamp(point.arrivalTime); @@ -130,7 +159,7 @@ export default class Store extends VuexModule { stopObj.beginsHere = getTimestamp(point.arrivalTime) == 0 ? true : false; stopObj.terminatesHere = getTimestamp(point.departureTime) == 0 ? true : false; stopObj.confirmed = point.confirmed; - stopObj.stopped = point.stopped; + stopObj.stopped = point.isStopped; stopObj.stopTime = point.pointStopTime; acc.push(stopObj); @@ -172,8 +201,9 @@ export default class Store extends VuexModule { const stationStatus = onlineDispatchersData.find(status => status[0] == station.stationHash && status[1] == 'eu'); - const statusLabel = getStationLabel(stationStatus); - const statusTimestamp = stationStatus ? stationStatus[3] : -1; + const statusLabel = getStatusLabel(stationStatus); + // let statusTimestamp = stationStatus ? stationStatus[3] : -1; + const statusTimestamp = getStatusTimestamp(stationStatus); const stationTrains = onlineTrainsData.filter(train => train.region === 'eu' && train.isOnline && train.station.stationName === station.stationName); @@ -248,7 +278,7 @@ export default class Store extends VuexModule { dispatcherId: 0, online: false, occupiedTo: 'WOLNA', - statusTimestamp: 0, + statusTimestamp: -3, stationTrains: [], scheduledTrains: [], ...stationData, @@ -273,7 +303,7 @@ export default class Store extends VuexModule { dispatcherExp: -1, dispatcherId: 0, occupiedTo: 'WOLNA', - statusTimestamp: 0, + statusTimestamp: -3, online: false, }); } else @@ -286,8 +316,6 @@ export default class Store extends VuexModule { return acc; }, [] as Station[]); - console.log(this.stationList); - // Dodawanie do listy online potencjalnych scenerii niewpisanych do bazy updatedStationList.forEach(updatedStation => { const alreadyInList: any = this.stationList.findIndex(station => station.stationName === updatedStation.stationName); @@ -342,6 +370,7 @@ export default class Store extends VuexModule { driverName: timetableData.driverName, driverId: timetableData.driverId, currentStationName: timetableData.currentStationName, + category: timetableData.category, }); }