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.unavailable
|
||||
"
|
||||
:style="calculateExpStyle(station.generalInfo.reqLevel, station.generalInfo.supportersOnly)"
|
||||
:style="calculateExpStyle(station.generalInfo.reqLevel)"
|
||||
>
|
||||
{{ station.generalInfo.reqLevel >= 2 ? station.generalInfo.reqLevel : 'L' }}
|
||||
</span>
|
||||
@@ -109,43 +109,43 @@
|
||||
|
||||
<td class="station_tracks twoway">
|
||||
<span
|
||||
v-if="station.generalInfo && station.generalInfo.routes.twoWay.catenary > 0"
|
||||
v-if="station.generalInfo && station.generalInfo.routes.twoWayCatenaryRouteNames.length > 0"
|
||||
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
|
||||
v-if="station.generalInfo && station.generalInfo.routes.twoWay.noCatenary > 0"
|
||||
v-if="station.generalInfo && station.generalInfo.routes.twoWayNoCatenaryRouteNames.length > 0"
|
||||
class="track no-catenary"
|
||||
: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 class="separator"></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"
|
||||
: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
|
||||
v-if="station.generalInfo && station.generalInfo.routes.oneWay.noCatenary > 0"
|
||||
v-if="station.generalInfo && station.generalInfo.routes.oneWayNoCatenaryRouteNames.length > 0"
|
||||
class="track no-catenary"
|
||||
: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>
|
||||
</td>
|
||||
|
||||
@@ -175,10 +175,10 @@
|
||||
/>
|
||||
|
||||
<img
|
||||
v-if="station.generalInfo?.SBL && station.generalInfo?.SBL !== ''"
|
||||
v-if="station.generalInfo && station.generalInfo.routes.sblRouteNames.length > 0"
|
||||
:src="SBLIcon"
|
||||
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')" />
|
||||
@@ -296,11 +296,11 @@ export default defineComponent({
|
||||
},
|
||||
|
||||
openForumSite(e: Event, url: string | undefined) {
|
||||
if(!url) return;
|
||||
if (!url) return;
|
||||
|
||||
e.preventDefault();
|
||||
window.open(url, '_blank');
|
||||
}
|
||||
e.preventDefault();
|
||||
window.open(url, '_blank');
|
||||
},
|
||||
},
|
||||
});
|
||||
</script>
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import ScheduledTrain from "./ScheduledTrain";
|
||||
import StationRoutes from "./StationRoutes";
|
||||
|
||||
export default interface Station {
|
||||
name: string;
|
||||
@@ -8,13 +9,11 @@ export default interface Station {
|
||||
url: string;
|
||||
|
||||
reqLevel: number;
|
||||
supportersOnly: boolean;
|
||||
// supportersOnly: boolean;
|
||||
|
||||
lines: string;
|
||||
project: string;
|
||||
|
||||
SBL: string;
|
||||
TWB: string;
|
||||
signalType: string;
|
||||
controlType: string;
|
||||
|
||||
@@ -24,17 +23,14 @@ export default interface Station {
|
||||
nonPublic: boolean;
|
||||
unavailable: boolean;
|
||||
|
||||
routes: {
|
||||
oneWay: { catenary: number; noCatenary: number };
|
||||
twoWay: { catenary: number; noCatenary: number };
|
||||
};
|
||||
routes: StationRoutes;
|
||||
|
||||
checkpoints: {
|
||||
checkpointName: string;
|
||||
scheduledTrains: ScheduledTrain[];
|
||||
}[];
|
||||
};
|
||||
|
||||
|
||||
onlineInfo?: {
|
||||
hash: string;
|
||||
name: string;
|
||||
@@ -42,23 +38,23 @@ export default interface Station {
|
||||
maxUsers: number;
|
||||
currentUsers: number;
|
||||
|
||||
spawns: { spawnName: string; spawnLength: number }[];
|
||||
spawns: { spawnName: string; spawnLength: number }[];
|
||||
dispatcherRate: number;
|
||||
dispatcherName: string;
|
||||
dispatcherExp: number;
|
||||
dispatcherId: number;
|
||||
dispatcherIsSupporter: boolean;
|
||||
|
||||
|
||||
statusTimestamp: number;
|
||||
statusTimeString: string;
|
||||
statusID: string;
|
||||
|
||||
|
||||
stationTrains?: {
|
||||
driverName: string;
|
||||
trainNo: number;
|
||||
stopStatus?: string;
|
||||
}[];
|
||||
|
||||
|
||||
scheduledTrains?: ScheduledTrain[];
|
||||
}
|
||||
|
||||
|
||||
@@ -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) {
|
||||
const routes = station.generalInfo.routes;
|
||||
|
||||
if (station.generalInfo.default && filters['default']) return returnMode;
|
||||
if (!station.generalInfo.default && filters['notDefault']) return returnMode;
|
||||
|
||||
if (filters['real'] && 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['maxLevel']) return returnMode;
|
||||
|
||||
if (filters['no-1track'] && (station.generalInfo.routes.oneWay.catenary != 0 || station.generalInfo.routes.oneWay.noCatenary != 0)) return returnMode;
|
||||
if (filters['no-2track'] && (station.generalInfo.routes.twoWay.catenary != 0 || station.generalInfo.routes.twoWay.noCatenary != 0)) return returnMode;
|
||||
if (filters['no-1track'] && (routes.oneWayCatenaryRouteNames.length != 0 || routes.oneWayNoCatenaryRouteNames.length != 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 (station.generalInfo.routes.oneWay.noCatenary < filters['minOneWay']) return returnMode;
|
||||
if (routes.oneWayCatenaryRouteNames.length < filters['minOneWayCatenary']) return returnMode;
|
||||
if (routes.oneWayNoCatenaryRouteNames.length < filters['minOneWay']) return returnMode;
|
||||
|
||||
if (station.generalInfo.routes.twoWay.catenary < filters['minTwoWayCatenary']) return returnMode;
|
||||
if (station.generalInfo.routes.twoWay.noCatenary < filters['minTwoWay']) return returnMode;
|
||||
if (routes.twoWayCatenaryRouteNames.length < filters['minTwoWayCatenary']) return returnMode;
|
||||
if (routes.twoWayNoCatenaryRouteNames.length < filters['minTwoWay']) return returnMode;
|
||||
|
||||
if (filters[station.generalInfo.controlType]) 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['SBL'] && station.generalInfo.SBL) return returnMode;
|
||||
if (filters['SBL'] && routes.sblRouteNames.length > 0) return returnMode;
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
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",
|
||||
stations: "https://api.td2.info.pl:9640/?method=getStationsOnline",
|
||||
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 { URLs } from '@/scripts/utils/apiURLs';
|
||||
import ScheduledTrain from '@/scripts/interfaces/ScheduledTrain';
|
||||
import StationRoutes from '@/scripts/interfaces/StationRoutes';
|
||||
|
||||
export interface State {
|
||||
stationList: Station[],
|
||||
@@ -52,27 +53,14 @@ interface StationJSONData {
|
||||
|
||||
reqLevel: number;
|
||||
|
||||
supportersOnly: boolean;
|
||||
// supportersOnly: boolean;
|
||||
|
||||
signalType: string;
|
||||
controlType: string;
|
||||
|
||||
SUP: boolean;
|
||||
|
||||
SBL: string;
|
||||
TWB: string;
|
||||
|
||||
routes: {
|
||||
oneWay: {
|
||||
catenary: number;
|
||||
noCatenary: number;
|
||||
};
|
||||
twoWay: {
|
||||
catenary: number;
|
||||
noCatenary: number;
|
||||
}
|
||||
};
|
||||
|
||||
routes: string;
|
||||
checkpoints: string | null;
|
||||
|
||||
default: boolean;
|
||||
@@ -351,11 +339,44 @@ export const store = createStore<State>({
|
||||
|
||||
mutations: {
|
||||
SET_SCENERY_DATA(state, data: StationJSONData[]) {
|
||||
|
||||
state.stationList = data.map(stationData => ({
|
||||
name: stationData.name,
|
||||
|
||||
generalInfo: {
|
||||
...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: [] })) : [],
|
||||
}
|
||||
}));
|
||||
|
||||
Reference in New Issue
Block a user