Aktywacja widoku historii rozkładów jazdy (WIP)

This commit is contained in:
2021-12-30 21:31:25 +01:00
parent 967356a02a
commit d62b74652e
2 changed files with 68 additions and 81 deletions
+65 -72
View File
@@ -131,12 +131,7 @@ export const store = createStore<State>({
const sceneryData = await (await axios.get(sceneryDataQuery)).data;
// const sceneryData = await (await axios.get(sceneryDataQuery)).data;
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, sceneryData);
commit(MUTATIONS.SET_SCENERY_DATA_STATUS, DataStatus.Loaded);
dispatch(ACTIONS.fetchOnlineData);
@@ -317,81 +312,35 @@ export const store = createStore<State>({
},
mutations: {
SET_SCENERY_DATA(state, data: SceneryData[]) {
SET_SCENERY_DATA(state, data: any[][]) {
// state.sceneryData = [...data];
console.log('Data:', data);
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: scenery.track_oneway_e,
noCatenary: scenery.track_oneway_ne
},
twoWay: {
catenary: scenery.track_twoway_e,
noCatenary: scenery.track_twoway_ne
}
},
checkpoints: scenery.checkpoints ? scenery.checkpoints.split(";").map(sub => ({ checkpointName: sub, scheduledTrains: [] })) : [],
default: scenery.is_default,
nonPublic: scenery.is_nonpublic,
unavailable: scenery.is_unavailable,
stationHash: "",
maxUsers: 0,
currentUsers: 0,
dispatcherName: "",
dispatcherRate: 0,
dispatcherExp: -1,
dispatcherId: 0,
dispatcherIsSupporter: false,
online: false,
statusTimestamp: -3,
statusID: "free",
statusTimeString: "",
stationTrains: [],
scheduledTrains: [],
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,
// 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,
@@ -410,6 +359,50 @@ export const store = createStore<State>({
// 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: Number(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: []
}));
},
+3 -9
View File
@@ -25,13 +25,7 @@
<div class="history_list">
<div class="list_wrapper">
<transition name="warning" mode="out-in">
<div class="history_warning">
Usługa czasowo wyłączona!
<div>
<router-link to="/">[Powrót na stronę główną]</router-link>
</div>
</div>
<!-- <div :key="historyDataStatus.status">
<div :key="historyDataStatus.status">
<div v-if="isDataLoading" class="history_warning">Ładowanie...</div>
<div
@@ -127,7 +121,7 @@
</div>
</li>
</ul>
</div> -->
</div>
</transition>
</div>
</div>
@@ -146,7 +140,7 @@ import { DataStatus } from "@/scripts/enums/DataStatus";
const PROD_MODE = true;
const API_URL = PROD_MODE
? "https://stacjownik-api-7xmt4.ondigitalocean.app/api/getTimetables"
? "https://stacjownik-api-di22o.ondigitalocean.app/api/getTimetables"
: "http://localhost:3001/api/getTimetables";
interface APIResponse {