-
-
{{el.title}}
+
+ -
+
+
+
+ -
+
+
+
Poziomy dyżurnego
+
+
+
+
+
+
+ -
+
+
+
+ Szlaki jednotorowe
+
(minimum)
+
+
+
+
+
+
+
+
+
+ Szlaki dwutorowe
+
(minimum)
+
+
+
+
+
+
+
@@ -105,11 +215,15 @@ export default Vue.extend({
}
}),
methods: {
- ...mapActions(["addFilters", "removeFilters"]),
+ ...mapActions(["setFilter"]),
handleChange(e: any) {
- if (e.target.checked) {
- this.removeFilters([e.target.name]);
- } else this.addFilters([e.target.name]);
+ this.setFilter({ filterName: e.target.name, value: !e.target.checked });
+ },
+ handleInput(e: any) {
+ this.setFilter({
+ filterName: e.target.name,
+ value: parseInt(e.target.value)
+ });
}
}
});
@@ -117,39 +231,52 @@ export default Vue.extend({
\ No newline at end of file
diff --git a/src/store/backup.ts b/src/store/backup.ts
new file mode 100644
index 0000000..164a5a0
--- /dev/null
+++ b/src/store/backup.ts
@@ -0,0 +1,134 @@
+import Vue from 'vue'
+import Vuex from 'vuex'
+import data from '@/data/stations.json';
+
+Vue.use(Vuex)
+
+export default new Vuex.Store({
+ state: {
+ stations: [],
+ filteredStations: [],
+ filters: [],
+ trainCount: 0
+ },
+ actions: {
+ fetchStations: async ({ commit }) => {
+ let onlineStations, statusList, onlineTrains
+
+ try {
+ onlineStations = (await (await fetch('https://api.td2.info.pl:9640/?method=getStationsOnline')).json()).message
+ statusList = (await (await fetch('https://api.td2.info.pl:9640/?method=readFromSWDR&value=getDispatcherStatusList%3B1')).json()).message
+ onlineTrains = (await (await fetch('https://api.td2.info.pl:9640/?method=getTrainsOnline')).json()).message
+ } catch (error) {
+ throw Error(error.message);
+ }
+
+ commit('setTrainCount', onlineTrains.filter((train) => train.isOnline && train.region === 'eu').length);
+
+ const mappedStations = onlineStations
+ .filter((station) => station.region === 'eu')
+ .filter((station) => station.isOnline)
+ .map((
+ { stationName = '', stationHash = '', maxUsers = 0, currentUsers = 0, spawnString = '',
+ dispatcherRate = 0, dispatcherName = '', dispatcherExp = 0, dispatcherId = 0 }) => {
+
+ const status = statusList.find((s) => s[0] === stationHash && s[1] === 'eu')
+ let occupiedTo = "---"
+ let occupiedTimestamp = 0
+
+ if (!status)
+ occupiedTo = "NIEZALOGOWANY";
+ else {
+ let occupiedCode = status[2];
+
+ occupiedTimestamp = status[3];
+ occupiedTo = "NIEDOSTĘPNY";
+
+ if (occupiedCode === 0) {
+ if (occupiedTimestamp - Date.now() > 21000000)
+ occupiedTo = "BEZ LIMITU";
+ else
+ occupiedTo = new Date(status[3])
+ .toLocaleTimeString('en-US',
+ { hour12: false, hour: '2-digit', minute: '2-digit' });
+ }
+
+ if (occupiedCode === 1)
+ occupiedTo = "Z/W";
+
+ if (occupiedCode === 2 && occupiedTimestamp === 0)
+ occupiedTo = "KOŃCZY";
+
+ if (occupiedCode === 3)
+ occupiedTo = "BRAK MIEJSCA";
+ }
+
+ const trains = onlineTrains.filter((train) =>
+ train.region === 'eu' && train.isOnline === 1 && train.station.stationName === stationName)
+
+ const stationData = data.find((station) => station.stationName === stationName) || { stationName, stationURL: "" }
+
+ return {
+ ...stationData,
+ stationHash,
+ maxUsers,
+ currentUsers,
+ spawnString: spawnString && spawnString.split(';').map(v => v.split(',')[6] ? v.split(',')[6] : v.split(',')[0]),
+ dispatcherName,
+ dispatcherRate,
+ dispatcherId,
+ dispatcherExp: dispatcherExp < 2 ? 'L' : dispatcherExp,
+ occupiedTo,
+ trains
+ }
+ })
+
+ commit('setStations', mappedStations);
+ commit('filterStations');
+ },
+
+ addFilters({ commit }, filterId) {
+ commit('addFilters', filterId);
+ commit('filterStations');
+ },
+
+ removeFilters({ commit }, filterId) {
+ commit('removeFilters', filterId);
+ commit('filterStations');
+ }
+ },
+ mutations: {
+ setStations: (state, stations) => state.stations = stations,
+ setTrainCount: (state, count) => state.trainCount = count,
+
+ addFilters(state, filters) {
+ state.filters.push(...filters);
+ },
+ removeFilters: (state, filters) => {
+ filters.forEach(filter => {
+ state.filters = state.filters.filter((id) => id !== filter);
+ })
+ },
+
+ filterStations(state) {
+ state.filteredStations = state.stations.filter((station) => {
+ if (station.default && state.filters.includes("default")) return false;
+ if ((!station.default) && state.filters.includes("notDefault")) return false;
+ if ((station.nonPublic || !station.reqLevel) && (state.filters.includes("nonPublic"))) return false;
+
+ if (state.filters.includes(station.controlType)) return false;
+ if (state.filters.includes(station.signalType)) return false;
+
+ if (station.controlType && state.filters.filter((f) => station.controlType.includes(f)).length > 0) return false;
+
+ return true;
+ })
+ }
+ },
+ getters: {
+ getStations: state => state.filteredStations,
+ getStationCount: state => state.stations.length,
+ getTrainCount: state => state.trainCount,
+ getFilters: state => state.filters,
+ }
+})
\ No newline at end of file
diff --git a/src/store/index.ts b/src/store/index.ts
index 2d48e10..9b21490 100644
--- a/src/store/index.ts
+++ b/src/store/index.ts
@@ -1,134 +1,10 @@
import Vue from 'vue'
import Vuex from 'vuex'
-import data from '@/data/stations.json';
-
+import Store from '@/store/modules/store'
Vue.use(Vuex)
-
-export default new Vuex.Store({
- state: {
- stations: [],
- filteredStations: [],
- filters: [],
- trainCount: 0
- },
- actions: {
- fetchStations: async ({ commit }) => {
- let onlineStations, statusList: any, onlineTrains: any
-
- try {
- onlineStations = (await (await fetch('https://api.td2.info.pl:9640/?method=getStationsOnline')).json()).message
- statusList = (await (await fetch('https://api.td2.info.pl:9640/?method=readFromSWDR&value=getDispatcherStatusList%3B1')).json()).message
- onlineTrains = (await (await fetch('https://api.td2.info.pl:9640/?method=getTrainsOnline')).json()).message
- } catch (error) {
- throw Error(error.message);
- }
-
- commit('setTrainCount', onlineTrains.filter((train: any) => train.isOnline && train.region === 'eu').length);
-
- const mappedStations = onlineStations
- .filter((station: any) => station.region === 'eu')
- .filter((station: any) => station.isOnline)
- .map((
- { stationName = '', stationHash = '', maxUsers = 0, currentUsers = 0, spawnString = '',
- dispatcherRate = 0, dispatcherName = '', dispatcherExp = 0, dispatcherId = 0 }) => {
-
- const status = statusList.find((s: any) => s[0] === stationHash && s[1] === 'eu')
- let occupiedTo: string = "---"
- let occupiedTimestamp: number = 0
-
- if (!status)
- occupiedTo = "NIEZALOGOWANY";
- else {
- let occupiedCode: number = status[2];
-
- occupiedTimestamp = status[3];
- occupiedTo = "NIEDOSTĘPNY";
-
- if (occupiedCode === 0) {
- if (occupiedTimestamp - Date.now() > 21000000)
- occupiedTo = "BEZ LIMITU";
- else
- occupiedTo = new Date(status[3])
- .toLocaleTimeString('en-US',
- { hour12: false, hour: '2-digit', minute: '2-digit' });
- }
-
- if (occupiedCode === 1)
- occupiedTo = "Z/W";
-
- if (occupiedCode === 2 && occupiedTimestamp === 0)
- occupiedTo = "KOŃCZY";
-
- if (occupiedCode === 3)
- occupiedTo = "BRAK MIEJSCA";
- }
-
- const trains: {} = onlineTrains.filter((train: any) =>
- train.region === 'eu' && train.isOnline === 1 && train.station.stationName === stationName)
-
- const stationData: {} = data.find((station: any) => station.stationName === stationName) || { stationName, stationURL: "" }
-
- return {
- ...stationData,
- stationHash,
- maxUsers,
- currentUsers,
- spawnString: spawnString && spawnString.split(';').map(v => v.split(',')[6] ? v.split(',')[6] : v.split(',')[0]),
- dispatcherName,
- dispatcherRate,
- dispatcherId,
- dispatcherExp: dispatcherExp < 2 ? 'L' : dispatcherExp,
- occupiedTo,
- trains
- }
- })
-
- commit('setStations', mappedStations);
- commit('filterStations');
- },
-
- addFilters({ commit }, filterId) {
- commit('addFilters', filterId);
- commit('filterStations');
- },
-
- removeFilters({ commit }, filterId) {
- commit('removeFilters', filterId);
- commit('filterStations');
+const store = new Vuex.Store({
+ modules: {
+ Store
}
- },
- mutations: {
- setStations: (state, stations) => state.stations = stations,
- setTrainCount: (state, count) => state.trainCount = count,
-
- addFilters(state: any, filters: string[]) {
- state.filters.push(...filters);
- },
- removeFilters: (state: { filters: string[] }, filters: string[]) => {
- filters.forEach(filter => {
- state.filters = state.filters.filter((id: string) => id !== filter);
- })
- },
-
- filterStations(state: any) {
- state.filteredStations = state.stations.filter((station: any) => {
- if (station.default && state.filters.includes("default")) return false;
- if ((!station.default) && state.filters.includes("notDefault")) return false;
- if ((station.nonPublic || !station.reqLevel) && (state.filters.includes("nonPublic"))) return false;
-
- if (state.filters.includes(station.controlType)) return false;
- if (state.filters.includes(station.signalType)) return false;
-
- if (station.controlType && state.filters.filter((f: string) => station.controlType.includes(f)).length > 0) return false;
-
- return true;
- })
- }
- },
- getters: {
- getStations: state => state.filteredStations,
- getStationCount: state => state.stations.length,
- getTrainCount: state => state.trainCount,
- getFilters: (state: any) => state.filters,
- }
})
+export default store
\ No newline at end of file
diff --git a/src/store/modules/store.ts b/src/store/modules/store.ts
new file mode 100644
index 0000000..d5cc4c8
--- /dev/null
+++ b/src/store/modules/store.ts
@@ -0,0 +1,215 @@
+import { VuexModule, Module, Mutation, Action } from 'vuex-module-decorators';
+import data from '@/data/stations.json';
+
+@Module
+class Store extends VuexModule {
+ public trainCount: number = 0;
+ public stations: {
+ stationName: string;
+ stationHash: string;
+ maxUsers: number;
+ currentUsers: number;
+ spawnString: string;
+ dispatcherRate: number;
+ dispatcherName: string;
+ dispatcherExp: number;
+ dispatcherId: number;
+ stationLines: string;
+ stationProject: string;
+ reqLevel: string;
+ supportersOnly: string;
+ signalType: string;
+ controlType: string;
+ default: boolean;
+ nonPublic: boolean;
+ routes: { oneWay: { catenary: number; noCatenary: number; }, twoWay: { catenary: number; noCatenary: number; } };
+ }[] = [];
+
+ public filteredStations: {}[] = [];
+
+ public filters = {
+ "default": false,
+ "notDefault": false,
+ "nonPublic": false,
+ "SPK": false,
+ "SCS": false,
+ "ręczne": false,
+ "mechaniczne": false,
+ "współczesna": false,
+ "kształtowa": false,
+ "historyczna": false,
+ "mieszana": false,
+ "levelFrom": 0,
+ "levelTo": 20,
+ "1track-ne": 0,
+ "2track-ne": 0,
+ "1track-e": 0,
+ "2track-e": 0,
+ } as any;
+
+
+ get getStationCount(): number {
+ return this.stations.length;
+ }
+
+ get getTrainCount(): number {
+ return this.trainCount;
+ }
+
+ get getStations() {
+ return this.filteredStations;
+ }
+
+ get getFilters() {
+ return this.filters;
+ }
+
+ @Action
+ public setFilter(payload: { filterName: string, value: number | boolean }) {
+ this.context.commit('mutateFilter', payload);
+ this.context.commit('filterStations');
+ }
+
+ @Action
+ public async fetchStations() {
+ let onlineStations: {
+ stationName: string,
+ stationHash: string,
+ maxUsers: number,
+ currentUsers: number,
+ spawnString: string,
+ dispatcherRate: number,
+ dispatcherName: string,
+ dispatcherExp: number,
+ dispatcherId: number,
+ region: string,
+ isOnline: number
+ }[];
+
+ let statusList: [string, string, number, number][];
+
+ let onlineTrains: { isOnline: number, region: string, station: { stationName: string } }[];
+
+ try {
+ onlineStations = (await (await fetch('https://api.td2.info.pl:9640/?method=getStationsOnline')).json()).message
+ statusList = (await (await fetch('https://api.td2.info.pl:9640/?method=readFromSWDR&value=getDispatcherStatusList%3B1')).json()).message
+ onlineTrains = (await (await fetch('https://api.td2.info.pl:9640/?method=getTrainsOnline')).json()).message
+ } catch (error) {
+ throw Error(error.message);
+ }
+
+ this.context.commit('setTrainCount', onlineTrains.filter((train) => train.isOnline && train.region === 'eu').length);
+
+ const mappedStations = onlineStations
+ .filter((station) => station.region === 'eu')
+ .filter((station) => station.isOnline)
+ .map((
+ { stationName = '', stationHash = '', maxUsers = 0, currentUsers = 0, spawnString = '',
+ dispatcherRate = 0, dispatcherName = '', dispatcherExp = 0, dispatcherId = 0 }) => {
+
+ const status = statusList.find((s) => s[0] === stationHash && s[1] === 'eu')
+ let occupiedTo = "---"
+ let occupiedTimestamp = 0
+
+ if (!status)
+ occupiedTo = "NIEZALOGOWANY";
+ else {
+ let occupiedCode = status[2];
+
+ occupiedTimestamp = status[3];
+ occupiedTo = "NIEDOSTĘPNY";
+
+ if (occupiedCode === 0) {
+ if (occupiedTimestamp - Date.now() > 21000000)
+ occupiedTo = "BEZ LIMITU";
+ else
+ occupiedTo = new Date(status[3])
+ .toLocaleTimeString('en-US',
+ { hour12: false, hour: '2-digit', minute: '2-digit' });
+ }
+
+ if (occupiedCode === 1)
+ occupiedTo = "Z/W";
+
+ if (occupiedCode === 2 && occupiedTimestamp === 0)
+ occupiedTo = "KOŃCZY";
+
+ if (occupiedCode === 3)
+ occupiedTo = "BRAK MIEJSCA";
+ }
+
+ const trains = onlineTrains.filter((train) =>
+ train.region === 'eu' && train.isOnline && train.station.stationName === stationName)
+
+ const stationData = data.find((station) => station.stationName === stationName) || { stationName, stationURL: "" }
+
+ return {
+ ...stationData,
+ stationHash,
+ maxUsers,
+ currentUsers,
+ spawnString: spawnString && spawnString.split(';').map(v => v.split(',')[6] ? v.split(',')[6] : v.split(',')[0]),
+ dispatcherName,
+ dispatcherRate,
+ dispatcherId,
+ dispatcherExp: dispatcherExp < 2 ? 'L' : dispatcherExp,
+ occupiedTo,
+ trains
+ }
+ })
+
+ this.context.commit('setStations', mappedStations);
+ this.context.commit('filterStations');
+ }
+
+ @Mutation
+ public filterStations() {
+ this.filteredStations = this.stations.filter(station => {
+
+ if ((station.nonPublic || !station.reqLevel) && this.filters['nonPublic']) return false;
+ if (!station.reqLevel) return true;
+
+ if (station.default && this.filters['default']) return false;
+ if (!station.default && this.filters['notDefault']) return false;
+
+ if (station.reqLevel < this.filters['level-from']) return false;
+ if (station.reqLevel > this.filters['level-to']) return false;
+
+ if (station.routes.oneWay.catenary < this.filters['1track-e']) return false;
+ if (station.routes.oneWay.noCatenary < this.filters['1track-ne']) return false;
+
+ if (station.routes.twoWay.catenary < this.filters['2track-e']) return false;
+ if (station.routes.twoWay.noCatenary < this.filters['2track-ne']) return false;
+
+
+ if (this.filters[station.controlType]) return false;
+ if (this.filters[station.signalType]) return false;
+
+
+ if (this.filters["SPK"] && station.controlType.includes("SPK")) return false;
+ if (this.filters["SCS"] && station.controlType.includes("SCS")) return false;
+ if (this.filters["mechaniczne"] && station.controlType.includes("mechaniczne")) return false;
+ if (this.filters["ręczne"] && station.controlType.includes("ręczne")) return false;
+
+ return true;
+ })
+ }
+
+ @Mutation
+ public setStations(stations: []) {
+ this.stations = stations;
+ }
+
+ @Mutation
+ public setTrainCount(count: number) {
+ this.trainCount = count;
+ }
+
+ @Mutation
+ public mutateFilter(payload: { filterName: string, value: number | boolean }) {
+ this.filters[payload.filterName] = payload.value;
+ }
+
+}
+
+export default Store;
\ No newline at end of file
diff --git a/src/styles/responsive.scss b/src/styles/responsive.scss
index ff106a7..8573682 100644
--- a/src/styles/responsive.scss
+++ b/src/styles/responsive.scss
@@ -1,5 +1,5 @@
@mixin smallScreen() {
- @media only screen and (max-width: 850px) {
+ @media only screen and (max-width: 650px) {
@content;
}
}
diff --git a/src/styles/variables.scss b/src/styles/variables.scss
index 5c7bea9..bec59b5 100644
--- a/src/styles/variables.scss
+++ b/src/styles/variables.scss
@@ -6,5 +6,5 @@ $bgCol: #525252;
$errorCol: #ff1919;
$warningCol: #ff975b;
-$accentCol: #ffbb00;
+$accentCol: #ffc62b;
$accent2Col: #ff3d5d;
diff --git a/src/views/Home.vue b/src/views/Home.vue
index 64388fd..2024f2f 100644
--- a/src/views/Home.vue
+++ b/src/views/Home.vue
@@ -1,6 +1,5 @@
-
@@ -8,11 +7,11 @@