Oznaczenia statusu postoju w sekcji maszynistów na stacji

This commit is contained in:
2020-09-13 23:54:12 +02:00
parent 1c329d9ea9
commit acb4f03b7f
3 changed files with 83 additions and 37 deletions
+50 -7
View File
@@ -124,9 +124,9 @@
<div class="users-content"> <div class="users-content">
<div <div
class="user" class="user"
:class="train.stopStatus"
v-for="train in computedStationTrains" v-for="train in computedStationTrains"
:key="train.trainNo + train.driverName" :key="train.trainNo + train.driverName"
:class="{'no-timetable': !train.timetableData}"
> >
<router-link <router-link
:to="{ name: 'TrainsView', params: { passedSearchedTrain: train.trainNo.toString()}}" :to="{ name: 'TrainsView', params: { passedSearchedTrain: train.trainNo.toString()}}"
@@ -145,7 +145,11 @@
</div> </div>
</div> </div>
<StationTimetable :class="{show: cardMode == 1}" :stationInfo="stationInfo" /> <StationTimetable
:class="{show: cardMode == 1}"
:scheduledTrains="computedScheduledTrains"
:stationName="stationInfo.stationName"
/>
</section> </section>
</template> </template>
@@ -156,6 +160,7 @@ import { Getter } from "vuex-class";
import styleMixin from "@/mixins/styleMixin"; import styleMixin from "@/mixins/styleMixin";
import Station from "@/scripts/interfaces/Station"; import Station from "@/scripts/interfaces/Station";
import Train from "@/scripts/interfaces/Train";
import StationTimetable from "@/components/StationsView/StationTimetable.vue"; import StationTimetable from "@/components/StationsView/StationTimetable.vue";
@@ -167,7 +172,6 @@ import StationTimetable from "@/components/StationsView/StationTimetable.vue";
export default class StationCard extends styleMixin { export default class StationCard extends styleMixin {
@Prop() stationInfo!: Station; @Prop() stationInfo!: Station;
@Prop() exit!: void; @Prop() exit!: void;
@Getter('getTrainList') trains;
cardMode: number = 0; cardMode: number = 0;
@@ -177,11 +181,34 @@ export default class StationCard extends styleMixin {
: `${this.stationInfo.dispatcherExp}`; : `${this.stationInfo.dispatcherExp}`;
} }
get computedScheduledTrains() {
return this.stationInfo.scheduledTrains.map(scheduledTrain => {
let stopStatus = "";
let stopLabel = "";
if (scheduledTrain.terminatesHere && scheduledTrain.confirmed) { stopStatus = "terminated"; stopLabel = "Skończył bieg" }
else if (!scheduledTrain.terminatesHere && scheduledTrain.confirmed) { stopStatus = "departed"; stopLabel = "Odprawiony" }
else if (scheduledTrain.currentStationName == this.stationInfo.stationName && !scheduledTrain.stopped) { stopStatus = "online"; stopLabel = "Na stacji" }
else if (scheduledTrain.currentStationName == this.stationInfo.stationName && scheduledTrain.stopped) { stopStatus = "stopped"; stopLabel = "Postój" }
else if (scheduledTrain.currentStationName != this.stationInfo.stationName) { stopStatus = "arriving"; stopLabel = "W drodze" }
return {
...scheduledTrain,
stopStatus,
stopLabel
}
})
}
get computedStationTrains() { get computedStationTrains() {
return this.stationInfo.stationTrains.map(stationTrain => ({ return this.stationInfo.stationTrains.map(stationTrain => {
...stationTrain, const scheduledData = this.computedScheduledTrains.find(scheduledTrain => scheduledTrain.trainNo === stationTrain.trainNo);
timetableData: this.trains.find(train => train.timetableData && train.trainNo === stationTrain.trainNo)
})) return {
...stationTrain,
stopStatus: scheduledData?.stopStatus || "no-timetable"
}
})
} }
} }
</script> </script>
@@ -401,6 +428,22 @@ export default class StationCard extends styleMixin {
pointer-events: none; pointer-events: none;
} }
} }
&.departed {
border: 1px solid lime;
}
&.stopped {
border: 1px solid #ffa600;
}
&.online {
border: 1px solid gold;
}
&.terminated {
border: 1px solid red;
}
} }
} }
} }
@@ -2,7 +2,7 @@
<div class="station-timetable"> <div class="station-timetable">
<div class="timetable-wrapper"> <div class="timetable-wrapper">
<div class="timetable-title title"> <div class="timetable-title title">
<div style="font-size: 1.5em;">{{stationInfo.stationName.toUpperCase()}}</div> <div style="font-size: 1.5em;">{{stationName.toUpperCase()}}</div>
<div style="font-size: 0.7em;">AKTYWNE ROZKŁADY JAZDY</div> <div style="font-size: 0.7em;">AKTYWNE ROZKŁADY JAZDY</div>
</div> </div>
@@ -26,28 +26,8 @@
</span> </span>
</span> </span>
<span class="general-confirmed"> <span class="general-status">
<span <span :class="scheduledTrain.stopStatus">{{scheduledTrain.stopLabel}}</span>
style="color: red"
v-if="scheduledTrain.terminatesHere && scheduledTrain.confimed"
>Skończył bieg</span>
<span
style="color: lime"
v-else-if="scheduledTrain.confirmed && !scheduledTrain.terminatesHere"
>Odprawiony</span>
<span
style="color: gold"
v-else-if="scheduledTrain.currentStationName == stationInfo.stationName && !scheduledTrain.stopped"
>Na stacji</span>
<span
style="color: #aaa"
v-else-if="!scheduledTrain.confirmed && scheduledTrain.currentStationName != stationInfo.stationName"
>W drodze</span>
<span style="color: orangered" v-else-if="scheduledTrain.stopped">Postój</span>
</span> </span>
</span> </span>
@@ -87,15 +67,13 @@
<script lang="ts"> <script lang="ts">
import { Component, Vue, Prop } from 'vue-property-decorator'; import { Component, Vue, Prop } from 'vue-property-decorator';
import Station from "@/scripts/interfaces/Station";
@Component @Component
export default class StationTimetable extends Vue { export default class StationTimetable extends Vue {
@Prop() readonly stationInfo!: Station; @Prop() readonly scheduledTrains;
@Prop() readonly stationName;
get computedScheduledTrains() { get computedScheduledTrains() {
return this.stationInfo.scheduledTrains.sort((a, b) => { return this.scheduledTrains.sort((a, b) => {
if (a.arrivalTime > b.arrivalTime) return 1; if (a.arrivalTime > b.arrivalTime) return 1;
else if ((a.arrivalTime < b.arrivalTime)) return -1; else if ((a.arrivalTime < b.arrivalTime)) return -1;
@@ -240,6 +218,28 @@ export default class StationTimetable extends Vue {
} }
} }
.general-status {
span.arriving {
color: #aaa;
}
span.departed {
color: lime;
}
span.stopped {
color: #ffa600;
}
span.online {
color: gold;
}
span.terminated {
color: red;
}
}
.schedule { .schedule {
&-arrival, &-arrival,
&-stop, &-stop,
+5 -2
View File
@@ -325,13 +325,16 @@ export default class Store extends VuexModule {
// Dodawanie do listy online potencjalnych scenerii niewpisanych do bazy // Dodawanie do listy online potencjalnych scenerii niewpisanych do bazy
updatedStationList.forEach(updatedStation => { updatedStationList.forEach(updatedStation => {
const alreadyInList: any = this.stationList.findIndex(station => station.stationName === updatedStation.stationName); const alreadyInList: any = this.stationList.some(station => station.stationName === updatedStation.stationName);
if (alreadyInList < 0) { if (!alreadyInList) {
this.stationList.push({ this.stationList.push({
...updatedStation, ...updatedStation,
scheduledTrains: [],
stationTrains: [],
online: true, online: true,
reqLevel: '-1', reqLevel: '-1',
nonPublic: true,
}); });
} }
}); });