Dodano kolumnę z aktywnymi RJ w zakładce ze sceneriami

This commit is contained in:
2020-08-29 23:50:04 +02:00
parent 5f48c4688f
commit 2f482d94b2
2 changed files with 104 additions and 39 deletions
+95 -38
View File
@@ -118,7 +118,24 @@
>{{station.routes.oneWay.noCatenary}}</span> >{{station.routes.oneWay.noCatenary}}</span>
</td> </td>
<td class="active-timetables">0</td> <td class="active-timetables">
<transition name="change-anim" mode="out-in">
<span
:key="trainsDataState + station.scheduledTrains.length"
@click="() => getScheduledTrains(station.stationName)"
>
<span v-if="trainsDataState == 2">
<span style="color:#eee">{{ station.scheduledTrains.length}}</span>
/
<span
style="color:#bbb"
>{{ station.scheduledTrains.filter(train => train.confirmed).length }}</span>
</span>
<span v-else>...</span>
</span>
</transition>
</td>
</tr> </tr>
</table> </table>
<div class="no-stations" v-if="stations.length == 0">Ups! Brak stacji do wyświetlenia!</div> <div class="no-stations" v-if="stations.length == 0">Ups! Brak stacji do wyświetlenia!</div>
@@ -150,6 +167,7 @@ export default class StationTable extends styleMixin {
@Prop() readonly setFocusedStation!: () => void; @Prop() readonly setFocusedStation!: () => void;
@Getter("trainsDataList") trains!: Train[]; @Getter("trainsDataList") trains!: Train[];
@Getter("trainsDataState") trainsDataState!: number;
icons: { ascSVG; descSVG } = { ascSVG, descSVG }; icons: { ascSVG; descSVG } = { ascSVG, descSVG };
sorterActive: { index: number; dir: number } = { index: 0, dir: 1 }; sorterActive: { index: number; dir: number } = { index: 0, dir: 1 };
@@ -176,69 +194,96 @@ export default class StationTable extends styleMixin {
this.sorterActive.index = index; this.sorterActive.index = index;
} }
getScheduledTrains(stationName: string) {
if (this.trainsDataState != 2) return null;
// console.log(
// this.computedStations.find((s) => s.stationName === stationName)
// ?.scheduledTrains
// );
}
get scheduledTrains() { get scheduledTrains() {
return this.stations.reduce((acc, station) => { const reducedList = this.stations.reduce((acc, station) => {
if (!acc[station.stationName]) acc[station.stationName] = []; if (!acc[station.stationName]) acc[station.stationName] = [];
this.trains this.trains
.filter((train) => !train.noTimetable) .filter((train) => !train.noTimetable)
.forEach((train) => { .forEach((train) => {
const found = train.stopPoints!.find( const found = train.stopPoints!.find(
(sp: any) => (sp) =>
(station.stationName.includes(sp.pointNameRAW) || (station.stationName
station.stationName.includes(sp.pointNameRAW.split(" ")[0])) && .toLowerCase()
!acc[station.stationName].find((t) => t === train.trainNo) .includes(sp.pointNameRAW.toLowerCase()) ||
// !acc[station.stationName].find((t) => t.trainNo === train.trainNo) station.stationName
.toLowerCase()
.includes(sp.pointNameRAW.toLowerCase().split(",")[0]) ||
station.stationName
.toLowerCase()
.includes(sp.pointNameRAW.toLowerCase().split(" ")[0])) &&
!acc[station.stationName].find((t) => t.trainNo === train.trainNo)
); );
if (!found) return acc; if (!found) return acc;
acc[station.stationName].push(train.trainNo); acc[station.stationName].push({
trainNo: train.trainNo,
driverName: train.driverName,
category: train.category,
...found,
});
}); });
return acc; return acc;
}, {}); }, {});
return reducedList;
} }
get computedStations() { get computedStations() {
const dir: number = this.sorterActive.dir; const dir: number = this.sorterActive.dir;
const scheduledTrainList = this.scheduledTrains;
return this.stations.sort((a, b) => { return this.stations
switch (this.sorterActive.index) { .sort((a, b) => {
case 1: switch (this.sorterActive.index) {
if (parseInt(a.reqLevel) > parseInt(b.reqLevel)) return dir; case 1:
if (parseInt(a.reqLevel) < parseInt(b.reqLevel)) return -dir; if (parseInt(a.reqLevel) > parseInt(b.reqLevel)) return dir;
break; if (parseInt(a.reqLevel) < parseInt(b.reqLevel)) return -dir;
break;
case 2: case 2:
if (a.statusTimestamp > b.statusTimestamp) return dir; if (a.statusTimestamp > b.statusTimestamp) return dir;
if (a.statusTimestamp < b.statusTimestamp) return -dir; if (a.statusTimestamp < b.statusTimestamp) return -dir;
break; break;
case 3: case 3:
if (a.dispatcherName > b.dispatcherName) return dir; if (a.dispatcherName > b.dispatcherName) return dir;
if (a.dispatcherName < b.dispatcherName) return -dir; if (a.dispatcherName < b.dispatcherName) return -dir;
break; break;
case 4: case 4:
if (a.dispatcherExp > b.dispatcherExp) return dir; if (a.dispatcherExp > b.dispatcherExp) return dir;
if (a.dispatcherExp < b.dispatcherExp) return -dir; if (a.dispatcherExp < b.dispatcherExp) return -dir;
break; break;
case 5: case 5:
if (a.currentUsers > b.currentUsers) return dir; if (a.currentUsers > b.currentUsers) return dir;
if (a.currentUsers < b.currentUsers) return -dir; if (a.currentUsers < b.currentUsers) return -dir;
if (a.maxUsers > b.maxUsers) return dir; if (a.maxUsers > b.maxUsers) return dir;
if (a.maxUsers < b.maxUsers) return -dir; if (a.maxUsers < b.maxUsers) return -dir;
break; break;
default: default:
break; break;
} }
if (a.stationName >= b.stationName) return dir; if (a.stationName >= b.stationName) return dir;
return -dir; return -dir;
}); })
.map((station) => ({
...station,
scheduledTrains: scheduledTrainList[station.stationName],
}));
} }
} }
</script> </script>
@@ -248,6 +293,18 @@ export default class StationTable extends styleMixin {
@import "../../styles/variables.scss"; @import "../../styles/variables.scss";
@import "../../styles/global.scss"; @import "../../styles/global.scss";
.change-anim {
&-enter-active,
&-leave-active {
transition: opacity 100ms ease-in;
}
&-enter,
&-leave-to {
opacity: 0;
}
}
.station-table { .station-table {
font-size: calc(0.6rem + 0.3vw); font-size: calc(0.6rem + 0.3vw);
} }
+9 -1
View File
@@ -19,5 +19,13 @@ export default interface Train {
locoURL: string; locoURL: string;
locoType: string; locoType: string;
routeDistance: number; routeDistance: number;
stopPoints?: []; stopPoints: {
arrivalTime: string;
arrivalDelay: number;
departureTime: string;
departureDelay: number;
pointNameRAW: string;
pointStopType: string;
confirmed: boolean;
}[];
} }