Poprawki w widoku historii scenerii

This commit is contained in:
2022-02-20 15:15:10 +01:00
parent bfe0fdb658
commit 259d5b5db1
4 changed files with 52 additions and 33 deletions
@@ -73,7 +73,7 @@ interface SceneryHistory {
}
interface HistoryResultAPI {
result: SceneryHistory;
response: SceneryHistory;
errorMessage?: any;
}
@@ -100,13 +100,16 @@ export default defineComponent({
async mounted() {
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;
if (!apiResult || !apiResult.result) return;
if (!apiResult.errorMessage) {
this.dispatcherHistory = apiResult.result.dispatcherHistory;
this.dispatcherHistory = apiResult.response.dispatcherHistory;
this.dispatcherTimeline = this.dispatcherHistory
.reduce((acc, dispatcher) => {
+7 -3
View File
@@ -7,8 +7,8 @@
<scenery-info-icons :station="station" />
<!-- info dispatcher -->
<scenery-info-dispatcher :station="station" />
<scenery-info-dispatcher :station="station" :onlineFrom="onlineFrom" />
<div class="info-lists">
<!-- user list -->
<scenery-info-user-list :station="station" />
@@ -45,8 +45,12 @@ export default defineComponent({
default: {},
},
timetableOnly: Boolean,
timetableOnly: Boolean
},
data: () => ({
onlineFrom: -1
}),
});
</script>
@@ -31,17 +31,6 @@ import { defineComponent } from 'vue';
import styleMixin from '@/mixins/styleMixin';
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({
mixins: [styleMixin],
@@ -50,22 +39,18 @@ export default defineComponent({
type: Object as () => Station,
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: () => ({
icons: {
spawn: require('@/assets/icon-spawn.svg'),
},
onlineFrom: -1
}
}),
});
</script>