Dodano zakładkę z historią RJ scenerii

This commit is contained in:
2022-07-10 17:02:08 +02:00
parent 29e9924339
commit b246f2d2d7
7 changed files with 218 additions and 47 deletions
-1
View File
@@ -1 +0,0 @@
<?xml version="1.0" ?><svg height="21px" version="1.1" viewBox="0 0 20 21" width="20px" xmlns="http://www.w3.org/2000/svg" xmlns:sketch="http://www.bohemiancoding.com/sketch/ns" xmlns:xlink="http://www.w3.org/1999/xlink"><title/><desc/><defs/><g fill="none" fill-rule="evenodd" id="Page-1" stroke="none" stroke-width="1"><g fill="#ffffff" id="Core" opacity="0.9" transform="translate(-464.000000, -254.000000)"><g id="history" transform="translate(464.000000, 254.500000)"><path d="M10.5,0 C7,0 3.9,1.9 2.3,4.8 L0,2.5 L0,9 L6.5,9 L3.7,6.2 C5,3.7 7.5,2 10.5,2 C14.6,2 18,5.4 18,9.5 C18,13.6 14.6,17 10.5,17 C7.2,17 4.5,14.9 3.4,12 L1.3,12 C2.4,16 6.1,19 10.5,19 C15.8,19 20,14.7 20,9.5 C20,4.3 15.7,0 10.5,0 L10.5,0 Z M9,5 L9,10.1 L13.7,12.9 L14.5,11.6 L10.5,9.2 L10.5,5 L9,5 L9,5 Z" id="Shape"/></g></g></g></svg>

Before

Width:  |  Height:  |  Size: 813 B

