mirror of
https://github.com/Spythere/stacjownik.git
synced 2026-05-03 05:18:11 +00:00
Przygotowanie pod nowszą wersję pliku JSON
This commit is contained in:
@@ -64,7 +64,7 @@
|
|||||||
!station.generalInfo.nonPublic &&
|
!station.generalInfo.nonPublic &&
|
||||||
!station.generalInfo.unavailable
|
!station.generalInfo.unavailable
|
||||||
"
|
"
|
||||||
:style="calculateExpStyle(station.generalInfo.reqLevel, station.generalInfo.supportersOnly)"
|
:style="calculateExpStyle(station.generalInfo.reqLevel)"
|
||||||
>
|
>
|
||||||
{{ station.generalInfo.reqLevel >= 2 ? station.generalInfo.reqLevel : 'L' }}
|
{{ station.generalInfo.reqLevel >= 2 ? station.generalInfo.reqLevel : 'L' }}
|
||||||
</span>
|
</span>
|
||||||
@@ -109,43 +109,43 @@
|
|||||||
|
|
||||||
<td class="station_tracks twoway">
|
<td class="station_tracks twoway">
|
||||||
<span
|
<span
|
||||||
v-if="station.generalInfo && station.generalInfo.routes.twoWay.catenary > 0"
|
v-if="station.generalInfo && station.generalInfo.routes.twoWayCatenaryRouteNames.length > 0"
|
||||||
class="track catenary"
|
class="track catenary"
|
||||||
:title="`Liczba zelektryfikowanych szlaków dwutorowych: ${station.generalInfo.routes.twoWay.catenary}`"
|
:title="`Liczba zelektryfikowanych szlaków dwutorowych: ${station.generalInfo.routes.twoWayCatenaryRouteNames.length }`"
|
||||||
>
|
>
|
||||||
{{ station.generalInfo.routes.twoWay.catenary }}
|
{{ station.generalInfo.routes.twoWayCatenaryRouteNames.length }}
|
||||||
</span>
|
</span>
|
||||||
|
|
||||||
<span
|
<span
|
||||||
v-if="station.generalInfo && station.generalInfo.routes.twoWay.noCatenary > 0"
|
v-if="station.generalInfo && station.generalInfo.routes.twoWayNoCatenaryRouteNames.length > 0"
|
||||||
class="track no-catenary"
|
class="track no-catenary"
|
||||||
:title="
|
:title="
|
||||||
`Liczba niezelektryfikowanych szlaków dwutorowych: ${station.generalInfo.routes.twoWay.noCatenary}`
|
`Liczba niezelektryfikowanych szlaków dwutorowych: ${station.generalInfo.routes.twoWayNoCatenaryRouteNames.length}`
|
||||||
"
|
"
|
||||||
>
|
>
|
||||||
{{ station.generalInfo.routes.twoWay.noCatenary }}
|
{{ station.generalInfo.routes.twoWayNoCatenaryRouteNames.length }}
|
||||||
</span>
|
</span>
|
||||||
|
|
||||||
<span class="separator"></span>
|
<span class="separator"></span>
|
||||||
|
|
||||||
<span
|
<span
|
||||||
v-if="station.generalInfo && station.generalInfo.routes.oneWay.catenary > 0"
|
v-if="station.generalInfo && station.generalInfo.routes.oneWayCatenaryRouteNames.length > 0"
|
||||||
class="track catenary"
|
class="track catenary"
|
||||||
:title="
|
:title="
|
||||||
`Liczba zelektryfikowanych szlaków jednotorowych: ${station.generalInfo.routes.oneWay.catenary}`
|
`Liczba zelektryfikowanych szlaków jednotorowych: ${station.generalInfo.routes.oneWayCatenaryRouteNames.length}`
|
||||||
"
|
"
|
||||||
>
|
>
|
||||||
{{ station.generalInfo.routes.oneWay.catenary }}
|
{{ station.generalInfo.routes.oneWayCatenaryRouteNames.length }}
|
||||||
</span>
|
</span>
|
||||||
|
|
||||||
<span
|
<span
|
||||||
v-if="station.generalInfo && station.generalInfo.routes.oneWay.noCatenary > 0"
|
v-if="station.generalInfo && station.generalInfo.routes.oneWayNoCatenaryRouteNames.length > 0"
|
||||||
class="track no-catenary"
|
class="track no-catenary"
|
||||||
:title="
|
:title="
|
||||||
`Liczba niezelektryfikowanych szlaków jednotorowych: ${station.generalInfo.routes.oneWay.noCatenary}`
|
`Liczba niezelektryfikowanych szlaków jednotorowych: ${station.generalInfo.routes.oneWayNoCatenaryRouteNames.length}`
|
||||||
"
|
"
|
||||||
>
|
>
|
||||||
{{ station.generalInfo.routes.oneWay.noCatenary }}
|
{{ station.generalInfo.routes.oneWayNoCatenaryRouteNames.length }}
|
||||||
</span>
|
</span>
|
||||||
</td>
|
</td>
|
||||||
|
|
||||||
@@ -175,10 +175,10 @@
|
|||||||
/>
|
/>
|
||||||
|
|
||||||
<img
|
<img
|
||||||
v-if="station.generalInfo?.SBL && station.generalInfo?.SBL !== ''"
|
v-if="station.generalInfo && station.generalInfo.routes.sblRouteNames.length > 0"
|
||||||
:src="SBLIcon"
|
:src="SBLIcon"
|
||||||
alt="SBL"
|
alt="SBL"
|
||||||
:title="$t('desc.SBL') + `${station.generalInfo.SBL}`"
|
:title="$t('desc.SBL') + `${station.generalInfo.routes.sblRouteNames.join(',')}`"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<img v-if="!station.generalInfo" :src="unknownIcon" alt="icon-unknown" :title="$t('desc.unknown')" />
|
<img v-if="!station.generalInfo" :src="unknownIcon" alt="icon-unknown" :title="$t('desc.unknown')" />
|
||||||
@@ -296,11 +296,11 @@ export default defineComponent({
|
|||||||
},
|
},
|
||||||
|
|
||||||
openForumSite(e: Event, url: string | undefined) {
|
openForumSite(e: Event, url: string | undefined) {
|
||||||
if(!url) return;
|
if (!url) return;
|
||||||
|
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
window.open(url, '_blank');
|
window.open(url, '_blank');
|
||||||
}
|
},
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import ScheduledTrain from "./ScheduledTrain";
|
import ScheduledTrain from "./ScheduledTrain";
|
||||||
|
import StationRoutes from "./StationRoutes";
|
||||||
|
|
||||||
export default interface Station {
|
export default interface Station {
|
||||||
name: string;
|
name: string;
|
||||||
@@ -8,13 +9,11 @@ export default interface Station {
|
|||||||
url: string;
|
url: string;
|
||||||
|
|
||||||
reqLevel: number;
|
reqLevel: number;
|
||||||
supportersOnly: boolean;
|
// supportersOnly: boolean;
|
||||||
|
|
||||||
lines: string;
|
lines: string;
|
||||||
project: string;
|
project: string;
|
||||||
|
|
||||||
SBL: string;
|
|
||||||
TWB: string;
|
|
||||||
signalType: string;
|
signalType: string;
|
||||||
controlType: string;
|
controlType: string;
|
||||||
|
|
||||||
@@ -24,10 +23,7 @@ export default interface Station {
|
|||||||
nonPublic: boolean;
|
nonPublic: boolean;
|
||||||
unavailable: boolean;
|
unavailable: boolean;
|
||||||
|
|
||||||
routes: {
|
routes: StationRoutes;
|
||||||
oneWay: { catenary: number; noCatenary: number };
|
|
||||||
twoWay: { catenary: number; noCatenary: number };
|
|
||||||
};
|
|
||||||
|
|
||||||
checkpoints: {
|
checkpoints: {
|
||||||
checkpointName: string;
|
checkpointName: string;
|
||||||
|
|||||||
@@ -0,0 +1,23 @@
|
|||||||
|
export default interface StationRoutes {
|
||||||
|
oneWay:
|
||||||
|
{
|
||||||
|
name: string;
|
||||||
|
catenary: boolean;
|
||||||
|
SBL: boolean;
|
||||||
|
TWB: boolean
|
||||||
|
}[];
|
||||||
|
|
||||||
|
twoWay: {
|
||||||
|
name: string;
|
||||||
|
catenary: boolean;
|
||||||
|
SBL: boolean;
|
||||||
|
TWB: boolean
|
||||||
|
}[];
|
||||||
|
|
||||||
|
/* [catenary, noCatenary] */
|
||||||
|
oneWayCatenaryRouteNames: string[];
|
||||||
|
oneWayNoCatenaryRouteNames: string[];
|
||||||
|
twoWayCatenaryRouteNames: string[];
|
||||||
|
twoWayNoCatenaryRouteNames: string[];
|
||||||
|
sblRouteNames: string[];
|
||||||
|
}
|
||||||
@@ -77,26 +77,25 @@ const filterStations = (station: Station, filters: Filter) => {
|
|||||||
if (station.generalInfo?.unavailable && filters['unavailable']) return returnMode;
|
if (station.generalInfo?.unavailable && filters['unavailable']) return returnMode;
|
||||||
|
|
||||||
if (station.generalInfo) {
|
if (station.generalInfo) {
|
||||||
|
const routes = station.generalInfo.routes;
|
||||||
|
|
||||||
if (station.generalInfo.default && filters['default']) return returnMode;
|
if (station.generalInfo.default && filters['default']) return returnMode;
|
||||||
if (!station.generalInfo.default && filters['notDefault']) return returnMode;
|
if (!station.generalInfo.default && filters['notDefault']) return returnMode;
|
||||||
|
|
||||||
if (filters['real'] && station.generalInfo.lines != '') return returnMode;
|
if (filters['real'] && station.generalInfo.lines != '') return returnMode;
|
||||||
if (filters['fictional'] && station.generalInfo.lines == '') return returnMode;
|
if (filters['fictional'] && station.generalInfo.lines == '') return returnMode;
|
||||||
|
|
||||||
// if (station.generalInfo.reqLevel == -1) return true;
|
|
||||||
// if (station.generalInfo.reqLevel == -1 && filters['minLevel'] == 0) return true;
|
|
||||||
|
|
||||||
if (station.generalInfo.reqLevel + ((station.generalInfo.nonPublic || station.generalInfo.unavailable) ? 1 : 0) < filters['minLevel']) return returnMode;
|
if (station.generalInfo.reqLevel + ((station.generalInfo.nonPublic || station.generalInfo.unavailable) ? 1 : 0) < filters['minLevel']) return returnMode;
|
||||||
if (station.generalInfo.reqLevel + ((station.generalInfo.nonPublic || station.generalInfo.unavailable) ? 1 : 0) > filters['maxLevel']) return returnMode;
|
if (station.generalInfo.reqLevel + ((station.generalInfo.nonPublic || station.generalInfo.unavailable) ? 1 : 0) > filters['maxLevel']) return returnMode;
|
||||||
|
|
||||||
if (filters['no-1track'] && (station.generalInfo.routes.oneWay.catenary != 0 || station.generalInfo.routes.oneWay.noCatenary != 0)) return returnMode;
|
if (filters['no-1track'] && (routes.oneWayCatenaryRouteNames.length != 0 || routes.oneWayNoCatenaryRouteNames.length != 0)) return returnMode;
|
||||||
if (filters['no-2track'] && (station.generalInfo.routes.twoWay.catenary != 0 || station.generalInfo.routes.twoWay.noCatenary != 0)) return returnMode;
|
if (filters['no-2track'] && (routes.twoWayCatenaryRouteNames.length != 0 || routes.twoWayNoCatenaryRouteNames.length != 0)) return returnMode;
|
||||||
|
|
||||||
if (station.generalInfo.routes.oneWay.catenary < filters['minOneWayCatenary']) return returnMode;
|
if (routes.oneWayCatenaryRouteNames.length < filters['minOneWayCatenary']) return returnMode;
|
||||||
if (station.generalInfo.routes.oneWay.noCatenary < filters['minOneWay']) return returnMode;
|
if (routes.oneWayNoCatenaryRouteNames.length < filters['minOneWay']) return returnMode;
|
||||||
|
|
||||||
if (station.generalInfo.routes.twoWay.catenary < filters['minTwoWayCatenary']) return returnMode;
|
if (routes.twoWayCatenaryRouteNames.length < filters['minTwoWayCatenary']) return returnMode;
|
||||||
if (station.generalInfo.routes.twoWay.noCatenary < filters['minTwoWay']) return returnMode;
|
if (routes.twoWayNoCatenaryRouteNames.length < filters['minTwoWay']) return returnMode;
|
||||||
|
|
||||||
if (filters[station.generalInfo.controlType]) return returnMode;
|
if (filters[station.generalInfo.controlType]) return returnMode;
|
||||||
if (filters[station.generalInfo.signalType]) return returnMode;
|
if (filters[station.generalInfo.signalType]) return returnMode;
|
||||||
@@ -112,7 +111,7 @@ const filterStations = (station: Station, filters: Filter) => {
|
|||||||
|
|
||||||
if (filters['ręczne'] && station.generalInfo.controlType.includes('ręczne')) return returnMode;
|
if (filters['ręczne'] && station.generalInfo.controlType.includes('ręczne')) return returnMode;
|
||||||
|
|
||||||
if (filters['SBL'] && station.generalInfo.SBL) return returnMode;
|
if (filters['SBL'] && routes.sblRouteNames.length > 0) return returnMode;
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
export const URLs = {
|
export const URLs = {
|
||||||
sceneryData: "https://spythere.github.io/api/stationDataDev.json",
|
sceneryData: "https://spythere.github.io/api/stationDataNew.json",
|
||||||
sceneryDataDev: "http://127.0.0.1:8000/data",
|
sceneryDataDev: "http://127.0.0.1:8000/data",
|
||||||
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",
|
||||||
|
|||||||
+36
-15
@@ -22,6 +22,7 @@ import { DataStatus } from "@/scripts/enums/DataStatus";
|
|||||||
import { getLocoURL, getStatusID, getStatusTimestamp, getTimestamp, getTrainStopStatus, parseSpawns, timestampToString } from "@/scripts/utils/storeUtils";
|
import { getLocoURL, getStatusID, getStatusTimestamp, getTimestamp, getTrainStopStatus, parseSpawns, timestampToString } from "@/scripts/utils/storeUtils";
|
||||||
import { URLs } from '@/scripts/utils/apiURLs';
|
import { URLs } from '@/scripts/utils/apiURLs';
|
||||||
import ScheduledTrain from '@/scripts/interfaces/ScheduledTrain';
|
import ScheduledTrain from '@/scripts/interfaces/ScheduledTrain';
|
||||||
|
import StationRoutes from '@/scripts/interfaces/StationRoutes';
|
||||||
|
|
||||||
export interface State {
|
export interface State {
|
||||||
stationList: Station[],
|
stationList: Station[],
|
||||||
@@ -52,27 +53,14 @@ interface StationJSONData {
|
|||||||
|
|
||||||
reqLevel: number;
|
reqLevel: number;
|
||||||
|
|
||||||
supportersOnly: boolean;
|
// supportersOnly: boolean;
|
||||||
|
|
||||||
signalType: string;
|
signalType: string;
|
||||||
controlType: string;
|
controlType: string;
|
||||||
|
|
||||||
SUP: boolean;
|
SUP: boolean;
|
||||||
|
|
||||||
SBL: string;
|
routes: string;
|
||||||
TWB: string;
|
|
||||||
|
|
||||||
routes: {
|
|
||||||
oneWay: {
|
|
||||||
catenary: number;
|
|
||||||
noCatenary: number;
|
|
||||||
};
|
|
||||||
twoWay: {
|
|
||||||
catenary: number;
|
|
||||||
noCatenary: number;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
checkpoints: string | null;
|
checkpoints: string | null;
|
||||||
|
|
||||||
default: boolean;
|
default: boolean;
|
||||||
@@ -351,11 +339,44 @@ export const store = createStore<State>({
|
|||||||
|
|
||||||
mutations: {
|
mutations: {
|
||||||
SET_SCENERY_DATA(state, data: StationJSONData[]) {
|
SET_SCENERY_DATA(state, data: StationJSONData[]) {
|
||||||
|
|
||||||
state.stationList = data.map(stationData => ({
|
state.stationList = data.map(stationData => ({
|
||||||
name: stationData.name,
|
name: stationData.name,
|
||||||
|
|
||||||
generalInfo: {
|
generalInfo: {
|
||||||
...stationData,
|
...stationData,
|
||||||
|
routes: stationData.routes?.split(";").filter(routeString => routeString).reduce((acc, routeString) => {
|
||||||
|
const name = routeString.split("_")[0];
|
||||||
|
const specs = routeString.split("_")[1].split("");
|
||||||
|
|
||||||
|
const twoWay = specs[0] == "2";
|
||||||
|
const catenary = specs[1] == "E";
|
||||||
|
const SBL = specs[2] == "S";
|
||||||
|
const TWB = specs[3] ? true : false;
|
||||||
|
|
||||||
|
const propName = twoWay
|
||||||
|
? catenary
|
||||||
|
? 'twoWayCatenaryRouteNames'
|
||||||
|
: 'twoWayNoCatenaryRouteNames'
|
||||||
|
: catenary
|
||||||
|
? 'oneWayCatenaryRouteNames'
|
||||||
|
: 'oneWayNoCatenaryRouteNames';
|
||||||
|
|
||||||
|
acc[twoWay ? 'twoWay' : 'oneWay'].push({ name, SBL, TWB, catenary });
|
||||||
|
acc[propName].push(name);
|
||||||
|
|
||||||
|
if (SBL) acc['sblRouteNames'].push(name);
|
||||||
|
|
||||||
|
return acc;
|
||||||
|
}, {
|
||||||
|
oneWay: [],
|
||||||
|
twoWay: [],
|
||||||
|
sblRouteNames: [],
|
||||||
|
oneWayCatenaryRouteNames: [],
|
||||||
|
oneWayNoCatenaryRouteNames: [],
|
||||||
|
twoWayCatenaryRouteNames: [],
|
||||||
|
twoWayNoCatenaryRouteNames: []
|
||||||
|
} as StationRoutes) || {},
|
||||||
checkpoints: stationData.checkpoints ? stationData.checkpoints.split(";").map(sub => ({ checkpointName: sub, scheduledTrains: [] })) : [],
|
checkpoints: stationData.checkpoints ? stationData.checkpoints.split(";").map(sub => ({ checkpointName: sub, scheduledTrains: [] })) : [],
|
||||||
}
|
}
|
||||||
}));
|
}));
|
||||||
|
|||||||
Reference in New Issue
Block a user