Merge branch 'development' into feature/journal-dispatchers

This commit is contained in:
2022-05-19 23:48:01 +02:00
4 changed files with 20563 additions and 26291 deletions
+20514 -26256
View File
File diff suppressed because it is too large Load Diff
+8 -7
View File
@@ -1,6 +1,6 @@
{
"name": "stacjownik",
"version": "1.6.8",
"version": "1.7.1",
"private": true,
"scripts": {
"serve": "vue-cli-service serve",
@@ -11,21 +11,22 @@
"dependencies": {
"core-js": "^3.12.1",
"dotenv": "^8.6.0",
"firebase": "^9.8.1",
"firestore": "^1.1.6",
"howler": "^2.2.1",
"socket.io-client": "^4.4.1",
"vue": "^3.1.2",
"vue": "^3.2.34",
"vue-class-component": "^7.2.6",
"vue-i18n": "^9.1.6",
"vue-router": "^4.0.0-0",
"vuex": "^4.0.0-0"
},
"devDependencies": {
"@vue/cli-plugin-babel": "~4.4.0",
"@vue/cli-plugin-router": "~4.4.0",
"@vue/cli-plugin-typescript": "~4.4.0",
"@vue/cli-plugin-vuex": "~4.4.0",
"@vue/cli-service": "^4.5.13",
"@vue/cli-plugin-babel": "^5.0.4",
"@vue/cli-plugin-router": "^5.0.4",
"@vue/cli-plugin-typescript": "^5.0.4",
"@vue/cli-plugin-vuex": "^5.0.4",
"@vue/cli-service": "^5.0.4",
"@vue/compiler-sfc": "^3.1.0",
"axios": "^0.21.1",
"sass": "^1.32.13",
+2 -1
View File
@@ -166,7 +166,8 @@
import { GETTERS } from '@/constants/storeConstants';
import { DataStatus } from '@/scripts/enums/DataStatus';
import { StoreData } from '@/scripts/interfaces/StoreData';
import { State, useStore } from '@/store';
import { useStore } from '@/store';
import { State } from '@/store/types';
import { computed, defineComponent } from 'vue';
import { Store } from 'vuex';
+39 -27
View File
@@ -28,14 +28,16 @@
<!-- <transition name="unfold-anim" @enter="enter" @afterEnter="afterEnter" @leave="leave"> -->
<!-- <div class="dispatcher-list" v-if="timeline.showTimeline"> -->
<div class="dispatcher-item" v-for="dispatcher in timeline.dispatchers" :key="dispatcher.dispatcherFrom">
<div class="dispatcher-item" v-for="dispatcher in timeline.dispatchers" :key="dispatcher.timestampFrom">
<b>{{ dispatcher.dispatcherName }}</b>
<span>
<span class="dispatcher-from text--primary">
{{ timestampToString(dispatcher.dispatcherFrom, true) }}
{{ timestampToString(dispatcher.timestampFrom, true) }}
</span>
<span class="dispatcher-to text--primary" v-if="dispatcher.timestampTo">
&gt; {{ timestampToString(dispatcher.timestampTo, true) }}
</span>
&gt;
<span class="dispatcher-to text--primary"> {{ timestampToString(dispatcher.dispatcherTo, true) }}</span>
</span>
</div>
<!-- </div> -->
@@ -60,30 +62,32 @@ interface DispatcherTimeline {
interface DispatcherHistory {
dispatcherName: string;
dispatcherId: number;
dispatcherFrom: any;
dispatcherTo: any;
timestampFrom: number;
timestampTo?: number;
}
interface SceneryHistory {
stops: any[];
checkpoints: any[];
interface SceneryHistoryResponse {
stationName: string;
currentDispatcher: string;
currentDispatcherId: number;
currentDispatcherFrom: number;
dispatcherHistory: DispatcherHistory[];
stationHash: string;
region: string;
dispatcherName: string;
dispatcherId: number;
timestampFrom: number;
timestampTo?: number;
currentDuration: number;
isOnline: boolean;
lastOnlineTimestamp: number;
}
interface HistoryResultAPI {
response: SceneryHistory;
errorMessage?: any;
response: SceneryHistoryResponse[];
errorMessage?: string;
}
const API_URL = `${URLs.stacjownikAPI}/api/getSceneryHistory`;
const HISTORY_API_URL = `${URLs.stacjownikAPI}/api/getSceneryHistory`;
export default defineComponent({
data: () => ({
dispatcherHistory: [] as DispatcherHistory[],
dispatcherTimeline: [] as DispatcherTimeline[],
isLoaded: false,
@@ -105,21 +109,23 @@ export default defineComponent({
};
},
async mounted() {
async mounted() {
try {
const apiResult: HistoryResultAPI = (await axios.get(`${API_URL}?name=${this.name}&historyCount=100`)).data;
const apiResult: HistoryResultAPI = (await axios.get(`${HISTORY_API_URL}?name=${this.name}&historyCount=100`)).data;
if (!apiResult || !apiResult.response) return;
this.isLoaded = true;
if (apiResult.errorMessage) return;
this.dispatcherHistory = apiResult.response.dispatcherHistory;
this.savedSceneryHistory = this.dispatcherHistory;
console.log(apiResult);
this.dispatcherTimeline = this.dispatcherHistory
.reduce((acc, dispatcher) => {
const dateStr = new Date(dispatcher.dispatcherFrom).toLocaleDateString('pl-PL').replace(/\./g, '/');
const dispatcherHistoryResult = apiResult.response;
this.savedSceneryHistory = dispatcherHistoryResult;
this.dispatcherTimeline = apiResult.response.reduce(
(acc, { timestampFrom, timestampTo, dispatcherId, dispatcherName }) => {
const dateStr = new Date(timestampFrom).toLocaleDateString('pl-PL').replace(/\./g, '/');
const timelineDay = acc.find((timeline) => timeline.date == dateStr) || {
date: dateStr,
@@ -127,13 +133,19 @@ export default defineComponent({
showTimeline: false,
};
timelineDay.dispatchers.unshift(dispatcher);
timelineDay.dispatchers.unshift({
timestampFrom,
timestampTo,
dispatcherId,
dispatcherName,
});
if (!acc.find((timeline) => timeline.date == dateStr)) acc.push(timelineDay);
return acc;
}, [] as DispatcherTimeline[])
.reverse();
},
[] as DispatcherTimeline[]
);
} catch (error) {
console.error(error);
}