mirror of
https://github.com/Spythere/stacjownik.git
synced 2026-05-03 05:18:11 +00:00
Dodano sortowanie i filtrowanie pociągów
This commit is contained in:
@@ -0,0 +1,173 @@
|
||||
<template>
|
||||
<div class="train-sorter">
|
||||
<div class="sorter-wrapper">
|
||||
<div class="sorter-box">
|
||||
<div class="title">Sortuj według</div>
|
||||
|
||||
<div class="selected" @click="toggleOptionList">
|
||||
<span>{{sorterName}}</span>
|
||||
<img :src="require('@/assets/icon-select.svg')" alt="icon-select" />
|
||||
</div>
|
||||
|
||||
<div class="options-container">
|
||||
<ul class="options-list" :class="{'open': listOpen}">
|
||||
<li
|
||||
class="option"
|
||||
v-for="(option, i) in sortOptionList"
|
||||
:key="i"
|
||||
@click="() => chooseOption(option)"
|
||||
>
|
||||
<input type="radio" name="sort" :id="option.id" />
|
||||
<label :for="option.id">{{option.content}}</label>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script lang="ts">
|
||||
import { Vue, Component, Prop } from "vue-property-decorator";
|
||||
|
||||
const ascSVG = require("@/assets/icon-arrow-asc.svg");
|
||||
const descSVG = require("@/assets/icon-arrow-desc.svg");
|
||||
|
||||
@Component
|
||||
export default class TrainSorter extends Vue {
|
||||
ascSVG = ascSVG;
|
||||
descSVG = descSVG;
|
||||
|
||||
@Prop() trainList!: [];
|
||||
|
||||
listOpen: boolean = false;
|
||||
sorterName: string = "numer pociągu";
|
||||
|
||||
sortOptionList: { id: string; content: string }[] = [
|
||||
{
|
||||
id: "mass",
|
||||
content: "masa",
|
||||
},
|
||||
{
|
||||
id: "speed",
|
||||
content: "prędkość",
|
||||
},
|
||||
{
|
||||
id: "length",
|
||||
content: "długość",
|
||||
},
|
||||
{
|
||||
id: "distance",
|
||||
content: "kilometraż",
|
||||
},
|
||||
{
|
||||
id: "timetable",
|
||||
content: "numer pociągu",
|
||||
},
|
||||
];
|
||||
|
||||
toggleOptionList() {
|
||||
this.listOpen = !this.listOpen;
|
||||
}
|
||||
|
||||
closeOptionList() {
|
||||
this.listOpen = false;
|
||||
}
|
||||
|
||||
chooseOption(option: { id: string; content: string }) {
|
||||
this.$emit("changeSorter", { id: option.id, dir: -1 });
|
||||
this.sorterName = option.content;
|
||||
|
||||
this.closeOptionList();
|
||||
}
|
||||
|
||||
get compTrainList() {
|
||||
return this.trainList;
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.title {
|
||||
padding-left: 0.3em;
|
||||
}
|
||||
|
||||
.sorter-wrapper {
|
||||
display: flex;
|
||||
|
||||
user-select: none;
|
||||
-moz-user-select: none;
|
||||
-webkit-user-select: none;
|
||||
}
|
||||
|
||||
.selected {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
|
||||
span {
|
||||
margin-right: 2rem;
|
||||
}
|
||||
|
||||
img {
|
||||
max-width: 0.75em;
|
||||
}
|
||||
}
|
||||
|
||||
.selected,
|
||||
.options-list {
|
||||
background: #333;
|
||||
border-radius: 0.5em;
|
||||
|
||||
margin: 0.3rem 0;
|
||||
}
|
||||
|
||||
.selected {
|
||||
padding: 0.5rem 1rem;
|
||||
min-width: 150px;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.options-container {
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.options-list {
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 0;
|
||||
|
||||
width: 100%;
|
||||
background-color: rgba(#333, 0.85);
|
||||
overflow: hidden;
|
||||
|
||||
max-height: 0;
|
||||
|
||||
&.open {
|
||||
max-height: 250px;
|
||||
opacity: 1;
|
||||
}
|
||||
|
||||
transition: all 250ms ease-in;
|
||||
}
|
||||
|
||||
.option {
|
||||
display: flex;
|
||||
|
||||
&:hover {
|
||||
background-color: rgba(#868686, 0.85);
|
||||
}
|
||||
|
||||
transition: background 150ms ease-in;
|
||||
}
|
||||
|
||||
input {
|
||||
display: none;
|
||||
}
|
||||
|
||||
label {
|
||||
padding: 0.5rem 1rem;
|
||||
width: 100%;
|
||||
cursor: pointer;
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,258 @@
|
||||
<template>
|
||||
<ul class="list">
|
||||
<li class="item" v-for="train in computedTrains" :key="train.timetableId">
|
||||
<a :href="'https://rj.td2.info.pl/train#' + train.trainNo + ';eu'" target="_blank">
|
||||
<span class="info">
|
||||
<div class="info-category">
|
||||
<span>
|
||||
<strong>{{ train.category }}</strong>
|
||||
{{ train.trainNo }} |
|
||||
</span>
|
||||
<span style=" color: gold;">{{ train.routeDistance }} km</span>
|
||||
</div>
|
||||
|
||||
<div class="info-warnings">
|
||||
<span class="warning twr" v-if="train.TWR">TWR</span>
|
||||
<span class="warning skr" v-if="train.SKR">SKR</span>
|
||||
</div>
|
||||
|
||||
<div class="info-route">
|
||||
<strong>
|
||||
{{
|
||||
train.route && train.route.replace("|", " - ")
|
||||
}}
|
||||
</strong>
|
||||
</div>
|
||||
|
||||
<div class="info-stations">
|
||||
<i v-if="train.sceneries.length > 0">Przez: {{ train.sceneries }}</i>
|
||||
</div>
|
||||
</span>
|
||||
</a>
|
||||
|
||||
<span class="driver">
|
||||
<span class="driver-name">
|
||||
{{ train.driverName }}
|
||||
<span style="color: #bbb; margin-left: 1em;">
|
||||
{{
|
||||
train.locoType
|
||||
}}
|
||||
</span>
|
||||
</span>
|
||||
<span class="driver-loco">
|
||||
<img :src="train.locoURL" @error="onImageError" />
|
||||
</span>
|
||||
</span>
|
||||
|
||||
<span class="stats">
|
||||
<div class="stats-general">
|
||||
<span class="mass">
|
||||
<img :src="massIcon" alt="icon-mass" />
|
||||
{{ train.mass / 1000 }}t
|
||||
</span>
|
||||
|
||||
<span class="speed">
|
||||
<img :src="speedIcon" alt="icon-speed" />
|
||||
{{ train.speed }} km/h
|
||||
</span>
|
||||
|
||||
<span class="length">
|
||||
<img :src="lengthIcon" alt="icon-length" />
|
||||
{{ train.length }}m
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<div class="stats-position">
|
||||
<span class="station">
|
||||
<p>
|
||||
<strong>SCENERIA</strong>
|
||||
</p>
|
||||
{{ train.currentStationName }}
|
||||
</span>
|
||||
<span class="track">
|
||||
<p>
|
||||
<strong>SZLAK</strong>
|
||||
</p>
|
||||
{{ train.connectedTrack || "---" }}
|
||||
</span>
|
||||
<span class="signal">
|
||||
<p>
|
||||
<strong>SEMAFOR</strong>
|
||||
</p>
|
||||
{{ train.signal || "---" }}
|
||||
</span>
|
||||
</div>
|
||||
</span>
|
||||
</li>
|
||||
</ul>
|
||||
</template>
|
||||
|
||||
<script lang="ts">
|
||||
import { Vue, Component, Prop } from "vue-property-decorator";
|
||||
|
||||
const unknownTrainImage = require("@/assets/unknown.png");
|
||||
|
||||
import Train from "@/scripts/interfaces/Train";
|
||||
|
||||
@Component
|
||||
export default class TrainTable extends Vue {
|
||||
@Prop() readonly computedTrains!: Train[];
|
||||
|
||||
speedIcon: string = require("@/assets/icon-speed.svg");
|
||||
massIcon: string = require("@/assets/icon-mass.svg");
|
||||
lengthIcon: string = require("@/assets/icon-length.svg");
|
||||
|
||||
onImageError(e: Event) {
|
||||
(e.target as HTMLImageElement).src = unknownTrainImage;
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
@import "../../styles/responsive.scss";
|
||||
|
||||
.list {
|
||||
overflow: auto;
|
||||
|
||||
@include smallScreen() {
|
||||
width: 100%;
|
||||
}
|
||||
}
|
||||
|
||||
.item {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(auto-fit, minmax(0, 1fr));
|
||||
|
||||
font-size: calc(0.4rem + 0.5vw);
|
||||
|
||||
background-color: #444;
|
||||
padding: 1rem;
|
||||
|
||||
margin: 1rem 0;
|
||||
|
||||
&:nth-child(even) {
|
||||
background-color: #666;
|
||||
}
|
||||
|
||||
@include smallScreen() {
|
||||
grid-template-columns: 1fr;
|
||||
grid-template-rows: repeat(3, 1fr);
|
||||
|
||||
font-size: 0.8rem;
|
||||
gap: 0.4em 0;
|
||||
// grid-template-columns: repeat(3, 1fr);
|
||||
}
|
||||
}
|
||||
|
||||
.info {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
|
||||
&-category {
|
||||
flex-grow: 2;
|
||||
font-size: 1.05em;
|
||||
}
|
||||
|
||||
&-route {
|
||||
width: 100%;
|
||||
font-size: 1.2em;
|
||||
}
|
||||
|
||||
&-stations {
|
||||
margin-top: 0.35em;
|
||||
font-size: 0.75em;
|
||||
}
|
||||
}
|
||||
|
||||
.driver {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
flex-wrap: wrap;
|
||||
|
||||
&-exp {
|
||||
font-size: 1.4em;
|
||||
padding: 0.3em 0.6em;
|
||||
|
||||
border-radius: 0.4em;
|
||||
|
||||
background-color: red;
|
||||
}
|
||||
|
||||
&-name {
|
||||
margin: 0 0.3em;
|
||||
}
|
||||
|
||||
&-loco {
|
||||
width: 100%;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
&-loco img {
|
||||
width: 13em;
|
||||
max-width: 190px;
|
||||
}
|
||||
}
|
||||
|
||||
.stats {
|
||||
width: 100%;
|
||||
|
||||
&-general {
|
||||
display: flex;
|
||||
|
||||
span {
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
|
||||
width: 100%;
|
||||
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
img {
|
||||
margin: 0 0.3em;
|
||||
width: 1.8em;
|
||||
}
|
||||
}
|
||||
|
||||
&-position {
|
||||
display: flex;
|
||||
|
||||
margin-top: 1em;
|
||||
text-align: center;
|
||||
|
||||
span {
|
||||
width: 100%;
|
||||
font-size: 300;
|
||||
}
|
||||
|
||||
p {
|
||||
color: #00cff3;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.warning {
|
||||
border-radius: 1em;
|
||||
padding: 0.1em 1.2em;
|
||||
margin: 0 0.2em;
|
||||
|
||||
color: black;
|
||||
font-weight: bold;
|
||||
font-size: 0.85em;
|
||||
|
||||
&.twr {
|
||||
background-color: #ffc700;
|
||||
}
|
||||
|
||||
&.skr {
|
||||
background-color: #ff4646;
|
||||
}
|
||||
}
|
||||
|
||||
@include bigScreen() {
|
||||
.item {
|
||||
font-size: 1rem;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
Reference in New Issue
Block a user