diff --git a/src/App.vue b/src/App.vue
index cd5838f..ac25ee7 100644
--- a/src/App.vue
+++ b/src/App.vue
@@ -102,6 +102,7 @@ import { StoreData } from './scripts/interfaces/StoreData';
import { useStore } from './store';
import packageInfo from '.././package.json';
+import axios from 'axios';
export default defineComponent({
components: {
@@ -149,7 +150,7 @@ export default defineComponent({
this.loadLang();
},
- mounted() {
+ async mounted() {
if (StorageManager.getStringValue('version') != this.VERSION) {
StorageManager.setStringValue('version', this.VERSION);
@@ -158,7 +159,7 @@ export default defineComponent({
this.updateModalVisible = this.hasReleaseNotes && !StorageManager.getBooleanValue('version_notes_read');
- this.updateToNewestVersion();
+ this.updateToNewestVersion();
},
methods: {
diff --git a/src/components/SceneryView/SceneryInfo.vue b/src/components/SceneryView/SceneryInfo.vue
index bfde9e2..a0138c5 100644
--- a/src/components/SceneryView/SceneryInfo.vue
+++ b/src/components/SceneryView/SceneryInfo.vue
@@ -99,7 +99,7 @@
/>
-
- {{ Number(station.reqLevel) > -1 ? (Number(station.reqLevel) >= 2 ? station.reqLevel : 'L') : '?' }}
+
+ {{ station.reqLevel > -1 ? (station.reqLevel >= 2 ? station.reqLevel : 'L') : '?' }}
-
- ?
|
@@ -140,7 +138,7 @@
/>
-1 ? (exp < 2 ? '#26B0D9' : `hsl(${-exp * 5 + 100}, 85%, 50%)`) : '#666';
const fontColor = exp > 15 || exp == -1 ? 'white' : 'black';
diff --git a/src/scripts/interfaces/Station.ts b/src/scripts/interfaces/Station.ts
index 5e8dcd7..29904cf 100644
--- a/src/scripts/interfaces/Station.ts
+++ b/src/scripts/interfaces/Station.ts
@@ -19,7 +19,7 @@ export default interface Station {
stationLines: string;
stationProject: string;
- reqLevel: string;
+ reqLevel: number;
supportersOnly: boolean;
SBL: string;
diff --git a/src/scripts/managers/stationFilterManager.ts b/src/scripts/managers/stationFilterManager.ts
index 7cc1650..ab4a616 100644
--- a/src/scripts/managers/stationFilterManager.ts
+++ b/src/scripts/managers/stationFilterManager.ts
@@ -5,11 +5,8 @@ import StorageManager from './storageManager';
const sortStations = (a: Station, b: Station, sorter: { index: number; dir: number }) => {
switch (sorter.index) {
case 1:
- const aLevel = a.reqLevel == "" ? -1 : parseInt(a.reqLevel);
- const bLevel = b.reqLevel == "" ? -1 : parseInt(b.reqLevel);
-
- if (aLevel > bLevel) return sorter.dir;
- if (aLevel < bLevel) return -sorter.dir;
+ if (a.reqLevel > b.reqLevel) return sorter.dir;
+ if (a.reqLevel < b.reqLevel) return -sorter.dir;
break;
case 2:
@@ -85,9 +82,9 @@ const filterStations = (station: Station, filters: Filter) => {
if (filters['real'] && station.stationLines != '') return returnMode;
if (filters['fictional'] && station.stationLines == '') return returnMode;
- if (station.reqLevel == '-1') return true;
- if (parseInt(station.reqLevel) < filters['minLevel']) return returnMode;
- if (parseInt(station.reqLevel) > filters['maxLevel']) return returnMode;
+ if (station.reqLevel == -1) return true;
+ if (station.reqLevel < filters['minLevel']) return returnMode;
+ if (station.reqLevel > filters['maxLevel']) return returnMode;
if (filters['no-1track'] && (station.routes.oneWay.catenary != 0 || station.routes.oneWay.noCatenary != 0)) return returnMode;
if (filters['no-2track'] && (station.routes.twoWay.catenary != 0 || station.routes.twoWay.noCatenary != 0)) return returnMode;
diff --git a/src/scripts/utils/apiURLs.ts b/src/scripts/utils/apiURLs.ts
index 740aba7..8fc1e70 100644
--- a/src/scripts/utils/apiURLs.ts
+++ b/src/scripts/utils/apiURLs.ts
@@ -1,5 +1,6 @@
export const URLs = {
sceneryData: "https://spythere.github.io/api/stationData.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",
dispatchers: "https://api.td2.info.pl:9640/?method=readFromSWDR&value=getDispatcherStatusList%3B1",
diff --git a/src/store/index.ts b/src/store/index.ts
index 53d0bac..eaca1f9 100644
--- a/src/store/index.ts
+++ b/src/store/index.ts
@@ -42,6 +42,28 @@ export interface State {
listenerLaunched: boolean;
}
+interface SceneryData {
+ id: number;
+ name: string;
+ url: string;
+ project_lines: string;
+ project_name: string;
+ req_level?: number;
+ supporters_only: boolean;
+ signal_type: string;
+ control_type: string;
+ sbl_routes: string;
+ twb_routes: string;
+ track_oneway_e: number;
+ track_oneway_ne: number;
+ track_twoway_e: number;
+ track_twoway_ne: number;
+ checkpoints?: string;
+ is_default: boolean;
+ is_nonpublic: boolean;
+ is_unavailable: boolean;
+}
+
export const key: InjectionKey> = Symbol()
export const store = createStore({
@@ -107,8 +129,14 @@ export const store = createStore({
}
const sceneryData = await (await axios.get(sceneryDataQuery)).data;
+ // const sceneryData = await (await axios.get(sceneryDataQuery)).data;
- commit(MUTATIONS.SET_SCENERY_DATA, sceneryData);
+ const sceneryData2 = await (await axios.get('http://127.0.0.1:8000/data')).data;
+ console.log(sceneryData2);
+
+
+
+ commit(MUTATIONS.SET_SCENERY_DATA, sceneryData2);
commit(MUTATIONS.SET_SCENERY_DATA_STATUS, DataStatus.Loaded);
dispatch(ACTIONS.fetchOnlineData);
@@ -122,8 +150,6 @@ export const store = createStore({
async fetchOnlineData({ commit, dispatch }) {
commit(MUTATIONS.SET_DATA_CONNECTION_STATUS, DataStatus.Loading);
-
-
Promise.all([axios.get(URLs.stations), axios.get(URLs.trains), axios.get(URLs.dispatchers)])
.then(async response => {
const onlineStationsData: StationAPIData[] = response[0].data.message;
@@ -291,35 +317,37 @@ export const store = createStore({
},
mutations: {
- SET_SCENERY_DATA(state, data: any[][]) {
- state.sceneryData = [...data];
+ SET_SCENERY_DATA(state, data: SceneryData[]) {
+ // state.sceneryData = [...data];
+ console.log('Data:', data);
+
- state.stationList = data.map(station => ({
- stationName: station[0] as string,
- stationURL: station[1] as string,
- stationLines: station[2] as string,
- stationProject: station[3] as string,
- reqLevel: station[4] as string,
- supportersOnly: station[5] == "TAK",
- signalType: station[6] as string,
- controlType: station[7] as string,
- SBL: station[8] as string,
- TWB: station[9] as string,
+ state.stationList = data.map(scenery => ({
+ stationName: scenery.name,
+ stationURL: scenery.url,
+ stationLines: scenery.project_lines,
+ stationProject: scenery.project_name,
+ reqLevel: scenery.req_level === undefined ? -1 : scenery.req_level,
+ supportersOnly: scenery.supporters_only,
+ signalType: scenery.signal_type,
+ controlType: scenery.control_type,
+ SBL: scenery.sbl_routes,
+ TWB: scenery.twb_routes,
routes: {
oneWay: {
- catenary: station[10] as number,
- noCatenary: station[11] as number
+ catenary: scenery.track_oneway_e,
+ noCatenary: scenery.track_oneway_ne
},
twoWay: {
- catenary: station[12] as number,
- noCatenary: station[13] as number
+ catenary: scenery.track_twoway_e,
+ noCatenary: scenery.track_twoway_ne
}
},
- checkpoints: station[14] ? (station[14] as string).split(";").map(sub => ({ checkpointName: sub, scheduledTrains: [] })) : [],
+ checkpoints: scenery.checkpoints ? scenery.checkpoints.split(";").map(sub => ({ checkpointName: sub, scheduledTrains: [] })) : [],
- default: station[15] as boolean,
- nonPublic: station[16] as boolean,
- unavailable: station[17] as boolean,
+ default: scenery.is_default,
+ nonPublic: scenery.is_nonpublic,
+ unavailable: scenery.is_unavailable,
stationHash: "",
maxUsers: 0,
@@ -338,6 +366,50 @@ export const store = createStore({
spawns: []
}));
+ // state.stationList = data.map(station => ({
+ // stationName: station[0] as string,
+ // stationURL: station[1] as string,
+ // stationLines: station[2] as string,
+ // stationProject: station[3] as string,
+ // reqLevel: station[4] as string,
+ // supportersOnly: station[5] == "TAK",
+ // signalType: station[6] as string,
+ // controlType: station[7] as string,
+ // SBL: station[8] as string,
+ // TWB: station[9] as string,
+ // routes: {
+ // oneWay: {
+ // catenary: station[10] as number,
+ // noCatenary: station[11] as number
+ // },
+ // twoWay: {
+ // catenary: station[12] as number,
+ // noCatenary: station[13] as number
+ // }
+ // },
+ // checkpoints: station[14] ? (station[14] as string).split(";").map(sub => ({ checkpointName: sub, scheduledTrains: [] })) : [],
+
+ // default: station[15] as boolean,
+ // nonPublic: station[16] as boolean,
+ // unavailable: station[17] as boolean,
+
+ // stationHash: "",
+ // maxUsers: 0,
+ // currentUsers: 0,
+ // dispatcherName: "",
+ // dispatcherRate: 0,
+ // dispatcherExp: -1,
+ // dispatcherId: 0,
+ // dispatcherIsSupporter: false,
+ // online: false,
+ // statusTimestamp: -3,
+ // statusID: "free",
+ // statusTimeString: "",
+ // stationTrains: [],
+ // scheduledTrains: [],
+ // spawns: []
+ // }));
+
},
@@ -361,7 +433,7 @@ export const store = createStore({
state.stationList = state.stationList.reduce((acc: Station[], station) => {
const onlineStationData = updatedStationList.find(updatedStation => updatedStation.stationName === station.stationName);
- const listedStationData = state.sceneryData.find(data => data[0] === station.stationName);
+ const listedStationData = state.stationList.find(data => data.stationName === station.stationName);
if (onlineStationData)
acc.push({
@@ -400,7 +472,7 @@ export const store = createStore({
stationTrains: uStation.stationTrains || [],
subStations: [],
online: true,
- reqLevel: "-1",
+ reqLevel: -1,
nonPublic: true
});
});
|