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