mirror of
https://github.com/Spythere/stacjownik.git
synced 2026-05-03 05:18:11 +00:00
148 lines
4.2 KiB
Vue
148 lines
4.2 KiB
Vue
<template>
|
|
<!-- WIP -->
|
|
<!-- <div class="top-filters">
|
|
<button class="btn btn--option">ROZPOCZYNA BIEG</button>
|
|
|
|
<button class="btn btn--option">PRZEZ</button>
|
|
|
|
<button class="btn btn--option">KOŃCZY BIEG</button>
|
|
</div> -->
|
|
|
|
<section class="scenery-table-section">
|
|
<Loading v-if="dataStatus != DataStatus.Loaded" />
|
|
|
|
<div class="no-history" v-else-if="historyList.length == 0">
|
|
{{ $t('scenery.history-list-empty') }}
|
|
</div>
|
|
|
|
<table class="scenery-history-table" v-else>
|
|
<thead>
|
|
<th>{{ $t('scenery.timetables-history-id') }}</th>
|
|
<th>{{ $t('scenery.timetables-history-number') }}</th>
|
|
<th>{{ $t('scenery.timetables-history-route') }}</th>
|
|
<th>{{ $t('scenery.timetables-history-driver') }}</th>
|
|
<th>{{ $t('scenery.timetables-history-author') }}</th>
|
|
<th>{{ $t('scenery.timetables-history-date') }}</th>
|
|
</thead>
|
|
|
|
<tbody>
|
|
<tr v-for="historyItem in historyList" :key="historyItem.id">
|
|
<td>
|
|
<router-link :to="`/journal/timetables?timetableId=${historyItem.id}`">
|
|
#{{ historyItem.id }}
|
|
</router-link>
|
|
</td>
|
|
<td>
|
|
<b class="text--primary">{{ historyItem.trainCategoryCode }}</b> <br />
|
|
{{ historyItem.trainNo }}
|
|
</td>
|
|
<td>{{ historyItem.route.replace('|', ' -> ') }}</td>
|
|
<td>{{ historyItem.driverName }}</td>
|
|
<td>
|
|
<router-link
|
|
v-if="historyItem.authorName"
|
|
:to="`/journal/timetables?authorName=${historyItem.authorName}`"
|
|
>{{ historyItem.authorName }}
|
|
</router-link>
|
|
<i v-else>{{ $t('scenery.timetable-author-unknown') }}</i>
|
|
</td>
|
|
<td>
|
|
<b>{{ localeDay(historyItem.beginDate, $i18n.locale) }}</b>
|
|
{{ localeTime(historyItem.beginDate, $i18n.locale) }}
|
|
</td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
</section>
|
|
|
|
<div class="bottom-info">
|
|
<button class="btn btn--option" v-if="historyList.length > 0" @click="navigateToHistory()">
|
|
{{ $t('scenery.bottom-info') }}
|
|
</button>
|
|
</div>
|
|
</template>
|
|
|
|
<script lang="ts">
|
|
import axios from 'axios';
|
|
import { defineComponent, PropType } from 'vue';
|
|
import dateMixin from '../../mixins/dateMixin';
|
|
|
|
import Station from '../../scripts/interfaces/Station';
|
|
import { URLs } from '../../scripts/utils/apiURLs';
|
|
import Loading from '../Global/Loading.vue';
|
|
import listObserverMixin from '../../mixins/listObserverMixin';
|
|
import { OnlineScenery } from '../../store/typings';
|
|
import { API } from '../../typings/api';
|
|
import { Status } from '../../typings/common';
|
|
|
|
export default defineComponent({
|
|
name: 'SceneryTimetablesHistory',
|
|
mixins: [dateMixin, listObserverMixin],
|
|
props: {
|
|
station: {
|
|
type: Object as PropType<Station>
|
|
},
|
|
onlineScenery: {
|
|
type: Object as PropType<OnlineScenery>
|
|
}
|
|
},
|
|
|
|
data() {
|
|
return {
|
|
historyList: [] as API.TimetableHistory.Response,
|
|
dataStatus: Status.Data.Loading,
|
|
DataStatus: Status.Data
|
|
};
|
|
},
|
|
|
|
async activated() {
|
|
this.fetchAPIData();
|
|
},
|
|
|
|
methods: {
|
|
async fetchAPIData(countFrom = 0, countLimit = 15) {
|
|
if (!this.station && !this.onlineScenery) {
|
|
this.dataStatus = Status.Data.Loaded;
|
|
return;
|
|
}
|
|
|
|
try {
|
|
const requestString = `${URLs.stacjownikAPI}/api/getTimetables?issuedFrom=${
|
|
this.station?.name || this.onlineScenery?.name
|
|
}&countFrom=${countFrom}&countLimit=${countLimit}`;
|
|
|
|
const response: API.TimetableHistory.Response = await (await axios.get(requestString)).data;
|
|
|
|
this.historyList = response;
|
|
|
|
this.dataStatus = Status.Data.Loaded;
|
|
} catch (error) {
|
|
console.error(error);
|
|
}
|
|
},
|
|
|
|
navigateToHistory() {
|
|
this.$router.push(
|
|
`/journal/timetables?issuedFrom=${this.station?.name || this.onlineScenery?.name}`
|
|
);
|
|
}
|
|
},
|
|
components: { Loading }
|
|
});
|
|
</script>
|
|
|
|
<style lang="scss" scoped>
|
|
@import '../../styles/responsive.scss';
|
|
@import '../../styles/sceneryViewTables.scss';
|
|
|
|
.top-filters {
|
|
display: flex;
|
|
justify-content: center;
|
|
gap: 0.5em;
|
|
|
|
button {
|
|
padding: 0.5em;
|
|
}
|
|
}
|
|
</style>
|