Zmiany w wyglądzie i funkcjonalnościach dziennika RJ

This commit is contained in:
2022-09-03 00:11:42 +02:00
parent 76d0ff88f1
commit b90ac6c09e
4 changed files with 149 additions and 135 deletions
+1 -1
View File
@@ -66,7 +66,7 @@
<main class="app_main"> <main class="app_main">
<router-view v-slot="{ Component }"> <router-view v-slot="{ Component }">
<keep-alive> <keep-alive>
<component :is="Component" :key="$route.path" /> <component :is="Component" :key="$route.name" />
</keep-alive> </keep-alive>
</router-view> </router-view>
</main> </main>
+117 -110
View File
@@ -25,55 +25,60 @@
{{ $t('app.error') }} {{ $t('app.error') }}
</div> </div>
<div class="journal_warning" v-else-if="historyList.length == 0"> <div class="journal_warning" v-else-if="computedTimetableHistory.length == 0">
{{ $t('app.no-result') }} {{ $t('app.no-result') }}
</div> </div>
<ul v-else> <ul v-else>
<transition-group name="journal-list-anim"> <transition-group name="journal-list-anim">
<li v-for="(item, i) in historyList" class="journal_item" :key="item.timetableId"> <li
<div class="journal_item-top"> v-for="{ timetable, sceneryList } in computedTimetableHistory"
<span> class="journal_item"
<span :key="timetable.timetableId"
tabindex="0"
@click="navigateToTimetable(item)"
@keydown.enter="navigateToTimetable(item)"
style="cursor: pointer"
> >
<b class="text--primary">{{ item.trainCategoryCode }}&nbsp;</b> <div class="journal_item-info">
<b>{{ item.trainNo }}</b> <div style="margin-bottom: 0.5em">
| <span>{{ item.driverName }}</span> | <b class="info-date">{{ localeDay(timetable.beginDate, $i18n.locale) }}</b>
<span class="text--grayed">#{{ item.timetableId }}</span>
</span>
&bull;
<b <b
class="journal_item-status" class="info-status"
:class="{ :class="{
fulfilled: item.fulfilled || item.currentDistance >= item.routeDistance * 0.9, fulfilled:
terminated: item.terminated && !item.fulfilled, timetable.fulfilled || timetable.currentDistance >= timetable.routeDistance * 0.9,
active: !item.terminated, terminated: timetable.terminated && !timetable.fulfilled,
active: !timetable.terminated,
}" }"
> >
{{ {{
!item.terminated !timetable.terminated
? $t('journal.timetable-active') ? $t('journal.timetable-active')
: item.fulfilled || item.currentDistance >= item.routeDistance * 0.9 : timetable.fulfilled || timetable.currentDistance >= timetable.routeDistance * 0.9
? $t('journal.timetable-fulfilled') ? $t('journal.timetable-fulfilled')
: $t('journal.timetable-abandoned') : `${$t('journal.timetable-abandoned')} ${localeTime(timetable.endDate, $i18n.locale)}`
}} }}
</b> </b>
</div>
<div> <span
<b>{{ item.route.replace('|', ' - ') }}</b> tabindex="0"
@click="showTimetable(timetable)"
@keydown.enter="showTimetable(timetable)"
style="cursor: pointer"
>
<b class="text--primary">{{ timetable.trainCategoryCode }}&nbsp;</b>
<b>{{ timetable.trainNo }}</b>
| <span>{{ timetable.driverName }}</span> |
<span class="text--grayed">#{{ timetable.timetableId }}</span>
</span>
<div style="margin-top: 0.25em">
<b>{{ timetable.route.replace('|', ' - ') }}</b>
</div> </div>
<hr style="margin: 0.25em 0" /> <hr style="margin: 0.25em 0" />
<div class="scenery-list"> <div class="scenery-list">
<span <span
v-for="(scenery, i) in getSceneryList(item)" v-for="(scenery, i) in sceneryList"
:key="scenery.name" :key="scenery.name"
:class="{ confirmed: scenery.confirmed }" :class="{ confirmed: scenery.confirmed }"
> >
@@ -83,58 +88,41 @@
<!-- Data odjazdu ze stacji początkowej --> <!-- Data odjazdu ze stacji początkowej -->
<span v-if="i == 0" v-html="scenery.beginDateHTML"></span> <span v-if="i == 0" v-html="scenery.beginDateHTML"></span>
<!-- Data porzucenia rozkładu jazdy -->
<span
v-if="
!item.fulfilled &&
item.terminated &&
scenery.confirmed &&
!getSceneryList(item)[i + 1]?.confirmed
"
style="color: salmon"
v-html="scenery.abandonedDateHTML"
>
</span>
<!-- Data przyjazdu do stacji końcowej --> <!-- Data przyjazdu do stacji końcowej -->
<span v-if="i == getSceneryList(item).length - 1" v-html="scenery.endDateHTML"> </span> <span v-if="i == sceneryList.length - 1" v-html="scenery.endDateHTML"> </span>
</span>
</div>
</span> </span>
</div> </div>
<div style="margin-top: 1em"> <div style="margin-top: 1em">
<div>
{{ $t('journal.timetable-day') }} <b>{{ localeDay(item.beginDate, $i18n.locale) }}</b>
</div>
<!-- Nick dyżurnego --> <!-- Nick dyżurnego -->
<div v-if="item.authorName"> <div v-if="timetable.authorName">
<b class="text--grayed">{{ $t('journal.dispatcher-name') }}&nbsp;</b> <b class="text--grayed">{{ $t('journal.dispatcher-name') }}&nbsp;</b>
<router-link <router-link
class="dispatcher-link" class="dispatcher-link"
:to="`/journal/dispatchers?dispatcherName=${item.authorName}`" :to="`/journal/dispatchers?dispatcherName=${timetable.authorName}`"
>{{ item.authorName }}</router-link
> >
<b>{{ timetable.authorName }}</b>
</router-link>
</div> </div>
</div> </div>
<div style="margin-top: 1em"> <div style="margin-top: 1em">
<span> <span>
<b>{{ $t('journal.route-length') }}</b> <b>{{ $t('journal.route-length') }}</b>
{{ !item.fulfilled ? item.currentDistance + ' /' : '' }} {{ !timetable.fulfilled ? timetable.currentDistance + ' /' : '' }}
{{ item.routeDistance }} km {{ timetable.routeDistance }} km
</span> </span>
&bull; &bull;
<span> <span>
<b>{{ $t('journal.station-count') }}</b> <b>{{ $t('journal.station-count') }}</b>
{{ item.confirmedStopsCount }} / {{ timetable.confirmedStopsCount }} /
{{ item.allStopsCount }} {{ timetable.allStopsCount }}
</span> </span>
</div> </div>
</div>
<div v-if="item.stockString"> <div class="journal_item-stock" v-if="timetable.stockString">
<!-- {{ item.stockString }} --> {{ timetable.stockString}}
</div> </div>
</li> </li>
</transition-group> </transition-group>
@@ -165,16 +153,14 @@ import { TimetableHistory } from '../../scripts/interfaces/api/TimetablesAPIData
import { URLs } from '../../scripts/utils/apiURLs'; import { URLs } from '../../scripts/utils/apiURLs';
import { useStore } from '../../store/store'; import { useStore } from '../../store/store';
import JournalOptions from './JournalOptions.vue'; import JournalOptions from './JournalOptions.vue';
import { JournalTimetableSearcher } from '../../types/JournalTimetablesTypes';
import modalTrainMixin from '../../mixins/modalTrainMixin';
const TIMETABLES_API_URL = `${URLs.stacjownikAPI}/api/getTimetables`; const TIMETABLES_API_URL = `${URLs.stacjownikAPI}/api/getTimetables`;
type JournalTimetableSearcher = {
[key in 'search-driver' | 'search-train']: string;
};
export default defineComponent({ export default defineComponent({
components: { DriverStats, Loading, JournalOptions }, components: { DriverStats, Loading, JournalOptions },
mixins: [dateMixin, routerMixin], mixins: [dateMixin, routerMixin, modalTrainMixin],
name: 'JournalTimetables', name: 'JournalTimetables',
@@ -192,6 +178,8 @@ export default defineComponent({
showReturnButton: false, showReturnButton: false,
statsCardOpen: false, statsCardOpen: false,
timetableHistory: [] as TimetableHistory[],
journalTimetableFilters, journalTimetableFilters,
}), }),
@@ -219,7 +207,6 @@ export default defineComponent({
const scrollElement: Ref<HTMLElement | null> = ref(null); const scrollElement: Ref<HTMLElement | null> = ref(null);
return { return {
historyList: ref([]) as Ref<TimetableHistory[]>,
historyDataStatus, historyDataStatus,
isDataLoading: computed(() => historyDataStatus.value.status === DataStatus.Loading), isDataLoading: computed(() => historyDataStatus.value.status === DataStatus.Loading),
@@ -256,48 +243,60 @@ export default defineComponent({
window.removeEventListener('wheel', this.handleScroll); window.removeEventListener('wheel', this.handleScroll);
}, },
methods: { computed: {
navigateToTimetable(historyItem: TimetableHistory) { computedTimetableHistory() {
if (historyItem.terminated) return; return this.timetableHistory.map((timetable) => ({
timetable,
sceneryList: this.getSceneryList(timetable),
}));
},
},
this.navigateTo('/trains', { methods: {
trainNo: historyItem.trainNo, showTimetable(timetable: TimetableHistory) {
driverName: historyItem.driverName, if (timetable.terminated) return;
});
this.selectModalTrain(timetable.driverName + timetable.trainNo.toString());
// this.navigateTo('/trains', {
// trainNo: timetable.trainNo,
// driverName: timetable.driverName,
// });
}, },
closeCard() { closeCard() {
this.statsCardOpen = false; this.statsCardOpen = false;
}, },
getSceneryList(item: TimetableHistory) { getSceneryList(timetable: TimetableHistory) {
return item.sceneriesString.split('%').map((name, i) => { return timetable.sceneriesString.split('%').map((name, i) => {
const beginDateHTML = const beginDateHTML =
' (o. ' + ' (o. ' +
(item.beginDate != item.scheduledBeginDate (timetable.beginDate != timetable.scheduledBeginDate
? `<s class='text--grayed'>${this.localeTime(item.beginDate, this.$i18n.locale)}</s> ` ? `<s class='text--grayed'>${this.localeTime(timetable.beginDate, this.$i18n.locale)}</s> `
: '') + : '') +
`<span>${this.localeTime(item.scheduledBeginDate, this.$i18n.locale)}</span>)`; `<span>${this.localeTime(timetable.scheduledBeginDate, this.$i18n.locale)}</span>)`;
const endDateHTML = const endDateHTML =
' (p. ' + ' (p. ' +
(item.endDate != item.scheduledEndDate && item.fulfilled (timetable.endDate != timetable.scheduledEndDate && timetable.fulfilled
? `<s class='text--grayed'>${this.localeTime( ? `<s class='text--grayed'>${this.localeTime(
item.fulfilled ? item.endDate : item.scheduledEndDate, timetable.fulfilled ? timetable.endDate : timetable.scheduledEndDate,
this.$i18n.locale this.$i18n.locale
)}</s> ` )}</s> `
: '') + : '') +
`<span>${this.localeTime( `<span>${this.localeTime(
item.fulfilled || (item.terminated && !item.fulfilled) ? item.scheduledEndDate : item.endDate, timetable.fulfilled || (timetable.terminated && !timetable.fulfilled)
? timetable.scheduledEndDate
: timetable.endDate,
this.$i18n.locale this.$i18n.locale
)}</span>)`; )}</span>)`;
const abandonedDateHTML = ` (porz. ${this.localeTime( const abandonedDateHTML = ` (porz. ${this.localeTime(
item.fulfilled ? item.scheduledEndDate : item.endDate, timetable.fulfilled ? timetable.scheduledEndDate : timetable.endDate,
this.$i18n.locale this.$i18n.locale
)})`; )})`;
return { name, confirmed: i < item.confirmedStopsCount, beginDateHTML, endDateHTML, abandonedDateHTML }; return { name, confirmed: i < timetable.confirmedStopsCount, beginDateHTML, endDateHTML, abandonedDateHTML };
}); });
}, },
@@ -332,7 +331,7 @@ export default defineComponent({
async addHistoryData() { async addHistoryData() {
this.scrollDataLoaded = false; this.scrollDataLoaded = false;
const countFrom = this.historyList.length; const countFrom = this.timetableHistory.length;
const responseData: TimetableHistory[] = await ( const responseData: TimetableHistory[] = await (
await axios.get(`${TIMETABLES_API_URL}?${this.currentQuery}&countFrom=${countFrom}`) await axios.get(`${TIMETABLES_API_URL}?${this.currentQuery}&countFrom=${countFrom}`)
@@ -345,7 +344,7 @@ export default defineComponent({
return; return;
} }
this.historyList.push(...responseData); this.timetableHistory.push(...responseData);
this.scrollDataLoaded = true; this.scrollDataLoaded = true;
}, },
@@ -406,12 +405,12 @@ export default defineComponent({
if (!responseData) return; if (!responseData) return;
// Response data exists // Response data exists
this.historyList = responseData; this.timetableHistory = responseData;
// Stats display // Stats display
this.store.driverStatsName = this.store.driverStatsName =
this.historyList.length > 0 && this.searchersValues['search-driver'].trim() this.timetableHistory.length > 0 && this.searchersValues['search-driver'].trim()
? this.historyList[0].driverName ? this.timetableHistory[0].driverName
: ''; : '';
this.historyDataStatus.status = DataStatus.Loaded; this.historyDataStatus.status = DataStatus.Loaded;
@@ -428,38 +427,46 @@ export default defineComponent({
<style lang="scss" scoped> <style lang="scss" scoped>
@import '../../styles/JournalSection.scss'; @import '../../styles/JournalSection.scss';
@import '../../styles/variables.scss';
.journal_item { .journal_item {
&-top {
display: flex;
justify-content: space-between;
padding: 0.2em 0; &-stock {
overflow: auto;
}
}
.scenery-list {
.info {
&-date {
padding: 0.05em 0.35em;
background-color: lightcyan;
color: black;
}
&-status {
padding: 0.05em 0.35em;
color: black;
&.terminated {
background-color: salmon;
}
&.fulfilled {
background-color: lightgreen;
}
&.active {
background-color: lightblue;
}
}
}
.scenery-list {
color: #adadad; color: #adadad;
span.confirmed { span.confirmed {
color: #a3eba3; color: #a3eba3;
} }
}
}
&-status {
&.terminated {
color: salmon;
}
&.fulfilled {
color: lightgreen;
}
&.active {
color: lightblue;
}
}
}
.dispatcher-link {
font-weight: bold;
} }
</style> </style>
@@ -31,6 +31,10 @@ export interface TimetableHistory {
stockMass?: number; stockMass?: number;
stockLength?: number; stockLength?: number;
maxSpeed?: number; maxSpeed?: number;
hashesString?: string;
currentSceneryName?: string;
currentSceneryHash?: string;
} }
export interface SceneryTimetableHistory { export interface SceneryTimetableHistory {
+3
View File
@@ -0,0 +1,3 @@
export type JournalTimetableSearcher = {
[key in 'search-driver' | 'search-train']: string;
};