Aktualizacja

This commit is contained in:
2021-04-17 00:14:44 +02:00
parent 6b867cc457
commit d31e88260a
13 changed files with 3725 additions and 3901 deletions
+43 -43
View File
@@ -3444,9 +3444,9 @@
} }
}, },
"core-js": { "core-js": {
"version": "3.6.5", "version": "3.10.1",
"resolved": "https://registry.npmjs.org/core-js/-/core-js-3.6.5.tgz", "resolved": "https://registry.npmjs.org/core-js/-/core-js-3.10.1.tgz",
"integrity": "sha512-vZVEEwZoIsI+vPEuoF9Iqf5H7/M3eeQqWlQnYa8FSKKePuYTf5MWnxb5SDAzCa60b3JBRS5g9b+Dq7b1y/RCrA==" "integrity": "sha512-pwCxEXnj27XG47mu7SXAwhLP3L5CrlvCB91ANUkIz40P27kUcvNfSdvyZJ9CLHiVoKSp+TTChMQMSKQEH/IQxA=="
}, },
"core-js-compat": { "core-js-compat": {
"version": "3.6.5", "version": "3.6.5",
@@ -4289,24 +4289,24 @@
"dev": true "dev": true
}, },
"elliptic": { "elliptic": {
"version": "6.5.3", "version": "6.5.4",
"resolved": "https://registry.npmjs.org/elliptic/-/elliptic-6.5.3.tgz", "resolved": "https://registry.npmjs.org/elliptic/-/elliptic-6.5.4.tgz",
"integrity": "sha512-IMqzv5wNQf+E6aHeIqATs0tOLeOTwj1QKbRcS3jBbYkl5oLAserA8yJTT7/VyHUYG91PRmPyeQDObKLPpeS4dw==", "integrity": "sha512-iLhC6ULemrljPZb+QutR5TQGB+pdW6KGD5RSegS+8sorOZT+rdQFbsQFJgvN3eRqNALqJer4oQ16YvJHlU8hzQ==",
"dev": true, "dev": true,
"requires": { "requires": {
"bn.js": "^4.4.0", "bn.js": "^4.11.9",
"brorand": "^1.0.1", "brorand": "^1.1.0",
"hash.js": "^1.0.0", "hash.js": "^1.0.0",
"hmac-drbg": "^1.0.0", "hmac-drbg": "^1.0.1",
"inherits": "^2.0.1", "inherits": "^2.0.4",
"minimalistic-assert": "^1.0.0", "minimalistic-assert": "^1.0.1",
"minimalistic-crypto-utils": "^1.0.0" "minimalistic-crypto-utils": "^1.0.1"
}, },
"dependencies": { "dependencies": {
"bn.js": { "bn.js": {
"version": "4.11.9", "version": "4.12.0",
"resolved": "https://registry.npmjs.org/bn.js/-/bn.js-4.11.9.tgz", "resolved": "https://registry.npmjs.org/bn.js/-/bn.js-4.12.0.tgz",
"integrity": "sha512-E6QoYqCKZfgatHTdHzs1RRKP7ip4vvm+EyRUeE2RF0NblwVvb0p6jSVeNTOFxPn26QXN2o6SMfNxKp6kU8zQaw==", "integrity": "sha512-c98Bf3tPniI+scsdk237ku1Dc3ujXQTSgyiPUDEOe7tRkhrqridvh8klBv0HCEso1OLOYcHuCv/cS6DNxKH+ZA==",
"dev": true "dev": true
} }
} }
@@ -8588,12 +8588,12 @@
"dev": true "dev": true
}, },
"sass": { "sass": {
"version": "1.26.10", "version": "1.32.9",
"resolved": "https://registry.npmjs.org/sass/-/sass-1.26.10.tgz", "resolved": "https://registry.npmjs.org/sass/-/sass-1.32.9.tgz",
"integrity": "sha512-bzN0uvmzfsTvjz0qwccN1sPm2HxxpNI/Xa+7PlUEMS+nQvbyuEK7Y0qFqxlPHhiNHb1Ze8WQJtU31olMObkAMw==", "integrity": "sha512-DGXRkoCF5w+WnlcfolMiNsZ/D0UfmOi4CW2ORMgrXg1eMF6Aoq7kj5qlMrkiXhXdRufTYclMsJUtxYozQT65Ig==",
"dev": true, "dev": true,
"requires": { "requires": {
"chokidar": ">=2.0.0 <4.0.0" "chokidar": ">=3.0.0 <4.0.0"
} }
}, },
"sass-loader": { "sass-loader": {
@@ -9820,9 +9820,9 @@
"dev": true "dev": true
}, },
"typescript": { "typescript": {
"version": "3.9.7", "version": "3.9.9",
"resolved": "https://registry.npmjs.org/typescript/-/typescript-3.9.7.tgz", "resolved": "https://registry.npmjs.org/typescript/-/typescript-3.9.9.tgz",
"integrity": "sha512-BLbiRkiBzAwsjut4x/dsibSTB6yWpwT5qWmC2OfuCg3GgVQCSgMs4vEctYPhsaGtd0AeuuHMkjZ2h2WG8MSzRw==", "integrity": "sha512-kdMjTiekY+z/ubJCATUPlRDl39vXYiMV9iyeMuEuXZh2we6zz80uovNN2WlAxmmdE/Z/YQe+EbOEXB5RHEED3w==",
"dev": true "dev": true
}, },
"uglify-js": { "uglify-js": {
@@ -10142,14 +10142,14 @@
"dev": true "dev": true
}, },
"vue": { "vue": {
"version": "2.6.11", "version": "2.6.12",
"resolved": "https://registry.npmjs.org/vue/-/vue-2.6.11.tgz", "resolved": "https://registry.npmjs.org/vue/-/vue-2.6.12.tgz",
"integrity": "sha512-VfPwgcGABbGAue9+sfrD4PuwFar7gPb1yl1UK1MwXoQPAw0BKSqWfoYCT/ThFrdEVWoI51dBuyCoiNU9bZDZxQ==" "integrity": "sha512-uhmLFETqPPNyuLLbsKz6ioJ4q7AZHzD8ZVFNATNyICSZouqP2Sz0rotWQC8UNBF6VGSCs5abnKJoStA6JbCbfg=="
}, },
"vue-class-component": { "vue-class-component": {
"version": "7.2.5", "version": "7.2.6",
"resolved": "https://registry.npmjs.org/vue-class-component/-/vue-class-component-7.2.5.tgz", "resolved": "https://registry.npmjs.org/vue-class-component/-/vue-class-component-7.2.6.tgz",
"integrity": "sha512-0CSftHY0bDTD+4FbYkuFf6+iKDjZ4h2in2YYJDRMk5daZIjrgT9LjFHvP7Rzqy9/s1pij3zDtTSLRUjsPWMwqg==" "integrity": "sha512-+eaQXVrAm/LldalI272PpDe3+i4mPis0ORiMYxF6Ae4hyuCh15W8Idet7wPUEs4N4YptgFHGys4UrgNQOMyO6w=="
}, },
"vue-hot-reload-api": { "vue-hot-reload-api": {
"version": "2.3.4", "version": "2.3.4",
@@ -10158,9 +10158,9 @@
"dev": true "dev": true
}, },
"vue-i18n": { "vue-i18n": {
"version": "8.23.0", "version": "8.24.3",
"resolved": "https://registry.npmjs.org/vue-i18n/-/vue-i18n-8.23.0.tgz", "resolved": "https://registry.npmjs.org/vue-i18n/-/vue-i18n-8.24.3.tgz",
"integrity": "sha512-mXgniaumwca8tKdp55fmvqIcW658vQQXq0zEyRHp8sgZ6t+Md+Whhu6CCPg9/erVNlvpKzsGsucGjt2N8GrFCA==" "integrity": "sha512-uKAYzGbwGIJndY7JwhQwIGi1uyvErWkBfFwooOtjcNnIfMbAR49ad5dT/MiykrJ9pCcgvnocFjFsNLtTzyW+rg=="
}, },
"vue-loader": { "vue-loader": {
"version": "15.9.3", "version": "15.9.3",
@@ -10192,9 +10192,9 @@
} }
}, },
"vue-router": { "vue-router": {
"version": "3.4.3", "version": "3.5.1",
"resolved": "https://registry.npmjs.org/vue-router/-/vue-router-3.4.3.tgz", "resolved": "https://registry.npmjs.org/vue-router/-/vue-router-3.5.1.tgz",
"integrity": "sha512-BADg1mjGWX18Dpmy6bOGzGNnk7B/ZA0RxuA6qedY/YJwirMfKXIDzcccmHbQI0A6k5PzMdMloc0ElHfyOoX35A==" "integrity": "sha512-RRQNLT8Mzr8z7eL4p7BtKvRaTSGdCbTy2+Mm5HTJvLGYSSeG9gDzNasJPP/yOYKLy+/cLG/ftrqq5fvkFwBJEw=="
}, },
"vue-style-loader": { "vue-style-loader": {
"version": "4.1.2", "version": "4.1.2",
@@ -10215,9 +10215,9 @@
} }
}, },
"vue-template-compiler": { "vue-template-compiler": {
"version": "2.6.11", "version": "2.6.12",
"resolved": "https://registry.npmjs.org/vue-template-compiler/-/vue-template-compiler-2.6.11.tgz", "resolved": "https://registry.npmjs.org/vue-template-compiler/-/vue-template-compiler-2.6.12.tgz",
"integrity": "sha512-KIq15bvQDrcCjpGjrAhx4mUlyyHfdmTaoNfeoATHLAiWB+MU3cx4lOzMwrnUh9cCxy0Lt1T11hAFY6TQgroUAA==", "integrity": "sha512-OzzZ52zS41YUbkCBfdXShQTe69j1gQDZ9HIX8miuC9C3rBCk9wIRjLiZZLrmX9V+Ftq/YEyv1JaVr5Y/hNtByg==",
"dev": true, "dev": true,
"requires": { "requires": {
"de-indent": "^1.0.2", "de-indent": "^1.0.2",
@@ -10231,9 +10231,9 @@
"dev": true "dev": true
}, },
"vuex": { "vuex": {
"version": "3.5.1", "version": "3.6.2",
"resolved": "https://registry.npmjs.org/vuex/-/vuex-3.5.1.tgz", "resolved": "https://registry.npmjs.org/vuex/-/vuex-3.6.2.tgz",
"integrity": "sha512-w7oJzmHQs0FM9LXodfskhw9wgKBiaB+totOdb8sNzbTB2KDCEEwEs29NzBZFh/lmEK1t5tDmM1vtsO7ubG1DFw==" "integrity": "sha512-ETW44IqCgBpVomy520DT5jf8n0zoCac+sxWnn+hMe/CzaSejb/eVw2YToiXYX+Ex/AuHHia28vWTq4goAexFbw=="
}, },
"vuex-class": { "vuex-class": {
"version": "0.3.2", "version": "0.3.2",
@@ -10968,9 +10968,9 @@
"dev": true "dev": true
}, },
"y18n": { "y18n": {
"version": "4.0.0", "version": "4.0.3",
"resolved": "https://registry.npmjs.org/y18n/-/y18n-4.0.0.tgz", "resolved": "https://registry.npmjs.org/y18n/-/y18n-4.0.3.tgz",
"integrity": "sha512-r9S/ZyXu/Xu9q1tYlpsLIsa3EeLXXk0VwlxqTcFRfg9EhMW+17kbt9G0NrgCmhGb5vT2hyhJZLfDGx+7+5Uj/w==", "integrity": "sha512-JKhqTOwSrqNA1NY5lSztJ1GrBiUodLMmIZuLiDaMRJ+itFd+ABVE8XBjOvIWL+rSqNDC74LCSFmlb/U4UZ4hJQ==",
"dev": true "dev": true
}, },
"yallist": { "yallist": {
+9 -9
View File
@@ -8,16 +8,16 @@
"deploy": "npm run build && firebase deploy --only hosting" "deploy": "npm run build && firebase deploy --only hosting"
}, },
"dependencies": { "dependencies": {
"core-js": "^3.6.5", "core-js": "^3.10.1",
"dotenv": "^8.2.0", "dotenv": "^8.2.0",
"firestore": "^1.1.6", "firestore": "^1.1.6",
"howler": "^2.2.1", "howler": "^2.2.1",
"vue": "^2.6.11", "vue": "^2.6.12",
"vue-class-component": "^7.2.5", "vue-class-component": "^7.2.6",
"vue-i18n": "^8.23.0", "vue-i18n": "^8.24.3",
"vue-property-decorator": "^8.4.2", "vue-property-decorator": "^8.4.2",
"vue-router": "^3.4.3", "vue-router": "^3.5.1",
"vuex": "^3.4.0" "vuex": "^3.6.2"
}, },
"devDependencies": { "devDependencies": {
"@vue/cli-plugin-babel": "~4.4.0", "@vue/cli-plugin-babel": "~4.4.0",
@@ -26,10 +26,10 @@
"@vue/cli-plugin-vuex": "~4.4.0", "@vue/cli-plugin-vuex": "~4.4.0",
"@vue/cli-service": "~4.4.0", "@vue/cli-service": "~4.4.0",
"axios": "^0.21.1", "axios": "^0.21.1",
"sass": "^1.26.10", "sass": "^1.32.9",
"sass-loader": "^8.0.2", "sass-loader": "^8.0.2",
"typescript": "^3.9.7", "typescript": "^3.9.9",
"vue-template-compiler": "^2.6.11", "vue-template-compiler": "^2.6.12",
"vuex-class": "^0.3.2", "vuex-class": "^0.3.2",
"vuex-module-decorators": "^0.17.0" "vuex-module-decorators": "^0.17.0"
}, },
+40 -48
View File
@@ -55,13 +55,6 @@
<router-link class="route" active-class="route-active" to="/trains" <router-link class="route" active-class="route-active" to="/trains"
>{{ $t("app.trains") }} >{{ $t("app.trains") }}
</router-link> </router-link>
<!-- <router-link
class="route"
active-class="route-active"
to="/history"
>{{ $t("app.journal") }}</router-link
> -->
</span> </span>
</div> </div>
</header> </header>
@@ -98,9 +91,6 @@ import Clock from "@/components/App/Clock.vue";
import StorageManager from "@/scripts/storageManager"; import StorageManager from "@/scripts/storageManager";
import DataModule from "@/store/modules/DataModule";
import { getModule } from "vuex-module-decorators";
@Component({ @Component({
components: { Clock, UpdateModal }, components: { Clock, UpdateModal },
}) })
@@ -118,35 +108,50 @@ export default class App extends Vue {
iconEN = require("@/assets/icon-en.jpg"); iconEN = require("@/assets/icon-en.jpg");
iconPL = require("@/assets/icon-pl.svg"); iconPL = require("@/assets/icon-pl.svg");
dataStore: DataModule = getModule(DataModule); toggleUpdateModal() {
this.updateModalVisible = !this.updateModalVisible;
StorageManager.setBooleanValue("version_notes_read", true);
}
get test() { changeLang(lang: string) {
return this.dataStore.getTest; this.$i18n.locale = lang;
this.currentLang = lang;
StorageManager.setStringValue("lang", lang);
}
loadLang() {
const storageLang = StorageManager.getStringValue("lang");
if (storageLang) {
this.changeLang(storageLang);
return;
}
if (!window.navigator.language) {
this.changeLang("pl");
return;
}
switch (window.navigator.language) {
case "pl-PL":
this.changeLang("pl");
break;
case "en-EN":
default:
this.changeLang("en");
break;
}
return;
}
created() {
this.loadLang();
this.synchronizeData();
} }
mounted() { mounted() {
this.synchronizeData();
setTimeout(() => {
this.dataStore.fetchTest();
}, 3000);
if (StorageManager.getStringValue("lang")) {
this.changeLang(StorageManager.getStringValue("lang"));
} else if (window.navigator.language) {
switch (window.navigator.language) {
case "pl-PL":
this.changeLang("pl");
break;
case "en-EN":
default:
this.changeLang("en");
break;
}
this.currentLang = this.$i18n.locale;
}
if (StorageManager.getStringValue("version") != this.VERSION) { if (StorageManager.getStringValue("version") != this.VERSION) {
StorageManager.setStringValue("version", this.VERSION); StorageManager.setStringValue("version", this.VERSION);
@@ -158,19 +163,6 @@ export default class App extends Vue {
this.hasReleaseNotes && this.hasReleaseNotes &&
!StorageManager.getBooleanValue("version_notes_read"); !StorageManager.getBooleanValue("version_notes_read");
} }
changeLang(lang: string) {
this.$i18n.locale = lang;
this.currentLang = lang;
StorageManager.setStringValue("lang", lang);
console.log("Switched to: " + lang);
}
toggleUpdateModal() {
this.updateModalVisible = !this.updateModalVisible;
StorageManager.setBooleanValue("version_notes_read", true);
}
} }
</script> </script>
-18
View File
@@ -1,18 +0,0 @@
import store from "@/store";
import { Module, VuexModule, Mutation, Action, MutationAction } from "vuex-module-decorators";
@Module({ dynamic: true, store, name: "dataModule" })
export default class MyModule extends VuexModule {
test: string = "xd";
get getTest() {
return this.test;
}
@MutationAction
async fetchTest() {
const fetched = "aaa";
return { test: fetched };
}
}
+116 -266
View File
@@ -1,20 +1,22 @@
import { Module, VuexModule, Mutation, Action } from 'vuex-module-decorators'; import { Module, VuexModule, Mutation, Action } from "vuex-module-decorators";
import axios from 'axios'; import axios from "axios";
import JSONStationData from '@/data/stationData.json'; import JSONStationData from "@/data/stationData.json";
import Station from '@/scripts/interfaces/Station'; import Station from "@/scripts/interfaces/Station";
import Train from '@/scripts/interfaces/Train'; import Train from "@/scripts/interfaces/Train";
import TrainStop from '@/scripts/interfaces/TrainStop'; import TrainStop from "@/scripts/interfaces/TrainStop";
import utils from "@/scripts/utils/storeUtils";
enum Status { enum Status {
Initialized = -1, Initialized = -1,
Loading = 0, Loading = 0,
Error = 1, Error = 1,
Loaded = 2, Loaded = 2
} }
interface ITimetableData { interface TimetableData {
trainNo: number; trainNo: number;
driverName: string; driverName: string;
driverId: number; driverId: number;
@@ -50,87 +52,11 @@ interface IOnlineStationData {
} }
const URLs = { const URLs = {
stations: 'https://api.td2.info.pl:9640/?method=getStationsOnline', stations: "https://api.td2.info.pl:9640/?method=getStationsOnline",
trains: 'https://api.td2.info.pl:9640/?method=getTrainsOnline', trains: "https://api.td2.info.pl:9640/?method=getTrainsOnline",
dispatchers: 'https://api.td2.info.pl:9640/?method=readFromSWDR&value=getDispatcherStatusList%3B1', dispatchers: "https://api.td2.info.pl:9640/?method=readFromSWDR&value=getDispatcherStatusList%3B1"
}; };
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 getStatusID = (stationStatus: any) => {
if (!stationStatus) return 'not-signed';
const statusCode = stationStatus[2];
const statusTimestamp = stationStatus[3];
switch (statusCode) {
case 0:
if (statusTimestamp - Date.now() > 21000000) return 'no-limit';
return 'online';
case 1:
return 'brb';
case 2:
if (statusTimestamp == 0) return 'ending';
break;
case 3:
return 'no-space';
default:
break;
}
return 'unavailable';
};
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 parseSpawns = (spawnString: string) => {
if (!spawnString) return [];
if (spawnString === 'NO_SPAWN') return [];
return spawnString.split(';').map(spawn => {
const spawnArray = spawn.split(',');
const spawnName = spawnArray[6] ? spawnArray[6] : spawnArray[0];
const spawnLength = parseInt(spawnArray[2]);
return { spawnName, spawnLength };
});
};
const getTimestamp = (date: string) => (date ? new Date(date).getTime() : 0);
const timestampToString = (timestamp: number) =>
new Date(timestamp).toLocaleTimeString('pl-PL', {
hour: '2-digit',
minute: '2-digit',
});
@Module @Module
export default class Store extends VuexModule { export default class Store extends VuexModule {
private trainCount: number = 0; private trainCount: number = 0;
@@ -151,7 +77,7 @@ export default class Store extends VuexModule {
trainCount: this.trainCount, trainCount: this.trainCount,
stationCount: this.stationCount, stationCount: this.stationCount,
dataConnectionStatus: this.dataConnectionStatus, dataConnectionStatus: this.dataConnectionStatus,
timetableDataStatus: this.timetableLoaded, timetableDataStatus: this.timetableLoaded
}; };
} }
@@ -177,27 +103,27 @@ export default class Store extends VuexModule {
//ACTIONS //ACTIONS
@Action @Action
async synchronizeData() { async synchronizeData() {
this.context.commit('setSceneryData'); this.context.commit("setSceneryData");
this.context.commit('setSceneryDataStatus', Status.Loaded); this.context.commit("setSceneryDataStatus", Status.Loaded);
this.context.dispatch('fetchOnlineData'); this.context.dispatch("fetchOnlineData");
setInterval(() => this.context.dispatch('fetchOnlineData'), 20000); setInterval(() => this.context.dispatch("fetchOnlineData"), 20000);
} }
@Action({ commit: 'updateTimetableData' }) @Action({ commit: "updateTimetableData" })
async fetchTimetableData() { async fetchTimetableData() {
return this.trainList.reduce(async (acc: Promise<ITimetableData[]>, train) => { return this.trainList.reduce(async (acc: Promise<TimetableData[]>, train) => {
const timetable = await (await axios.get(timetableURL(train.trainNo))).data.message; const timetable = await (await axios.get(utils.timetableURL(train.trainNo))).data.message;
const trainInfo = timetable.trainInfo; const trainInfo = timetable.trainInfo;
if (!timetable || !trainInfo) return acc; if (!timetable || !trainInfo) return acc;
const followingStops: TrainStop[] = timetable.stopPoints.reduce((stopsAcc: TrainStop[], point) => { const followingStops: TrainStop[] = timetable.stopPoints.reduce((stopsAcc: TrainStop[], point) => {
const arrivalTimestamp = getTimestamp(point.arrivalTime); const arrivalTimestamp = utils.getTimestamp(point.arrivalTime);
const arrivalRealTimestamp = getTimestamp(point.arrivalRealTime); const arrivalRealTimestamp = utils.getTimestamp(point.arrivalRealTime);
const departureTimestamp = getTimestamp(point.departureTime); const departureTimestamp = utils.getTimestamp(point.departureTime);
const departureRealTimestamp = getTimestamp(point.departureRealTime); const departureRealTimestamp = utils.getTimestamp(point.departureRealTime);
stopsAcc.push({ stopsAcc.push({
stopName: point.pointName, stopName: point.pointName,
@@ -205,19 +131,19 @@ export default class Store extends VuexModule {
stopType: point.pointStopType, stopType: point.pointStopType,
stopDistance: point.pointDistance, stopDistance: point.pointDistance,
mainStop: point.pointName.includes('strong'), mainStop: point.pointName.includes("strong"),
arrivalLine: point.arrivalLine, arrivalLine: point.arrivalLine,
arrivalTimeString: timestampToString(point.arrivalTime), arrivalTimeString: utils.timestampToString(point.arrivalTime),
arrivalTimestamp: arrivalTimestamp, arrivalTimestamp: arrivalTimestamp,
arrivalRealTimeString: timestampToString(point.arrivalRealTime), arrivalRealTimeString: utils.timestampToString(point.arrivalRealTime),
arrivalRealTimestamp: arrivalRealTimestamp, arrivalRealTimestamp: arrivalRealTimestamp,
arrivalDelay: point.arrivalDelay, arrivalDelay: point.arrivalDelay,
departureLine: point.departureLine, departureLine: point.departureLine,
departureTimeString: timestampToString(point.departureTime), departureTimeString: utils.timestampToString(point.departureTime),
departureTimestamp: departureTimestamp, departureTimestamp: departureTimestamp,
departureRealTimeString: timestampToString(point.departureRealTime), departureRealTimeString: utils.timestampToString(point.departureRealTime),
departureRealTimestamp: departureRealTimestamp, departureRealTimestamp: departureRealTimestamp,
departureDelay: point.departureDelay, departureDelay: point.departureDelay,
@@ -226,7 +152,7 @@ export default class Store extends VuexModule {
confirmed: point.confirmed, confirmed: point.confirmed,
stopped: point.isStopped, stopped: point.isStopped,
stopTime: point.pointStopTime, stopTime: point.pointStopTime
}); });
return stopsAcc; return stopsAcc;
@@ -245,7 +171,7 @@ export default class Store extends VuexModule {
SKR: trainInfo.skr, SKR: trainInfo.skr,
routeDistance: timetable.stopPoints[timetable.stopPoints.length - 1].pointDistance, routeDistance: timetable.stopPoints[timetable.stopPoints.length - 1].pointDistance,
followingStops, followingStops,
followingSceneries: trainInfo.sceneries, followingSceneries: trainInfo.sceneries
}); });
return acc; return acc;
@@ -261,15 +187,15 @@ export default class Store extends VuexModule {
const onlineDispatchersData = await response[2].data.message; const onlineDispatchersData = await response[2].data.message;
let updatedStationList = onlineStationsData.reduce((acc, station) => { let updatedStationList = onlineStationsData.reduce((acc, station) => {
if (station.region !== 'eu' || !station.isOnline) return acc; if (station.region !== "eu" || !station.isOnline) return acc;
const stationStatus = onlineDispatchersData.find(status => status[0] == station.stationHash && status[1] == 'eu'); const stationStatus = onlineDispatchersData.find(status => status[0] == station.stationHash && status[1] == "eu");
const statusTimestamp = getStatusTimestamp(stationStatus); const statusTimestamp = utils.getStatusTimestamp(stationStatus);
const statusID = getStatusID(stationStatus); const statusID = utils.getStatusID(stationStatus);
const stationTrains = onlineTrainsData.filter( const stationTrains = onlineTrainsData.filter(
train => train.region === 'eu' && train.isOnline && train.station.stationName === station.stationName train => train.region === "eu" && train.isOnline && train.station.stationName === station.stationName
); );
acc.push({ acc.push({
@@ -277,7 +203,7 @@ export default class Store extends VuexModule {
stationHash: station.stationHash, stationHash: station.stationHash,
maxUsers: station.maxUsers, maxUsers: station.maxUsers,
currentUsers: station.currentUsers, currentUsers: station.currentUsers,
spawns: parseSpawns(station.spawnString), spawns: utils.parseSpawns(station.spawnString),
dispatcherName: station.dispatcherName, dispatcherName: station.dispatcherName,
dispatcherRate: station.dispatcherRate, dispatcherRate: station.dispatcherRate,
dispatcherId: station.dispatcherId, dispatcherId: station.dispatcherId,
@@ -286,7 +212,7 @@ export default class Store extends VuexModule {
stationTrains, stationTrains,
statusTimestamp, statusTimestamp,
statusID, statusID,
statusTimeString: timestampToString(statusTimestamp), statusTimeString: utils.timestampToString(statusTimestamp)
}); });
return acc; return acc;
@@ -294,9 +220,9 @@ export default class Store extends VuexModule {
let updatedTrainList = await Promise.all( let updatedTrainList = await Promise.all(
onlineTrainsData onlineTrainsData
.filter(train => train.region === 'eu') .filter(train => train.region === "eu")
.map(async train => { .map(async train => {
const locoType = train.dataCon.split(';') ? train.dataCon.split(';')[0] : train.dataCon; const locoType = train.dataCon.split(";") ? train.dataCon.split(";")[0] : train.dataCon;
return { return {
trainNo: train.trainNo, trainNo: train.trainNo,
@@ -312,18 +238,18 @@ export default class Store extends VuexModule {
currentStationHash: train.station.stationHash, currentStationHash: train.station.stationHash,
connectedTrack: train.dataSceneryConnection, connectedTrack: train.dataSceneryConnection,
locoType, locoType,
locoURL: getLocoURL(locoType), locoURL: utils.getLocoURL(locoType)
}; };
}) })
); );
this.context.commit('updateOnlineStations', updatedStationList); this.context.commit("updateOnlineStations", updatedStationList);
this.context.commit('updateOnlineTrains', updatedTrainList); this.context.commit("updateOnlineTrains", updatedTrainList);
this.context.dispatch('fetchTimetableData'); this.context.dispatch("fetchTimetableData");
}) })
.catch(err => { .catch(err => {
this.context.commit('setDataConnectionStatus', Status.Error); this.context.commit("setDataConnectionStatus", Status.Error);
}); });
} }
@@ -368,7 +294,7 @@ export default class Store extends VuexModule {
stationLines: station[2] as string, stationLines: station[2] as string,
stationProject: station[3] as string, stationProject: station[3] as string,
reqLevel: station[4] as string, reqLevel: station[4] as string,
supportersOnly: station[5] == 'TAK', supportersOnly: station[5] == "TAK",
signalType: station[6] as string, signalType: station[6] as string,
controlType: station[7] as string, controlType: station[7] as string,
SBL: station[8] as string, SBL: station[8] as string,
@@ -376,12 +302,12 @@ export default class Store extends VuexModule {
routes: { routes: {
oneWay: { oneWay: {
catenary: station[10] as number, catenary: station[10] as number,
noCatenary: station[11] as number, noCatenary: station[11] as number
}, },
twoWay: { twoWay: {
catenary: station[12] as number, catenary: station[12] as number,
noCatenary: station[13] as number, noCatenary: station[13] as number
}, }
}, },
checkpoints: station[14] ? (station[14] as string[]).map(sub => ({ checkpointName: sub, scheduledTrains: [] })) : null, checkpoints: station[14] ? (station[14] as string[]).map(sub => ({ checkpointName: sub, scheduledTrains: [] })) : null,
stops: station[15] as string[], stops: station[15] as string[],
@@ -390,21 +316,21 @@ export default class Store extends VuexModule {
nonPublic: station[17] as boolean, nonPublic: station[17] as boolean,
unavailable: station[18] as boolean, unavailable: station[18] as boolean,
stationHash: '', stationHash: "",
maxUsers: 0, maxUsers: 0,
currentUsers: 0, currentUsers: 0,
dispatcherName: '', dispatcherName: "",
dispatcherRate: 0, dispatcherRate: 0,
dispatcherExp: -1, dispatcherExp: -1,
dispatcherId: 0, dispatcherId: 0,
dispatcherIsSupporter: false, dispatcherIsSupporter: false,
online: false, online: false,
statusTimestamp: -3, statusTimestamp: -3,
statusID: 'free', statusID: "free",
statusTimeString: '', statusTimeString: "",
stationTrains: [], stationTrains: [],
scheduledTrains: [], scheduledTrains: [],
spawns: [], spawns: []
})); }));
} }
@@ -418,27 +344,27 @@ export default class Store extends VuexModule {
acc.push({ acc.push({
...station, ...station,
...onlineStationData, ...onlineStationData,
online: true, online: true
}); });
else if (registeredStation) else if (registeredStation)
acc.push({ acc.push({
...station, ...station,
stationProject: '', stationProject: "",
stationHash: '', stationHash: "",
maxUsers: 0, maxUsers: 0,
currentUsers: 0, currentUsers: 0,
dispatcherName: '', dispatcherName: "",
dispatcherRate: 0, dispatcherRate: 0,
dispatcherExp: -1, dispatcherExp: -1,
dispatcherId: 0, dispatcherId: 0,
dispatcherIsSupporter: false, dispatcherIsSupporter: false,
online: false, online: false,
statusID: 'free', statusID: "free",
statusTimestamp: -3, statusTimestamp: -3,
statusTimeString: '', statusTimeString: "",
stationTrains: [], stationTrains: [],
scheduledTrains: [], scheduledTrains: [],
checkpoints: null, checkpoints: null
}); });
return acc; return acc;
@@ -453,8 +379,8 @@ export default class Store extends VuexModule {
stationTrains: [], stationTrains: [],
subStations: [], subStations: [],
online: true, online: true,
reqLevel: '-1', reqLevel: "-1",
nonPublic: true, nonPublic: true
}); });
}); });
@@ -478,153 +404,77 @@ export default class Store extends VuexModule {
} }
@Mutation @Mutation
private updateTimetableData(timetableList: ITimetableData[]) { private updateTimetableData(timetableList: TimetableData[]) {
this.stationList = this.stationList.map(station => { this.stationList = this.stationList.map(station => {
const stationName = station.stationName.toLowerCase(); const stationName = station.stationName.toLowerCase();
const scheduledTrains: Station['scheduledTrains'] = timetableList.reduce(
(acc: Station['scheduledTrains'], timetableData: ITimetableData, index) => {
if (!timetableData.followingSceneries.includes(station.stationHash)) return acc;
const stopInfoIndex = timetableData.followingStops.findIndex(stop => { const scheduledTrains: Station["scheduledTrains"] = timetableList.reduce((acc: Station["scheduledTrains"], timetable: TimetableData, index) => {
const stopName = stop.stopNameRAW.toLowerCase(); if (!timetable.followingSceneries.includes(station.stationHash)) return acc;
if (stationName === stopName) return true; const stopInfoIndex = timetable.followingStops.findIndex(stop => {
if (stopName.includes(stationName) && !stop.stopName.includes('po.') && !stop.stopName.includes('podg.')) return true; const stopName = stop.stopNameRAW.toLowerCase();
if (stationName.includes(stopName) && !stop.stopName.includes('po.') && !stop.stopName.includes('podg.')) return true;
if (stopName.includes('podg.') && stopName.split(', podg.')[0] && stationName.includes(stopName.split(', podg.')[0])) return true;
if (station.stops && station.stops.includes(stop.stopNameRAW)) return true; if (stationName === stopName) return true;
if (stopName.includes(stationName) && !stop.stopName.includes("po.") && !stop.stopName.includes("podg.")) return true;
if (stationName.includes(stopName) && !stop.stopName.includes("po.") && !stop.stopName.includes("podg.")) return true;
if (stopName.includes("podg.") && stopName.split(", podg.")[0] && stationName.includes(stopName.split(", podg.")[0])) return true;
return false; if (station.stops && station.stops.includes(stop.stopNameRAW)) return true;
});
if (stopInfoIndex == -1) return acc; return false;
});
const stopInfo = timetableData.followingStops[stopInfoIndex]; if (stopInfoIndex == -1) return acc;
let stopStatus = ''; const trainStop = timetable.followingStops[stopInfoIndex];
let stopLabel = ''; const trainStopStatus = utils.getTrainStopStatus(trainStop, timetable, station);
let stopStatusID = 0;
let nearestStop = '';
if (stopInfo.terminatesHere && stopInfo.confirmed) { acc.push({
stopStatus = 'terminated'; trainNo: timetable.trainNo,
stopLabel = 'Skończył bieg'; driverName: timetable.driverName,
stopStatusID = 5; driverId: timetable.driverId,
} else if (!stopInfo.terminatesHere && stopInfo.confirmed && timetableData.currentStationName == station.stationName) { currentStationName: timetable.currentStationName,
stopStatus = 'departed'; currentStationHash: timetable.currentStationHash,
stopLabel = 'Odprawiony'; category: timetable.category,
stopStatusID = 2; beginsAt: timetable.followingStops[0].stopNameRAW,
} else if (!stopInfo.terminatesHere && stopInfo.confirmed && timetableData.currentStationName != station.stationName) { terminatesAt: timetable.followingStops[timetable.followingStops.length - 1].stopNameRAW,
stopStatus = 'departed-away'; nearestStop: "",
stopLabel = 'Odjechał'; stopInfo: trainStop,
stopStatusID = 4; stopLabel: trainStopStatus.stopLabel,
} else if (timetableData.currentStationName == station.stationName && !stopInfo.stopped) { stopStatus: trainStopStatus.stopStatus,
stopStatus = 'online'; stopStatusID: trainStopStatus.stopStatusID
stopLabel = 'Na stacji'; });
stopStatusID = 0;
} else if (timetableData.currentStationName == station.stationName && stopInfo.stopped) {
stopStatus = 'stopped';
stopLabel = 'Postój';
stopStatusID = 1;
} else if (timetableData.currentStationName != station.stationName) {
stopStatus = 'arriving';
stopLabel = 'W drodze';
stopStatusID = 3;
}
if (stopInfoIndex < timetableData.followingStops.length - 2) { return acc;
for (let i = stopInfoIndex + 1; i < timetableData.followingStops.length - 1; i++) { }, []);
const stop = timetableData.followingStops[i];
if (stop.mainStop && stop.stopType.includes('ph')) {
nearestStop = stop.stopNameRAW;
break;
}
}
}
acc.push({
trainNo: timetableData.trainNo,
driverName: timetableData.driverName,
driverId: timetableData.driverId,
currentStationName: timetableData.currentStationName,
currentStationHash: timetableData.currentStationHash,
category: timetableData.category,
beginsAt: timetableData.followingStops[0].stopNameRAW,
terminatesAt: timetableData.followingStops[timetableData.followingStops.length - 1].stopNameRAW,
nearestStop,
stopInfo,
stopLabel,
stopStatus,
stopStatusID,
});
return acc;
},
[]
);
if (station.checkpoints) { if (station.checkpoints) {
station.checkpoints.forEach(cp => (cp.scheduledTrains.length = 0)); station.checkpoints.forEach(cp => (cp.scheduledTrains.length = 0));
for (let checkpoint of station.checkpoints) { for (let checkpoint of station.checkpoints) {
timetableList.reduce((acc, data) => { timetableList.forEach(timetable => {
data.followingStops timetable.followingStops
.filter(stop => stop.stopNameRAW.toLowerCase() === checkpoint.checkpointName.toLowerCase()) .filter(trainStop => trainStop.stopNameRAW.toLowerCase() === checkpoint.checkpointName.toLowerCase())
.forEach(stopInfo => { .forEach(trainStop => {
// const stopInfo = data.followingStops[stopInfoIndex]; const trainStopStatus = utils.getTrainStopStatus(trainStop, timetable, station);
let stopStatus = '';
let stopLabel = '';
let nearestStop = '';
let stopStatusID = 0;
if (stopInfo.terminatesHere && stopInfo.confirmed) {
stopStatus = 'terminated';
stopLabel = 'Skończył bieg';
stopStatusID = 5;
} else if (!stopInfo.terminatesHere && stopInfo.confirmed && data.currentStationName == station.stationName) {
stopStatus = 'departed';
stopLabel = 'Odprawiony';
stopStatusID = 2;
} else if (!stopInfo.terminatesHere && stopInfo.confirmed && data.currentStationName != station.stationName) {
stopStatus = 'departed-away';
stopLabel = 'Odjechał';
stopStatusID = 4;
} else if (data.currentStationName == station.stationName && !stopInfo.stopped) {
stopStatus = 'online';
stopLabel = 'Na stacji';
stopStatusID = 0;
} else if (data.currentStationName == station.stationName && stopInfo.stopped) {
stopStatus = 'stopped';
stopLabel = 'Postój';
stopStatusID = 1;
} else if (data.currentStationName != station.stationName) {
stopStatus = 'arriving';
stopLabel = 'W drodze';
stopStatusID = 3;
}
checkpoint.scheduledTrains.push({ checkpoint.scheduledTrains.push({
trainNo: data.trainNo, trainNo: timetable.trainNo,
driverName: data.driverName, driverName: timetable.driverName,
driverId: data.driverId, driverId: timetable.driverId,
currentStationName: data.currentStationName, currentStationName: timetable.currentStationName,
currentStationHash: data.currentStationHash, currentStationHash: timetable.currentStationHash,
category: data.category, category: timetable.category,
beginsAt: data.followingStops[0].stopNameRAW, beginsAt: timetable.followingStops[0].stopNameRAW,
terminatesAt: data.followingStops[data.followingStops.length - 1].stopNameRAW, terminatesAt: timetable.followingStops[timetable.followingStops.length - 1].stopNameRAW,
stopInfo, nearestStop: "",
stopLabel, stopInfo: trainStop,
stopStatus, stopLabel: trainStopStatus.stopLabel,
nearestStop, stopStatus: trainStopStatus.stopStatus,
stopStatusID, stopStatusID: trainStopStatus.stopStatusID
}); });
}); });
});
return acc;
}, []);
} }
} }
@@ -639,7 +489,7 @@ export default class Store extends VuexModule {
.find(station => station.stationName === train.currentStationName) .find(station => station.stationName === train.currentStationName)
?.scheduledTrains.find(stationTrain => stationTrain.trainNo === train.trainNo); ?.scheduledTrains.find(stationTrain => stationTrain.trainNo === train.trainNo);
acc.push({ ...train, timetableData, stopStatus: trainData?.stopStatus || '', stopLabel: trainData?.stopLabel || '' }); acc.push({ ...train, timetableData, stopStatus: trainData?.stopStatus || "", stopLabel: trainData?.stopLabel || "" });
} }
return acc; return acc;