+1 -1
View File
@@ -190,7 +190,7 @@ ul.options {
height: auto; height: auto;
z-index: 10; z-index: 100;
width: 100%; width: 100%;
} }
@@ -79,6 +79,7 @@ $terminated: salmon;
$disconnected: slategray; $disconnected: slategray;
.info-user-list { .info-user-list {
width: 100%;
ul { ul {
display: flex; display: flex;
+37 -18
View File
@@ -1,5 +1,17 @@
<template> <template>
<div class="scenery-timetable"> <section class="scenery-timetable">
<div class="timetable-header">
<h3>
<img :src="icons.timetable" alt="icon-timetable" />&nbsp;
<span>{{ $t('scenery.timetables') }}</span>
&nbsp;
<span class="text--primary">{{ station.onlineInfo?.scheduledTrains?.length || '0' }}</span>
<span>&nbsp;/&nbsp;</span>
<span class="text--grayed">
{{ station.onlineInfo?.scheduledTrains?.filter((train) => train.stopInfo.confirmed).length || '0' }}
</span>
</h3>
<div class="timetable-checkpoints" v-if="station && station.generalInfo?.checkpoints"> <div class="timetable-checkpoints" v-if="station && station.generalInfo?.checkpoints">
<button <button
v-for="cp in station.generalInfo.checkpoints" v-for="cp in station.generalInfo.checkpoints"
@@ -11,6 +23,7 @@
{{ cp.checkpointName }} {{ cp.checkpointName }}
</button> </button>
</div> </div>
</div>
<div class="timetable-list"> <div class="timetable-list">
<!-- <transition name="scenery-timetable-list-anim" mode="out-in"> --> <!-- <transition name="scenery-timetable-list-anim" mode="out-in"> -->
@@ -141,13 +154,13 @@
</div> </div>
<!-- </transition> --> <!-- </transition> -->
</div> </section>
</template> </template>
<script lang="ts"> <script lang="ts">
import Station from '@/scripts/interfaces/Station'; import Station from '@/scripts/interfaces/Station';
import SelectBox from '../Global/SelectBox.vue'; import SelectBox from '../Global/SelectBox.vue';
import { computed, defineComponent, ref } from '@vue/runtime-core'; import { computed, defineComponent, PropType, ref } from '@vue/runtime-core';
import { useRoute } from 'vue-router'; import { useRoute } from 'vue-router';
import dateMixin from '@/mixins/dateMixin'; import dateMixin from '@/mixins/dateMixin';
import routerMixin from '@/mixins/routerMixin'; import routerMixin from '@/mixins/routerMixin';
@@ -155,18 +168,17 @@ import { useStore } from '@/store/store';
import Loading from '../Global/Loading.vue'; import Loading from '../Global/Loading.vue';
export default defineComponent({ export default defineComponent({
name: 'SceneryTimetable',
components: { SelectBox, Loading }, components: { SelectBox, Loading },
mixins: [dateMixin, routerMixin], mixins: [dateMixin, routerMixin],
props: { props: {
station: { station: {
type: Object as () => Station, type: Object as PropType<Station>,
required: true, required: true,
}, },
timetableOnly: {
type: Boolean,
},
}, },
data: () => ({ data: () => ({
@@ -271,9 +283,19 @@ export default defineComponent({
display: flex; display: flex;
align-items: center; align-items: center;
justify-content: center; justify-content: center;
flex-direction: column;
font-size: 1.3em; position: sticky;
margin-top: 1em; top: 0;
z-index: 99;
background-color: #181818;
h3 {
display: flex;
align-items: center;
font-size: 1.4em;
}
} }
.timetable { .timetable {
@@ -282,7 +304,7 @@ export default defineComponent({
} }
&-item { &-item {
margin: 1em auto; margin: 0.5em auto;
padding: 0 0.5em; padding: 0 0.5em;
max-width: 1100px; max-width: 1100px;
@@ -290,7 +312,7 @@ export default defineComponent({
grid-template-columns: repeat(auto-fit, minmax(0, 1fr)); grid-template-columns: repeat(auto-fit, minmax(0, 1fr));
gap: 0 0.5em; gap: 0 0.5em;
background: $bgCol; background: #353535;
cursor: pointer; cursor: pointer;
z-index: 10; z-index: 10;
@@ -319,6 +341,10 @@ export default defineComponent({
} }
} }
.timetable-list {
position: relative;
}
.timetable-checkpoints { .timetable-checkpoints {
display: flex; display: flex;
justify-content: center; justify-content: center;
@@ -326,13 +352,6 @@ export default defineComponent({
flex-wrap: wrap; flex-wrap: wrap;
font-size: 1.1em; font-size: 1.1em;
padding: 0.75em 0; padding: 0.75em 0;
position: sticky;
top: 0;
z-index: 555;
background-color: #181818;
.checkpoint_item { .checkpoint_item {
&.current { &.current {
font-weight: bold; font-weight: bold;
@@ -0,0 +1,95 @@
<template>
<section class="scenery-timetables-history">
<Loading v-if="dataStatus != 2" />
<ul class="history-list" v-else>
<li class="list-item" v-for="historyItem in sceneryHistoryList">
<div>
<span class="text--grayed"> #{{ historyItem.timetableId }} </span>
<b class="text--primary">&nbsp;{{ historyItem.trainCategoryCode }} {{ historyItem.trainNo }}</b>
{{ historyItem.driverName }}
<div>Odjazd: {{ localeDate(historyItem.beginDate, $i18n.locale) }}</div>
</div>
<div style="text-align: right">
{{ historyItem.route.replace('|', ' -> ') }} | {{ historyItem.routeDistance }} km
<div v-if="historyItem.authorName">
Autor:
<b>{{ historyItem.authorName }}</b>
</div>
</div>
<!-- <div v-if="historyItem.authorId">{{ historyItem.authorName }}</div> -->
</li>
</ul>
</section>
</template>
<script lang="ts">
import dateMixin from '@/mixins/dateMixin';
import { DataStatus } from '@/scripts/enums/DataStatus';
import { SceneryTimetableHistory, TimetableHistory } from '@/scripts/interfaces/api/TimetablesAPIData';
import Station from '@/scripts/interfaces/Station';
import { URLs } from '@/scripts/utils/apiURLs';
import axios from 'axios';
import { defineComponent, PropType } from 'vue';
import Loading from '../Global/Loading.vue';
export default defineComponent({
name: 'SceneryTimetablesHistory',
mixins: [dateMixin],
props: {
station: {
type: Object as PropType<Station>,
required: true,
},
},
data() {
return {
sceneryHistoryList: [] as TimetableHistory[],
dataStatus: DataStatus.Loading,
};
},
mounted() {
this.fetchAPIData();
},
methods: {
async fetchAPIData(countFrom = 0, countLimit = 15) {
try {
const requestString = `${URLs.stacjownikAPI}/api/getSceneryTimetables?name=${this.station.name}&countFrom=${countFrom}&countLimit=${countLimit}`;
const historyAPIData: SceneryTimetableHistory = await (await axios.get(requestString)).data;
this.sceneryHistoryList = historyAPIData.sceneryTimetables;
this.dataStatus = DataStatus.Loaded;
} catch (error) {
console.error(error);
}
},
},
components: { Loading },
});
</script>
<style lang="scss" scoped>
.scenery-timetables-history {
position: relative;
height: 100%;
overflow-y: scroll;
}
.history-list {
padding: 0 0.5em;
}
.list-item {
display: flex;
flex-wrap: wrap;
justify-content: space-between;
text-align: left;
background-color: #353535;
padding: 0.5em;
margin: 0.5em 0;
line-height: 1.5em;
}
</style>
@@ -1,4 +1,3 @@
export interface TimetableHistory { export interface TimetableHistory {
timetableId: number; timetableId: number;
trainNo: number; trainNo: number;
@@ -28,3 +27,9 @@ export interface TimetableHistory {
authorName?: string; authorName?: string;
authorId?: number; authorId?: number;
} }
export interface SceneryTimetableHistory {
sceneryTimetables: TimetableHistory[];
totalCount: number;
sceneryName: string;
}
+68 -16
View File
@@ -22,16 +22,26 @@
<div class="scenery-right"> <div class="scenery-right">
<div class="info-actions"> <div class="info-actions">
<button class="btn btn--option checked">Aktywne rozkłady jazdy</button> <button
<button class="btn btn--option">Historia rozkładów scenerii</button> v-for="viewMode in viewModes"
<button class="btn btn--option">Historia dyżurów scenerii</button> class="btn btn--option"
@click="setViewMode(viewMode.component)"
:data-checked="currentViewCompontent == viewMode.component"
>
{{ viewMode.value }}
</button>
</div> </div>
<SceneryTimetable <keep-alive>
:station="stationInfo" <component :is="currentViewCompontent" :station="stationInfo" :key="currentViewCompontent"></component>
:timetableOnly="timetableOnly" </keep-alive>
:selectedCheckpoint="selectedCheckpoint" <!-- Timetables active -->
/> <!-- <SceneryTimetable />
<SceneryTimetablesHistory
v-if="currentViewMode == sceneryViewMode.TIMETABLES_HISTORY"
:stationName="stationInfo.name"
/> -->
</div> </div>
</div> </div>
</div> </div>
@@ -49,22 +59,48 @@ import { useRoute } from 'vue-router';
import { useStore } from '@/store/store'; import { useStore } from '@/store/store';
import routerMixin from '@/mixins/routerMixin'; import routerMixin from '@/mixins/routerMixin';
import SceneryTimetablesHistory from '../components/SceneryView/SceneryTimetablesHistory.vue';
enum SceneryViewMode {
'TIMETABLES_ACTIVE',
'TIMETABLES_HISTORY',
'SCENERY_HISTORY',
}
export default defineComponent({ export default defineComponent({
components: { SceneryInfo, SceneryTimetable, ActionButton, SceneryHeader }, components: { SceneryInfo, SceneryTimetable, ActionButton, SceneryHeader, SceneryTimetablesHistory },
mixins: [routerMixin], mixins: [routerMixin],
data: () => ({ data: () => ({
icons: { icons: {
history: require('@/assets/icon-history.svg'),
user: require('@/assets/icon-user.svg'), user: require('@/assets/icon-user.svg'),
back: require('@/assets/icon-back.svg'), back: require('@/assets/icon-back.svg'),
}, },
viewModes: [
{
name: SceneryViewMode.TIMETABLES_ACTIVE,
value: 'Aktywne rozkłady jazdy',
component: 'SceneryTimetable',
},
{
name: SceneryViewMode.TIMETABLES_HISTORY,
value: 'Historia rozkładów scenerii',
component: 'SceneryTimetablesHistory',
},
{
name: SceneryViewMode.SCENERY_HISTORY,
value: 'Historia dyżurów scenerii',
component: 'SceneryDispatchersHistory',
},
],
sceneryViewMode: SceneryViewMode,
selectedCheckpoint: '', selectedCheckpoint: '',
viewMode: 'info', currentViewCompontent: 'SceneryTimetable',
onlineFrom: -1, onlineFrom: -1,
}), }),
@@ -94,8 +130,8 @@ export default defineComponent({
}, },
methods: { methods: {
setCardViewMode(mode: string) { setViewMode(componentName: string) {
this.viewMode = mode; this.currentViewCompontent = componentName;
}, },
loadSelectedCheckpoint() { loadSelectedCheckpoint() {
@@ -157,7 +193,6 @@ button.back-btn {
width: 100%; width: 100%;
max-width: 1700px; max-width: 1700px;
padding: 1em;
margin: 1rem 0; margin: 1rem 0;
text-align: center; text-align: center;
@@ -187,7 +222,7 @@ button.back-btn {
max-height: 1000px; max-height: 1000px;
display: grid; display: grid;
grid-template-rows: 50px 1fr; grid-template-rows: auto 1fr;
gap: 1em; gap: 1em;
} }
@@ -198,10 +233,17 @@ button.back-btn {
.info-actions { .info-actions {
display: flex; display: flex;
justify-content: center; justify-content: center;
align-items: center;
.btn { .btn {
margin: 0.5em; margin: 0.5em;
padding: 0.5em;
box-shadow: 0 0 10px 4px #242424; box-shadow: 0 0 10px 4px #242424;
&[data-checked='true'] {
color: var(--clr-primary);
font-weight: bold;
}
} }
} }
@@ -234,8 +276,18 @@ button.back-btn {
} }
.scenery-left { .scenery-left {
border-radius: 1em;
margin-bottom: 1em;
height: auto; height: auto;
margin-bottom: 2em; }
.scenery-right {
border-radius: 1em;
height: auto;
}
.info-actions {
flex-wrap: wrap;
} }
} }
</style> </style>