mirror of
https://github.com/Spythere/stacjownik.git
synced 2026-05-03 13:28:11 +00:00
Poprawki wyświetlania
This commit is contained in:
@@ -3,18 +3,6 @@
|
|||||||
@import "./styles/global.scss";
|
@import "./styles/global.scss";
|
||||||
@import "./styles/scenery_status.scss";
|
@import "./styles/scenery_status.scss";
|
||||||
|
|
||||||
:root {
|
|
||||||
--clr-primary: #ffc014;
|
|
||||||
--clr-secondary: #2f2f2f;
|
|
||||||
|
|
||||||
--clr-bg: #333;
|
|
||||||
|
|
||||||
--clr-accent: #1085b3;
|
|
||||||
--clr-accent2: #ff3d5d;
|
|
||||||
|
|
||||||
--clr-skr: #ff5100;
|
|
||||||
--clr-twr: #ffbb00;
|
|
||||||
}
|
|
||||||
|
|
||||||
// VUE ROUTE CHANGE ANIMATION
|
// VUE ROUTE CHANGE ANIMATION
|
||||||
.view-anim {
|
.view-anim {
|
||||||
|
|||||||
@@ -21,10 +21,10 @@
|
|||||||
v-for="(train, i) in computedTrains"
|
v-for="(train, i) in computedTrains"
|
||||||
:key="i"
|
:key="i"
|
||||||
:ref="
|
:ref="
|
||||||
train.timetableData &&
|
(el) => {
|
||||||
((el) => {
|
if (!train.timetableData) return;
|
||||||
elList[train.timetableData.timetableId] = el;
|
elList[train.timetableData.timetableId] = el;
|
||||||
})
|
}
|
||||||
"
|
"
|
||||||
>
|
>
|
||||||
<div
|
<div
|
||||||
@@ -169,7 +169,7 @@
|
|||||||
<TrainSchedule
|
<TrainSchedule
|
||||||
:followingStops="train.timetableData.followingStops"
|
:followingStops="train.timetableData.followingStops"
|
||||||
:currentStationName="train.currentStationName"
|
:currentStationName="train.currentStationName"
|
||||||
@click="changeScheduleShowState(train.timetableData.timetableId)"
|
@click="changeScheduleShowState(train.timetableData?.timetableId)"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</li>
|
</li>
|
||||||
@@ -259,7 +259,7 @@ export default defineComponent({
|
|||||||
|
|
||||||
setup(props) {
|
setup(props) {
|
||||||
const store = useStore();
|
const store = useStore();
|
||||||
const elList: Ref<HTMLElement[]> = ref([]);
|
const elList: Ref<(HTMLElement | null)[]> = ref([]);
|
||||||
|
|
||||||
onBeforeUpdate(() => {
|
onBeforeUpdate(() => {
|
||||||
elList.value.length = 0;
|
elList.value.length = 0;
|
||||||
@@ -293,16 +293,25 @@ export default defineComponent({
|
|||||||
},
|
},
|
||||||
|
|
||||||
methods: {
|
methods: {
|
||||||
|
focusOnTrain(trainNoStr: string) {
|
||||||
|
const timetableId = this.computedTrains.find(
|
||||||
|
(train) => train.trainNo == Number(trainNoStr)
|
||||||
|
)?.timetableData?.timetableId;
|
||||||
|
|
||||||
|
if (!timetableId) return;
|
||||||
|
|
||||||
|
this.changeScheduleShowState(timetableId);
|
||||||
|
},
|
||||||
|
|
||||||
changeScheduleShowState(timetableId: number | undefined) {
|
changeScheduleShowState(timetableId: number | undefined) {
|
||||||
if (!timetableId || timetableId < 0) return;
|
if (!timetableId || timetableId < 0) return;
|
||||||
|
|
||||||
this.showedSchedule =
|
this.showedSchedule =
|
||||||
this.showedSchedule == timetableId ? 0 : timetableId;
|
this.showedSchedule == timetableId ? 0 : timetableId;
|
||||||
|
|
||||||
this.$nextTick(() => {
|
this.$nextTick(() => {
|
||||||
const currentEl: HTMLElement = this.elList[timetableId];
|
const currentEl = this.elList[timetableId];
|
||||||
|
|
||||||
currentEl.scrollIntoView({
|
currentEl?.scrollIntoView({
|
||||||
behavior: "smooth",
|
behavior: "smooth",
|
||||||
block: "nearest",
|
block: "nearest",
|
||||||
});
|
});
|
||||||
@@ -352,16 +361,8 @@ export default defineComponent({
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
watch: {
|
activated() {
|
||||||
queryTrain(trainNo: string) {
|
if (this.queryTrain) this.focusOnTrain(this.queryTrain);
|
||||||
const timetableId = this.computedTrains.find(
|
|
||||||
(train) => train.trainNo == parseInt(trainNo)
|
|
||||||
)?.timetableData?.timetableId;
|
|
||||||
|
|
||||||
if (!timetableId) return;
|
|
||||||
|
|
||||||
this.changeScheduleShowState(timetableId);
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
@@ -388,7 +389,7 @@ img.train-image {
|
|||||||
.traffic-warning {
|
.traffic-warning {
|
||||||
padding: 1em 0.5em;
|
padding: 1em 0.5em;
|
||||||
margin-bottom: 0.5em;
|
margin-bottom: 0.5em;
|
||||||
background: firebrick;
|
background: var(--clr-warning);
|
||||||
}
|
}
|
||||||
|
|
||||||
.train {
|
.train {
|
||||||
|
|||||||
@@ -1,3 +1,20 @@
|
|||||||
|
:root {
|
||||||
|
--clr-primary: #ffc014;
|
||||||
|
--clr-secondary: #2f2f2f;
|
||||||
|
|
||||||
|
--clr-bg: #333;
|
||||||
|
|
||||||
|
--clr-accent: #1085b3;
|
||||||
|
--clr-accent2: #ff3d5d;
|
||||||
|
|
||||||
|
--clr-skr: #ff5100;
|
||||||
|
--clr-twr: #ffbb00;
|
||||||
|
|
||||||
|
--clr-error: #df3e3e;
|
||||||
|
--clr-warning: #c59429;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
html {
|
html {
|
||||||
scroll-behavior: smooth;
|
scroll-behavior: smooth;
|
||||||
}
|
}
|
||||||
@@ -171,4 +188,10 @@ ul {
|
|||||||
&-column {
|
&-column {
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.text {
|
||||||
|
&--primary {
|
||||||
|
color: var(--clr-primary);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
+180
-109
@@ -30,77 +30,110 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="history_list">
|
<div class="history_list">
|
||||||
<transition-group name="list" tag="ul">
|
<div class="list_wrapper">
|
||||||
<li v-for="(item, i) in historyList" :key="i">
|
<transition name="warning" mode="out-in">
|
||||||
<div class="history_item-top">
|
<div :key="historyDataStatus.status">
|
||||||
<span>
|
<div v-if="isDataLoading" class="history_warning">Ładowanie...</div>
|
||||||
<span
|
|
||||||
@click="
|
|
||||||
() =>
|
|
||||||
!item.terminated ? navigateToTrain(item.trainNo) : null
|
|
||||||
"
|
|
||||||
style="cursor: pointer"
|
|
||||||
>
|
|
||||||
{{ item.trainCategoryCode }} {{ item.trainNo }}
|
|
||||||
</span>
|
|
||||||
|
|
||||||
<div>
|
<div
|
||||||
<b>{{ item.route.replace("|", " - ") }}</b>
|
v-if="!isDataLoading && isDataError"
|
||||||
</div>
|
class="history_warning error"
|
||||||
</span>
|
|
||||||
|
|
||||||
<span
|
|
||||||
class="history_item-status"
|
|
||||||
:class="{
|
|
||||||
fulfilled: item.fulfilled,
|
|
||||||
terminated: item.terminated && !item.fulfilled,
|
|
||||||
active: !item.terminated,
|
|
||||||
}"
|
|
||||||
>
|
>
|
||||||
{{
|
Wystąpił błąd!
|
||||||
!item.terminated
|
</div>
|
||||||
? "AKTYWNY"
|
|
||||||
: item.fulfilled
|
<div
|
||||||
? "WYPEŁNIONY"
|
class="history_warning"
|
||||||
: "NIEWYPEŁNIONY"
|
v-if="!isDataLoading && !isDataError && historyList.length == 0"
|
||||||
}}
|
>
|
||||||
</span>
|
Brak wyników!
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<ul v-if="!isDataLoading && !isDataError">
|
||||||
|
<li
|
||||||
|
v-for="(item, i) in historyList"
|
||||||
|
:key="item.timetableId"
|
||||||
|
:style="`--delay: ${i * 50}ms`"
|
||||||
|
>
|
||||||
|
<div class="history_item-top">
|
||||||
|
<span>
|
||||||
|
<span
|
||||||
|
@click="
|
||||||
|
navigateToTrain(!item.terminated ? item.trainNo : null)
|
||||||
|
"
|
||||||
|
style="cursor: pointer"
|
||||||
|
>
|
||||||
|
<b class="text--primary">{{ item.trainCategoryCode }}</b>
|
||||||
|
{{ item.trainNo }}
|
||||||
|
</span>
|
||||||
|
|
||||||
|
<div>
|
||||||
|
<b>{{ item.route.replace("|", " - ") }}</b>
|
||||||
|
</div>
|
||||||
|
</span>
|
||||||
|
|
||||||
|
<span
|
||||||
|
class="history_item-status"
|
||||||
|
:class="{
|
||||||
|
fulfilled: item.fulfilled,
|
||||||
|
terminated: item.terminated && !item.fulfilled,
|
||||||
|
active: !item.terminated,
|
||||||
|
}"
|
||||||
|
>
|
||||||
|
{{
|
||||||
|
!item.terminated
|
||||||
|
? "AKTYWNY"
|
||||||
|
: item.fulfilled
|
||||||
|
? "WYPEŁNIONY"
|
||||||
|
: "NIEWYPEŁNIONY"
|
||||||
|
}}
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div style="margin: 1em 0">
|
||||||
|
<div>
|
||||||
|
<b>Maszynista:</b>
|
||||||
|
{{ item.driverName }}
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<b>Kilometraż:</b>
|
||||||
|
{{ !item.fulfilled ? item.currentDistance + " /" : "" }}
|
||||||
|
{{ item.routeDistance }} km
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div>
|
||||||
|
<b>Stacje:</b>
|
||||||
|
{{ item.confirmedStopsCount }} /
|
||||||
|
{{ item.allStopsCount }}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div>
|
||||||
|
<b>Rozpoczęcie:</b>
|
||||||
|
{{ localeDate(item.beginDate) }}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div>
|
||||||
|
<b>Zakończenie:</b>
|
||||||
|
{{ localeDate(item.endDate) }}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
|
</transition>
|
||||||
<div style="margin: 1em 0">
|
</div>
|
||||||
<div><b>Maszynista:</b> {{ item.driverName }}</div>
|
|
||||||
<div>
|
|
||||||
<b>Kilometraż:</b>
|
|
||||||
{{ !item.fulfilled ? item.currentDistance + " /" : "" }}
|
|
||||||
{{ item.routeDistance }} km
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div>
|
|
||||||
<b>Stacje:</b>
|
|
||||||
{{ item.confirmedStopsCount }} /
|
|
||||||
{{ item.allStopsCount }}
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div>
|
|
||||||
<b>Rozpoczęcie:</b>
|
|
||||||
{{ localeDate(item.beginDate) }}
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div><b>Zakończenie:</b> {{ localeDate(item.endDate) }}</div>
|
|
||||||
</div>
|
|
||||||
</li>
|
|
||||||
</transition-group>
|
|
||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { defineComponent, Ref, ref } from "vue";
|
import { computed, defineComponent, Ref, ref } from "vue";
|
||||||
import axios from "axios";
|
import axios from "axios";
|
||||||
|
|
||||||
import ActionButton from "@/components/Global/ActionButton.vue";
|
import ActionButton from "@/components/Global/ActionButton.vue";
|
||||||
import SearchBox from "@/components/Global/SearchBox.vue";
|
import SearchBox from "@/components/Global/SearchBox.vue";
|
||||||
import dateMixin from "@/mixins/dateMixin";
|
import dateMixin from "@/mixins/dateMixin";
|
||||||
|
import { DataStatus } from "@/scripts/enums/DataStatus";
|
||||||
|
|
||||||
const API_URL =
|
const API_URL =
|
||||||
"https://stacjownik-api-m9z4k.ondigitalocean.app/api/getTimetables";
|
"https://stacjownik-api-m9z4k.ondigitalocean.app/api/getTimetables";
|
||||||
@@ -134,49 +167,86 @@ interface TimetableHistory {
|
|||||||
fulfilled: boolean;
|
fulfilled: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
async function fetchData(props: {
|
|
||||||
searchedDriver?: string;
|
|
||||||
searchedTrain?: string;
|
|
||||||
maxCount?: number;
|
|
||||||
}): Promise<TimetableHistory[] | null> {
|
|
||||||
const queries: string[] = [];
|
|
||||||
|
|
||||||
if (!props.searchedDriver && !props.searchedTrain) queries.push("count=15");
|
|
||||||
if (props.maxCount) queries.push(`count=${props.maxCount}`);
|
|
||||||
if (props.searchedDriver) queries.push(`driver=${props.searchedDriver}`);
|
|
||||||
if (props.searchedTrain) queries.push(`train=${props.searchedTrain}`);
|
|
||||||
|
|
||||||
const responseData: APIResponse | null = await (
|
|
||||||
await axios.get(`${API_URL}?${queries.join("&")}`)
|
|
||||||
).data;
|
|
||||||
|
|
||||||
return responseData?.response || null;
|
|
||||||
}
|
|
||||||
|
|
||||||
export default defineComponent({
|
export default defineComponent({
|
||||||
components: { SearchBox, ActionButton },
|
components: { SearchBox, ActionButton },
|
||||||
mixins: [dateMixin],
|
mixins: [dateMixin],
|
||||||
setup() {
|
setup() {
|
||||||
const historyList: Ref<TimetableHistory[]> = ref([]);
|
const historyList: Ref<TimetableHistory[]> = ref([]);
|
||||||
|
const historyDataStatus: Ref<{ status: DataStatus; error: string | null }> =
|
||||||
|
ref({ status: DataStatus.Loading, error: null });
|
||||||
|
|
||||||
const searchedDriver = ref("");
|
const searchedDriver = ref("");
|
||||||
const searchedTrain = ref("");
|
const searchedTrain = ref("");
|
||||||
const maxCount = ref(15);
|
const maxCount = ref(15);
|
||||||
|
|
||||||
(async () => {
|
const fetchHistoryData = async (
|
||||||
const response = await fetchData({});
|
props: {
|
||||||
|
searchedDriver?: string;
|
||||||
|
searchedTrain?: string;
|
||||||
|
maxCount?: number;
|
||||||
|
} = {}
|
||||||
|
) => {
|
||||||
|
historyDataStatus.value.status = DataStatus.Loading;
|
||||||
|
|
||||||
if (response) historyList.value = response;
|
const queries: string[] = [];
|
||||||
})();
|
|
||||||
|
if (!props.searchedDriver && !props.searchedTrain)
|
||||||
|
queries.push("count=15");
|
||||||
|
if (props.maxCount) queries.push(`count=${props.maxCount}`);
|
||||||
|
if (props.searchedDriver) queries.push(`driver=${props.searchedDriver}`);
|
||||||
|
if (props.searchedTrain) queries.push(`train=${props.searchedTrain}`);
|
||||||
|
|
||||||
|
try {
|
||||||
|
const responseData: APIResponse | null = await (
|
||||||
|
await axios.get(`${API_URL}?${queries.join("&")}`)
|
||||||
|
).data;
|
||||||
|
|
||||||
|
if (!responseData) {
|
||||||
|
historyDataStatus.value.status = DataStatus.Error;
|
||||||
|
historyDataStatus.value.error = "Brak danych!";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (responseData.errorMessage) {
|
||||||
|
historyDataStatus.value.status = DataStatus.Error;
|
||||||
|
historyDataStatus.value.error = responseData.errorMessage;
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!responseData.response) return;
|
||||||
|
|
||||||
|
// Response data exists
|
||||||
|
historyList.value = responseData.response;
|
||||||
|
historyDataStatus.value.status = DataStatus.Loaded;
|
||||||
|
} catch (error) {
|
||||||
|
historyDataStatus.value.status = DataStatus.Error;
|
||||||
|
historyDataStatus.value.error = "Ups! Coś poszło nie tak!";
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
// on created
|
||||||
|
fetchHistoryData();
|
||||||
|
|
||||||
return {
|
return {
|
||||||
historyList,
|
historyList,
|
||||||
searchedDriver,
|
searchedDriver,
|
||||||
searchedTrain,
|
searchedTrain,
|
||||||
maxCount,
|
maxCount,
|
||||||
|
fetchHistoryData,
|
||||||
|
historyDataStatus,
|
||||||
|
isDataLoading: computed(
|
||||||
|
() => historyDataStatus.value.status === DataStatus.Loading
|
||||||
|
),
|
||||||
|
isDataError: computed(
|
||||||
|
() => historyDataStatus.value.status === DataStatus.Error
|
||||||
|
),
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
navigateToTrain(trainNo: number) {
|
navigateToTrain(trainNo: number | null) {
|
||||||
|
if (!trainNo) return;
|
||||||
|
|
||||||
this.$router.push({
|
this.$router.push({
|
||||||
name: "TrainsView",
|
name: "TrainsView",
|
||||||
params: { queryTrain: trainNo.toString() },
|
params: { queryTrain: trainNo.toString() },
|
||||||
@@ -196,12 +266,10 @@ export default defineComponent({
|
|||||||
},
|
},
|
||||||
|
|
||||||
async search() {
|
async search() {
|
||||||
const response = await fetchData({
|
this.fetchHistoryData({
|
||||||
searchedDriver: this.searchedDriver,
|
searchedDriver: this.searchedDriver,
|
||||||
searchedTrain: this.searchedTrain,
|
searchedTrain: this.searchedTrain,
|
||||||
});
|
});
|
||||||
|
|
||||||
if (response) this.historyList = response;
|
|
||||||
},
|
},
|
||||||
|
|
||||||
keyPressed({ keyCode }) {
|
keyPressed({ keyCode }) {
|
||||||
@@ -212,8 +280,22 @@ export default defineComponent({
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="scss" scoped>
|
<style lang="scss" scoped>
|
||||||
|
.warning {
|
||||||
|
&-enter-from,
|
||||||
|
&-leave-to {
|
||||||
|
opacity: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
&-enter-active {
|
||||||
|
transition: all 100ms ease-out;
|
||||||
|
}
|
||||||
|
|
||||||
|
&-leave-active {
|
||||||
|
transition: all 100ms ease-out 100ms;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
.history-view {
|
.history-view {
|
||||||
/* min-height: 100vh; */
|
|
||||||
height: 100%;
|
height: 100%;
|
||||||
|
|
||||||
padding: 2em;
|
padding: 2em;
|
||||||
@@ -224,10 +306,6 @@ h2 {
|
|||||||
margin-bottom: 1rem;
|
margin-bottom: 1rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
h3 {
|
|
||||||
text-align: center;
|
|
||||||
}
|
|
||||||
|
|
||||||
.history_list {
|
.history_list {
|
||||||
display: flex;
|
display: flex;
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
@@ -256,30 +334,23 @@ h3 {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ul {
|
.history_warning {
|
||||||
|
text-align: center;
|
||||||
|
font-size: 1.3em;
|
||||||
|
|
||||||
|
&.error {
|
||||||
|
background-color: var(--clr-error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.list_wrapper {
|
||||||
width: 1000px;
|
width: 1000px;
|
||||||
}
|
}
|
||||||
|
|
||||||
li {
|
li,
|
||||||
|
.history_warning {
|
||||||
background: #202020;
|
background: #202020;
|
||||||
padding: 1em;
|
padding: 1em;
|
||||||
margin: 1em 0;
|
margin: 1em 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
.list-enter-active,
|
|
||||||
.list-leave-active {
|
|
||||||
transition: all 350ms ease;
|
|
||||||
}
|
|
||||||
|
|
||||||
.list-enter-from,
|
|
||||||
.list-leave-to {
|
|
||||||
opacity: 0;
|
|
||||||
transform: scale(0.95);
|
|
||||||
/* transform: translateX(30px); */
|
|
||||||
}
|
|
||||||
|
|
||||||
.list-enter-to,
|
|
||||||
.list-leave-from {
|
|
||||||
opacity: 1;
|
|
||||||
}
|
|
||||||
</style>
|
</style>
|
||||||
@@ -2,10 +2,7 @@
|
|||||||
<section class="trains-view">
|
<section class="trains-view">
|
||||||
<div class="wrapper">
|
<div class="wrapper">
|
||||||
<div class="options-bar">
|
<div class="options-bar">
|
||||||
<TrainStats
|
<TrainStats :trains="trainList" :trainStatsOpen="trainStatsOpen" />
|
||||||
:trains="trainList"
|
|
||||||
:trainStatsOpen="trainStatsOpen"
|
|
||||||
/>
|
|
||||||
|
|
||||||
<TrainOptions
|
<TrainOptions
|
||||||
:queryTrain="queryTrain"
|
:queryTrain="queryTrain"
|
||||||
@@ -15,10 +12,7 @@
|
|||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<TrainTable
|
<TrainTable :computedTrains="computedTrains" :queryTrain="queryTrain" />
|
||||||
:computedTrains="computedTrains"
|
|
||||||
:queryTrain="queryTrain"
|
|
||||||
/>
|
|
||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
</template>
|
</template>
|
||||||
|
|||||||
Reference in New Issue
Block a user