mirror of
https://github.com/Spythere/stacjownik.git
synced 2026-05-03 05:18:11 +00:00
Aktualizacja scenerii; WIP: zmiana serwerów SWDR
This commit is contained in:
+11
@@ -104,8 +104,13 @@ export default defineComponent({
|
|||||||
() => store.getters[GETTERS.allData]
|
() => store.getters[GETTERS.allData]
|
||||||
);
|
);
|
||||||
|
|
||||||
|
const currentRegion: ComputedRef<string> = computed(
|
||||||
|
() => store.getters[GETTERS.currentRegion]
|
||||||
|
);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
data,
|
data,
|
||||||
|
currentRegion,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
|
||||||
@@ -149,6 +154,12 @@ export default defineComponent({
|
|||||||
StorageManager.setStringValue("lang", lang);
|
StorageManager.setStringValue("lang", lang);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
// changeRegion(region: string = "eu") {
|
||||||
|
// this.$store.commit(MUTATIONS.SET_REGION, region);
|
||||||
|
// this.$store.dispatch(ACTIONS.fetchOnlineData);
|
||||||
|
|
||||||
|
// },
|
||||||
|
|
||||||
loadLang() {
|
loadLang() {
|
||||||
const storageLang = StorageManager.getStringValue("lang");
|
const storageLang = StorageManager.getStringValue("lang");
|
||||||
|
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ export const MUTATIONS = {
|
|||||||
SET_SCENERY_DATA: "SET_SCENERY_DATA",
|
SET_SCENERY_DATA: "SET_SCENERY_DATA",
|
||||||
SET_SCENERY_DATA_STATUS: "SET_SCENERY_DATA_STATUS",
|
SET_SCENERY_DATA_STATUS: "SET_SCENERY_DATA_STATUS",
|
||||||
SET_DATA_CONNECTION_STATUS: "SET_DATA_CONNECTION_STATUS",
|
SET_DATA_CONNECTION_STATUS: "SET_DATA_CONNECTION_STATUS",
|
||||||
|
SET_REGION: "SET_REGION",
|
||||||
UPDATE_STATIONS: "UPDATE_STATIONS",
|
UPDATE_STATIONS: "UPDATE_STATIONS",
|
||||||
UPDATE_TRAINS: "UPDATE_TRAINS",
|
UPDATE_TRAINS: "UPDATE_TRAINS",
|
||||||
UPDATE_TIMETABLES: "UPDATE_TIMETABLES"
|
UPDATE_TIMETABLES: "UPDATE_TIMETABLES"
|
||||||
@@ -19,5 +20,6 @@ export const GETTERS = {
|
|||||||
allData: "allData",
|
allData: "allData",
|
||||||
timetableDataStatus: "timetableDataStatus",
|
timetableDataStatus: "timetableDataStatus",
|
||||||
sceneryDataStatus: "sceneryDataStatus",
|
sceneryDataStatus: "sceneryDataStatus",
|
||||||
dataStatus: "dataStatus"
|
dataStatus: "dataStatus",
|
||||||
|
currentRegion: "currentRegion"
|
||||||
}
|
}
|
||||||
File diff suppressed because one or more lines are too long
+14
-8
@@ -24,11 +24,11 @@ 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';
|
||||||
|
|
||||||
|
|
||||||
export interface State {
|
export interface State {
|
||||||
stationList: Station[],
|
stationList: Station[],
|
||||||
trainList: Train[],
|
trainList: Train[],
|
||||||
|
|
||||||
|
region: string;
|
||||||
trainCount: number;
|
trainCount: number;
|
||||||
stationCount: number;
|
stationCount: number;
|
||||||
|
|
||||||
@@ -45,6 +45,8 @@ export const store = createStore<State>({
|
|||||||
state: () => ({
|
state: () => ({
|
||||||
stationList: [],
|
stationList: [],
|
||||||
trainList: [],
|
trainList: [],
|
||||||
|
|
||||||
|
region: "eu",
|
||||||
|
|
||||||
trainCount: 0,
|
trainCount: 0,
|
||||||
stationCount: 0,
|
stationCount: 0,
|
||||||
@@ -71,7 +73,8 @@ export const store = createStore<State>({
|
|||||||
}),
|
}),
|
||||||
timetableDataStatus: (state): DataStatus => state.timetableDataStatus,
|
timetableDataStatus: (state): DataStatus => state.timetableDataStatus,
|
||||||
sceneryDataStatus: (state): DataStatus => state.sceneryDataStatus,
|
sceneryDataStatus: (state): DataStatus => state.sceneryDataStatus,
|
||||||
dataStatus: (state): DataStatus => state.dataConnectionStatus
|
dataStatus: (state): DataStatus => state.dataConnectionStatus,
|
||||||
|
currentRegion: (state): string => state.region
|
||||||
},
|
},
|
||||||
|
|
||||||
actions: {
|
actions: {
|
||||||
@@ -84,7 +87,6 @@ export const store = createStore<State>({
|
|||||||
dispatch(ACTIONS.fetchOnlineData);
|
dispatch(ACTIONS.fetchOnlineData);
|
||||||
|
|
||||||
setInterval(() => dispatch(ACTIONS.fetchOnlineData), 30000);
|
setInterval(() => dispatch(ACTIONS.fetchOnlineData), 30000);
|
||||||
|
|
||||||
},
|
},
|
||||||
|
|
||||||
async fetchOnlineData({ commit, dispatch }) {
|
async fetchOnlineData({ commit, dispatch }) {
|
||||||
@@ -95,15 +97,15 @@ export const store = createStore<State>({
|
|||||||
const onlineDispatchersData: string[][] = await response[2].data.message;
|
const onlineDispatchersData: string[][] = await response[2].data.message;
|
||||||
|
|
||||||
const updatedStationList = onlineStationsData.reduce((acc, station) => {
|
const updatedStationList = onlineStationsData.reduce((acc, station) => {
|
||||||
if (station.region !== "eu" || !station.isOnline) return acc;
|
if (station.region !== this.state.region || !station.isOnline) return acc;
|
||||||
|
|
||||||
const stationStatus = onlineDispatchersData.find((status: string[]) => status[0] == station.stationHash && status[1] == "eu");
|
const stationStatus = onlineDispatchersData.find((status: string[]) => status[0] == station.stationHash && status[1] == this.state.region);
|
||||||
|
|
||||||
const statusTimestamp = getStatusTimestamp(stationStatus);
|
const statusTimestamp = getStatusTimestamp(stationStatus);
|
||||||
const statusID = getStatusID(stationStatus);
|
const statusID = getStatusID(stationStatus);
|
||||||
|
|
||||||
const stationTrains = onlineTrainsData
|
const stationTrains = onlineTrainsData
|
||||||
.filter(train => train.region === "eu" && train.isOnline && train.station.stationName === station.stationName)
|
.filter(train => train.region === this.state.region && train.isOnline && train.station.stationName === station.stationName)
|
||||||
.map(train => ({ driverName: train.driverName, trainNo: train.trainNo }));
|
.map(train => ({ driverName: train.driverName, trainNo: train.trainNo }));
|
||||||
|
|
||||||
acc.push({
|
acc.push({
|
||||||
@@ -128,7 +130,7 @@ export const store = createStore<State>({
|
|||||||
|
|
||||||
const updatedTrainList = await Promise.all(
|
const updatedTrainList = await Promise.all(
|
||||||
onlineTrainsData
|
onlineTrainsData
|
||||||
.filter(train => train.region === "eu")
|
.filter(train => train.region === this.state.region)
|
||||||
.map(async train => {
|
.map(async train => {
|
||||||
const locoType = train.dataCon.split(";") ? train.dataCon.split(";")[0] : train.dataCon;
|
const locoType = train.dataCon.split(";") ? train.dataCon.split(";")[0] : train.dataCon;
|
||||||
|
|
||||||
@@ -292,6 +294,10 @@ export const store = createStore<State>({
|
|||||||
state.dataConnectionStatus = status;
|
state.dataConnectionStatus = status;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
SET_REGION(state, region: string) {
|
||||||
|
state.region = region;
|
||||||
|
},
|
||||||
|
|
||||||
UPDATE_STATIONS(state, updatedStationList: any[]) {
|
UPDATE_STATIONS(state, updatedStationList: any[]) {
|
||||||
state.stationList = state.stationList.reduce((acc: Station[], station) => {
|
state.stationList = state.stationList.reduce((acc: Station[], station) => {
|
||||||
const onlineStationData = updatedStationList.find(updatedStation => updatedStation.stationName === station.stationName);
|
const onlineStationData = updatedStationList.find(updatedStation => updatedStation.stationName === station.stationName);
|
||||||
|
|||||||
@@ -11,6 +11,14 @@
|
|||||||
@resetFilters="resetFilters"
|
@resetFilters="resetFilters"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
|
<!-- <action-button>PL1</action-button> -->
|
||||||
|
|
||||||
|
<!-- <select-box
|
||||||
|
style="margin-left: 0.5em"
|
||||||
|
:itemList="regions"
|
||||||
|
@selected="selectRegion"
|
||||||
|
></select-box> -->
|
||||||
|
|
||||||
<div class="paypal-link">
|
<div class="paypal-link">
|
||||||
<a target="_blank" href="https://paypal.me/spythere">
|
<a target="_blank" href="https://paypal.me/spythere">
|
||||||
<img
|
<img
|
||||||
@@ -43,19 +51,19 @@ import inputData from "@/data/options.json";
|
|||||||
|
|
||||||
import StationTable from "@/components/StationsView/StationTable.vue";
|
import StationTable from "@/components/StationsView/StationTable.vue";
|
||||||
import FilterCard from "@/components/StationsView/StationFilterCard.vue";
|
import FilterCard from "@/components/StationsView/StationFilterCard.vue";
|
||||||
import ActionButton from "@/components/Global/ActionButton.vue";
|
import SelectBox from "@/components/Global/SelectBox.vue";
|
||||||
|
|
||||||
import { StoreData } from "@/scripts/interfaces/StoreData";
|
import { StoreData } from "@/scripts/interfaces/StoreData";
|
||||||
import { DataStatus } from "@/scripts/enums/DataStatus";
|
import { DataStatus } from "@/scripts/enums/DataStatus";
|
||||||
import { computed, ComputedRef, defineComponent, reactive } from "vue";
|
import { computed, ComputedRef, defineComponent, reactive } from "vue";
|
||||||
import { useStore } from "@/store";
|
import { useStore } from "@/store";
|
||||||
import { GETTERS } from "@/constants/storeConstants";
|
import { ACTIONS, GETTERS, MUTATIONS } from "@/constants/storeConstants";
|
||||||
|
|
||||||
export default defineComponent({
|
export default defineComponent({
|
||||||
components: {
|
components: {
|
||||||
StationTable,
|
StationTable,
|
||||||
FilterCard,
|
FilterCard,
|
||||||
ActionButton,
|
SelectBox,
|
||||||
},
|
},
|
||||||
data: () => ({
|
data: () => ({
|
||||||
trainIcon: require("@/assets/icon-train.svg"),
|
trainIcon: require("@/assets/icon-train.svg"),
|
||||||
@@ -65,7 +73,19 @@ export default defineComponent({
|
|||||||
modalHidden: true,
|
modalHidden: true,
|
||||||
STORAGE_KEY: "options_saved",
|
STORAGE_KEY: "options_saved",
|
||||||
inputs: inputData,
|
inputs: inputData,
|
||||||
|
|
||||||
|
regions: [
|
||||||
|
{
|
||||||
|
id: "eu",
|
||||||
|
value: "PL1",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: "ru",
|
||||||
|
value: "ENG",
|
||||||
|
},
|
||||||
|
],
|
||||||
}),
|
}),
|
||||||
|
|
||||||
setup() {
|
setup() {
|
||||||
const store = useStore();
|
const store = useStore();
|
||||||
const filterManager = reactive(new StationFilterManager());
|
const filterManager = reactive(new StationFilterManager());
|
||||||
@@ -148,6 +168,10 @@ export default defineComponent({
|
|||||||
setFocusedStation(name: string) {
|
setFocusedStation(name: string) {
|
||||||
this.focusedStationName = this.focusedStationName == name ? "" : name;
|
this.focusedStationName = this.focusedStationName == name ? "" : name;
|
||||||
},
|
},
|
||||||
|
selectRegion(region: { id: string; value: string }) {
|
||||||
|
this.$store.commit(MUTATIONS.SET_REGION, region.id);
|
||||||
|
this.$store.dispatch(ACTIONS.fetchOnlineData);
|
||||||
|
},
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
@@ -199,6 +223,7 @@ export default defineComponent({
|
|||||||
|
|
||||||
.options-bar {
|
.options-bar {
|
||||||
display: flex;
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
|
||||||
margin-bottom: 0.5em;
|
margin-bottom: 0.5em;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user