mirror of
https://github.com/Spythere/stacjownik.git
synced 2026-05-03 13:28:11 +00:00
Migracja pozostałych klas i komponentów na TS, optymalizacja kodu
This commit is contained in:
+20
-22
@@ -14,9 +14,9 @@
|
|||||||
<AppBar :stationCount="stationCount" :trainCount="trainCount" />
|
<AppBar :stationCount="stationCount" :trainCount="trainCount" />
|
||||||
|
|
||||||
<main class="app-main">
|
<main class="app-main">
|
||||||
<Loading v-if="connectionState == 0" />
|
<Loading v-if="connectionState == 0" />
|
||||||
<Error v-else-if="connectionState == 1" :error="errorMessage" />
|
<Error v-else-if="connectionState == 1" :error="errorMessage" />
|
||||||
<router-view v-else />
|
<router-view v-else />
|
||||||
</main>
|
</main>
|
||||||
|
|
||||||
<footer class="app-footer flex">© Spythere 2020</footer>
|
<footer class="app-footer flex">© Spythere 2020</footer>
|
||||||
@@ -36,30 +36,32 @@ import Clock from "@/components/ui/Clock.vue";
|
|||||||
import AppBar from "@/components/ui/AppBar.vue";
|
import AppBar from "@/components/ui/AppBar.vue";
|
||||||
|
|
||||||
enum ConnState {
|
enum ConnState {
|
||||||
Loading = 0,
|
Loading = 0,
|
||||||
Error = 1,
|
Error = 1,
|
||||||
Connected = 2
|
Connected = 2
|
||||||
}
|
}
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
components: { Error, Loading, Clock, AppBar }
|
components: { Error, Loading, Clock, AppBar }
|
||||||
})
|
})
|
||||||
export default class App extends Vue {
|
export default class App extends Vue {
|
||||||
@Getter('getStations') stations
|
@Getter("getStations") stations;
|
||||||
@Getter('getTrainCount') trainCount
|
@Getter("getTrainCount") trainCount;
|
||||||
@Getter("getStationCount") stationCount
|
@Getter("getStationCount") stationCount;
|
||||||
|
|
||||||
@Action("initStations") initStations
|
@Action("initStations") initStations;
|
||||||
|
|
||||||
errorMessage: string = "";
|
errorMessage: string = "";
|
||||||
connectionState: ConnState = ConnState.Loading;
|
connectionState: ConnState = ConnState.Loading;
|
||||||
|
|
||||||
mounted() {
|
mounted() {
|
||||||
this.initStations();
|
this.initStations();
|
||||||
|
|
||||||
this.$store.watch((state, getters) => getters.getConnectionState, (state: ConnState) => this.connectionState = state);
|
this.$store.watch(
|
||||||
|
(state, getters) => getters.getConnectionState,
|
||||||
|
(state: ConnState) => (this.connectionState = state)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
@@ -126,7 +128,7 @@ input {
|
|||||||
border-radius: 1.3rem;
|
border-radius: 1.3rem;
|
||||||
font-weight: 500;
|
font-weight: 500;
|
||||||
|
|
||||||
font-size: .95em;
|
font-size: 0.95em;
|
||||||
padding: 0.25em 0.4em;
|
padding: 0.25em 0.4em;
|
||||||
|
|
||||||
background-color: #00be19;
|
background-color: #00be19;
|
||||||
@@ -144,17 +146,13 @@ input {
|
|||||||
|
|
||||||
&.no-limit {
|
&.no-limit {
|
||||||
background-color: #0077ae;
|
background-color: #0077ae;
|
||||||
font-size: 0.9em;
|
font-size: 0.85em;
|
||||||
}
|
|
||||||
|
|
||||||
&.not-signed {
|
|
||||||
background-color: $accent2Col;
|
|
||||||
font-size: 0.8em;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
&.not-signed,
|
||||||
&.unavailable {
|
&.unavailable {
|
||||||
background-color: $accent2Col;
|
background-color: $accent2Col;
|
||||||
font-size: 0.9em;
|
font-size: 0.8em;
|
||||||
}
|
}
|
||||||
|
|
||||||
&.brb {
|
&.brb {
|
||||||
@@ -196,7 +194,7 @@ input {
|
|||||||
max-height: 95%;
|
max-height: 95%;
|
||||||
|
|
||||||
// font-size: calc(0.6rem + 0.5vw);
|
// font-size: calc(0.6rem + 0.5vw);
|
||||||
font-size: calc(0.55rem + 0.35vw);
|
font-size: calc(0.45rem + 0.35vw);
|
||||||
|
|
||||||
@include smallScreen {
|
@include smallScreen {
|
||||||
width: 95%;
|
width: 95%;
|
||||||
|
|||||||
@@ -43,7 +43,7 @@ export default class AppBar extends Vue {
|
|||||||
|
|
||||||
position: sticky;
|
position: sticky;
|
||||||
top: 0;
|
top: 0;
|
||||||
font-size: 0.3em;
|
font-size: 0.25em;
|
||||||
background: #222;
|
background: #222;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -58,6 +58,11 @@ export default class LegendCard extends Vue {
|
|||||||
name: "mieszana",
|
name: "mieszana",
|
||||||
desc:
|
desc:
|
||||||
"Sceneria ze sygnalizacją mieszaną (kształtowe, historyczne lub/i współczesne)"
|
"Sceneria ze sygnalizacją mieszaną (kształtowe, historyczne lub/i współczesne)"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "SBL",
|
||||||
|
desc:
|
||||||
|
"Sceneria posiadająca samoczynną blokadę liniową na co najmniej jednym z jej szlaków"
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|||||||
+216
-258
@@ -27,293 +27,251 @@
|
|||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
|
|
||||||
<tr
|
<tr
|
||||||
class="table-item"
|
class="table-item"
|
||||||
v-for="(station, i) in computedStations"
|
v-for="(station, i) in computedStations"
|
||||||
:key="i + station.stationHash"
|
:key="i + station.stationHash"
|
||||||
@click="() => { if(station.online) setFocusedStation(station.stationName) }"
|
@click="() => { if(station.online) setFocusedStation(station.stationName) }"
|
||||||
>
|
>
|
||||||
<td
|
<td
|
||||||
class="item-station-name"
|
class="item-station-name"
|
||||||
:class="{'default-station': station.default, 'online': station.online}"
|
:class="{'default-station': station.default, 'online': station.online}"
|
||||||
>{{station.stationName}}</td>
|
>{{station.stationName}}</td>
|
||||||
|
|
||||||
<td class="item-station-level">
|
<td class="item-station-level">
|
||||||
<span
|
<span
|
||||||
v-if="station.reqLevel"
|
v-if="station.reqLevel"
|
||||||
:style="calculateStyle(station.reqLevel)"
|
:style="calculateExpStyle(station.reqLevel)"
|
||||||
>{{ (station.reqLevel && station.reqLevel > -1) ? (parseInt(station.reqLevel) >= 2 ? station.reqLevel : "L") : "?" }}</span>
|
>{{ (station.reqLevel && station.reqLevel > -1) ? (parseInt(station.reqLevel) >= 2 ? station.reqLevel : "L") : "?" }}</span>
|
||||||
|
|
||||||
<span v-else>?</span>
|
<span v-else>?</span>
|
||||||
</td>
|
</td>
|
||||||
|
|
||||||
<td class="item-station-status">
|
<td class="item-station-status">
|
||||||
<span
|
<span class="status" :class="statusClasses(station.occupiedTo)">{{station.occupiedTo}}</span>
|
||||||
class="status"
|
</td>
|
||||||
:class="occupationClasses(station.occupiedTo)"
|
|
||||||
>{{station.occupiedTo}}</span>
|
|
||||||
</td>
|
|
||||||
|
|
||||||
<td class="item-dispatcher-name">{{station.online ? station.dispatcherName : ""}}</td>
|
<td class="item-dispatcher-name">{{station.online ? station.dispatcherName : ""}}</td>
|
||||||
<td class="item-dispatcher-exp">
|
<td class="item-dispatcher-exp">
|
||||||
<span
|
<span
|
||||||
v-if="station.online"
|
v-if="station.online"
|
||||||
:style="calculateStyle(station.dispatcherExp)"
|
:style="calculateExpStyle(station.dispatcherExp)"
|
||||||
>{{station.dispatcherExp < 2 ? 'L' : station.dispatcherExp}}</span>
|
>{{station.dispatcherExp < 2 ? 'L' : station.dispatcherExp}}</span>
|
||||||
</td>
|
</td>
|
||||||
<td
|
<td
|
||||||
class="item-users"
|
class="item-users"
|
||||||
>{{station.online ? (station.currentUsers + "/" + station.maxUsers) : ""}}</td>
|
>{{station.online ? (station.currentUsers + "/" + station.maxUsers) : ""}}</td>
|
||||||
<td class="item-info">
|
<td class="item-info">
|
||||||
<img
|
<img
|
||||||
class="icon-info"
|
class="icon-info"
|
||||||
v-if="station.controlType"
|
v-if="station.controlType"
|
||||||
:src="require(`@/assets/icon-${station.controlType}.svg`)"
|
:src="require(`@/assets/icon-${station.controlType}.svg`)"
|
||||||
:alt="station.controlType"
|
:alt="station.controlType"
|
||||||
:title="'Sterowanie ' + station.controlType"
|
:title="'Sterowanie ' + station.controlType"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<img
|
<img
|
||||||
class="icon-info"
|
class="icon-info"
|
||||||
v-if="station.signalType"
|
v-if="station.signalType"
|
||||||
:src="require(`@/assets/icon-${station.signalType}.svg`)"
|
:src="require(`@/assets/icon-${station.signalType}.svg`)"
|
||||||
:alt="station.signalType"
|
:alt="station.signalType"
|
||||||
:title="'Sygnalizacja ' + station.signalType"
|
:title="'Sygnalizacja ' + station.signalType"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<img
|
<img
|
||||||
class="icon-info"
|
class="icon-info"
|
||||||
v-if="station.SBL && station.SBL !== ''"
|
v-if="station.SBL && station.SBL !== ''"
|
||||||
:src="require(`@/assets/icon-SBL.svg`)"
|
:src="require(`@/assets/icon-SBL.svg`)"
|
||||||
alt="SBL"
|
alt="SBL"
|
||||||
title="Sceneria posiada SBL na przynajmniej jednym ze szlaków"
|
title="Sceneria posiada SBL na przynajmniej jednym ze szlaków"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<img
|
<img
|
||||||
class="icon-info"
|
class="icon-info"
|
||||||
v-if="!station.reqLevel || station.nonPublic"
|
v-if="!station.reqLevel || station.nonPublic"
|
||||||
:src="require(`@/assets/icon-lock.svg`)"
|
:src="require(`@/assets/icon-lock.svg`)"
|
||||||
alt="non-public"
|
alt="non-public"
|
||||||
title="Sceneria niepubliczna"
|
title="Sceneria niepubliczna"
|
||||||
/>
|
/>
|
||||||
</td>
|
</td>
|
||||||
|
|
||||||
<td class="item-tracks twoway">
|
<td class="item-tracks twoway">
|
||||||
<span
|
<span
|
||||||
v-if="station.routes && station.routes.twoWay.catenary > 0"
|
v-if="station.routes && station.routes.twoWay.catenary > 0"
|
||||||
class="track catenary"
|
class="track catenary"
|
||||||
:title="'Liczba zelektryfikowanych szlaków dwutorowych: ' + station.routes.twoWay.catenary"
|
:title="'Liczba zelektryfikowanych szlaków dwutorowych: ' + station.routes.twoWay.catenary"
|
||||||
>{{station.routes.twoWay.catenary}}</span>
|
>{{station.routes.twoWay.catenary}}</span>
|
||||||
|
|
||||||
<span
|
<span
|
||||||
v-if="station.routes && station.routes.twoWay.noCatenary > 0"
|
v-if="station.routes && station.routes.twoWay.noCatenary > 0"
|
||||||
class="track no-catenary"
|
class="track no-catenary"
|
||||||
:title="'Liczba niezelektryfikowanych szlaków dwutorowych: ' + station.routes.twoWay.noCatenary"
|
:title="'Liczba niezelektryfikowanych szlaków dwutorowych: ' + station.routes.twoWay.noCatenary"
|
||||||
>{{station.routes.twoWay.noCatenary}}</span>
|
>{{station.routes.twoWay.noCatenary}}</span>
|
||||||
</td>
|
</td>
|
||||||
|
|
||||||
<td class="item-tracks oneway">
|
<td class="item-tracks oneway">
|
||||||
<span
|
<span
|
||||||
v-if="station.routes && station.routes.oneWay.catenary > 0"
|
v-if="station.routes && station.routes.oneWay.catenary > 0"
|
||||||
class="track catenary"
|
class="track catenary"
|
||||||
:title="'Liczba zelektryfikowanych szlaków jednotorowych: ' + station.routes.oneWay.catenary"
|
:title="'Liczba zelektryfikowanych szlaków jednotorowych: ' + station.routes.oneWay.catenary"
|
||||||
>{{station.routes.oneWay.catenary}}</span>
|
>{{station.routes.oneWay.catenary}}</span>
|
||||||
|
|
||||||
<span
|
<span
|
||||||
v-if="station.routes && station.routes.oneWay.noCatenary > 0"
|
v-if="station.routes && station.routes.oneWay.noCatenary > 0"
|
||||||
class="track no-catenary"
|
class="track no-catenary"
|
||||||
:title="'Liczba niezelektryfikowanych szlaków jednotorowych: ' + station.routes.oneWay.noCatenary"
|
:title="'Liczba niezelektryfikowanych szlaków jednotorowych: ' + station.routes.oneWay.noCatenary"
|
||||||
>{{station.routes.oneWay.noCatenary}}</span>
|
>{{station.routes.oneWay.noCatenary}}</span>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import Vue from "vue";
|
import { Component } from "vue-property-decorator";
|
||||||
import { mapGetters } from "vuex";
|
import { Getter } from "vuex-class";
|
||||||
|
|
||||||
import styleMixin from "@/mixins/styleMixin";
|
import styleMixin from "@/mixins/styleMixin";
|
||||||
|
|
||||||
import StationCard from "@/components/ui/StationCard.vue";
|
import StationCard from "@/components/ui/StationCard.vue";
|
||||||
|
|
||||||
|
import Station from "@/scripts/interfaces/Station";
|
||||||
|
|
||||||
const ascSVG = require("@/assets/icon-arrow-asc.svg");
|
const ascSVG = require("@/assets/icon-arrow-asc.svg");
|
||||||
const descSVG = require("@/assets/icon-arrow-desc.svg");
|
const descSVG = require("@/assets/icon-arrow-desc.svg");
|
||||||
|
|
||||||
export default Vue.extend({
|
@Component({
|
||||||
name: "List",
|
components: { StationCard }
|
||||||
components: {
|
})
|
||||||
StationCard
|
export default class List extends styleMixin {
|
||||||
},
|
focusedStationName: string = "";
|
||||||
data: () => ({
|
icons: { ascSVG; descSVG } = { ascSVG, descSVG };
|
||||||
focusedStationName: "",
|
sorterActive: { index: number; type: number } = { index: 0, type: 1 };
|
||||||
icons: {
|
|
||||||
ascSVG,
|
|
||||||
descSVG
|
|
||||||
},
|
|
||||||
sorterActive: { index: 0, type: 1 },
|
|
||||||
headTitles: [
|
|
||||||
["Stacja"],
|
|
||||||
["Wymagany poz.", "dyżurnego"],
|
|
||||||
["Status"],
|
|
||||||
["Dyżurny"],
|
|
||||||
["Poziom", "dyżurnego"],
|
|
||||||
["Maszyniści"],
|
|
||||||
["Informacje", "ogólne"],
|
|
||||||
["Szlaki", "dwutorowe"],
|
|
||||||
["Szlaki", "jednotorowe"]
|
|
||||||
]
|
|
||||||
}),
|
|
||||||
computed: {
|
|
||||||
...mapGetters({ stations: "getStations" }),
|
|
||||||
computedStations() {
|
|
||||||
let sortFun;
|
|
||||||
const type: number = this.sorterActive.type;
|
|
||||||
|
|
||||||
const sortByName = (a, b) => {
|
@Getter("getStations") stations!: Station[];
|
||||||
if (a.stationName >= b.stationName) return type;
|
|
||||||
if (a.stationName < b.stationName) return -type;
|
|
||||||
};
|
|
||||||
|
|
||||||
switch (this.sorterActive.index) {
|
headTitles: string[][] = [
|
||||||
case 0:
|
["Stacja"],
|
||||||
default:
|
["Wymagany poz.", "dyżurnego"],
|
||||||
sortFun = sortByName;
|
["Status"],
|
||||||
break;
|
["Dyżurny"],
|
||||||
|
["Poziom", "dyżurnego"],
|
||||||
|
["Maszyniści"],
|
||||||
|
["Informacje", "ogólne"],
|
||||||
|
["Szlaki", "dwutorowe"],
|
||||||
|
["Szlaki", "jednotorowe"]
|
||||||
|
];
|
||||||
|
|
||||||
case 1:
|
changeSorter(index: number) {
|
||||||
sortFun = (a, b) => {
|
if (index > 5) return;
|
||||||
if (parseInt(a.reqLevel) > parseInt(b.reqLevel)) return type;
|
|
||||||
if (parseInt(a.reqLevel) < parseInt(b.reqLevel)) return -type;
|
|
||||||
|
|
||||||
return sortByName(a, b);
|
if (index == this.sorterActive.index)
|
||||||
};
|
this.sorterActive.type = this.sorterActive.type == 1 ? -1 : 1;
|
||||||
break;
|
else this.sorterActive.type = 1;
|
||||||
|
|
||||||
case 2:
|
this.sorterActive.index = index;
|
||||||
sortFun = (a, b) => {
|
|
||||||
if (a.statusTimestamp > b.statusTimestamp) return type;
|
|
||||||
if (a.statusTimestamp < b.statusTimestamp) return -type;
|
|
||||||
|
|
||||||
if (a.occupiedTo > b.occupiedTo) return type;
|
|
||||||
if (a.occupiedTo < b.occupiedTo) return -type;
|
|
||||||
|
|
||||||
return sortByName(a, b);
|
|
||||||
};
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 3:
|
|
||||||
sortFun = (a, b) => {
|
|
||||||
if (a.dispatcherName > b.dispatcherName) return type;
|
|
||||||
if (a.dispatcherName < b.dispatcherName) return -type;
|
|
||||||
|
|
||||||
return sortByName(a, b);
|
|
||||||
};
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 4:
|
|
||||||
sortFun = (a, b) => {
|
|
||||||
if (a.dispatcherExp > b.dispatcherExp) return type;
|
|
||||||
if (a.dispatcherExp < b.dispatcherExp) return -type;
|
|
||||||
|
|
||||||
return sortByName(a, b);
|
|
||||||
};
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 5:
|
|
||||||
sortFun = (a, b) => {
|
|
||||||
if (a.currentUsers > b.currentUsers) return type;
|
|
||||||
if (a.currentUsers < b.currentUsers) return -type;
|
|
||||||
|
|
||||||
return sortByName(a, b);
|
|
||||||
};
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 6:
|
|
||||||
sortFun = (a, b) => {
|
|
||||||
if (a.currentUsers > b.currentUsers) return type;
|
|
||||||
if (a.currentUsers < b.currentUsers) return -type;
|
|
||||||
|
|
||||||
if (a.maxUsers > b.maxUsers) return type;
|
|
||||||
if (a.maxUsers < b.maxUsers) return -type;
|
|
||||||
};
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
return this.stations.sort(sortFun);
|
|
||||||
},
|
|
||||||
focusedStationInfo() {
|
|
||||||
return this.stations.find(
|
|
||||||
(station: any) => station.stationName === this.focusedStationName
|
|
||||||
);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
methods: {
|
|
||||||
changeSorter(index: number) {
|
|
||||||
if (index > 5) return;
|
|
||||||
|
|
||||||
if (index == this.sorterActive.index)
|
|
||||||
this.sorterActive.type = this.sorterActive.type == 1 ? -1 : 1;
|
|
||||||
else this.sorterActive.type = 1;
|
|
||||||
|
|
||||||
this.sorterActive.index = index;
|
|
||||||
},
|
|
||||||
calculateStyle(exp: string | number): string {
|
|
||||||
const bgColor =
|
|
||||||
exp > -1
|
|
||||||
? exp < 2
|
|
||||||
? "#26B0D9"
|
|
||||||
: `hsl(${-exp * 5 + 100}, 65%, 50%)`
|
|
||||||
: "#888";
|
|
||||||
|
|
||||||
const fontColor = exp > 15 ? "white" : "black";
|
|
||||||
|
|
||||||
return `backgroundColor: ${bgColor}; color: ${fontColor}`;
|
|
||||||
},
|
|
||||||
occupationClasses: (occupiedTo: string) => {
|
|
||||||
let className = "";
|
|
||||||
|
|
||||||
switch (occupiedTo) {
|
|
||||||
case "WOLNA":
|
|
||||||
className = "free";
|
|
||||||
break;
|
|
||||||
case "KOŃCZY":
|
|
||||||
className = "ending";
|
|
||||||
break;
|
|
||||||
case "NIEZALOGOWANY":
|
|
||||||
className = "not-signed";
|
|
||||||
break;
|
|
||||||
case "BEZ LIMITU":
|
|
||||||
className = "no-limit";
|
|
||||||
break;
|
|
||||||
case "NIEDOSTĘPNY":
|
|
||||||
className = "unavailable";
|
|
||||||
break;
|
|
||||||
case "Z/W":
|
|
||||||
className = "brb";
|
|
||||||
break;
|
|
||||||
case "BRAK MIEJSCA":
|
|
||||||
className = "no-space";
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
return className;
|
|
||||||
},
|
|
||||||
|
|
||||||
setFocusedStation(name: string) {
|
|
||||||
if (this.focusedStationName == name) this.focusedStationName = "";
|
|
||||||
else this.focusedStationName = name;
|
|
||||||
},
|
|
||||||
|
|
||||||
closeCard() {
|
|
||||||
this.focusedStationName = "";
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
|
||||||
|
setFocusedStation(name: string) {
|
||||||
|
if (this.focusedStationName == name) this.focusedStationName = "";
|
||||||
|
else this.focusedStationName = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
closeCard() {
|
||||||
|
this.focusedStationName = "";
|
||||||
|
}
|
||||||
|
|
||||||
|
get focusedStationInfo() {
|
||||||
|
return this.stations.find(
|
||||||
|
station => station.stationName === this.focusedStationName
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
get computedStations() {
|
||||||
|
const type: number = this.sorterActive.type;
|
||||||
|
|
||||||
|
const sortByName = (a: Station, b: Station) => {
|
||||||
|
if (a.stationName >= b.stationName) return type;
|
||||||
|
return -type;
|
||||||
|
};
|
||||||
|
|
||||||
|
if (this.sorterActive.index == 0)
|
||||||
|
return this.stations.sort((a, b) => {
|
||||||
|
if (a.stationName >= b.stationName) return type;
|
||||||
|
return -type;
|
||||||
|
});
|
||||||
|
|
||||||
|
let currentSort;
|
||||||
|
|
||||||
|
switch (this.sorterActive.index) {
|
||||||
|
case 0:
|
||||||
|
default:
|
||||||
|
return (currentSort = sortByName);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 1:
|
||||||
|
currentSort = (a, b) => {
|
||||||
|
if (parseInt(a.reqLevel) > parseInt(b.reqLevel)) return type;
|
||||||
|
if (parseInt(a.reqLevel) < parseInt(b.reqLevel)) return -type;
|
||||||
|
|
||||||
|
return sortByName(a, b);
|
||||||
|
};
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 2:
|
||||||
|
currentSort = (a, b) => {
|
||||||
|
if (a.statusTimestamp > b.statusTimestamp) return type;
|
||||||
|
if (a.statusTimestamp < b.statusTimestamp) return -type;
|
||||||
|
|
||||||
|
if (a.occupiedTo > b.occupiedTo) return type;
|
||||||
|
if (a.occupiedTo < b.occupiedTo) return -type;
|
||||||
|
|
||||||
|
return sortByName(a, b);
|
||||||
|
};
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 3:
|
||||||
|
currentSort = (a, b) => {
|
||||||
|
if (a.dispatcherName > b.dispatcherName) return type;
|
||||||
|
if (a.dispatcherName < b.dispatcherName) return -type;
|
||||||
|
|
||||||
|
return sortByName(a, b);
|
||||||
|
};
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 4:
|
||||||
|
currentSort = (a, b) => {
|
||||||
|
if (a.dispatcherExp > b.dispatcherExp) return type;
|
||||||
|
if (a.dispatcherExp < b.dispatcherExp) return -type;
|
||||||
|
|
||||||
|
return sortByName(a, b);
|
||||||
|
};
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 5:
|
||||||
|
currentSort = (a, b) => {
|
||||||
|
if (a.currentUsers > b.currentUsers) return type;
|
||||||
|
if (a.currentUsers < b.currentUsers) return -type;
|
||||||
|
|
||||||
|
return sortByName(a, b);
|
||||||
|
};
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 6:
|
||||||
|
currentSort = (a, b) => {
|
||||||
|
if (a.currentUsers > b.currentUsers) return type;
|
||||||
|
if (a.currentUsers < b.currentUsers) return -type;
|
||||||
|
|
||||||
|
if (a.maxUsers > b.maxUsers) return type;
|
||||||
|
if (a.maxUsers < b.maxUsers) return -type;
|
||||||
|
};
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return this.stations.sort(currentSort);
|
||||||
|
}
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="scss" scoped>
|
<style lang="scss" scoped>
|
||||||
@@ -342,10 +300,10 @@ export default Vue.extend({
|
|||||||
white-space: nowrap;
|
white-space: nowrap;
|
||||||
border-collapse: collapse;
|
border-collapse: collapse;
|
||||||
|
|
||||||
font-size: calc(0.7rem + 0.3vw);
|
font-size: calc(0.5rem + 0.3vw);
|
||||||
|
|
||||||
@include smallScreen() {
|
@include smallScreen() {
|
||||||
font-size: 0.75rem;
|
font-size: 0.65rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
&-head th {
|
&-head th {
|
||||||
|
|||||||
@@ -92,7 +92,7 @@ export default class Options extends Vue {
|
|||||||
border: none;
|
border: none;
|
||||||
|
|
||||||
color: #e0e0e0;
|
color: #e0e0e0;
|
||||||
font-size: 0.9em;
|
font-size: 0.7em;
|
||||||
|
|
||||||
padding: 0.3em;
|
padding: 0.3em;
|
||||||
|
|
||||||
|
|||||||
@@ -67,7 +67,7 @@
|
|||||||
<div class="dispatcher">
|
<div class="dispatcher">
|
||||||
<div
|
<div
|
||||||
class="dispatcher-level flex"
|
class="dispatcher-level flex"
|
||||||
:style="calculateStyle(stationInfo.dispatcherExp)"
|
:style="calculateExpStyle(stationInfo.dispatcherExp)"
|
||||||
>{{computedExp}}</div>
|
>{{computedExp}}</div>
|
||||||
<div class="dispatcher-info">
|
<div class="dispatcher-info">
|
||||||
<div class="dispatcher-name">
|
<div class="dispatcher-name">
|
||||||
@@ -136,52 +136,14 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { Vue, Component, Prop } from "vue-property-decorator";
|
import { Component, Prop } from "vue-property-decorator";
|
||||||
|
import styleMixin from "@/mixins/styleMixin";
|
||||||
|
|
||||||
@Component
|
@Component
|
||||||
export default class StationCard extends Vue {
|
export default class StationCard extends styleMixin {
|
||||||
@Prop() stationInfo;
|
@Prop() stationInfo;
|
||||||
@Prop() exit!: void;
|
@Prop() exit!: void;
|
||||||
|
|
||||||
calculateStyle(exp: number): string {
|
|
||||||
const bgColor = exp < 2 ? "#26B0D9" : `hsl(${-exp * 5 + 100}, 65%, 50%)`;
|
|
||||||
const fontColor = exp > 15 ? "white" : "black";
|
|
||||||
|
|
||||||
return `backgroundColor: ${bgColor}; color: ${fontColor}`;
|
|
||||||
}
|
|
||||||
|
|
||||||
statusClasses(status: string) {
|
|
||||||
let className = "";
|
|
||||||
|
|
||||||
switch (status) {
|
|
||||||
case "WOLNA":
|
|
||||||
className = "free";
|
|
||||||
break;
|
|
||||||
case "KOŃCZY":
|
|
||||||
className = "ending";
|
|
||||||
break;
|
|
||||||
case "NIEZALOGOWANY":
|
|
||||||
className = "not-signed";
|
|
||||||
break;
|
|
||||||
case "BEZ LIMITU":
|
|
||||||
className = "no-limit";
|
|
||||||
break;
|
|
||||||
case "NIEDOSTĘPNY":
|
|
||||||
className = "unavailable";
|
|
||||||
break;
|
|
||||||
case "Z/W":
|
|
||||||
className = "brb";
|
|
||||||
break;
|
|
||||||
case "BRAK MIEJSCA":
|
|
||||||
className = "no-space";
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
return className;
|
|
||||||
}
|
|
||||||
|
|
||||||
get computedExp(): string {
|
get computedExp(): string {
|
||||||
return this.stationInfo.dispatcherExp < 2
|
return this.stationInfo.dispatcherExp < 2
|
||||||
? "L"
|
? "L"
|
||||||
@@ -282,7 +244,7 @@ export default class StationCard extends Vue {
|
|||||||
&-level {
|
&-level {
|
||||||
font-size: 2.5em;
|
font-size: 2.5em;
|
||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
margin-right: .3em;
|
margin-right: 0.3em;
|
||||||
|
|
||||||
max-width: 2em;
|
max-width: 2em;
|
||||||
|
|
||||||
|
|||||||
@@ -4,10 +4,49 @@ import Component from 'vue-class-component'
|
|||||||
// You can declare mixins as the same style as components.
|
// You can declare mixins as the same style as components.
|
||||||
@Component
|
@Component
|
||||||
export default class styleMixin extends Vue {
|
export default class styleMixin extends Vue {
|
||||||
calculateStyle(exp: string | number): string {
|
calculateExpStyle(exp: string | number): string {
|
||||||
const bgColor = exp < 2 ? "#26B0D9" : `hsl(${-exp * 5 + 100}, 65%, 50%)`;
|
const bgColor =
|
||||||
|
exp > -1
|
||||||
|
? exp < 2
|
||||||
|
? "#26B0D9"
|
||||||
|
: `hsl(${-exp * 5 + 100}, 65%, 50%)`
|
||||||
|
: "#888";
|
||||||
|
|
||||||
const fontColor = exp > 15 ? "white" : "black";
|
const fontColor = exp > 15 ? "white" : "black";
|
||||||
|
|
||||||
return `backgroundColor: ${bgColor}; color: ${fontColor}`;
|
return `backgroundColor: ${bgColor}; color: ${fontColor}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
statusClasses(occupiedTo: string) {
|
||||||
|
let className = "";
|
||||||
|
|
||||||
|
switch (occupiedTo) {
|
||||||
|
case "WOLNA":
|
||||||
|
className = "free";
|
||||||
|
break;
|
||||||
|
case "KOŃCZY":
|
||||||
|
className = "ending";
|
||||||
|
break;
|
||||||
|
case "NIEZALOGOWANY":
|
||||||
|
className = "not-signed";
|
||||||
|
break;
|
||||||
|
case "BEZ LIMITU":
|
||||||
|
className = "no-limit";
|
||||||
|
break;
|
||||||
|
case "NIEDOSTĘPNY":
|
||||||
|
className = "unavailable";
|
||||||
|
break;
|
||||||
|
case "Z/W":
|
||||||
|
className = "brb";
|
||||||
|
break;
|
||||||
|
case "BRAK MIEJSCA":
|
||||||
|
className = "no-space";
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return className;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,23 @@
|
|||||||
|
export default interface Filter {
|
||||||
|
"default": false,
|
||||||
|
"notDefault": false,
|
||||||
|
"nonPublic": false,
|
||||||
|
"SPK": false,
|
||||||
|
"SCS": false,
|
||||||
|
"ręczne": false,
|
||||||
|
"mechaniczne": false,
|
||||||
|
"współczesna": false,
|
||||||
|
"kształtowa": false,
|
||||||
|
"historyczna": false,
|
||||||
|
"mieszana": false,
|
||||||
|
"minLevel": 0,
|
||||||
|
"minOneWayCatenary": 0,
|
||||||
|
"minOneWay": 0,
|
||||||
|
"minTwoWayCatenary": 0,
|
||||||
|
"minTwoWay": 0,
|
||||||
|
"no-1track": false,
|
||||||
|
"no-2track": false,
|
||||||
|
"free": true,
|
||||||
|
"occupied": false,
|
||||||
|
"ending": false
|
||||||
|
}
|
||||||
@@ -0,0 +1,23 @@
|
|||||||
|
export default interface Station {
|
||||||
|
stationName: string;
|
||||||
|
stationHash: string;
|
||||||
|
maxUsers: number;
|
||||||
|
currentUsers: number;
|
||||||
|
spawnString: string;
|
||||||
|
dispatcherRate: number;
|
||||||
|
dispatcherName: string;
|
||||||
|
dispatcherExp: number;
|
||||||
|
dispatcherId: number;
|
||||||
|
stationLines: string;
|
||||||
|
stationProject: string;
|
||||||
|
reqLevel: string;
|
||||||
|
supportersOnly: string;
|
||||||
|
signalType: string;
|
||||||
|
controlType: string;
|
||||||
|
default: boolean;
|
||||||
|
nonPublic: boolean;
|
||||||
|
routes: { oneWay: { catenary: number; noCatenary: number; }, twoWay: { catenary: number; noCatenary: number; } };
|
||||||
|
online: boolean;
|
||||||
|
occupiedTo: string;
|
||||||
|
statusTimestamp: number;
|
||||||
|
}
|
||||||
@@ -2,6 +2,8 @@ import { VuexModule, Module, Mutation, Action } from 'vuex-module-decorators';
|
|||||||
import axios from 'axios';
|
import axios from 'axios';
|
||||||
import data from '@/data/stations.json';
|
import data from '@/data/stations.json';
|
||||||
|
|
||||||
|
import Station from "@/scripts/interfaces/Station";
|
||||||
|
|
||||||
enum ConnState {
|
enum ConnState {
|
||||||
Loading = 0,
|
Loading = 0,
|
||||||
Error = 1,
|
Error = 1,
|
||||||
@@ -21,29 +23,7 @@ class Store extends VuexModule {
|
|||||||
dispatcherDataURL: "https://api.td2.info.pl:9640/?method=readFromSWDR&value=getDispatcherStatusList%3B1"
|
dispatcherDataURL: "https://api.td2.info.pl:9640/?method=readFromSWDR&value=getDispatcherStatusList%3B1"
|
||||||
}
|
}
|
||||||
|
|
||||||
private stations: {
|
private stations: Station[] = [];
|
||||||
stationName: string;
|
|
||||||
stationHash: string;
|
|
||||||
maxUsers: number;
|
|
||||||
currentUsers: number;
|
|
||||||
spawnString: string;
|
|
||||||
dispatcherRate: number;
|
|
||||||
dispatcherName: string;
|
|
||||||
dispatcherExp: number;
|
|
||||||
dispatcherId: number;
|
|
||||||
stationLines: string;
|
|
||||||
stationProject: string;
|
|
||||||
reqLevel: string;
|
|
||||||
supportersOnly: string;
|
|
||||||
signalType: string;
|
|
||||||
controlType: string;
|
|
||||||
default: boolean;
|
|
||||||
nonPublic: boolean;
|
|
||||||
routes: { oneWay: { catenary: number; noCatenary: number; }, twoWay: { catenary: number; noCatenary: number; } };
|
|
||||||
online: boolean;
|
|
||||||
occupiedTo: string;
|
|
||||||
statusTimestamp: number;
|
|
||||||
}[] = [];
|
|
||||||
|
|
||||||
private filteredStations: {}[] = [];
|
private filteredStations: {}[] = [];
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user