mirror of
https://github.com/Spythere/stacjownik.git
synced 2026-05-03 13:28:11 +00:00
Restrukturyzacja pobierania danych, zmiany w wyglądzie
This commit is contained in:
@@ -77,7 +77,7 @@ export default class TrainStats extends Vue {
|
||||
).toFixed(2);
|
||||
|
||||
const minMax = this.trains.reduce((acc, train) => {
|
||||
if (train.noTimetable) return acc;
|
||||
if (!train.timetableData) return acc;
|
||||
|
||||
acc[0] =
|
||||
acc[0] === undefined || train.speed < acc[0] ? train.speed : acc[0];
|
||||
@@ -94,21 +94,21 @@ export default class TrainStats extends Vue {
|
||||
if (this.trains.length == 0) return { avg: "0", min: "0", max: "0" };
|
||||
|
||||
const avg = (
|
||||
this.trains.reduce((acc, train) => acc + train.routeDistance, 0) /
|
||||
this.trains.reduce((acc, train) => train.timetableData ? acc + train.timetableData.routeDistance : acc, 0) /
|
||||
this.trains.length
|
||||
).toFixed(2);
|
||||
|
||||
const minMax = this.trains.reduce((acc, train) => {
|
||||
if (train.noTimetable) return acc;
|
||||
if (!train.timetableData) return acc;
|
||||
|
||||
acc[0] =
|
||||
acc[0] === undefined || train.routeDistance < acc[0]
|
||||
? train.routeDistance
|
||||
acc[0] === undefined || train.timetableData.routeDistance < acc[0]
|
||||
? train.timetableData.routeDistance
|
||||
: acc[0];
|
||||
|
||||
acc[1] =
|
||||
acc[1] === undefined || train.routeDistance > acc[1]
|
||||
? train.routeDistance
|
||||
acc[1] === undefined || train.timetableData.routeDistance > acc[1]
|
||||
? train.timetableData.routeDistance
|
||||
: acc[1];
|
||||
return acc;
|
||||
}, [] as any);
|
||||
@@ -118,11 +118,11 @@ export default class TrainStats extends Vue {
|
||||
|
||||
get categoryList(): Map<string, number> {
|
||||
const map = this.trains.reduce((acc, train) => {
|
||||
if (train.noTimetable || !train.category) return acc;
|
||||
if (!train.timetableData || !train.timetableData.category) return acc;
|
||||
|
||||
acc.set(
|
||||
train.category,
|
||||
acc.get(train.category) ? acc.get(train.category) + 1 : 1
|
||||
train.timetableData.category,
|
||||
acc.get(train.timetableData.category) ? acc.get(train.timetableData.category) + 1 : 1
|
||||
);
|
||||
|
||||
return acc;
|
||||
@@ -133,7 +133,7 @@ export default class TrainStats extends Vue {
|
||||
|
||||
get locoList(): any[] {
|
||||
const map = this.trains.reduce((acc, train) => {
|
||||
if (train.noTimetable || !train.locoType) return acc;
|
||||
if (!train.timetableData || !train.locoType) return acc;
|
||||
|
||||
acc.set(
|
||||
train.locoType,
|
||||
@@ -151,8 +151,8 @@ export default class TrainStats extends Vue {
|
||||
}
|
||||
|
||||
get specialTrainCount(): [number, number] {
|
||||
const twrList = this.trains.filter((train) => train.TWR);
|
||||
const skrList = this.trains.filter((train) => train.SKR);
|
||||
const twrList = this.trains.filter((train) => train.timetableData && train.timetableData.TWR);
|
||||
const skrList = this.trains.filter((train) => train.timetableData && train.timetableData.SKR);
|
||||
|
||||
return [twrList.length, skrList.length];
|
||||
}
|
||||
@@ -177,18 +177,18 @@ export default class TrainStats extends Vue {
|
||||
|
||||
.train-stats {
|
||||
padding: 0.3em 0;
|
||||
font-size: 0.9em;
|
||||
font-size: 1.1em;
|
||||
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.button {
|
||||
font-size: 1.1em;
|
||||
font-size: 1em;
|
||||
padding: 0.5em;
|
||||
}
|
||||
|
||||
.content {
|
||||
font-size: 1.2em;
|
||||
font-size: 1.1em;
|
||||
color: #ddd;
|
||||
}
|
||||
|
||||
@@ -199,7 +199,7 @@ export default class TrainStats extends Vue {
|
||||
.stats-body {
|
||||
position: absolute;
|
||||
display: inline-block;
|
||||
max-width: 800px;
|
||||
max-width: 700px;
|
||||
|
||||
background: rgba(black, 0.85);
|
||||
border-radius: 0 1em 1em 1em;
|
||||
@@ -213,6 +213,8 @@ export default class TrainStats extends Vue {
|
||||
}
|
||||
|
||||
.category {
|
||||
font-size: 0.9em;
|
||||
|
||||
margin-right: 0.4em;
|
||||
margin-bottom: 0.4em;
|
||||
|
||||
@@ -256,11 +258,17 @@ export default class TrainStats extends Vue {
|
||||
|
||||
@include smallScreen {
|
||||
.button {
|
||||
font-size: 0.9rem;
|
||||
font-size: 0.85rem;
|
||||
}
|
||||
.stats-body {
|
||||
display: block;
|
||||
font-size: 0.9em;
|
||||
// position: fixed;
|
||||
// top: 0;
|
||||
// left: 0;
|
||||
|
||||
width: 100%;
|
||||
// height: 100%;
|
||||
|
||||
border-radius: 0 0 1em 1em;
|
||||
}
|
||||
|
||||
@@ -8,31 +8,31 @@
|
||||
<div class="info-top">
|
||||
<div class="info-category">
|
||||
<span>
|
||||
<strong>{{ train.category }}</strong>
|
||||
<strong>{{ train.timetableData.category }}</strong>
|
||||
{{ train.trainNo }} |
|
||||
</span>
|
||||
<span style=" color: gold;">{{ train.routeDistance }} km</span>
|
||||
<span style=" color: gold;">{{ train.timetableData.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>
|
||||
<span class="warning twr" v-if="train.timetableData.TWR">TWR</span>
|
||||
<span class="warning skr" v-if="train.timetableData.SKR">SKR</span>
|
||||
</div>
|
||||
|
||||
<div class="info-route">
|
||||
<a :href="'https://rj.td2.info.pl/train#' + train.trainNo + ';eu'" target="_blank">
|
||||
<strong>
|
||||
{{
|
||||
train.route && train.route.replace("|", " - ")
|
||||
train.timetableData.route.replace("|", " - ")
|
||||
}}
|
||||
</strong>
|
||||
</a>
|
||||
</div>
|
||||
|
||||
<div class="info-stations">
|
||||
<span v-if="train.followingStops.length > 2">
|
||||
<span v-if="train.timetableData.followingStops.length > 2">
|
||||
Przez:
|
||||
<span v-html="generateStopList(train.followingStops)"></span>
|
||||
<span v-html="generateStopList(train.timetableData.followingStops)"></span>
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
@@ -114,7 +114,6 @@
|
||||
|
||||
<script lang="ts">
|
||||
import { Vue, Component, Prop } from "vue-property-decorator";
|
||||
import { Getter } from "vuex-class";
|
||||
|
||||
const unknownTrainImage = require("@/assets/unknown.png");
|
||||
|
||||
@@ -125,8 +124,6 @@ import Station from "@/scripts/interfaces/Station";
|
||||
export default class TrainTable extends Vue {
|
||||
@Prop() readonly computedTrains!: Train[];
|
||||
|
||||
@Getter("getAllStations") stations!: Station[];
|
||||
|
||||
speedIcon: string = require("@/assets/icon-speed.svg");
|
||||
massIcon: string = require("@/assets/icon-mass.svg");
|
||||
lengthIcon: string = require("@/assets/icon-length.svg");
|
||||
|
||||
Reference in New Issue
Block a user