Compare commits

...

25 Commits

Author SHA1 Message Date
Spythere 619ce97b52 Merge pull request #101 from Spythere/development
v1.26.0
2024-08-05 16:11:07 +02:00
Spythere 47d35f335f chore: deleted merge workflow 2024-08-05 16:01:54 +02:00
Spythere 8fda8fa0df chore: package scripts 2024-08-05 15:59:54 +02:00
Spythere 71d697eda5 chore: changed workflow npm to yarn 2024-08-05 15:55:15 +02:00
Spythere f2b1fc5369 chore: disabled workflow on master push 2024-08-05 15:54:02 +02:00
Spythere 4a9b142e16 hotfix: lock files 2024-08-03 01:56:58 +02:00
Spythere 08d8bf3c57 bump: v1.26.0 2024-08-03 01:55:12 +02:00
Spythere 0ee90357aa chore: code structure 2024-08-03 01:53:36 +02:00
Spythere c8964dc20f chore: dispatcher history revamp & statuses 2024-08-02 02:00:44 +02:00
Spythere 6a62276d95 fix: vehicle preview loading 2024-08-01 19:26:25 +02:00
Spythere b8550eed9a chore: cleanup 2024-08-01 19:22:54 +02:00
Spythere 27b23ccc95 chore: lazy thumbnail loading & animations 2024-08-01 19:22:43 +02:00
Spythere b49517aded chore: packages upgrade 2024-07-24 18:55:41 +02:00
Spythere ed2b8be4dc chore: offline & fetching fixes 2024-07-24 17:52:20 +02:00
Spythere 54c1dbbf15 fix: stop labels statuses 2024-07-16 21:39:54 +02:00
Spythere 0ac7ba51e5 Merge pull request #100 from Spythere/development
v1.25.2
2024-07-12 16:13:06 +02:00
Spythere bdf85cd8ec bump: 1.25.2 2024-07-12 16:01:45 +02:00
Spythere 63b268d9b9 feat: added journal timetable path 2024-07-12 15:59:08 +02:00
Spythere d73c8ef112 fix: update modal won't open on first visit 2024-07-12 15:11:17 +02:00
Spythere 3d1c66b420 fix: cache control 2024-07-12 14:50:01 +02:00
Spythere b3f7108979 fix: detecting podg in timetables 2024-07-12 13:58:43 +02:00
Spythere feabfd29e0 Merge pull request #99 from Spythere/development
fix: recognizing timetables for sceneries with the same stop names
2024-07-09 20:33:16 +02:00
Spythere f17fedc976 fix: recognizing timetables for sceneries with the same stop names; optimization 2024-07-09 19:15:04 +02:00
Spythere c83c75e014 Merge pull request #98 from Spythere/development
hotfix: thumbnails v2 src
2024-07-08 22:12:41 +02:00
Spythere e57143f517 hotfix: thumbnails v2 src 2024-07-08 22:12:05 +02:00
26 changed files with 1547 additions and 3168 deletions
@@ -1,20 +0,0 @@
# This file was auto-generated by the Firebase CLI
# https://github.com/firebase/firebase-tools
name: Deploy to Firebase Hosting on merge
'on':
push:
branches:
- master
jobs:
build_and_deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- run: npm ci && npm run build
- uses: FirebaseExtended/action-hosting-deploy@v0
with:
repoToken: '${{ secrets.GITHUB_TOKEN }}'
firebaseServiceAccount: '${{ secrets.FIREBASE_SERVICE_ACCOUNT_STACJOWNIK_TD2 }}'
channelId: live
projectId: stacjownik-td2
@@ -9,7 +9,7 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/checkout@v2 - uses: actions/checkout@v2
- run: npm ci && npm run build - run: yarn && yarn build
- uses: FirebaseExtended/action-hosting-deploy@v0 - uses: FirebaseExtended/action-hosting-deploy@v0
with: with:
repoToken: '${{ secrets.GITHUB_TOKEN }}' repoToken: '${{ secrets.GITHUB_TOKEN }}'
-1
View File
@@ -19,7 +19,6 @@
<link rel="manifest" href="/site.webmanifest" /> <link rel="manifest" href="/site.webmanifest" />
<link rel="mask-icon" href="/safari-pinned-tab.svg" color="#5bbad5" /> <link rel="mask-icon" href="/safari-pinned-tab.svg" color="#5bbad5" />
<meta name="msapplication-TileColor" content="#da532c" /> <meta name="msapplication-TileColor" content="#da532c" />
<meta name="theme-color" content="#222222" />
<link rel="icon" href="favicon.ico" /> <link rel="icon" href="favicon.ico" />
+457 -1761
View File
File diff suppressed because it is too large Load Diff
+13 -16
View File
@@ -1,11 +1,13 @@
{ {
"name": "stacjownik", "name": "stacjownik",
"version": "1.25.1", "version": "1.26.0",
"private": true, "private": true,
"type": "module",
"scripts": { "scripts": {
"dev": "vite", "dev": "vite",
"build": "vue-tsc --noEmit && vite build", "build": "vue-tsc --noEmit && vite build",
"deploy": "yarn build && firebase deploy --only hosting", "deploy:prod": "yarn build && firebase deploy --only hosting",
"deploy:dev": "yarn build && firebase hosting:channel:deploy dev --expires 7d",
"preview": "yarn build && vite preview", "preview": "yarn build && vite preview",
"type-check": "vue-tsc --noEmit -p tsconfig.app.json --composite false", "type-check": "vue-tsc --noEmit -p tsconfig.app.json --composite false",
"lint": "eslint . --ext .vue,.js,.jsx,.cjs,.mjs,.ts,.tsx,.cts,.mts --fix --ignore-path .gitignore", "lint": "eslint . --ext .vue,.js,.jsx,.cjs,.mjs,.ts,.tsx,.cts,.mts --fix --ignore-path .gitignore",
@@ -19,25 +21,20 @@
"showdown": "^2.1.0", "showdown": "^2.1.0",
"vue": "^3.3.4", "vue": "^3.3.4",
"vue-i18n": "^9.4.1", "vue-i18n": "^9.4.1",
"vue-router": "^4.2.4" "vue-router": "^4.4.0"
}, },
"devDependencies": { "devDependencies": {
"@rushstack/eslint-patch": "^1.3.3", "@types/node": "^20.14.12",
"@types/node": "^20.6.2",
"@types/showdown": "^2.0.6", "@types/showdown": "^2.0.6",
"@vite-pwa/assets-generator": "^0.2.4", "@vite-pwa/assets-generator": "^0.2.4",
"@vitejs/plugin-vue": "^4.3.4", "@vitejs/plugin-vue": "^5.1.0",
"@vue/eslint-config-prettier": "^8.0.0", "@vue/tsconfig": "^0.5.1",
"@vue/eslint-config-typescript": "^12.0.0", "axios": "^1.7.2",
"@vue/tsconfig": "^0.4.0", "prettier": "^3.3.3",
"axios": "^1.5.0", "typescript": "^5.5.4",
"eslint": "^8.49.0", "vite": "^5.3.4",
"eslint-plugin-vue": "^9.17.0",
"prettier": "^3.0.3",
"typescript": "^5.2.2",
"vite": "^4.4.9",
"vite-plugin-pwa": "^0.20.0", "vite-plugin-pwa": "^0.20.0",
"vue-tsc": "^1.8.11" "vue-tsc": "^2.0.28"
}, },
"browserslist": [ "browserslist": [
"> 1%", "> 1%",
+6 -15
View File
@@ -81,9 +81,7 @@ export default defineComponent({
isUpdateCardOpen: false, isUpdateCardOpen: false,
currentLang: 'pl', currentLang: 'pl',
isOnProductionHost: location.hostname == 'stacjownik-td2.web.app', isOnProductionHost: location.hostname == 'stacjownik-td2.web.app'
nextUpdateTime: 0
}), }),
created() { created() {
@@ -96,22 +94,13 @@ export default defineComponent({
methods: { methods: {
init() { init() {
if (!this.isOnProductionHost) document.title = 'Stacjownik Dev';
this.loadLang(); this.loadLang();
this.setupOfflineHandling(); this.setupOfflineHandling();
this.checkAppVersion(); this.checkAppVersion();
this.apiStore.setupAPIData(); this.apiStore.setupAPIData();
window.requestAnimationFrame(this.update);
if (!this.isOnProductionHost) document.title = 'Stacjownik Dev';
},
update(t: number) {
if (t >= this.nextUpdateTime) {
this.apiStore.fetchActiveData();
this.nextUpdateTime = t + 20000;
}
window.requestAnimationFrame(this.update);
}, },
async checkAppVersion() { async checkAppVersion() {
@@ -131,7 +120,8 @@ export default defineComponent({
}; };
this.isUpdateCardOpen = this.isUpdateCardOpen =
storageVersion != version || import.meta.env.VITE_UPDATE_TEST === 'test'; (storageVersion != '' && storageVersion != version && this.isOnProductionHost) ||
import.meta.env.VITE_UPDATE_TEST === 'test';
} catch (error) { } catch (error) {
console.error(`Wystąpił błąd podczas pobierania danych z API GitHuba: ${error}`); console.error(`Wystąpił błąd podczas pobierania danych z API GitHuba: ${error}`);
} }
@@ -157,6 +147,7 @@ export default defineComponent({
handleOnlineMode() { handleOnlineMode() {
this.store.isOffline = false; this.store.isOffline = false;
this.apiStore.dataStatuses.connection = Status.Data.Loading;
this.apiStore.connectToAPI(); this.apiStore.connectToAPI();
}, },
+5 -4
View File
@@ -88,8 +88,9 @@ $unknown: #b93c3c;
.status-badge { .status-badge {
border-radius: 1em; border-radius: 1em;
font-weight: 500; font-weight: 500;
text-wrap: nowrap;
padding: 0.2em 0.55em; padding: 0.2rem 0.55rem;
background-color: $online; background-color: $online;
@@ -106,13 +107,13 @@ $unknown: #b93c3c;
&.no-limit { &.no-limit {
background-color: $no-limit; background-color: $no-limit;
font-size: 0.85em; font-size: 0.9em;
} }
&.not-signed, &.not-signed,
&.unavailable { &.unavailable {
background-color: $unav; background-color: $unav;
font-size: 0.85em; font-size: 0.9em;
} }
&.afk { &.afk {
@@ -125,7 +126,7 @@ $unknown: #b93c3c;
background-color: $no-space; background-color: $no-space;
border: 1px solid white; border: 1px solid white;
color: white; color: white;
font-size: 0.85em; font-size: 0.9em;
} }
&.unknown, &.unknown,
+9 -10
View File
@@ -11,15 +11,11 @@
</div> </div>
<span> <span>
<img <VehicleThumbnail
v-for="(thumbnailImage, imageIndex) in images" v-for="(thumbnailImage, imageIndex) in images"
:data-mouseover="vehicleName" :vehicle-name="vehicleName"
data-tooltip-type="VehiclePreviewTooltip" :img-name="thumbnailImage"
:data-tooltip-content="vehicleName" :fallback-name="imagesFallbacks[imageIndex]"
:src="`https://static.spythere.eu/thumbnails/${thumbnailImage}.png`"
@error="onImageError($event, imagesFallbacks[imageIndex])"
@click.stop="() => {}"
height="60"
/> />
</span> </span>
</li> </li>
@@ -30,8 +26,11 @@
<script lang="ts"> <script lang="ts">
import { PropType, defineComponent } from 'vue'; import { PropType, defineComponent } from 'vue';
import { useApiStore } from '../../store/apiStore'; import { useApiStore } from '../../store/apiStore';
import VehicleThumbnail from './VehicleThumbnail.vue';
export default defineComponent({ export default defineComponent({
components: { VehicleThumbnail },
props: { props: {
trainStockList: { trainStockList: {
type: Array as PropType<string[]>, type: Array as PropType<string[]>,
@@ -143,7 +142,7 @@ export default defineComponent({
else { else {
let fallbackVehicleImage = 'unknown_cargo'; let fallbackVehicleImage = 'unknown_cargo';
if (/^(EP|EU)/.test(vehicleName)) fallbackVehicleImage = 'unknown_train'; if (/^(EP|EU|ET|201E)/.test(vehicleName)) fallbackVehicleImage = 'unknown_train';
else if (/^(SM42)/.test(vehicleName)) fallbackVehicleImage = 'unknown_SM42'; else if (/^(SM42)/.test(vehicleName)) fallbackVehicleImage = 'unknown_SM42';
else if (/(\d{3}a|(Bau|Gor)\d{2}|304C)_/.test(vehicleName)) else if (/(\d{3}a|(Bau|Gor)\d{2}|304C)_/.test(vehicleName))
fallbackVehicleImage = 'unknown_passenger'; fallbackVehicleImage = 'unknown_passenger';
@@ -160,7 +159,7 @@ export default defineComponent({
}, },
methods: { methods: {
onImageError(event: Event, fallbackImage: string) { onImageError(event: Event, fallbackImage: string) {
(event.target as HTMLImageElement).src = `/images/${fallbackImage}.png`; (event.target as HTMLImageElement).src = `/images/${fallbackImage}.png`;
} }
} }
@@ -0,0 +1,62 @@
<template>
<div class="vehicle-thumbnail">
<img
ref="imgRef"
:src="`https://static.spythere.eu/thumbnails/v2/${imgName}.png`"
height="60"
loading="lazy"
:data-mouseover="vehicleName"
:data-tooltip-content="vehicleName"
:data-load-status="imgStatus"
data-tooltip-type="VehiclePreviewTooltip"
@error="onImageError"
@load="onImageLoad"
/>
</div>
</template>
<script setup lang="ts">
import { onMounted, Ref, ref } from 'vue';
const props = defineProps({
vehicleName: { type: String, required: true },
imgName: { type: String, required: true },
fallbackName: { type: String, required: true },
placeholderName: String
});
const imgRef = ref(null) as Ref<HTMLElement | null>;
const imgStatus = ref('loading');
function onImageError(event: Event) {
console.log('error');
(event.target as HTMLImageElement).src = `/images/${props.fallbackName}.png`;
imgStatus.value = 'error';
}
function onImageLoad() {
if (imgStatus.value != 'error') {
imgStatus.value = 'loaded';
}
imgRef.value!.style.opacity = '1';
}
</script>
<style lang="scss" scoped>
.vehicle-thumbnail {
position: relative;
}
img {
opacity: 0;
transition: opacity 100ms ease-in-out;
&[data-load-status='loading'] {
min-height: 60px;
min-width: 150px;
}
}
</style>
@@ -0,0 +1,217 @@
<template>
<li class="dispatcher-history-entry">
<div class="entry-info">
<span>
<span>
<router-link :to="`/journal/dispatchers?search-station=${entry.stationName}`">
<b>{{ entry.stationName }}</b>
</router-link>
<b class="text--grayed"> #{{ entry.stationHash }}</b>
</span>
&bull;
<b
v-if="entry.dispatcherLevel !== null"
class="level-badge dispatcher"
:style="calculateExpStyle(entry.dispatcherLevel, entry.dispatcherIsSupporter)"
>
{{ entry.dispatcherLevel >= 2 ? entry.dispatcherLevel : 'L' }}
</b>
<b style="margin-left: 5px">
<span
v-if="apiStore.donatorsData.includes(entry.dispatcherName)"
data-tooltip-type="DonatorTooltip"
:data-tooltip-content="$t('donations.dispatcher-message')"
>
<router-link
class="text--donator"
:to="`/journal/dispatchers?search-dispatcher=${entry.dispatcherName}`"
>
{{ entry.dispatcherName }}
</router-link>
</span>
<router-link
v-else
:to="`/journal/dispatchers?search-dispatcher=${entry.dispatcherName}`"
>
{{ entry.dispatcherName }}
</router-link>
</b>
<div>
<span v-if="entry.timestampTo">
<b>{{ $d(entry.timestampFrom) }}</b>
{{ timestampToString(entry.timestampFrom) }}
-
<b
v-if="
new Date(entry.timestampFrom).getDate() != new Date(entry.timestampTo).getDate()
"
>
{{ $d(entry.timestampTo) }}
</b>
{{ timestampToString(entry.timestampTo) }} ({{
calculateDuration(entry.currentDuration)
}})
</span>
<router-link
:to="`/scenery?station=${entry.stationName}`"
class="dispatcher-online"
v-else
>
{{ $t('journal.online-since') }}
<b>
{{
new Date().getDate() != new Date(entry.timestampFrom).getDate()
? $d(entry.timestampFrom)
: ''
}}
{{ timestampToString(entry.timestampFrom) }}
</b>
({{ calculateDuration(entry.currentDuration) }})
</router-link>
</div>
</span>
<span class="entry-info-right">
<div>
<span>
{{ $t('scenery.dispatcher-rate') }}
<b class="text--primary"> {{ entry.dispatcherRate }}</b>
</span>
<button class="btn btn--option" @click="toggleExtraInfo">
{{ $t('scenery.dispatcher-status-changes') }}
<b class="text--primary">{{ entry.statusHistory.length }}</b>
</button>
</div>
<b class="region-badge" :aria-describedby="entry.region">
REGION: {{ regions.find((r) => r.id == entry.region)?.name }}
</b>
</span>
</div>
<div class="entry-extra" v-if="showExtraInfo">
<ul class="status-list">
<li v-for="statusItem in entry.statusHistory">
<b style="margin-right: 0.5em">{{
timestampToString(parseInt(statusItem.split('@')[0]))
}}</b>
<StationStatusBadge
:dispatcher-status="Number(statusItem.split('@')[1])"
:is-online="true"
/>
</li>
</ul>
</div>
</li>
</template>
<script lang="ts">
import { defineComponent, PropType } from 'vue';
import { regions } from '../../../data/options.json';
import { API } from '../../../typings/api';
import dateMixin from '../../../mixins/dateMixin';
import styleMixin from '../../../mixins/styleMixin';
import { useApiStore } from '../../../store/apiStore';
import StationStatusBadge from '../../Global/StationStatusBadge.vue';
export default defineComponent({
props: {
entry: {
type: Object as PropType<API.DispatcherHistory.Data>,
required: true
},
showExtraInfo: {
type: Boolean,
required: true
}
},
components: { StationStatusBadge },
mixins: [dateMixin, styleMixin],
emits: ['toggleShowExtraInfo'],
data() {
return {
regions,
apiStore: useApiStore()
};
},
methods: {
toggleExtraInfo() {
this.$emit('toggleShowExtraInfo', this.entry.id);
}
}
});
</script>
<style lang="scss" scoped>
@import '../../../styles/responsive.scss';
@import '../../../styles/badge.scss';
.region-badge {
padding: 0 0.25em;
}
.level-badge {
text-align: center;
display: inline-block;
line-height: 1.6em;
}
.dispatcher-online {
color: springgreen;
}
.dispatcher-history-entry {
background-color: #1a1a1a;
padding: 1em;
}
.entry-info {
display: flex;
justify-content: space-between;
align-items: center;
flex-wrap: wrap;
line-height: 1.75em;
gap: 0.5em;
}
.entry-info-right {
display: flex;
flex-wrap: wrap;
align-items: center;
text-align: center;
gap: 1em;
}
.entry-extra {
margin-top: 1em;
}
.status-list {
display: flex;
overflow: auto;
gap: 0.5em;
}
.status-list > li {
background-color: #313131;
padding: 0.2rem 0 0.2rem 0.5em;
margin: 0.5em 0;
border-radius: 1em;
}
@include smallScreen {
.entry-info {
flex-direction: column;
justify-content: center;
text-align: center;
}
}
</style>
@@ -15,90 +15,16 @@
{{ $t('app.no-result') }} {{ $t('app.no-result') }}
</div> </div>
<div v-else> <ul v-else class="journal-list">
<table class="dispatchers-table"> <transition-group name="list-anim">
<thead> <JournalDispatcherEntry
<th>{{ $t('journal.history-name') }}</th> v-for="entry in dispatcherHistory"
<th>{{ $t('journal.history-hash') }}</th> :key="entry.id"
<th>{{ $t('journal.history-dispatcher') }}</th> :entry="entry"
<th>{{ $t('journal.history-level') }}</th> :onToggleShowExtraInfo="toggleExtraInfo"
<th>{{ $t('journal.history-rate') }}</th> :showExtraInfo="extraInfoIndexes.includes(entry.id)"
<th>{{ $t('journal.history-region') }}</th> />
<th>{{ $t('journal.history-date') }}</th> </transition-group>
</thead>
<tbody>
<transition-group name="list-anim">
<tr v-for="historyItem in dispatcherHistory" :key="historyItem.id">
<td>
<router-link
:to="`/journal/dispatchers?search-station=${historyItem.stationName}`"
>
<b>{{ historyItem.stationName }}</b>
</router-link>
</td>
<td>#{{ historyItem.stationHash }}</td>
<td>
<router-link
:to="`/journal/dispatchers?search-dispatcher=${historyItem.dispatcherName}`"
>
<b
v-if="apiStore.donatorsData.includes(historyItem.dispatcherName)"
class="text--donator"
:title="$t('donations.dispatcher-message')"
>
{{ historyItem.dispatcherName }}
</b>
<b v-else>
{{ historyItem.dispatcherName }}
</b>
</router-link>
</td>
<td>
<b
v-if="historyItem.dispatcherLevel !== null"
class="level-badge dispatcher"
:style="
calculateExpStyle(
historyItem.dispatcherLevel,
historyItem.dispatcherIsSupporter
)
"
>
{{ historyItem.dispatcherLevel >= 2 ? historyItem.dispatcherLevel : 'L' }}
</b>
</td>
<td class="text--primary">
<b>{{ historyItem.dispatcherRate }}</b>
</td>
<td>
<b class="region-badge" :aria-describedby="historyItem.region">{{
regions.find((r) => r.id == historyItem.region)?.value || '???'
}}</b>
</td>
<td style="min-width: 200px" class="time">
<span v-if="historyItem.timestampTo" class="text--offline">
<b>{{ $d(historyItem.timestampFrom) }}</b>
{{ timestampToString(historyItem.timestampFrom) }}
- {{ timestampToString(historyItem.timestampTo) }} ({{
calculateDuration(historyItem.currentDuration)
}})
</span>
<span class="dispatcher-online" v-else>
<b class="text--online">
<router-link :to="`/scenery?station=${historyItem.stationName}`">{{
$t('journal.online-since')
}}</router-link>
{{ timestampToString(historyItem.timestampFrom) }}
</b>
({{ calculateDuration(historyItem.currentDuration) }})
</span>
</td>
</tr>
</transition-group>
</tbody>
</table>
<AddDataButton <AddDataButton
:list="dispatcherHistory" :list="dispatcherHistory"
@@ -106,7 +32,7 @@
:scrollNoMoreData="scrollNoMoreData" :scrollNoMoreData="scrollNoMoreData"
@addHistoryData="addHistoryData" @addHistoryData="addHistoryData"
/> />
</div> </ul>
<div class="journal_warning" v-if="scrollNoMoreData"> <div class="journal_warning" v-if="scrollNoMoreData">
{{ $t('journal.no-further-data') }} {{ $t('journal.no-further-data') }}
@@ -121,20 +47,15 @@
<script lang="ts"> <script lang="ts">
import { defineComponent, PropType } from 'vue'; import { defineComponent, PropType } from 'vue';
import { regions } from '../../../data/options.json';
import { useMainStore } from '../../../store/mainStore'; import { useMainStore } from '../../../store/mainStore';
import { API } from '../../../typings/api'; import { API } from '../../../typings/api';
import { Status } from '../../../typings/common'; import { Status } from '../../../typings/common';
import Loading from '../../Global/Loading.vue'; import Loading from '../../Global/Loading.vue';
import AddDataButton from '../../Global/AddDataButton.vue'; import AddDataButton from '../../Global/AddDataButton.vue';
import dateMixin from '../../../mixins/dateMixin'; import JournalDispatcherEntry from './JournalDispatcherEntry.vue';
import styleMixin from '../../../mixins/styleMixin';
import { useApiStore } from '../../../store/apiStore';
export default defineComponent({ export default defineComponent({
components: { Loading, AddDataButton }, components: { Loading, AddDataButton, JournalDispatcherEntry },
mixins: [dateMixin, styleMixin],
props: { props: {
dispatcherHistory: { dispatcherHistory: {
@@ -159,99 +80,30 @@ export default defineComponent({
return { return {
Status, Status,
store: useMainStore(), store: useMainStore(),
apiStore: useApiStore(),
regions extraInfoIndexes: [] as number[]
}; };
}, },
computed: {
computedDispatcherHistory() {
return this.dispatcherHistory.reduce(
(acc, historyItem, i) => {
if (this.isAnotherDay(i - 1, i))
acc.push(new Date(historyItem.timestampFrom).toLocaleDateString('pl-PL'));
acc.push(historyItem);
return acc;
},
[] as (API.DispatcherHistory.Data | string)[]
);
}
},
methods: { methods: {
navigateToScenery(name: string, isOnline: boolean) { toggleExtraInfo(id: number) {
if (!isOnline) return; const existingIdx = this.extraInfoIndexes.indexOf(id);
this.$router.push(`/scenery?station=${name.trim().replace(/ /g, '_')}`); if (existingIdx != -1) this.extraInfoIndexes.splice(existingIdx, 1);
}, else this.extraInfoIndexes.push(id);
isAnotherDay(prevIndex: number, currIndex: number) {
if (currIndex == 0) return true;
return (
new Date(this.dispatcherHistory[prevIndex].timestampFrom).getDate() !=
new Date(this.dispatcherHistory[currIndex].timestampFrom).getDate()
);
} }
} }
}); });
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
@import '../../../styles/animations.scss';
@import '../../../styles/responsive.scss';
@import '../../../styles/badge.scss';
@import '../../../styles/variables.scss'; @import '../../../styles/variables.scss';
@import '../../../styles/JournalSection.scss'; @import '../../../styles/JournalSection.scss';
table.dispatchers-table { .journal-list {
--_bg-table: #111; display: flex;
--_bg-head: #101010; flex-direction: column;
--_bg-row: #2f2f2f; gap: 0.5em;
text-align: left;
width: 100%;
border-collapse: collapse;
position: relative;
text-align: center;
margin-bottom: 1em;
thead {
position: sticky;
top: 0;
background-color: var(--_bg-head);
}
th {
padding: 0.5em;
}
tr {
background-color: var(--_bg-row);
border-bottom: 2px solid black;
&:last-child {
border: none;
}
}
td {
padding: 0.75em;
.level-badge {
margin: 0 auto;
}
}
}
.text {
&--online {
color: springgreen;
}
&--offline {
color: #ddd;
}
} }
</style> </style>
@@ -26,7 +26,8 @@
<strong <strong
v-if="apiStore.donatorsData.includes(timetable.driverName)" v-if="apiStore.donatorsData.includes(timetable.driverName)"
class="text--donator" class="text--donator"
:title="$t('donations.driver-message')" data-tooltip-type="DonatorTooltip"
:data-tooltip-content="$t('donations.driver-message')"
> >
{{ timetable.driverName }} {{ timetable.driverName }}
</strong> </strong>
@@ -1,101 +0,0 @@
<template>
<ul class="journal-list">
<transition-group name="list-anim">
<li
v-for="{ timetable, showExtraInfo } in computedTimetableHistory"
class="journal_item"
:key="timetable.id"
@click="showExtraInfo.value = !showExtraInfo.value"
>
<div class="journal_item-info">
<!-- General -->
<TimetableGeneral :timetable="timetable" />
<!-- Route -->
<span class="item-route">
<b>{{ timetable.route.replace('|', ' - ') }}</b>
</span>
<hr />
<!-- Stops -->
<TimetableStops :timetable="timetable" :showExtraInfo="showExtraInfo.value" />
<!-- Status -->
<TimetableStatus :timetable="timetable" />
<button class="btn--action btn--show">
{{ $t('journal.stock-info') }}
<img
:src="`/images/icon-arrow-${showExtraInfo.value ? 'asc' : 'desc'}.svg`"
alt="Arrow icon"
/>
</button>
<!-- Extra -->
<TimetableExtra :timetable="timetable" :showExtraInfo="showExtraInfo.value" />
</div>
</li>
</transition-group>
</ul>
</template>
<script lang="ts">
import { PropType, defineComponent, ref } from 'vue';
import TimetableGeneral from './TimetableGeneral.vue';
import TimetableStops from './TimetableStops.vue';
import TimetableStatus from './TimetableStatus.vue';
import TimetableExtra from './TimetableExtra.vue';
import { API } from '../../../typings/api';
export default defineComponent({
components: { TimetableGeneral, TimetableStops, TimetableStatus, TimetableExtra },
props: {
timetableHistory: {
type: Array as PropType<API.TimetableHistory.Response>,
required: true
}
},
computed: {
computedTimetableHistory() {
return this.timetableHistory.map((timetable) => ({
timetable,
showExtraInfo: ref(false)
}));
}
}
});
</script>
<style lang="scss" scoped>
@import '../../../styles/variables';
@import '../../../styles/responsive';
@import '../../../styles/JournalSection';
.btn--show {
display: flex;
font-weight: bold;
padding: 0.2em 0.45em;
img {
height: 1.3em;
}
}
hr {
margin: 0.25em 0;
}
@include smallScreen {
.journal_item-info {
text-align: center;
}
.item-route {
display: flex;
justify-content: center;
}
.btn--show {
margin: 1em auto 0 auto;
}
}
</style>
@@ -1,23 +1,41 @@
<template> <template>
<div class="stop-list" v-if="showExtraInfo == true"> <div class="timetable-stops">
<span <div class="stop-list">
v-for="(stop, i) in timetableStops.filter((_, i) => <span
!showExtraInfo ? i == 0 || i == timetableStops.length - 1 : true v-for="(stop, i) in timetableStops.filter((_, i) =>
)" !showExtraInfo ? i == 0 || i == timetableStops.length - 1 : true
class="stop-list-item" )"
:key="stop.stopName" class="stop-list-item"
:data-confirmed="stop.confirmed" :key="stop.stopName"
> :data-confirmed="stop.confirmed"
<span v-if="i > 0"> >
&gt; <span v-if="i > 0">
<span v-if="!showExtraInfo && i == 1 && timetableStops.length > 2"> &gt;
... (+{{ timetableStops.length - 2 }}) &gt; <span v-if="!showExtraInfo && i == 1 && timetableStops.length > 2">
... (+{{ timetableStops.length - 2 }}) &gt;
</span>
</span>
<span class="stop-name">{{ stop.stopName }}</span>
<span v-html="stop.html"></span>
</span>
</div>
<div class="path-details" v-if="showExtraInfo && timetablePathDetails">
<span
v-for="(pathData, i) in timetablePathDetails"
:data-visited="pathData.isVisited"
:data-next-visited="
i < timetablePathDetails.length - 1 && timetablePathDetails[i + 1].isVisited
"
>
<span class="path-arrival" v-if="pathData.arrival">/ {{ pathData.arrival }} &RightArrow; </span>
<b class="path-scenery">{{ pathData.sceneryName }}</b>
<span class="path-departure" v-if="pathData.departure">
&RightArrow; {{ pathData.departure }}&nbsp;
</span> </span>
</span> </span>
</div>
<span class="stop-name">{{ stop.stopName }}</span>
<span v-html="stop.html"></span>
</span>
</div> </div>
</template> </template>
@@ -42,6 +60,24 @@ export default defineComponent({
}, },
computed: { computed: {
timetablePathDetails() {
if (!this.timetable.path || this.timetable.path == '') return null;
return this.timetable.path.split(';').map((pathEl, i) => {
const [arrival, name, departure] = pathEl.split(',');
const sceneryName = name.split(' ').slice(0, -1).join(' ');
const sceneryHash = name.split(' ').pop()?.replace('.sc', '') ?? '';
return {
arrival,
sceneryName,
sceneryHash,
departure,
isVisited: this.timetable.visitedSceneries?.includes(sceneryHash) ?? false
};
});
},
timetableStops() { timetableStops() {
const timetable = this.timetable; const timetable = this.timetable;
@@ -94,13 +130,14 @@ export default defineComponent({
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
.stop-list { .timetable-stops {
word-wrap: break-word; word-wrap: break-word;
gap: 0.25em; gap: 0.25em;
font-size: 0.95em; font-size: 0.95em;
color: #adadad; color: #adadad;
}
.stop-list {
&-item[data-confirmed='true'] { &-item[data-confirmed='true'] {
color: lightgreen; color: lightgreen;
@@ -109,4 +146,19 @@ export default defineComponent({
} }
} }
} }
.path-details {
margin-top: 0.5em;
}
.path-details > span[data-visited='true'] {
.path-arrival,
.path-scenery {
color: lightgreen;
}
&[data-next-visited='true'] .path-departure {
color: lightgreen;
}
}
</style> </style>
@@ -7,7 +7,7 @@
{{ $t('scenery.history-list-empty') }} {{ $t('scenery.history-list-empty') }}
</div> </div>
<div v-else class="history-list"> <div v-else class="journal-list">
<div v-for="historyItem in historyList" :key="historyItem.id"> <div v-for="historyItem in historyList" :key="historyItem.id">
<span> <span>
<span class="text--grayed" style="margin-right: 10px"> <span class="text--grayed" style="margin-right: 10px">
@@ -165,14 +165,14 @@ export default defineComponent({
overflow: auto; overflow: auto;
} }
.history-list { .journal-list {
display: flex; display: flex;
flex-direction: column; flex-direction: column;
gap: 0.5em; gap: 0.5em;
text-align: left; text-align: left;
} }
.history-list > div { .journal-list > div {
display: flex; display: flex;
justify-content: space-between; justify-content: space-between;
align-items: center; align-items: center;
@@ -195,7 +195,7 @@ export default defineComponent({
} }
@include smallScreen { @include smallScreen {
.history-list > div { .journal-list > div {
flex-direction: column; flex-direction: column;
justify-content: center; justify-content: center;
text-align: center; text-align: center;
@@ -238,11 +238,12 @@ export default defineComponent({
sceneryTimetables(): SceneryTimetableRow[] { sceneryTimetables(): SceneryTimetableRow[] {
if (!this.onlineScenery) return []; if (!this.onlineScenery) return [];
const sceneryName = this.$route.query['station']?.toString() ?? ''; const sceneryName = this.$route.query['station']?.toString().replace(/_/g, ' ') ?? '';
return this.onlineScenery.scheduledTrains return this.onlineScenery.scheduledTrains
.filter( .filter(
(ct) => (ct) =>
ct.timetablePathElement.stationName == sceneryName &&
ct.train.region == this.mainStore.region.id && ct.train.region == this.mainStore.region.id &&
this.chosenCheckpoint && this.chosenCheckpoint &&
ct.checkpointStop.stopNameRAW.toLowerCase() == this.chosenCheckpoint.toLowerCase() ct.checkpointStop.stopNameRAW.toLowerCase() == this.chosenCheckpoint.toLowerCase()
@@ -251,75 +252,18 @@ export default defineComponent({
const trainStopStatus = getTrainStopStatus( const trainStopStatus = getTrainStopStatus(
ct.checkpointStop, ct.checkpointStop,
ct.train.currentStationName, ct.train.currentStationName,
sceneryName.replace(/_/g, ' ') sceneryName
); );
const trainStopIndex =
ct.train.timetableData?.followingStops.findIndex(
(stop) => stop.stopName == ct.checkpointStop.stopName
) ?? -1;
let prevStationName = '',
nextStationName = '';
let departureLine: string | null = null;
let arrivingLine: string | null = null;
let prevDepartureLine: string | null = null,
nextArrivalLine: string | null = null;
if (trainStopIndex > -1 && ct.train.timetableData?.followingStops !== undefined) {
for (let i = trainStopIndex; i >= 0; i--) {
const stop = ct.train.timetableData.followingStops[i];
if (
/strong|podg\.|pe\./g.test(stop.stopName) &&
!prevStationName &&
i <= trainStopIndex - 1
)
prevStationName = stop.stopNameRAW.replace(/,.*/g, '');
if (
stop.arrivalLine != null &&
!arrivingLine &&
!/-|_|it|sbl/gi.test(stop.arrivalLine)
) {
arrivingLine = stop.arrivalLine;
prevDepartureLine =
ct.train.timetableData.followingStops[i - 1]?.departureLine || null;
}
}
for (let i = trainStopIndex; i < ct.train.timetableData.followingStops.length; i++) {
const stop = ct.train.timetableData.followingStops[i];
if (
/strong|podg\.|pe\./g.test(stop.stopName) &&
!nextStationName &&
i > trainStopIndex
)
nextStationName = stop.stopNameRAW.replace(/,.*/g, '');
if (
stop.departureLine &&
!departureLine &&
!/-|_|it|sbl/gi.test(stop.departureLine)
) {
departureLine = stop.departureLine;
nextArrivalLine = ct.train.timetableData.followingStops[i + 1]?.arrivalLine || null;
}
}
}
return { return {
checkpointStop: ct.checkpointStop, checkpointStop: ct.checkpointStop,
train: ct.train, train: ct.train,
prevDepartureLine, prevDepartureLine: ct.previousSceneryElement?.departureRouteExt ?? null,
nextArrivalLine, nextArrivalLine: ct.nextSceneryElement?.arrivalRouteExt ?? null,
departureLine, departureLine: ct.timetablePathElement.departureRouteExt ?? null,
arrivingLine, arrivingLine: ct.timetablePathElement.arrivalRouteExt ?? null,
prevStationName, prevStationName: ct.previousSceneryElement?.stationName ?? null,
nextStationName, nextStationName: ct.nextSceneryElement?.stationName ?? null,
status: trainStopStatus status: trainStopStatus
}; };
}) })
@@ -19,7 +19,7 @@
{{ $t('scenery.history-list-empty') }} {{ $t('scenery.history-list-empty') }}
</div> </div>
<div v-else class="history-list"> <div v-else class="journal-list">
<div v-for="timetableHistory in historyList" :key="timetableHistory.id"> <div v-for="timetableHistory in historyList" :key="timetableHistory.id">
<span> <span>
<div> <div>
@@ -219,14 +219,14 @@ export default defineComponent({
} }
} }
.history-list { .journal-list {
display: flex; display: flex;
flex-direction: column; flex-direction: column;
gap: 0.5em; gap: 0.5em;
text-align: left; text-align: left;
} }
.history-list > div { .journal-list > div {
display: flex; display: flex;
justify-content: space-between; justify-content: space-between;
align-items: center; align-items: center;
@@ -235,7 +235,7 @@ export default defineComponent({
line-height: 1.5em; line-height: 1.5em;
} }
.history-list > div > button > img { .journal-list > div > button > img {
width: 2em; width: 2em;
transform: rotate(180deg); transform: rotate(180deg);
} }
@@ -50,7 +50,7 @@ export default defineComponent({
}, },
watch: { watch: {
'tooltipStore.type'(prev, val) { vehicleName(prev, val) {
if (prev != val) this.imageState = 'loading'; if (prev != val) this.imageState = 'loading';
} }
}, },
@@ -81,18 +81,6 @@ export default defineComponent({
(c) => c.id == this.tooltipStore.content.split(':')[1] (c) => c.id == this.tooltipStore.content.split(':')[1]
); );
} }
// vehicleProps() {
// const vehicleDataArray = this.apiStore.vehiclesData?.vehicleList.find(
// ([name]) => name === this.vehicleName
// );
// if (!vehicleDataArray) return null;
// return (
// this.apiStore.vehiclesData!.vehicleProps.find((v) => v.type == vehicleDataArray[1]) ?? null
// );
// }
} }
}); });
</script> </script>
+46 -42
View File
@@ -8,15 +8,9 @@
<span <span
v-if="stop.position != 'begin'" v-if="stop.position != 'begin'"
class="date arrival" class="date arrival"
:data-status=" :data-status-delayed="stop.arrivalDelay > 0"
stop.arrivalDelay > 0 && stop.status != 'unconfirmed' :data-status-preponed="stop.arrivalDelay < 0"
? 'delayed' :data-status="stop.status"
: stop.arrivalDelay < 0 && stop.status != 'unconfirmed'
? 'preponed'
: stop.arrivalDelay == 0 && stop.status == 'confirmed'
? 'on-time'
: ''
"
> >
p. p.
<span v-if="stop.arrivalDelay != 0 && stop.status != 'unconfirmed'"> <span v-if="stop.arrivalDelay != 0 && stop.status != 'unconfirmed'">
@@ -31,10 +25,7 @@
</span> </span>
<span <span
v-if=" v-if="stop.duration"
stop.duration ||
(stop.status == 'stopped' && stop.position != 'begin' && stop.departureDelay > 0)
"
class="date stop" class="date stop"
:data-stop-types="stop.type.replace(', ', '-')" :data-stop-types="stop.type.replace(', ', '-')"
:data-stop-status="stop.departureDelay > 0 && !stop.duration ? 'delayed' : ''" :data-stop-status="stop.departureDelay > 0 && !stop.duration ? 'delayed' : ''"
@@ -53,20 +44,12 @@
(stop.duration != 0 || stop.status == 'stopped' || stop.departureDelay != stop.arrivalDelay) (stop.duration != 0 || stop.status == 'stopped' || stop.departureDelay != stop.arrivalDelay)
" "
class="date departure" class="date departure"
:data-status=" :data-status-delayed="stop.departureDelay > 0"
stop.departureDelay > 0 && stop.status == 'confirmed' :data-status-preponed="stop.departureDelay < 0"
? 'delayed' :data-status-confirmed="stop.status == 'confirmed'"
: stop.departureDelay < 0 && stop.status == 'confirmed'
? 'preponed'
: stop.departureDelay == 0 && stop.status == 'confirmed'
? 'on-time'
: ''
"
> >
o. o.
<span <span v-if="stop.departureDelay != 0 && stop.status == 'confirmed'">
v-if="stop.departureDelay != 0 && (stop.status == 'confirmed' || stop.status == 'stopped')"
>
<s>{{ timestampToString(stop.departureScheduled) }}</s> <s>{{ timestampToString(stop.departureScheduled) }}</s>
{{ timestampToString(stop.departureReal) }} {{ timestampToString(stop.departureReal) }}
@@ -105,6 +88,10 @@ $stopExchangeClr: #db8e29;
$stopDefaultClr: #252525; $stopDefaultClr: #252525;
$stopNameClr: #303030; $stopNameClr: #303030;
s {
color: #ccc;
}
.stop-label { .stop-label {
display: flex; display: flex;
flex-wrap: wrap; flex-wrap: wrap;
@@ -157,27 +144,44 @@ $stopNameClr: #303030;
color: $delayedClr; color: $delayedClr;
} }
} }
}
.arrival, .stop .arrival {
.departure { &[data-status='confirmed'][data-status-delayed='true'] {
&[data-status='delayed'] { span {
s { color: $delayedClr;
color: #ccc;
}
span {
color: $delayedClr;
}
} }
}
&[data-status='preponed'] { &[data-status='confirmed'][data-status-preponed='true'] {
s { span {
color: #ccc; color: $preponedClr;
} }
}
span { &[data-status='stopped'][data-status-preponed='true'] {
color: $preponedClr; span {
} color: $preponedClr;
}
}
&[data-status='stopped'][data-status-delayed='true'] {
span {
color: $delayedClr;
}
}
}
.stop .departure[data-status-confirmed='true'] {
&[data-status-delayed='true'] {
span {
color: $delayedClr;
}
}
&[data-status-preponed='true'] {
span {
color: $preponedClr;
} }
} }
} }
+12 -9
View File
@@ -108,16 +108,19 @@ export default defineComponent({
}, },
currentDelay(stops: TrainStop[]) { currentDelay(stops: TrainStop[]) {
const delay = const lastConfirmedStop = stops.find(
stops.find( (stop, i) =>
(stop, i) => (i == 0 && !stop.confirmed) ||
(i == 0 && !stop.confirmed) || (i > 0 && stops[i - 1].confirmed && !stop.confirmed) (i > 0 && stops[i - 1].confirmed && !stop.confirmed) ||
)?.departureDelay || 0; (stops[i + 1] == undefined && stop.confirmed)
);
if (delay > 0) const lastDelay = lastConfirmedStop?.departureDelay ?? lastConfirmedStop?.arrivalDelay ?? 0;
return `<span style='color: salmon'>${this.$t('trains.delayed')} ${delay} min</span>`;
else if (delay < 0) if (lastDelay > 0)
return `<span style='color: lightgreen'>${this.$t('trains.preponed')} ${delay} min</span>`; return `<span style='color: salmon'>${this.$t('trains.delayed')} ${lastDelay} min</span>`;
else if (lastDelay < 0)
return `<span style='color: lightgreen'>${this.$t('trains.preponed')} ${lastDelay} min</span>`;
else return this.$t('trains.on-time'); else return this.$t('trains.on-time');
}, },
+22 -11
View File
@@ -18,7 +18,7 @@ export const useApiStore = defineStore('apiStore', {
donatorsData: [] as API.Donators.Response, donatorsData: [] as API.Donators.Response,
sceneryData: [] as StationJSONData[], sceneryData: [] as StationJSONData[],
lastFetchData: new Date(), nextUpdateTime: 0,
client: undefined as AxiosInstance | undefined, client: undefined as AxiosInstance | undefined,
@@ -52,20 +52,32 @@ export const useApiStore = defineStore('apiStore', {
this.fetchDonatorsData(); this.fetchDonatorsData();
this.fetchStationsGeneralInfo(); this.fetchStationsGeneralInfo();
this.fetchVehiclesInfo(); this.fetchVehiclesInfo();
window.requestAnimationFrame(this.updateTick);
},
updateTick(t: number) {
if (this.dataStatuses.connection == Status.Data.Offline) return;
if (t >= this.nextUpdateTime) {
this.fetchActiveData();
this.nextUpdateTime = t + 20000;
}
window.requestAnimationFrame(this.updateTick);
}, },
async fetchActiveData() { async fetchActiveData() {
if (import.meta.env.VITE_API_ACTIVE_DATA_MODE == 'mocking') { // if (import.meta.env.VITE_API_ACTIVE_DATA_MODE == 'mocking') {
import('../../tests/data/getActiveData.json').then((data) => { // import('../../tests/data/getActiveData.json').then((data) => {
console.warn('activeData: mocking mode'); // console.warn('activeData: mocking mode');
this.activeData = data.default as API.ActiveData.Response; // this.activeData = data.default as API.ActiveData.Response;
this.lastFetchData = new Date();
this.dataStatuses.connection = Status.Data.Loaded; // this.dataStatuses.connection = Status.Data.Loaded;
}); // });
return; // return;
} // }
if (!this.activeData) this.dataStatuses.connection = Status.Data.Loading; if (!this.activeData) this.dataStatuses.connection = Status.Data.Loading;
@@ -73,7 +85,6 @@ export const useApiStore = defineStore('apiStore', {
const response = await this.client!.get<API.ActiveData.Response>('api/getActiveData'); const response = await this.client!.get<API.ActiveData.Response>('api/getActiveData');
this.activeData = response.data; this.activeData = response.data;
this.lastFetchData = new Date();
this.dataStatuses.connection = Status.Data.Loaded; this.dataStatuses.connection = Status.Data.Loaded;
} catch (error) { } catch (error) {
this.dataStatuses.connection = Status.Data.Error; this.dataStatuses.connection = Status.Data.Error;
+47 -17
View File
@@ -96,7 +96,17 @@ export const useMainStore = defineStore('mainStore', {
followingStops: timetable.stopList, followingStops: timetable.stopList,
routeDistance: timetable.stopList[timetable.stopList.length - 1].stopDistance, routeDistance: timetable.stopList[timetable.stopList.length - 1].stopDistance,
sceneries: timetable.sceneries, sceneries: timetable.sceneries,
sceneryNames: sceneryNames.reverse() sceneryNames: sceneryNames.reverse(),
timetablePath: timetable.path.split(';').map((pathElementString) => {
const [arrival, station, departure] = pathElementString.split(',');
return {
arrivalRouteExt: arrival,
departureRouteExt: departure,
stationName: station.split(' ').slice(0, -1).join(' '),
stationHash: station.split(' ').slice(-1).join(' ')
};
})
} }
: undefined : undefined
} as Train; } as Train;
@@ -110,21 +120,39 @@ export const useMainStore = defineStore('mainStore', {
} else sceneriesTrains.set(train.currentStationName, [trainObj]); } else sceneriesTrains.set(train.currentStationName, [trainObj]);
// Checkpoints trains map // Checkpoints trains map
timetable?.stopList.forEach((stop, i) => { if (trainObj.timetableData) {
if (/strong|podg\.|pe\./.test(stop.stopName)) { let currentSceneryIndex = 0;
const checkpointTrain: CheckpointTrain = { const timetablePath = trainObj.timetableData.timetablePath;
train: trainObj,
checkpointStop: stop
};
if (checkpointsTrains.has(stop.stopNameRAW.toLowerCase())) { trainObj.timetableData.followingStops.forEach((stop, i) => {
checkpointsTrains.set(stop.stopNameRAW.toLowerCase(), [ if (/strong|podg|pe/.test(stop.stopName)) {
...checkpointsTrains.get(stop.stopNameRAW.toLowerCase())!, const checkpointTrain: CheckpointTrain = {
checkpointTrain train: trainObj,
]); checkpointStop: stop,
} else checkpointsTrains.set(stop.stopNameRAW.toLowerCase(), [checkpointTrain]);
} previousSceneryElement:
}); currentSceneryIndex > 0 ? timetablePath[currentSceneryIndex - 1] : null,
nextSceneryElement:
currentSceneryIndex < timetablePath.length - 1
? timetablePath[currentSceneryIndex + 1]
: null,
timetablePathElement: timetablePath[currentSceneryIndex]
};
if (checkpointsTrains.has(stop.stopNameRAW.toLowerCase())) {
checkpointsTrains.set(stop.stopNameRAW.toLowerCase(), [
...checkpointsTrains.get(stop.stopNameRAW.toLowerCase())!,
checkpointTrain
]);
} else checkpointsTrains.set(stop.stopNameRAW.toLowerCase(), [checkpointTrain]);
}
if (timetablePath[currentSceneryIndex].departureRouteExt == stop.departureLine)
currentSceneryIndex++;
});
}
return trainObj; return trainObj;
}); });
@@ -252,8 +280,10 @@ export const useMainStore = defineStore('mainStore', {
if (!scheduledTrains) return; if (!scheduledTrains) return;
scheduledTrains.forEach(({ train, checkpointStop }) => { scheduledTrains.forEach(({ train, checkpointStop, timetablePathElement, ...v }) => {
scenery.scheduledTrains.push({ train, checkpointStop }); if (scenery.name != timetablePathElement.stationName) return;
scenery.scheduledTrains.push({ train, checkpointStop, timetablePathElement, ...v });
if (uniqueTrainIds.includes(train.id) || train.region != this.region.id) return; if (uniqueTrainIds.includes(train.id) || train.region != this.region.id) return;
+5 -5
View File
@@ -24,7 +24,7 @@ export namespace API {
export type Response = Data[]; export type Response = Data[];
export interface Data { export interface Data {
id: string; id: number;
currentDuration: number; currentDuration: number;
dispatcherId: number; dispatcherId: number;
dispatcherName: string; dispatcherName: string;
@@ -195,6 +195,8 @@ export namespace API {
TWR: boolean; TWR: boolean;
SKR: boolean; SKR: boolean;
sceneries: string[]; sceneries: string[];
path: string;
} }
} }
@@ -249,16 +251,14 @@ export namespace API {
hashesString?: string; hashesString?: string;
currentSceneryName?: string; currentSceneryName?: string;
currentSceneryHash?: string; currentSceneryHash?: string;
routeSceneries?: string; routeSceneries?: string;
checkpointArrivals?: string[]; checkpointArrivals?: string[];
checkpointDepartures?: string[]; checkpointDepartures?: string[];
checkpointArrivalsScheduled?: string[]; checkpointArrivalsScheduled?: string[];
checkpointDeparturesScheduled?: string[]; checkpointDeparturesScheduled?: string[];
checkpointStopTypes?: string[]; checkpointStopTypes?: string[];
visitedSceneries?: string[];
path: string;
} }
export type Response = Data[]; export type Response = Data[];
+11
View File
@@ -39,6 +39,13 @@ export interface RegionCounters {
timetablesCount: number; timetablesCount: number;
} }
export interface TimetablePathElement {
arrivalRouteExt?: string;
departureRouteExt?: string;
stationName: string;
stationHash: string;
}
export interface Train { export interface Train {
id: string; id: string;
modalId: string; modalId: string;
@@ -73,6 +80,7 @@ export interface Train {
routeDistance: number; routeDistance: number;
sceneries: string[]; sceneries: string[];
sceneryNames: string[]; sceneryNames: string[];
timetablePath: TimetablePathElement[];
}; };
} }
@@ -188,6 +196,9 @@ export interface TrainStop {
export interface CheckpointTrain { export interface CheckpointTrain {
checkpointStop: TrainStop; checkpointStop: TrainStop;
train: Train; train: Train;
timetablePathElement: TimetablePathElement;
previousSceneryElement: TimetablePathElement | null;
nextSceneryElement: TimetablePathElement | null;
} }
// Vehicles Data // Vehicles Data
File diff suppressed because one or more lines are too long
+518 -876
View File
File diff suppressed because it is too large Load Diff