mirror of
https://github.com/Spythere/stacjownik.git
synced 2026-05-03 13:28:11 +00:00
Poprawki do zapamiętywania statusów dyżurnych
This commit is contained in:
+1
-3
@@ -8,7 +8,7 @@
|
|||||||
</div> -->
|
</div> -->
|
||||||
<header class="app_header">
|
<header class="app_header">
|
||||||
<div class="header_body">
|
<div class="header_body">
|
||||||
<status-indicator :dataStatus="dataStatus" />
|
<status-indicator />
|
||||||
|
|
||||||
<span class="header_brand">
|
<span class="header_brand">
|
||||||
<span>
|
<span>
|
||||||
@@ -116,7 +116,6 @@ export default defineComponent({
|
|||||||
() => store.getters[GETTERS.currentRegion]
|
() => store.getters[GETTERS.currentRegion]
|
||||||
);
|
);
|
||||||
|
|
||||||
const dataStatus = computed(() => data.value.sceneryDataStatus);
|
|
||||||
// const sceneryDataStatus = computed(() => data.value.sceneryDataStatus);
|
// const sceneryDataStatus = computed(() => data.value.sceneryDataStatus);
|
||||||
|
|
||||||
const isFilterCardVisible = ref(false);
|
const isFilterCardVisible = ref(false);
|
||||||
@@ -128,7 +127,6 @@ export default defineComponent({
|
|||||||
currentRegion,
|
currentRegion,
|
||||||
isFilterCardVisible,
|
isFilterCardVisible,
|
||||||
|
|
||||||
dataStatus,
|
|
||||||
dispatcherDataStatus: computed(() => data.value.dispatcherDataStatus),
|
dispatcherDataStatus: computed(() => data.value.dispatcherDataStatus),
|
||||||
|
|
||||||
trainCount: computed(() => data.value.trainList.length),
|
trainCount: computed(() => data.value.trainList.length),
|
||||||
|
|||||||
@@ -163,12 +163,14 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
|
import { GETTERS } from '@/constants/storeConstants';
|
||||||
import { DataStatus } from '@/scripts/enums/DataStatus';
|
import { DataStatus } from '@/scripts/enums/DataStatus';
|
||||||
import { StoreData } from '@/scripts/interfaces/StoreData';
|
import { StoreData } from '@/scripts/interfaces/StoreData';
|
||||||
import { defineComponent } from 'vue';
|
import { State, useStore } from '@/store';
|
||||||
|
import { computed, defineComponent } from 'vue';
|
||||||
|
import { Store } from 'vuex';
|
||||||
|
|
||||||
export default defineComponent({
|
export default defineComponent({
|
||||||
props: ['dataStatus'],
|
|
||||||
|
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
@@ -193,11 +195,20 @@ export default defineComponent({
|
|||||||
this.setSignalStatus(DataStatus.Loading);
|
this.setSignalStatus(DataStatus.Loading);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
setup() {
|
||||||
|
const store: Store<State> = useStore();
|
||||||
|
|
||||||
|
return {
|
||||||
|
dataStatus: computed(() => store.getters[GETTERS.allData] as StoreData)
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
watch: {
|
watch: {
|
||||||
dataStatus(storeData: StoreData) {
|
dataStatus(storeData: StoreData) {
|
||||||
const sceneryDataStatus = storeData.sceneryDataStatus;
|
const sceneryDataStatus = storeData.sceneryDataStatus;
|
||||||
const trainsDataStatus = storeData.trainsDataStatus;
|
const trainsDataStatus = storeData.trainsDataStatus;
|
||||||
const dispatcherDataStatus = storeData.dispatcherDataStatus;
|
const dispatcherDataStatus = storeData.dispatcherDataStatus;
|
||||||
|
|
||||||
|
|
||||||
if (sceneryDataStatus == DataStatus.Error) {
|
if (sceneryDataStatus == DataStatus.Error) {
|
||||||
this.setSignalStatus(sceneryDataStatus);
|
this.setSignalStatus(sceneryDataStatus);
|
||||||
|
|||||||
@@ -2,9 +2,9 @@
|
|||||||
<div class="train-table" @keydown.esc="closeTimetableCard">
|
<div class="train-table" @keydown.esc="closeTimetableCard">
|
||||||
<transition name="anim" mode="out-in">
|
<transition name="anim" mode="out-in">
|
||||||
<div :key="trainsDataStatus">
|
<div :key="trainsDataStatus">
|
||||||
<div class="traffic-warning" v-if="distanceLimitExceeded">
|
<!-- <div class="traffic-warning" v-if="data.">
|
||||||
{{ $t('trains.distance-exceeded') }}
|
{{ $t('trains.distance-exceeded') }}
|
||||||
</div>
|
</div> -->
|
||||||
|
|
||||||
<div class="table-info no-trains" v-if="trains.length == 0 && trainsDataStatus >= 2">
|
<div class="table-info no-trains" v-if="trains.length == 0 && trainsDataStatus >= 2">
|
||||||
{{ $t('trains.no-trains') }}
|
{{ $t('trains.no-trains') }}
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ export const getStatusID = (stationStatus: any): string => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
export const getStatusTimestamp = (stationStatus: any): number => {
|
export const getStatusTimestamp = (stationStatus: any): number => {
|
||||||
if (!stationStatus || stationStatus == -1) return -2;
|
if (!stationStatus) return -2;
|
||||||
|
|
||||||
const statusCode = stationStatus[2];
|
const statusCode = stationStatus[2];
|
||||||
const statusTimestamp = stationStatus[3];
|
const statusTimestamp = stationStatus[3];
|
||||||
|
|||||||
+16
-4
@@ -24,6 +24,8 @@ import StationRoutes from '@/scripts/interfaces/StationRoutes';
|
|||||||
export interface State {
|
export interface State {
|
||||||
stationList: Station[],
|
stationList: Station[],
|
||||||
trainList: Train[],
|
trainList: Train[],
|
||||||
|
|
||||||
|
lastDispatcherStatuses: { hash: string; statusTimestamp: number; statusID: string; }[],
|
||||||
// timetableList: Timetable[],
|
// timetableList: Timetable[],
|
||||||
|
|
||||||
sceneryData: any[][],
|
sceneryData: any[][],
|
||||||
@@ -75,6 +77,7 @@ export const store = createStore<State>({
|
|||||||
// timetableList: [],
|
// timetableList: [],
|
||||||
|
|
||||||
sceneryData: [],
|
sceneryData: [],
|
||||||
|
lastDispatcherStatuses: [],
|
||||||
|
|
||||||
region: { id: "eu", value: "PL1" },
|
region: { id: "eu", value: "PL1" },
|
||||||
|
|
||||||
@@ -195,6 +198,7 @@ export const store = createStore<State>({
|
|||||||
}) || []
|
}) || []
|
||||||
|
|
||||||
const onlineStationNames: string[] = [];
|
const onlineStationNames: string[] = [];
|
||||||
|
const prevDispatcherStatuses: State['lastDispatcherStatuses'] = [];
|
||||||
|
|
||||||
stationsAPIData.message.forEach((stationAPI) => {
|
stationsAPIData.message.forEach((stationAPI) => {
|
||||||
if (stationAPI.region !== this.state.region.id || !stationAPI.isOnline) return;
|
if (stationAPI.region !== this.state.region.id || !stationAPI.isOnline) return;
|
||||||
@@ -204,9 +208,17 @@ export const store = createStore<State>({
|
|||||||
const stationName = stationAPI.stationName.toLowerCase();
|
const stationName = stationAPI.stationName.toLowerCase();
|
||||||
const station = this.state.stationList.find(s => s.name == stationAPI.stationName);
|
const station = this.state.stationList.find(s => s.name == stationAPI.stationName);
|
||||||
|
|
||||||
|
const prevDispatcherStatus = this.state.lastDispatcherStatuses.find(dispatcher => dispatcher.hash === stationAPI.stationHash);
|
||||||
const stationStatus = dispatchersAPIData.success ? dispatchersAPIData.message.find((status: string[]) => status[0] == stationAPI.stationHash && status[1] == this.state.region.id) : -1;
|
const stationStatus = dispatchersAPIData.success ? dispatchersAPIData.message.find((status: string[]) => status[0] == stationAPI.stationHash && status[1] == this.state.region.id) : -1;
|
||||||
const statusTimestamp = getStatusTimestamp(stationStatus);
|
|
||||||
const statusID = getStatusID(stationStatus);
|
const statusTimestamp = getStatusTimestamp(stationStatus == -1 && prevDispatcherStatus ? prevDispatcherStatus.statusTimestamp : stationStatus);
|
||||||
|
const statusID = getStatusID(stationStatus == -1 && prevDispatcherStatus ? prevDispatcherStatus.statusTimestamp : stationStatus );
|
||||||
|
|
||||||
|
prevDispatcherStatuses.push({
|
||||||
|
hash: stationAPI.stationHash,
|
||||||
|
statusID,
|
||||||
|
statusTimestamp
|
||||||
|
});
|
||||||
|
|
||||||
const stationTrains = trainsAPIData.response
|
const stationTrains = trainsAPIData.response
|
||||||
.filter(train => train.region === this.state.region.id && train.online && train.currentStationName === stationAPI.stationName)
|
.filter(train => train.region === this.state.region.id && train.online && train.currentStationName === stationAPI.stationName)
|
||||||
@@ -277,7 +289,6 @@ export const store = createStore<State>({
|
|||||||
statusTimestamp,
|
statusTimestamp,
|
||||||
statusID,
|
statusID,
|
||||||
scheduledTrains,
|
scheduledTrains,
|
||||||
// statusTimeString: timestampToString(statusTimestamp),
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!station) {
|
if (!station) {
|
||||||
@@ -298,9 +309,10 @@ export const store = createStore<State>({
|
|||||||
.forEach(offlineStation => {
|
.forEach(offlineStation => {
|
||||||
offlineStation.onlineInfo = undefined;
|
offlineStation.onlineInfo = undefined;
|
||||||
});
|
});
|
||||||
|
|
||||||
this.state.trainList = updatedTrainList;
|
this.state.trainList = updatedTrainList;
|
||||||
this.state.trainsDataStatus = DataStatus.Loaded;
|
this.state.trainsDataStatus = DataStatus.Loaded;
|
||||||
|
this.state.lastDispatcherStatuses = prevDispatcherStatuses;
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user