obsługa niezaładowanych miniaturek pojazdów
|
Before Width: | Height: | Size: 932 B After Width: | Height: | Size: 932 B |
|
Before Width: | Height: | Size: 953 B After Width: | Height: | Size: 953 B |
|
Before Width: | Height: | Size: 1.3 KiB After Width: | Height: | Size: 1.3 KiB |
|
Before Width: | Height: | Size: 1.6 KiB After Width: | Height: | Size: 1.6 KiB |
|
Before Width: | Height: | Size: 1020 B After Width: | Height: | Size: 1020 B |
|
After Width: | Height: | Size: 953 B |
@@ -0,0 +1,61 @@
|
|||||||
|
<template>
|
||||||
|
<img :src="url" loading="lazy" alt="Loco image not found" @error="onImageError" />
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script lang="ts">
|
||||||
|
import { defineComponent } from 'vue';
|
||||||
|
import imageMixin from '../../mixins/imageMixin';
|
||||||
|
import { useStore } from '../../store/store';
|
||||||
|
import { RollingStockInfo } from '../../scripts/interfaces/github_api/StockInfoGithubData';
|
||||||
|
|
||||||
|
export default defineComponent({
|
||||||
|
mixins: [imageMixin],
|
||||||
|
|
||||||
|
props: {
|
||||||
|
name: {
|
||||||
|
type: String,
|
||||||
|
required: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
store: useStore(),
|
||||||
|
};
|
||||||
|
},
|
||||||
|
|
||||||
|
computed: {
|
||||||
|
url() {
|
||||||
|
return `https://rj.td2.info.pl/dist/img/thumbnails/${this.name.split(':')[0]}.png`;
|
||||||
|
},
|
||||||
|
|
||||||
|
stockType() {
|
||||||
|
if (!this.store.rollingStockData) return 'unknown';
|
||||||
|
|
||||||
|
return (
|
||||||
|
Object.keys(this.store.rollingStockData.info).find((type) => {
|
||||||
|
return this.store.rollingStockData?.info[type as keyof RollingStockInfo].find((v) => v[0] === this.name.split(':')[0]);
|
||||||
|
}) || 'unknown'
|
||||||
|
);
|
||||||
|
},
|
||||||
|
},
|
||||||
|
|
||||||
|
methods: {
|
||||||
|
onImageError(e: Event) {
|
||||||
|
const imageEl = e.target as HTMLImageElement;
|
||||||
|
imageEl.src = this.getImage(`icon-${this.stockType}.png`);
|
||||||
|
},
|
||||||
|
},
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style lang="scss" scoped>
|
||||||
|
.wrapper {
|
||||||
|
display: flex;
|
||||||
|
justify-content: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
img {
|
||||||
|
display: inline-block;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
@@ -60,11 +60,7 @@
|
|||||||
).split(';')"
|
).split(';')"
|
||||||
:key="i"
|
:key="i"
|
||||||
>
|
>
|
||||||
<img
|
<TrainThumbnail :name="car" />
|
||||||
@error="onImageError"
|
|
||||||
:src="`https://rj.td2.info.pl/dist/img/thumbnails/${car.split(':')[0]}.png`"
|
|
||||||
:alt="car"
|
|
||||||
/>
|
|
||||||
<div>{{ car.replace(/_/g, ' ').split(':')[0] }}</div>
|
<div>{{ car.replace(/_/g, ' ').split(':')[0] }}</div>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
@@ -75,28 +71,25 @@
|
|||||||
import { PropType, defineComponent } from 'vue';
|
import { PropType, defineComponent } from 'vue';
|
||||||
import { TimetableHistory } from '../../../scripts/interfaces/api/TimetablesAPIData';
|
import { TimetableHistory } from '../../../scripts/interfaces/api/TimetablesAPIData';
|
||||||
import imageMixin from '../../../mixins/imageMixin';
|
import imageMixin from '../../../mixins/imageMixin';
|
||||||
|
import TrainThumbnail from '../../Global/TrainThumbnail.vue';
|
||||||
|
|
||||||
export default defineComponent({
|
export default defineComponent({
|
||||||
mixins: [imageMixin],
|
mixins: [imageMixin],
|
||||||
|
|
||||||
props: {
|
props: {
|
||||||
showExtraInfo: {
|
showExtraInfo: {
|
||||||
type: Boolean,
|
type: Boolean,
|
||||||
required: true,
|
required: true,
|
||||||
},
|
},
|
||||||
|
|
||||||
timetable: {
|
timetable: {
|
||||||
type: Object as PropType<TimetableHistory>,
|
type: Object as PropType<TimetableHistory>,
|
||||||
required: true,
|
required: true,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
currentHistoryIndex: 0,
|
currentHistoryIndex: 0,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
|
||||||
computed: {
|
computed: {
|
||||||
stockHistory() {
|
stockHistory() {
|
||||||
return this.timetable.stockHistory
|
return this.timetable.stockHistory
|
||||||
@@ -116,13 +109,13 @@ export default defineComponent({
|
|||||||
});
|
});
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
methods: {
|
methods: {
|
||||||
onImageError(e: Event) {
|
onImageError(e: Event) {
|
||||||
const imageEl = e.target as HTMLImageElement;
|
const imageEl = e.target as HTMLImageElement;
|
||||||
imageEl.src = this.getImage('unknown.png');
|
imageEl.src = this.getImage('unknown.png');
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
components: { TrainThumbnail },
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|||||||
@@ -62,15 +62,13 @@
|
|||||||
</section>
|
</section>
|
||||||
|
|
||||||
<section class="train-stats">
|
<section class="train-stats">
|
||||||
<div>
|
<TrainThumbnail :name="train.locoType" />
|
||||||
<img :src="train.locoURL" loading="lazy" alt="Loco image not found" @error="onImageError" />
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="text--grayed">
|
<div class="text--grayed">
|
||||||
{{ train.locoType }}
|
{{ train.locoType }}
|
||||||
<span v-if="train.cars.length > 0">
|
<span v-if="train.stockList.length > 0">
|
||||||
• {{ $t('trains.cars') }}:
|
• {{ $t('trains.cars') }}:
|
||||||
<span class="count">{{ train.cars.length }}</span>
|
<span class="count">{{ train.stockList.length }}</span>
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -91,6 +89,7 @@ import styleMixin from '../../mixins/styleMixin';
|
|||||||
import trainInfoMixin from '../../mixins/trainInfoMixin';
|
import trainInfoMixin from '../../mixins/trainInfoMixin';
|
||||||
import Train from '../../scripts/interfaces/Train';
|
import Train from '../../scripts/interfaces/Train';
|
||||||
import ProgressBar from '../Global/ProgressBar.vue';
|
import ProgressBar from '../Global/ProgressBar.vue';
|
||||||
|
import TrainThumbnail from '../Global/TrainThumbnail.vue';
|
||||||
|
|
||||||
export default defineComponent({
|
export default defineComponent({
|
||||||
props: {
|
props: {
|
||||||
@@ -104,7 +103,7 @@ export default defineComponent({
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
mixins: [trainInfoMixin, imageMixin, styleMixin],
|
mixins: [trainInfoMixin, imageMixin, styleMixin],
|
||||||
components: { ProgressBar },
|
components: { ProgressBar, TrainThumbnail },
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
@@ -127,7 +126,7 @@ export default defineComponent({
|
|||||||
text-align: center;
|
text-align: center;
|
||||||
|
|
||||||
img {
|
img {
|
||||||
margin: 0.5em 0;
|
margin: 0.5em auto;
|
||||||
width: 12em;
|
width: 12em;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,12 +2,12 @@
|
|||||||
<div class="train-schedule" @click="toggleShowState">
|
<div class="train-schedule" @click="toggleShowState">
|
||||||
<div class="train-stock">
|
<div class="train-stock">
|
||||||
<ul class="stock-list">
|
<ul class="stock-list">
|
||||||
<li>
|
<!-- <li>
|
||||||
<img class="train-image" :src="train.locoURL" alt="loco" @error="onImageError" />
|
<img class="train-image" :src="train.locoURL" alt="loco" @error="onImageError" />
|
||||||
<div>{{ train.locoType }}</div>
|
<div>{{ train.locoType }}</div>
|
||||||
</li>
|
</li> -->
|
||||||
|
|
||||||
<li v-if="train.locoType.startsWith('EN')">
|
<!-- <li v-if="train.locoType.startsWith('EN')">
|
||||||
<img :src="train.locoURL.replace('rb', 's')" @error="onImageError" alt="" />
|
<img :src="train.locoURL.replace('rb', 's')" @error="onImageError" alt="" />
|
||||||
<div>{{ train.locoType }}S</div>
|
<div>{{ train.locoType }}S</div>
|
||||||
</li>
|
</li>
|
||||||
@@ -20,16 +20,17 @@
|
|||||||
<li v-if="train.locoType.startsWith('EN')">
|
<li v-if="train.locoType.startsWith('EN')">
|
||||||
<img :src="train.locoURL.replace('rb', 'ra')" @error="onImageError" alt="" />
|
<img :src="train.locoURL.replace('rb', 'ra')" @error="onImageError" alt="" />
|
||||||
<div>{{ train.locoType }}RA</div>
|
<div>{{ train.locoType }}RA</div>
|
||||||
</li>
|
</li> -->
|
||||||
|
|
||||||
<li v-for="(car, i) in train.cars" :key="i">
|
<li v-for="(stockName, i) in train.stockList" :key="i">
|
||||||
<img
|
<!-- <img
|
||||||
:src="`https://rj.td2.info.pl/dist/img/thumbnails/${car.split(':')[0]}.png`"
|
:src="`https://rj.td2.info.pl/dist/img/thumbnails/${car.split(':')[0]}.png`"
|
||||||
@error="onImageError"
|
@error="onImageError"
|
||||||
alt="car"
|
alt="car"
|
||||||
/>
|
/> -->
|
||||||
|
|
||||||
<div>{{ car.replace(/_/g, ' ').split(':')[0] }}</div>
|
<TrainThumbnail :name="stockName" />
|
||||||
|
<div>{{ stockName.replace(/_/g, ' ').split(':')[0] }}</div>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
@@ -91,9 +92,10 @@ import Train from '../../scripts/interfaces/Train';
|
|||||||
import TrainStop from '../../scripts/interfaces/TrainStop';
|
import TrainStop from '../../scripts/interfaces/TrainStop';
|
||||||
import { useStore } from '../../store/store';
|
import { useStore } from '../../store/store';
|
||||||
import StopDate from '../Global/StopDate.vue';
|
import StopDate from '../Global/StopDate.vue';
|
||||||
|
import TrainThumbnail from '../Global/TrainThumbnail.vue';
|
||||||
|
|
||||||
export default defineComponent({
|
export default defineComponent({
|
||||||
components: { StopDate },
|
components: { StopDate, TrainThumbnail },
|
||||||
props: {
|
props: {
|
||||||
train: {
|
train: {
|
||||||
type: Object as PropType<Train>,
|
type: Object as PropType<Train>,
|
||||||
@@ -426,4 +428,3 @@ ul.stop_list > li.stop {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
|
|||||||
@@ -15,12 +15,11 @@ export default interface Train {
|
|||||||
driverLevel: number;
|
driverLevel: number;
|
||||||
currentStationName: string;
|
currentStationName: string;
|
||||||
currentStationHash: string;
|
currentStationHash: string;
|
||||||
locoURL: string;
|
|
||||||
locoType: string;
|
locoType: string;
|
||||||
online: boolean;
|
online: boolean;
|
||||||
lastSeen: number;
|
lastSeen: number;
|
||||||
region: string;
|
region: string;
|
||||||
cars: string[];
|
stockList: string[];
|
||||||
|
|
||||||
isTimeout: boolean;
|
isTimeout: boolean;
|
||||||
isSupporter: boolean;
|
isSupporter: boolean;
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ export default interface StationAPIData {
|
|||||||
lastSeen: number;
|
lastSeen: number;
|
||||||
dispatcherExp: number;
|
dispatcherExp: number;
|
||||||
nameFromHeader: string;
|
nameFromHeader: string;
|
||||||
spawnString: string;
|
spawnString: string | null;
|
||||||
networkConnectionString: string;
|
networkConnectionString: string;
|
||||||
isOnline: number;
|
isOnline: number;
|
||||||
dispatcherRate: number;
|
dispatcherRate: number;
|
||||||
|
|||||||
@@ -0,0 +1,13 @@
|
|||||||
|
export interface RollingStockGithubData {
|
||||||
|
usage: Record<string, string>;
|
||||||
|
info: RollingStockInfo;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface RollingStockInfo {
|
||||||
|
'loco-e': [string, string, string, string, boolean][];
|
||||||
|
'loco-s': [string, string, string, string, boolean][];
|
||||||
|
'loco-szt': [string, string, string, string, boolean][];
|
||||||
|
'loco-ezt': [string, string, string, string, boolean][];
|
||||||
|
'car-passenger': [string, string, boolean, boolean, string][];
|
||||||
|
'car-cargo': [string, string, boolean, boolean, string][];
|
||||||
|
}
|
||||||
@@ -6,7 +6,7 @@ import Station from '../Station';
|
|||||||
import Train from '../Train';
|
import Train from '../Train';
|
||||||
import { DispatcherStatsAPIData } from '../api/DispatcherStatsAPIData';
|
import { DispatcherStatsAPIData } from '../api/DispatcherStatsAPIData';
|
||||||
import { DriverStatsAPIData } from '../api/DriverStatsAPIData';
|
import { DriverStatsAPIData } from '../api/DriverStatsAPIData';
|
||||||
import { Ref } from 'vue';
|
import { RollingStockGithubData } from '../github_api/StockInfoGithubData';
|
||||||
|
|
||||||
export type Availability = 'default' | 'unavailable' | 'nonPublic' | 'abandoned' | 'nonDefault';
|
export type Availability = 'default' | 'unavailable' | 'nonPublic' | 'abandoned' | 'nonDefault';
|
||||||
|
|
||||||
@@ -14,6 +14,7 @@ export interface StoreState {
|
|||||||
stationList: Station[];
|
stationList: Station[];
|
||||||
trainList: Train[];
|
trainList: Train[];
|
||||||
apiData: APIData;
|
apiData: APIData;
|
||||||
|
rollingStockData?: RollingStockGithubData;
|
||||||
|
|
||||||
lastDispatcherStatuses: { hash: string; statusTimestamp: number; statusID: string }[];
|
lastDispatcherStatuses: { hash: string; statusTimestamp: number; statusID: string }[];
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
export const URLs = {
|
export const URLs = {
|
||||||
stacjownikAPI:
|
stacjownikAPI:
|
||||||
import.meta.env.VITE_APP_API_DEV == 1 && !import.meta.env.PROD
|
import.meta.env.VITE_APP_API_DEV === "1" && !import.meta.env.PROD
|
||||||
? 'http://localhost:3001'
|
? 'http://localhost:3001'
|
||||||
: 'https://stacjownik.spythere.pl',
|
: 'https://stacjownik.spythere.pl',
|
||||||
stacjownikAPIDev: 'localhost:3000',
|
stacjownikAPIDev: 'localhost:3000',
|
||||||
|
|||||||
@@ -1,9 +0,0 @@
|
|||||||
import { defineStore } from 'pinia';
|
|
||||||
|
|
||||||
export const useJournalFiltersStore = defineStore('journalFiltersStore', {
|
|
||||||
state: () => ({
|
|
||||||
timetableFilters: {
|
|
||||||
|
|
||||||
},
|
|
||||||
}),
|
|
||||||
});
|
|
||||||
@@ -8,14 +8,16 @@ import Station from '../scripts/interfaces/Station';
|
|||||||
import StationRoutes from '../scripts/interfaces/StationRoutes';
|
import StationRoutes from '../scripts/interfaces/StationRoutes';
|
||||||
import Train from '../scripts/interfaces/Train';
|
import Train from '../scripts/interfaces/Train';
|
||||||
import { URLs } from '../scripts/utils/apiURLs';
|
import { URLs } from '../scripts/utils/apiURLs';
|
||||||
import { getLocoURL, getStatusTimestamp, getStatusID, getScheduledTrain, parseSpawns } from '../scripts/utils/storeUtils';
|
import { getStatusTimestamp, getStatusID, getScheduledTrain, parseSpawns } from '../scripts/utils/storeUtils';
|
||||||
import { APIData, StationJSONData, StoreState } from '../scripts/interfaces/store/storeTypes';
|
import { APIData, StationJSONData, StoreState } from '../scripts/interfaces/store/storeTypes';
|
||||||
import packageInfo from '../../package.json';
|
import packageInfo from '../../package.json';
|
||||||
|
import { RollingStockInfo, RollingStockGithubData } from '../scripts/interfaces/github_api/StockInfoGithubData';
|
||||||
|
|
||||||
export const useStore = defineStore('store', {
|
export const useStore = defineStore('store', {
|
||||||
state: () =>
|
state: () =>
|
||||||
({
|
({
|
||||||
apiData: {} as unknown,
|
apiData: {} as unknown,
|
||||||
|
rollingStockData: undefined,
|
||||||
|
|
||||||
stationList: [],
|
stationList: [],
|
||||||
trainList: [],
|
trainList: [],
|
||||||
@@ -351,6 +353,7 @@ export const useStore = defineStore('store', {
|
|||||||
|
|
||||||
async connectToAPI() {
|
async connectToAPI() {
|
||||||
await this.fetchStationsGeneralInfo();
|
await this.fetchStationsGeneralInfo();
|
||||||
|
await this.fetchStockInfoData();
|
||||||
|
|
||||||
this.connectToWebsocket();
|
this.connectToWebsocket();
|
||||||
},
|
},
|
||||||
@@ -361,6 +364,14 @@ export const useStore = defineStore('store', {
|
|||||||
await this.setOnlineData();
|
await this.setOnlineData();
|
||||||
},
|
},
|
||||||
|
|
||||||
|
async fetchStockInfoData() {
|
||||||
|
try {
|
||||||
|
this.rollingStockData = (await axios.get<RollingStockGithubData>('https://raw.githubusercontent.com/Spythere/api/main/td2/data/stockInfo.json')).data;
|
||||||
|
} catch (error) {
|
||||||
|
console.error('Ups! Wystąpił błąd podczas pobierania informacji o taborze z API:', error);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
async setOnlineData() {
|
async setOnlineData() {
|
||||||
if (!this.apiData.stations) {
|
if (!this.apiData.stations) {
|
||||||
this.dataStatuses.sceneries = DataStatus.Error;
|
this.dataStatuses.sceneries = DataStatus.Error;
|
||||||
|
|||||||
@@ -1,19 +1,15 @@
|
|||||||
/// <reference types="vite/client" />
|
/// <reference types="vite/client" />
|
||||||
|
|
||||||
declare module '*.vue' {
|
declare module '*.vue' {
|
||||||
import type { DefineComponent } from 'vue'
|
import type { DefineComponent } from 'vue';
|
||||||
const component: DefineComponent<{}, {}, any>
|
const component: DefineComponent<{}, {}, any>;
|
||||||
export default component
|
export default component;
|
||||||
|
|
||||||
}
|
}
|
||||||
interface ImportMetaEnv {
|
interface ImportMetaEnv {
|
||||||
readonly VITE_APP_API_DEV: number;
|
readonly VITE_APP_API_DEV: string;
|
||||||
readonly VITE_APP_WS_DEV: number;
|
readonly VITE_APP_WS_DEV: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface ImportMeta {
|
interface ImportMeta {
|
||||||
readonly env: ImportMetaEnv;
|
readonly env: ImportMetaEnv;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||