diff --git a/public/index.html b/public/index.html
index a4bccd9..44c520a 100644
--- a/public/index.html
+++ b/public/index.html
@@ -6,7 +6,7 @@
-
+
Stacjownik
diff --git a/src/assets/icon-clock.svg b/src/assets/icon-clock.svg
new file mode 100644
index 0000000..85e41e0
--- /dev/null
+++ b/src/assets/icon-clock.svg
@@ -0,0 +1 @@
+
\ No newline at end of file
diff --git a/src/assets/icon-exit.svg b/src/assets/icon-exit.svg
index 85a4d05..0ffae97 100644
--- a/src/assets/icon-exit.svg
+++ b/src/assets/icon-exit.svg
@@ -1,3 +1 @@
-
+
\ No newline at end of file
diff --git a/src/components/StationsView/FilterCard.vue b/src/components/StationsView/FilterCard.vue
index 93a1753..b893d0f 100644
--- a/src/components/StationsView/FilterCard.vue
+++ b/src/components/StationsView/FilterCard.vue
@@ -166,7 +166,7 @@ export default class FilterCard extends Vue {
@include smallScreen() {
width: 85vw;
- font-size: 1em;
+ font-size: 0.45em;
}
}
diff --git a/src/components/StationsView/StationCard.vue b/src/components/StationsView/StationCard.vue
index 2accf47..657885d 100644
--- a/src/components/StationsView/StationCard.vue
+++ b/src/components/StationsView/StationCard.vue
@@ -1,7 +1,13 @@
-
-
![exit icon]()
+
+
![schedule-icon]()
cardMode = cardMode == 0 ? 1 : 0"
+ />
+
@@ -133,13 +139,63 @@
-
+
@@ -147,32 +203,55 @@
import { Component, Prop, Watch } from "vue-property-decorator";
import styleMixin from "@/mixins/styleMixin";
+import Station from "@/scripts/interfaces/Station";
+
@Component
export default class StationCard extends styleMixin {
- @Prop() stationInfo;
- @Prop() dispatcherHistory;
+ @Prop() stationInfo!: Station;
@Prop() exit!: void;
history: any[] = [];
+ cardMode: number = 0;
get computedExp(): string {
+ console.log(this.stationInfo.scheduledTrains);
+
return this.stationInfo.dispatcherExp < 2
? "L"
: `${this.stationInfo.dispatcherExp}`;
}
+
+ 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',
+ })
+ }
}
\ No newline at end of file
diff --git a/src/components/TrainsView/TrainTable.vue b/src/components/TrainsView/TrainTable.vue
index 53d1aa0..d77449b 100644
--- a/src/components/TrainsView/TrainTable.vue
+++ b/src/components/TrainsView/TrainTable.vue
@@ -30,9 +30,9 @@
-
+
Przez:
-
+
@@ -140,12 +140,18 @@ export default class TrainTable extends Vue {
(e.target as HTMLImageElement).src = unknownTrainImage;
}
- mapTimetableSceneries(sceneries: string[]): string {
- if (sceneries.length < 1) return "";
+ generateStopList(stops: any): string | undefined {
+ if (!stops) return "";
+ return stops.reduce((acc, stop, i) => {
+ if (i < 2 || i > stops.length - 2) return acc;
- return sceneries
- .filter((scenery, i) => i > 0 && i < sceneries.length - 1)
- .join(" * ");
+ if (stop.stopType.includes("ph")) acc.push(`${stop.stopName}`);
+ if (stop.stopType == "") acc.push(`${stop.stopName}`);
+ if (stop.stopType == "podg.") acc.push(`${stop.stopName
+ }`);
+
+ return acc;
+ }, []).join(" * ");
}
}
diff --git a/src/scripts/interfaces/Station.ts b/src/scripts/interfaces/Station.ts
index 81c08cb..f8218cc 100644
--- a/src/scripts/interfaces/Station.ts
+++ b/src/scripts/interfaces/Station.ts
@@ -25,8 +25,18 @@ export default interface Station {
statusTimestamp: number;
scheduledTrains: {
trainNo: number;
- trainCategory: string;
- arrivalTime: string;
- departureTime: string;
+ driverName: string;
+ category: string;
+ stopName: string;
+ stopType: string;
+ arrivalTime: number;
+ arrivalDelay: number;
+ departureTime: number;
+ departureDelay: number;
+ confirmed: boolean;
+ stopped: boolean;
+ stopTime: number;
+ beginsHere: boolean;
+ terminatesHere: boolean;
}[];
}
diff --git a/src/scripts/interfaces/Train.ts b/src/scripts/interfaces/Train.ts
index e99ef1f..b94bf50 100644
--- a/src/scripts/interfaces/Train.ts
+++ b/src/scripts/interfaces/Train.ts
@@ -12,7 +12,25 @@ export default interface Train {
route: string | null;
timetableId: number | null;
category: string | null;
- sceneries: string[] | null;
+ followingStops: {
+ stopName: string;
+ stopType: string;
+ arrivalLine?: string;
+ arrivalTime: number;
+ arrivalDelay: number;
+ departureLine?: string;
+ departureTime: number;
+ beginsHere: boolean;
+ terminatesHere: boolean;
+ departureDelay: number;
+ confirmed: boolean;
+ stopped: boolean;
+
+ stopTime: number;
+
+ arrivalScenery?: string;
+ departureScenery?: string;
+ }[];
TWR: boolean | null;
SKR: boolean | null;
noTimetable: boolean;
@@ -20,13 +38,4 @@ export default interface Train {
locoType: string;
routeDistance: number;
online: boolean;
- stopPoints: {
- arrivalTime: string;
- arrivalDelay: number;
- departureTime: string;
- departureDelay: number;
- pointNameRAW: string;
- pointStopType: string;
- confirmed: boolean;
- }[];
}
diff --git a/src/store/modules/trainsModule.ts b/src/store/modules/trainsModule.ts
index 9aa142a..3c40c70 100644
--- a/src/store/modules/trainsModule.ts
+++ b/src/store/modules/trainsModule.ts
@@ -1,9 +1,9 @@
-import { Module, VuexModule, Mutation, Action } from "vuex-module-decorators";
+import { Module, VuexModule, Mutation, Action } from 'vuex-module-decorators';
-import Train from "@/scripts/interfaces/Train";
+import Train from '@/scripts/interfaces/Train';
-import axios from "axios";
-const API_URL = "https://api.td2.info.pl:9640/?method=getTrainsOnline";
+import axios from 'axios';
+const API_URL = 'https://api.td2.info.pl:9640/?method=getTrainsOnline';
enum ConnState {
Loading = 0,
@@ -32,6 +32,15 @@ interface TimetableResponseData {
pointNameRAW: string;
pointName: string;
pointStopType: string;
+ arrivalLine: string;
+ departureLine: string;
+ arrivalTime: string;
+ arrivalDelay: number;
+ departureTime: string;
+ departureDelay: number;
+ confirmed: boolean;
+ stopped: boolean;
+ pointStopTime: number;
}[];
trainInfo: {
timetableId: number;
@@ -54,12 +63,14 @@ interface TimetableData {
stopPoints?: {}[];
}
+const getTimestamp = (date: string) => (date ? new Date(date).getTime() : 0);
+
const getTimetableURL = (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
+ locoType.includes('EN') ? locoType + 'rb' : locoType
}.png`;
@Module
@@ -67,21 +78,21 @@ export default class TrainsModule extends VuexModule {
onlineTrainsData: Train[] = [];
onlineTrainsState: ConnState = ConnState.Loading;
- @Action({ commit: "loadTrainsData" })
+ @Action({ commit: 'loadTrainsData' })
async fetchTrainsData() {
let trainDataResponse;
try {
trainDataResponse = await axios.get(API_URL);
} catch (error) {
- this.context.commit("setConnectionState", ConnState.Error);
+ this.context.commit('setConnectionState', ConnState.Error);
return null;
}
let onlineTrainsData: TrainData[] = trainDataResponse.data.message;
return await Promise.all(
- onlineTrainsData.map(async (train) => {
+ onlineTrainsData.map(async train => {
const timetableResponseData: TimetableResponseData | null = (
await axios.get(getTimetableURL(train.trainNo))
).data.message;
@@ -101,29 +112,57 @@ export default class TrainsModule extends VuexModule {
};
}
- const locoType = train.dataCon.split(";")
- ? train.dataCon.split(";")[0]
+ const locoType = train.dataCon.split(';')
+ ? train.dataCon.split(';')[0]
: train.dataCon;
- const stopPoints = timetableResponseData?.stopPoints.reduce(
+ const followingStops = timetableResponseData?.stopPoints.reduce(
(acc, point) => {
- if (point.pointName.includes("strong"))
- acc.push(
- point.pointStopType.includes("ph")
- ? `${point.pointNameRAW}`
- : `${point.pointNameRAW}`
- );
+ const stopObj: any = {};
+ if (
+ !point.pointName.includes('Południowy') &&
+ (point.pointName.includes('strong') ||
+ point.pointName.includes('podg.'))
+ ) {
+ if (point.pointName.includes('strong')) {
+ stopObj.stopName = point.pointNameRAW;
- if (point.pointName.includes("podg."))
- acc.push(
- `${
- point.pointNameRAW.split(",")[0]
- }`
- );
+ stopObj.stopType = point.pointStopType;
+ } else {
+ stopObj.stopName = point.pointNameRAW.split(',')[0];
+ stopObj.stopType = 'podg.';
+ }
+
+ stopObj.arrivalTime = getTimestamp(point.arrivalTime);
+ stopObj.departureTime = getTimestamp(point.departureTime);
+ stopObj.arrivalDelay = point.arrivalDelay;
+ stopObj.departureDelay = point.departureDelay;
+ 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.stopTime = point.pointStopTime;
+
+ acc.push(stopObj);
+ }
return acc;
},
- [] as string[]
+ [] as {
+ stopName: string;
+ stopType: string;
+ arrivalTime: number;
+ arrivalDelay: number;
+ departureTime: number;
+ departureDelay: number;
+ confirmed: boolean;
+ stopped: boolean;
+ stopTime: number;
+ beginsHere: boolean;
+ terminatesHere: boolean;
+ }[]
);
return {
@@ -145,8 +184,7 @@ export default class TrainsModule extends VuexModule {
timetableId: timetableData?.timetableId,
category: timetableData?.trainCategoryCode,
routeDistance: timetableData?.routeDistance || 0,
- sceneries: stopPoints,
- stopPoints: timetableData?.stopPoints,
+ followingStops,
TWR: timetableData?.twr,
SKR: timetableData?.skr,
};
diff --git a/src/styles/global.scss b/src/styles/global.scss
index 26da32c..76c3fc8 100644
--- a/src/styles/global.scss
+++ b/src/styles/global.scss
@@ -23,7 +23,8 @@ html {
body {
width: 100%;
margin: 0;
- font-family: "Open Sans", sans-serif;
+ // font-family: "Open Sans", sans-serif;
+ font-family: "Quicksand", sans-serif;
overflow-x: hidden;
}
@@ -31,7 +32,8 @@ body {
button,
input,
select {
- font-family: "Open Sans", sans-serif;
+ // font-family: "Open Sans", sans-serif;
+ font-family: "Quicksand", sans-serif;
}
input {
diff --git a/src/views/StationsView.vue b/src/views/StationsView.vue
index c2e96d4..5dadb92 100644
--- a/src/views/StationsView.vue
+++ b/src/views/StationsView.vue
@@ -127,28 +127,30 @@ export default class StationsView extends Vue {
this.trains
.filter((train) => !train.noTimetable)
.forEach((train) => {
- const found = train.stopPoints!.find(
- (sp) =>
+ const foundIndex = train.followingStops.findIndex(
+ (stop) =>
(station.stationName
.toLowerCase()
- .includes(sp.pointNameRAW.toLowerCase()) ||
+ .includes(stop.stopName) ||
station.stationName
.toLowerCase()
- .includes(sp.pointNameRAW.toLowerCase().split(",")[0]) ||
+ .includes(stop.stopName.toLowerCase().split(",")[0]) ||
(station.stationName
.toLowerCase()
- .includes(sp.pointNameRAW.toLowerCase().split(" ")[0]) &&
+ .includes(stop.stopName.toLowerCase().split(" ")[0]) &&
station.stationName.toLowerCase().includes("lcs"))) &&
!acc[station.stationName].find((t) => t.trainNo === train.trainNo)
);
- if (!found) return acc;
+ if (foundIndex < 0) return acc;
+
+ const foundStop = train.followingStops[foundIndex];
acc[station.stationName].push({
trainNo: train.trainNo,
driverName: train.driverName,
category: train.category,
- ...found,
+ ...foundStop
});
});
@@ -244,8 +246,8 @@ export default class StationsView extends Vue {
break;
case 3:
- if (a.dispatcherName > b.dispatcherName) return dir;
- if (a.dispatcherName < b.dispatcherName) return -dir;
+ if (a.dispatcherName.toLowerCase() > b.dispatcherName.toLowerCase()) return dir;
+ if (a.dispatcherName.toLowerCase() < b.dispatcherName.toLowerCase()) return -dir;
break;
case 4:
@@ -264,7 +266,7 @@ export default class StationsView extends Vue {
break;
}
- if (a.stationName >= b.stationName) return dir;
+ if (a.stationName.toLowerCase() >= b.stationName.toLowerCase()) return dir;
return -dir;
})
.map((station) => ({
@@ -307,7 +309,7 @@ export default class StationsView extends Vue {
}
get focusedStationInfo() {
- return this.stations.find(
+ return this.computedStations.find(
(station) => station.stationName === this.focusedStationName
);
}