poprawki do braku pokazywania się niezapisanych scenerii

This commit is contained in:
2023-12-07 16:16:06 +01:00
parent 188857d335
commit 0dc2c505db
14 changed files with 10678 additions and 85 deletions
-1
View File
@@ -74,7 +74,6 @@ export default defineComponent({
this.store.activeData.activeSceneries = []; this.store.activeData.activeSceneries = [];
this.store.activeData.trains = []; this.store.activeData.trains = [];
this.store.activeData.connectedSocketCount = 0;
this.store.setStatuses(); this.store.setStatuses();
}); });
@@ -33,6 +33,8 @@
> >
{{ historyItem.dispatcherLevel >= 2 ? historyItem.dispatcherLevel : 'L' }} {{ historyItem.dispatcherLevel >= 2 ? historyItem.dispatcherLevel : 'L' }}
</b> </b>
<b v-else>?</b>
</td> </td>
<td class="text--primary"> <td class="text--primary">
<b>{{ historyItem.dispatcherRate }}</b> <b>{{ historyItem.dispatcherRate }}</b>
@@ -84,12 +86,10 @@ export default defineComponent({
components: { Loading }, components: { Loading },
props: { props: {
station: { station: {
type: Object as PropType<Station>, type: Object as PropType<Station>
required: true
}, },
onlineScenery: { onlineScenery: {
type: Object as PropType<OnlineScenery>, type: Object as PropType<OnlineScenery>
required: false
} }
}, },
@@ -113,10 +113,17 @@ export default defineComponent({
countFrom = 0, countFrom = 0,
countLimit = 30 countLimit = 30
): Promise<API.DispatcherHistory.Response | null> { ): Promise<API.DispatcherHistory.Response | null> {
if (!this.station && !this.onlineScenery) {
this.dataStatus = Status.Data.Loaded;
return null;
}
try { try {
this.dataStatus = Status.Data.Loading; this.dataStatus = Status.Data.Loading;
const requestString = `${URLs.stacjownikAPI}/api/getDispatchers?stationName=${this.station.name}&countFrom=${countFrom}&countLimit=${countLimit}`; const requestString = `${URLs.stacjownikAPI}/api/getDispatchers?stationName=${
this.station?.name || this.onlineScenery?.name
}&countFrom=${countFrom}&countLimit=${countLimit}`;
const historyAPIData: API.DispatcherHistory.Response = await ( const historyAPIData: API.DispatcherHistory.Response = await (
await axios.get(requestString) await axios.get(requestString)
).data; ).data;
@@ -130,7 +137,9 @@ export default defineComponent({
} }
}, },
navigateToHistory() { navigateToHistory() {
this.$router.push(`/journal/dispatchers?sceneryName=${this.station.name}`); this.$router.push(
`/journal/dispatchers?sceneryName=${this.station?.name || this.onlineScenery?.name}`
);
} }
} }
}); });
+10 -8
View File
@@ -1,11 +1,11 @@
<template> <template>
<section class="info-header"> <section class="info-header">
<a class="scenery-name" :href="station.generalInfo?.url" target="_blank"> <a class="scenery-name" :href="station?.generalInfo?.url" target="_blank">
{{ station.name }} {{ stationName.replace(/_/g, ' ') }}
</a> </a>
<div class="scenery-abbrev"> <div class="scenery-abbrev" v-if="station?.generalInfo?.abbr">
{{ $t('scenery.abbrev') }} <b>{{ station.generalInfo?.abbr }}</b> {{ $t('scenery.abbrev') }} <b>{{ station.generalInfo.abbr }}</b>
</div> </div>
<div class="scenery-hash" v-if="onlineScenery?.hash">#{{ onlineScenery.hash }}</div> <div class="scenery-hash" v-if="onlineScenery?.hash">#{{ onlineScenery.hash }}</div>
@@ -20,13 +20,16 @@ import { OnlineScenery } from '../../store/typings';
export default defineComponent({ export default defineComponent({
props: { props: {
station: { station: {
type: Object as PropType<Station>, type: Object as PropType<Station>
},
stationName: {
type: String,
required: true required: true
}, },
onlineScenery: { onlineScenery: {
type: Object as PropType<OnlineScenery>, type: Object as PropType<OnlineScenery>
required: false
} }
} }
}); });
@@ -58,4 +61,3 @@ export default defineComponent({
font-size: 1.2em; font-size: 1.2em;
} }
</style> </style>
../../store/storeTypes
+6 -8
View File
@@ -1,10 +1,10 @@
<template> <template>
<div class="scenery-info"> <div class="scenery-info">
<section> <section>
<div class="scenery-info-general" v-if="station.generalInfo"> <div class="scenery-info-general">
<SceneryInfoIcons :station="station" /> <SceneryInfoIcons :station="station" />
<div class="scenery-general-list"> <div class="scenery-general-list" v-if="station?.generalInfo">
<span> <span>
<b>{{ $t('availability.title') }}:</b> <b>{{ $t('availability.title') }}:</b>
{{ $t(`availability.${station.generalInfo.availability}`) }} {{ $t(`availability.${station.generalInfo.availability}`) }}
@@ -46,11 +46,11 @@
</span> </span>
</div> </div>
<SceneryInfoRoutes :station="station" /> <SceneryInfoRoutes v-if="station" :station="station" />
<div <div
class="scenery-authors" class="scenery-authors"
v-if="station.generalInfo.authors && station.generalInfo.authors.length > 0" v-if="station?.generalInfo?.authors && station.generalInfo.authors.length > 0"
> >
<b> <b>
{{ {{
@@ -102,13 +102,11 @@ export default defineComponent({
}, },
props: { props: {
station: { station: {
type: Object as PropType<Station>, type: Object as PropType<Station>
required: true
}, },
onlineScenery: { onlineScenery: {
type: Object as PropType<OnlineScenery>, type: Object as PropType<OnlineScenery>
required: false
} }
} }
}); });
@@ -1,24 +1,33 @@
<template> <template>
<section class="info-icons"> <section class="info-icons">
<span <span v-if="!station || !station.generalInfo">
v-if="station.generalInfo && station.generalInfo.reqLevel >= 0" <img
class="scenery-icon icon-info level" class="icon-info"
:style="calculateExpStyle(station.generalInfo.reqLevel)" src="/images/icon-unknown.svg"
> alt="icon-unknown"
{{ station.generalInfo.reqLevel >= 2 ? station.generalInfo.reqLevel : 'L' }} :title="$t('desc.unknown')"
/>
</span> </span>
<span <span
v-if="station.generalInfo" v-if="station?.generalInfo && station?.generalInfo.reqLevel >= 0"
class="scenery-icon icon-info level"
:style="calculateExpStyle(station?.generalInfo.reqLevel)"
>
{{ station?.generalInfo.reqLevel >= 2 ? station?.generalInfo.reqLevel : 'L' }}
</span>
<span
v-if="station?.generalInfo"
class="scenery-icon icon-info" class="scenery-icon icon-info"
:class="station.generalInfo.controlType.replace('+', '-')" :class="station?.generalInfo.controlType.replace('+', '-')"
:title="$t('desc.control-type') + $t(`controls.${station.generalInfo.controlType}`)" :title="$t('desc.control-type') + $t(`controls.${station?.generalInfo.controlType}`)"
v-html="getControlTypeAbbrev(station.generalInfo.controlType)" v-html="getControlTypeAbbrev(station?.generalInfo.controlType)"
> >
</span> </span>
<img <img
v-if="station.generalInfo?.SUP" v-if="station?.generalInfo?.SUP"
class="icon-info" class="icon-info"
src="/images/icon-SUP.svg" src="/images/icon-SUP.svg"
alt="SUP (RASP-UZK)" alt="SUP (RASP-UZK)"
@@ -26,7 +35,7 @@
/> />
<img <img
v-if="station.generalInfo?.signalType" v-if="station?.generalInfo?.signalType"
class="icon-info" class="icon-info"
:src="`/images/icon-${station.generalInfo.signalType}.svg`" :src="`/images/icon-${station.generalInfo.signalType}.svg`"
:alt="station.generalInfo.signalType" :alt="station.generalInfo.signalType"
@@ -34,7 +43,7 @@
/> />
<img <img
v-if="station.generalInfo?.availability == 'nonPublic'" v-if="station?.generalInfo?.availability == 'nonPublic'"
class="icon-info" class="icon-info"
src="/images/icon-lock.svg" src="/images/icon-lock.svg"
alt="Non-public scenery" alt="Non-public scenery"
@@ -42,7 +51,7 @@
/> />
<img <img
v-if="station.generalInfo?.availability == 'unavailable'" v-if="station?.generalInfo?.availability == 'unavailable'"
class="icon-info" class="icon-info"
src="/images/icon-unavailable.svg" src="/images/icon-unavailable.svg"
alt="Unavailable scenery" alt="Unavailable scenery"
@@ -50,7 +59,7 @@
/> />
<img <img
v-if="station.generalInfo?.availability == 'abandoned'" v-if="station?.generalInfo?.availability == 'abandoned'"
class="icon-info" class="icon-info"
src="/images/icon-abandoned.svg" src="/images/icon-abandoned.svg"
alt="Abandoned scenery" alt="Abandoned scenery"
@@ -58,20 +67,12 @@
/> />
<img <img
v-if="station.generalInfo?.lines" v-if="station?.generalInfo?.lines"
class="icon-info" class="icon-info"
src="/images/icon-real.svg" src="/images/icon-real.svg"
alt="real scenery" alt="real scenery"
:title="`${$t('desc.real')} ${station.generalInfo.lines}`" :title="`${$t('desc.real')} ${station.generalInfo.lines}`"
/> />
<img
v-if="!station.generalInfo"
class="icon-info"
src="/images/icon-unknown.svg"
alt="icon-unknown"
:title="$t('desc.unknown')"
/>
</section> </section>
</template> </template>
@@ -85,8 +86,7 @@ export default defineComponent({
mixins: [stationInfoMixin, styleMixin], mixins: [stationInfoMixin, styleMixin],
props: { props: {
station: { station: {
type: Object as PropType<Station>, type: Object as PropType<Station>
required: true
} }
} }
}); });
@@ -13,7 +13,7 @@
</span> </span>
</span> </span>
<span class="header_links"> <span class="header_links" v-if="station">
<a <a
:href="`https://pragotron-td2.web.app/board?name=${station.name}`" :href="`https://pragotron-td2.web.app/board?name=${station.name}`"
target="_blank" target="_blank"
@@ -201,12 +201,10 @@ export default defineComponent({
props: { props: {
station: { station: {
type: Object as PropType<Station>, type: Object as PropType<Station>
required: true
}, },
onlineScenery: { onlineScenery: {
type: Object as PropType<OnlineScenery>, type: Object as PropType<OnlineScenery>
required: false
} }
}, },
@@ -243,19 +241,21 @@ export default defineComponent({
computed: { computed: {
tabliceZbiorczeHref() { tabliceZbiorczeHref() {
let url = `https://tablice-td2.web.app/?station=${this.station.name}`; let url = `https://tablice-td2.web.app/?station=${this.station!.name}`;
if (this.chosenCheckpoint) url += `&checkpoint=${this.chosenCheckpoint}`; if (this.chosenCheckpoint) url += `&checkpoint=${this.chosenCheckpoint}`;
return url; return url;
}, },
computedScheduledTrains() { computedScheduledTrains() {
if (!this.station) return [];
return ( return (
this.onlineScenery?.scheduledTrains this.onlineScenery?.scheduledTrains
?.filter( ?.filter(
(train) => (train) =>
train.checkpointName.toLocaleLowerCase() == train.checkpointName.toLocaleLowerCase() ==
(this.chosenCheckpoint || this.station.name).toLocaleLowerCase() && (this.chosenCheckpoint || this.station!.name).toLocaleLowerCase() &&
train.region == this.store.region.id train.region == this.store.region.id
) )
.sort((a, b) => { .sort((a, b) => {
@@ -273,6 +273,8 @@ export default defineComponent({
methods: { methods: {
loadSelectedOption() { loadSelectedOption() {
if (!this.station) return;
this.chosenCheckpoint = this.chosenCheckpoint =
this.station.generalInfo?.checkpoints[0]?.checkpointName || this.station.name; this.station.generalInfo?.checkpoints[0]?.checkpointName || this.station.name;
}, },
@@ -80,12 +80,10 @@ export default defineComponent({
mixins: [dateMixin, listObserverMixin], mixins: [dateMixin, listObserverMixin],
props: { props: {
station: { station: {
type: Object as PropType<Station>, type: Object as PropType<Station>
required: true
}, },
onlineScenery: { onlineScenery: {
type: Object as PropType<OnlineScenery>, type: Object as PropType<OnlineScenery>
required: false
} }
}, },
@@ -103,8 +101,15 @@ export default defineComponent({
methods: { methods: {
async fetchAPIData(countFrom = 0, countLimit = 15) { async fetchAPIData(countFrom = 0, countLimit = 15) {
if (!this.station && !this.onlineScenery) {
this.dataStatus = Status.Data.Loaded;
return;
}
try { try {
const requestString = `${URLs.stacjownikAPI}/api/getTimetables?issuedFrom=${this.station.name}&countFrom=${countFrom}&countLimit=${countLimit}`; const requestString = `${URLs.stacjownikAPI}/api/getTimetables?issuedFrom=${
this.station?.name || this.onlineScenery?.name
}&countFrom=${countFrom}&countLimit=${countLimit}`;
const response: API.TimetableHistory.Response = await (await axios.get(requestString)).data; const response: API.TimetableHistory.Response = await (await axios.get(requestString)).data;
@@ -117,7 +122,9 @@ export default defineComponent({
}, },
navigateToHistory() { navigateToHistory() {
this.$router.push(`/journal/timetables?issuedFrom=${this.station.name}`); this.$router.push(
`/journal/timetables?issuedFrom=${this.station?.name || this.onlineScenery?.name}`
);
} }
}, },
components: { Loading } components: { Loading }
File diff suppressed because it is too large Load Diff
+2 -2
View File
@@ -405,8 +405,8 @@
"two-way-routes": "Two way routes", "two-way-routes": "Two way routes",
"option-active-timetables": "Active timetables", "option-active-timetables": "Active timetables",
"option-timetables-history": "Timetables history", "option-timetables-history": "Timetables history PL1",
"option-dispatchers-history": "Dispatchers history", "option-dispatchers-history": "Dispatchers history PL1",
"timetable-author-title": "Issued by", "timetable-author-title": "Issued by",
"timetable-author-unknown": "Author unknown", "timetable-author-unknown": "Author unknown",
+2 -2
View File
@@ -386,8 +386,8 @@
"two-way-routes": "Szlaki dwutorowe", "two-way-routes": "Szlaki dwutorowe",
"option-active-timetables": "Aktywne rozkłady jazdy", "option-active-timetables": "Aktywne rozkłady jazdy",
"option-timetables-history": "Historia rozkładów", "option-timetables-history": "Historia rozkładów PL1",
"option-dispatchers-history": "Historia dyżurów", "option-dispatchers-history": "Historia dyżurów PL1",
"timetable-author-title": "Wydany przez", "timetable-author-title": "Wydany przez",
"timetable-author-unknown": "Autor nieznany", "timetable-author-unknown": "Autor nieznany",
+90 -4
View File
@@ -86,7 +86,7 @@ export const useStore = defineStore('store', {
distance: train.distance, distance: train.distance,
signal: train.signal, signal: train.signal,
online: train.online, online: Boolean(train.online),
driverId: train.driverId, driverId: train.driverId,
driverName: train.driverName, driverName: train.driverName,
currentStationName: train.currentStationName, currentStationName: train.currentStationName,
@@ -183,6 +183,91 @@ export const useStore = defineStore('store', {
} }
}, },
actions: { actions: {
async processStationsOnlineInfo() {
if (!this.activeData.activeSceneries) return;
const onlineSceneries = this.activeData.activeSceneries.reduce((acc, scenery) => {
const savedStation = this.stationList.find((st) => scenery.stationName === st.name);
if (scenery.isOnline !== 1 && Date.now() - scenery.lastSeen > 1000 * 60 * 2) return acc;
if (scenery.dispatcherStatus == Status.ActiveDispatcher.UNKNOWN) return acc;
const station = this.stationList.find((s) => s.name === scenery.stationName);
const scheduledTrains = getScheduledTrains(this.trainList, scenery, station?.generalInfo);
const stationTrains = getStationTrains(
this.trainList,
scheduledTrains,
this.region.id,
scenery
);
// Remove checkpoint duplicates
const uniqueScheduledTrains = scheduledTrains.reduce(
(uniqueList, sTrain) =>
uniqueList.find((v) => v.trainId === sTrain.trainId)
? uniqueList
: [...uniqueList, sTrain],
[] as ScheduledTrain[]
);
const dispatcherTimestamp =
scenery.dispatcherStatus == Status.ActiveDispatcher.NO_LIMIT
? Date.now() + 25500000
: scenery.dispatcherStatus > 5
? scenery.dispatcherStatus
: null;
const onlineInfo = {
name: scenery.stationName,
hash: scenery.stationHash,
region: scenery.region,
maxUsers: scenery.maxUsers,
currentUsers: scenery.currentUsers,
spawns: parseSpawns(scenery.spawnString),
dispatcherName: scenery.dispatcherName,
dispatcherRate: scenery.dispatcherRate,
dispatcherId: scenery.dispatcherId,
dispatcherExp: scenery.dispatcherExp,
dispatcherIsSupporter: scenery.dispatcherIsSupporter,
scheduledTrains: scheduledTrains,
stationTrains: stationTrains,
dispatcherStatus: scenery.dispatcherStatus,
dispatcherTimestamp: dispatcherTimestamp,
isOnline: scenery.isOnline == 1,
scheduledTrainCount: {
all: uniqueScheduledTrains.length,
confirmed: uniqueScheduledTrains.filter((train) => train.stopInfo.confirmed).length,
unconfirmed: uniqueScheduledTrains.filter((train) => !train.stopInfo.confirmed).length
}
};
if (savedStation) savedStation.onlineInfo = onlineInfo;
else
this.stationList.push({
name: onlineInfo.name,
onlineInfo: onlineInfo
});
acc.push(onlineInfo);
return acc;
}, [] as OnlineScenery[]);
// Reset online info of already offline sceneries
this.stationList
.filter(
(station) =>
station.onlineInfo &&
onlineSceneries.findIndex(
(os) => os.region == station.onlineInfo!.region && station.name == os.name
) != -1
)
.forEach((station) => (station.onlineInfo = undefined));
},
async fetchStationsGeneralInfo() { async fetchStationsGeneralInfo() {
const sceneryData: StationJSONData[] = await ( const sceneryData: StationJSONData[] = await (
await axios.get(`${URLs.stacjownikAPI}/api/getSceneries`) await axios.get(`${URLs.stacjownikAPI}/api/getSceneries`)
@@ -245,10 +330,10 @@ export const useStore = defineStore('store', {
}, },
async fetchActiveData() { async fetchActiveData() {
if (import.meta.env.VITE_APP_WS_DEV === '1') { if (import.meta.env.VITE_APP_API_MODE === 'mock') {
const mockWebsocketData = await import('../data/mockWebsocketData.json'); const mockActiveData = await import('../data/mockActiveData.json');
this.dataStatuses.connection = Status.Data.Loaded; this.dataStatuses.connection = Status.Data.Loaded;
this.activeData = mockWebsocketData as any; this.activeData = mockActiveData;
this.setStatuses(); this.setStatuses();
console.warn('Stacjownik działa w trybie mockowania danych z WS'); console.warn('Stacjownik działa w trybie mockowania danych z WS');
@@ -263,6 +348,7 @@ export const useStore = defineStore('store', {
this.activeData = data; this.activeData = data;
this.dataStatuses.connection = Status.Data.Loaded; this.dataStatuses.connection = Status.Data.Loaded;
this.setStatuses(); this.setStatuses();
} catch (error) { } catch (error) {
this.dataStatuses.connection = Status.Data.Error; this.dataStatuses.connection = Status.Data.Error;
+14 -2
View File
@@ -71,13 +71,25 @@ export const useStationFiltersStore = defineStore('stationFiltersStore', {
filteredStationList: (state) => { filteredStationList: (state) => {
const store = useStore(); const store = useStore();
return store.stationList const savedStationNames = store.stationList.map((s) => s.name);
.map((station) => ({
const onlineUnsavedStations = store.onlineSceneryList
.filter((os) => !savedStationNames.includes(os.name) && os.region == store.region.id)
.map((os) => ({
name: os.name,
generalInfo: undefined,
onlineInfo: os
}));
return [
...onlineUnsavedStations,
...store.stationList.map((station) => ({
...station, ...station,
onlineInfo: store.onlineSceneryList.find( onlineInfo: store.onlineSceneryList.find(
(os) => os.name == station.name && os.region == store.region.id (os) => os.name == station.name && os.region == store.region.id
) )
})) }))
]
.filter((station) => filterStations(station, state.filters)) .filter((station) => filterStations(station, state.filters))
.sort((a, b) => sortStations(a, b, state.sorterActive)); .sort((a, b) => sortStations(a, b, state.sorterActive));
} }
+8 -9
View File
@@ -5,7 +5,6 @@ export namespace API {
export interface Response { export interface Response {
activeSceneries?: API.ActiveSceneries.Response; activeSceneries?: API.ActiveSceneries.Response;
trains?: API.ActiveTrains.Response; trains?: API.ActiveTrains.Response;
connectedSocketCount: number;
} }
} }
export namespace DispatcherHistory { export namespace DispatcherHistory {
@@ -123,9 +122,9 @@ export namespace API {
driverLevel?: number; driverLevel?: number;
currentStationName: string; currentStationName: string;
currentStationHash: string; currentStationHash?: string;
online: boolean; online: number;
lastSeen: number; lastSeen: number;
region: string; region: string;
@@ -139,16 +138,16 @@ export namespace API {
stopNameRAW: string; stopNameRAW: string;
stopType: string; stopType: string;
stopDistance: number; stopDistance: number;
pointId: number; pointId: string;
mainStop: boolean; mainStop: boolean;
arrivalLine: string; arrivalLine: string | null;
arrivalTimestamp: number; arrivalTimestamp: number;
arrivalRealTimestamp: number; arrivalRealTimestamp: number;
arrivalDelay: number; arrivalDelay: number;
departureLine: string; departureLine: string | null;
departureTimestamp: number; departureTimestamp: number;
departureRealTimestamp: number; departureRealTimestamp: number;
departureDelay: number; departureDelay: number;
@@ -157,9 +156,9 @@ export namespace API {
beginsHere: boolean; beginsHere: boolean;
terminatesHere: boolean; terminatesHere: boolean;
confirmed: boolean; confirmed: number;
stopped: boolean; stopped: number;
stopTime: number; stopTime: number | null;
} }
export interface Timetable { export interface Timetable {
+11 -4
View File
@@ -1,14 +1,17 @@
<template> <template>
<div class="scenery-view"> <div class="scenery-view">
<div class="scenery-offline" v-if="!stationInfo && store.dataStatuses.sceneries == 2"> <!-- <div
class="scenery-offline"
v-if="!stationInfo && !onlineSceneryInfo && store.dataStatuses.sceneries == 2"
>
<div>{{ $t('scenery.no-scenery') }}</div> <div>{{ $t('scenery.no-scenery') }}</div>
<action-button> <action-button>
<router-link to="/">{{ $t('scenery.return-btn') }}</router-link> <router-link to="/">{{ $t('scenery.return-btn') }}</router-link>
</action-button> </action-button>
</div> </div> -->
<div class="scenery-wrapper" v-if="stationInfo" ref="card-wrapper"> <div class="scenery-wrapper" ref="card-wrapper">
<div class="scenery-left"> <div class="scenery-left">
<div class="scenery-actions"> <div class="scenery-actions">
<button class="back-btn btn" :title="$t('scenery.return-btn')" @click="navigateTo('/')"> <button class="back-btn btn" :title="$t('scenery.return-btn')" @click="navigateTo('/')">
@@ -16,7 +19,11 @@
</button> </button>
</div> </div>
<SceneryHeader :station="stationInfo" :onlineScenery="onlineSceneryInfo" /> <SceneryHeader
:stationName="station"
:station="stationInfo"
:onlineScenery="onlineSceneryInfo"
/>
<SceneryInfo :station="stationInfo" :onlineScenery="onlineSceneryInfo" /> <SceneryInfo :station="stationInfo" :onlineScenery="onlineSceneryInfo" />
</div> </div>