mirror of
https://github.com/Spythere/stacjownik.git
synced 2026-05-03 21:38:13 +00:00
Poprawki w widoku historii scenerii
This commit is contained in:
@@ -73,7 +73,7 @@ interface SceneryHistory {
|
|||||||
}
|
}
|
||||||
|
|
||||||
interface HistoryResultAPI {
|
interface HistoryResultAPI {
|
||||||
result: SceneryHistory;
|
response: SceneryHistory;
|
||||||
errorMessage?: any;
|
errorMessage?: any;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -100,13 +100,16 @@ export default defineComponent({
|
|||||||
|
|
||||||
async mounted() {
|
async mounted() {
|
||||||
try {
|
try {
|
||||||
const apiResult: HistoryResultAPI = (await axios.get(`${API_URL}?name=${this.name}`)).data;
|
const apiResult: HistoryResultAPI = (await axios.get(`${API_URL}?name=${this.name}&historyCount=100`)).data;
|
||||||
|
|
||||||
|
console.log(apiResult);
|
||||||
|
|
||||||
|
|
||||||
|
if (!apiResult || !apiResult.response) return;
|
||||||
this.isLoaded = true;
|
this.isLoaded = true;
|
||||||
if (!apiResult || !apiResult.result) return;
|
|
||||||
|
|
||||||
if (!apiResult.errorMessage) {
|
if (!apiResult.errorMessage) {
|
||||||
this.dispatcherHistory = apiResult.result.dispatcherHistory;
|
this.dispatcherHistory = apiResult.response.dispatcherHistory;
|
||||||
|
|
||||||
this.dispatcherTimeline = this.dispatcherHistory
|
this.dispatcherTimeline = this.dispatcherHistory
|
||||||
.reduce((acc, dispatcher) => {
|
.reduce((acc, dispatcher) => {
|
||||||
|
|||||||
@@ -7,8 +7,8 @@
|
|||||||
<scenery-info-icons :station="station" />
|
<scenery-info-icons :station="station" />
|
||||||
|
|
||||||
<!-- info dispatcher -->
|
<!-- info dispatcher -->
|
||||||
<scenery-info-dispatcher :station="station" />
|
<scenery-info-dispatcher :station="station" :onlineFrom="onlineFrom" />
|
||||||
|
|
||||||
<div class="info-lists">
|
<div class="info-lists">
|
||||||
<!-- user list -->
|
<!-- user list -->
|
||||||
<scenery-info-user-list :station="station" />
|
<scenery-info-user-list :station="station" />
|
||||||
@@ -45,8 +45,12 @@ export default defineComponent({
|
|||||||
default: {},
|
default: {},
|
||||||
},
|
},
|
||||||
|
|
||||||
timetableOnly: Boolean,
|
timetableOnly: Boolean
|
||||||
},
|
},
|
||||||
|
|
||||||
|
data: () => ({
|
||||||
|
onlineFrom: -1
|
||||||
|
}),
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|||||||
@@ -31,17 +31,6 @@ import { defineComponent } from 'vue';
|
|||||||
|
|
||||||
import styleMixin from '@/mixins/styleMixin';
|
import styleMixin from '@/mixins/styleMixin';
|
||||||
import Station from '@/scripts/interfaces/Station';
|
import Station from '@/scripts/interfaces/Station';
|
||||||
import axios from 'axios';
|
|
||||||
import { URLs } from '@/scripts/utils/apiURLs';
|
|
||||||
|
|
||||||
interface SceneryHistoryData {
|
|
||||||
response?: {
|
|
||||||
stationName: string;
|
|
||||||
currentDispatcher: string;
|
|
||||||
currentDispatcherId: number;
|
|
||||||
currentDispatcherFrom: number;
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
export default defineComponent({
|
export default defineComponent({
|
||||||
mixins: [styleMixin],
|
mixins: [styleMixin],
|
||||||
@@ -50,22 +39,18 @@ export default defineComponent({
|
|||||||
type: Object as () => Station,
|
type: Object as () => Station,
|
||||||
default: {},
|
default: {},
|
||||||
},
|
},
|
||||||
|
|
||||||
|
onlineFrom: {
|
||||||
|
type: Number,
|
||||||
|
default: -1
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
async mounted() {
|
|
||||||
const dispatcherInfo: SceneryHistoryData = await (
|
|
||||||
await axios.get(`${URLs.stacjownikAPI}/api/getSceneryHistory?name=${this.station.name.replace(/ /g, '_')}&historyCount=0`)
|
|
||||||
).data;
|
|
||||||
|
|
||||||
this.onlineFrom = dispatcherInfo.response?.currentDispatcherFrom || -1;
|
|
||||||
},
|
|
||||||
|
|
||||||
data: () => ({
|
data: () => ({
|
||||||
icons: {
|
icons: {
|
||||||
spawn: require('@/assets/icon-spawn.svg'),
|
spawn: require('@/assets/icon-spawn.svg'),
|
||||||
},
|
}
|
||||||
|
|
||||||
onlineFrom: -1
|
|
||||||
}),
|
}),
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@@ -61,6 +61,20 @@ import { useStore } from '@/store';
|
|||||||
import { GETTERS } from '@/constants/storeConstants';
|
import { GETTERS } from '@/constants/storeConstants';
|
||||||
import { useRoute } from 'vue-router';
|
import { useRoute } from 'vue-router';
|
||||||
|
|
||||||
|
import axios from 'axios';
|
||||||
|
import { URLs } from '@/scripts/utils/apiURLs';
|
||||||
|
import { watch, watchEffect } from 'vue';
|
||||||
|
import Station from '@/scripts/interfaces/Station';
|
||||||
|
|
||||||
|
interface SceneryHistoryData {
|
||||||
|
response?: {
|
||||||
|
stationName: string;
|
||||||
|
currentDispatcher: string;
|
||||||
|
currentDispatcherId: number;
|
||||||
|
currentDispatcherFrom: number;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
export default defineComponent({
|
export default defineComponent({
|
||||||
components: { SceneryInfo, SceneryTimetable, SceneryHistory, ActionButton, SceneryHeader },
|
components: { SceneryInfo, SceneryTimetable, SceneryHistory, ActionButton, SceneryHeader },
|
||||||
|
|
||||||
@@ -72,6 +86,9 @@ export default defineComponent({
|
|||||||
},
|
},
|
||||||
|
|
||||||
viewMode: 'info',
|
viewMode: 'info',
|
||||||
|
|
||||||
|
stationInfo: {} as (Station | undefined),
|
||||||
|
onlineFrom: -1
|
||||||
}),
|
}),
|
||||||
|
|
||||||
setup() {
|
setup() {
|
||||||
@@ -85,10 +102,14 @@ export default defineComponent({
|
|||||||
const isComponentVisible = computed(() => route.path === '/scenery');
|
const isComponentVisible = computed(() => route.path === '/scenery');
|
||||||
|
|
||||||
const isDataLoaded = computed(() => data.value.dataConnectionStatus === DataStatus.Loaded);
|
const isDataLoaded = computed(() => data.value.dataConnectionStatus === DataStatus.Loaded);
|
||||||
|
|
||||||
|
const stationInfo = computed(() => {
|
||||||
|
return data.value.stationList.find((station) => station.name === route.query.station?.toString().replace(/_/g, ' '))
|
||||||
|
})
|
||||||
|
|
||||||
const stationInfo = computed(() =>
|
// const onlineFrom = computed(async () => {
|
||||||
data.value.stationList.find((station) => station.name === route.query.station?.toString().replace(/_/g, ' '))
|
// return await (await axios.get(`${URLs.stacjownikAPI}?name=${route.query.station}&historyCount=0`)).data;
|
||||||
);
|
// });
|
||||||
|
|
||||||
return {
|
return {
|
||||||
data,
|
data,
|
||||||
@@ -96,7 +117,7 @@ export default defineComponent({
|
|||||||
timetableOnly,
|
timetableOnly,
|
||||||
isComponentVisible,
|
isComponentVisible,
|
||||||
isDataLoaded,
|
isDataLoaded,
|
||||||
stationInfo,
|
stationInfo
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
|
||||||
@@ -110,8 +131,14 @@ export default defineComponent({
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
activated() {
|
async mounted() {
|
||||||
|
this.stationInfo = (this.$store.getters[GETTERS.allData] as StoreData).stationList.find((station) => station.name === this.$route.query.station?.toString().replace(/_/g, ' '))
|
||||||
|
},
|
||||||
|
|
||||||
|
async activated() {
|
||||||
if (this.currentRegion.id != 'eu' && this.viewMode == 'history') this.viewMode = 'info';
|
if (this.currentRegion.id != 'eu' && this.viewMode == 'history') this.viewMode = 'info';
|
||||||
|
|
||||||
|
const onlineFrom = await (await axios.get(`${URLs.stacjownikAPI}/api/getSceneryHistory?name=${this.$route.query.station}&historyCount=0`)).data;
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
Reference in New Issue
Block a user