fixy filtrowania; ogólne

This commit is contained in:
2024-03-06 18:12:20 +01:00
parent 436e3e63f9
commit ed7d93e7fc
7 changed files with 80 additions and 34 deletions
+22 -7
View File
@@ -6,8 +6,6 @@
</keep-alive> </keep-alive>
</transition> </transition>
<!-- <UpdateModal /> -->
<AppHeader :current-lang="currentLang" @change-lang="changeLang" /> <AppHeader :current-lang="currentLang" @change-lang="changeLang" />
<main class="app_main"> <main class="app_main">
@@ -36,7 +34,7 @@
<script lang="ts"> <script lang="ts">
import { defineComponent, watch } from 'vue'; import { defineComponent, watch } from 'vue';
import axios from 'axios'; import axios from 'axios';
import packageInfo from '.././package.json'; import { version } from '.././package.json';
import Clock from './components/App/Clock.vue'; import Clock from './components/App/Clock.vue';
@@ -49,19 +47,19 @@ import TrainModal from './components/TrainsView/TrainModal.vue';
import StorageManager from './managers/storageManager'; import StorageManager from './managers/storageManager';
import { useApiStore } from './store/apiStore'; import { useApiStore } from './store/apiStore';
import { Status } from './typings/common'; import { Status } from './typings/common';
import UpdateModal from './components/App/UpdateModal.vue';
const STORAGE_VERSION_KEY = 'app_version';
export default defineComponent({ export default defineComponent({
components: { components: {
Clock, Clock,
StatusIndicator, StatusIndicator,
AppHeader, AppHeader,
TrainModal, TrainModal
UpdateModal
}, },
data: () => ({ data: () => ({
VERSION: packageInfo.version, VERSION: version,
store: useMainStore(), store: useMainStore(),
apiStore: useApiStore(), apiStore: useApiStore(),
@@ -89,12 +87,29 @@ export default defineComponent({
this.loadLang(); this.loadLang();
this.setReleaseURL(); this.setReleaseURL();
this.setupOfflineHandling(); this.setupOfflineHandling();
this.checkAppVersion();
this.apiStore.setupAPIData(); this.apiStore.setupAPIData();
if (!this.isOnProductionHost) document.title = 'Stacjownik Dev'; if (!this.isOnProductionHost) document.title = 'Stacjownik Dev';
}, },
checkAppVersion() {
if (import.meta.env.DEV) {
this.store.isNewUpdate = true;
return;
}
const storageVersion = StorageManager.getStringValue(STORAGE_VERSION_KEY);
if (storageVersion === undefined || storageVersion != version) {
this.store.isNewUpdate = true;
StorageManager.setStringValue(STORAGE_VERSION_KEY, version);
}
},
setupOfflineHandling() { setupOfflineHandling() {
this.store.isOffline = !window.navigator.onLine; this.store.isOffline = !window.navigator.onLine;
+34 -5
View File
@@ -1,19 +1,48 @@
<template> <template>
<div class="update-modal"> <AnimatedModal :is-open="mainStore.isNewUpdate" @toggle-modal="toggleModal">
<AnimatedModal :is-open="true">Test</AnimatedModal> <div class="modal_content">
</div> <h1 class="header">Aktualizacja Stacjownika</h1>
<h2>wersja {{ version }}</h2>
<b>Co nowego?</b>
<p>
<ul>
<li>test</li>
</ul>
</p>
</div>
</AnimatedModal>
</template> </template>
<script lang="ts"> <script lang="ts">
import { defineComponent } from 'vue'; import { defineComponent } from 'vue';
import { useMainStore } from '../../store/mainStore';
import { version } from '../../../package.json';
import AnimatedModal from '../Global/AnimatedModal.vue'; import AnimatedModal from '../Global/AnimatedModal.vue';
export default defineComponent({ export default defineComponent({
components: { AnimatedModal }, components: { AnimatedModal },
data() { data() {
return {}; return {
mainStore: useMainStore(),
version: version
};
},
methods: {
toggleModal(value: boolean) {
this.$emit('toggleModal', value);
}
} }
}); });
</script> </script>
<style scoped></style> <style lang="scss" scoped>
.modal_content {
text-align: center;
padding: 1em;
height: 80vh;
min-height: 550px;
}
</style>
@@ -1,11 +1,11 @@
<template> <template>
<section class="info-routes" v-if="station.generalInfo"> <section class="info-routes" v-if="station.generalInfo">
<div class="routes one-way" v-if="filteredOneWayRoutes.length > 0"> <div class="routes one-way" v-if="oneWayRoutes.length > 0">
<b>{{ $t('scenery.one-way-routes') }}</b> <b>{{ $t('scenery.one-way-routes') }}</b>
<ul class="routes-list"> <ul class="routes-list">
<li <li
v-for="route in filteredOneWayRoutes" v-for="route in oneWayRoutes"
:key="route.routeName" :key="route.routeName"
@click="setActiveShowLength(route.routeName)" @click="setActiveShowLength(route.routeName)"
> >
@@ -24,12 +24,12 @@
</ul> </ul>
</div> </div>
<div class="routes two-way" v-if="filteredTwoWayRoutes.length > 0"> <div class="routes two-way" v-if="twoWayRoutes.length > 0">
<b>{{ $t('scenery.two-way-routes') }}</b> <b>{{ $t('scenery.two-way-routes') }}</b>
<ul class="routes-list"> <ul class="routes-list">
<li <li
v-for="route in filteredTwoWayRoutes" v-for="route in twoWayRoutes"
:key="route.routeName" :key="route.routeName"
@click="setActiveShowLength(route.routeName)" @click="setActiveShowLength(route.routeName)"
> >
@@ -53,9 +53,6 @@
<script lang="ts"> <script lang="ts">
import { PropType, defineComponent } from 'vue'; import { PropType, defineComponent } from 'vue';
import Station from '../../../scripts/interfaces/Station'; import Station from '../../../scripts/interfaces/Station';
import { StationRoutesInfo } from '../../../store/typings';
const routeFilter = (route: StationRoutesInfo) => !route.hidden;
export default defineComponent({ export default defineComponent({
props: { props: {
@@ -80,12 +77,12 @@ export default defineComponent({
}, },
computed: { computed: {
filteredOneWayRoutes() { oneWayRoutes() {
return this.station.generalInfo?.routes.single.filter(routeFilter) || []; return this.station.generalInfo?.routes.single ?? [];
}, },
filteredTwoWayRoutes() { twoWayRoutes() {
return this.station.generalInfo?.routes.double.filter(routeFilter) || []; return this.station.generalInfo?.routes.double ?? [];
} }
} }
}); });
+9 -9
View File
@@ -196,21 +196,22 @@
</div> </div>
</td> </td>
<td class="station-info" v-if="station.generalInfo"> <td class="station-info">
<span <span
v-if="station.generalInfo?.signalType"
class="scenery-icon icon-info" class="scenery-icon icon-info"
:class="station.generalInfo.controlType.replace('+', '-')" :class="station.generalInfo?.controlType.replace('+', '-')"
:title=" :title="
$t('sceneries.info.control-type') + $t('sceneries.info.control-type') +
$t(`controls.${station.generalInfo.controlType}`) $t(`controls.${station.generalInfo?.controlType}`)
" "
v-html="getControlTypeAbbrev(station.generalInfo.controlType)" v-html="getControlTypeAbbrev(station.generalInfo.controlType)"
> >
</span> </span>
<img <img
v-if="station.generalInfo?.signalType"
class="icon-info" class="icon-info"
v-if="station.generalInfo.signalType"
:src="`/images/icon-${station.generalInfo.signalType}.svg`" :src="`/images/icon-${station.generalInfo.signalType}.svg`"
:alt="station.generalInfo.signalType" :alt="station.generalInfo.signalType"
:title=" :title="
@@ -220,24 +221,23 @@
/> />
<img <img
v-if="station.generalInfo?.SUP"
class="icon-info" class="icon-info"
v-if="station.generalInfo.SUP"
src="/images/icon-SUP.svg" src="/images/icon-SUP.svg"
alt="SUP (RASP-UZK)" alt="SUP (RASP-UZK)"
:title="$t('sceneries.info.SUP')" :title="$t('sceneries.info.SUP')"
/> />
<img <img
v-if="station.generalInfo?.ASDEK"
class="icon-info" class="icon-info"
v-if="station.generalInfo.ASDEK"
src="/images/icon-ASDEK.svg" src="/images/icon-ASDEK.svg"
alt="dSAT ASDEK" alt="dSAT ASDEK"
:title="$t('sceneries.info.ASDEK')" :title="$t('sceneries.info.ASDEK')"
/> />
</td>
<td class="station-info" v-else>
<img <img
v-if="!station.generalInfo"
class="icon-info" class="icon-info"
src="/images/icon-unknown.svg" src="/images/icon-unknown.svg"
alt="icon-unknown" alt="icon-unknown"
@@ -460,7 +460,7 @@ table {
} }
&.general { &.general {
width: 10em; width: 11em;
} }
&.header-image { &.header-image {
+4 -2
View File
@@ -56,12 +56,14 @@ export const sortStations = (
case 'routes-single': case 'routes-single':
diff = diff =
(a.generalInfo?.routes.single.length ?? -1) - (b.generalInfo?.routes.single.length ?? -1); (a.generalInfo?.routes.single.filter((r) => !r.hidden && !r.isInternal).length ?? -1) -
(b.generalInfo?.routes.single.filter((r) => !r.hidden && !r.isInternal).length ?? -1);
break; break;
case 'routes-double': case 'routes-double':
diff = diff =
(a.generalInfo?.routes.double.length ?? -1) - (b.generalInfo?.routes.double.length ?? -1); (a.generalInfo?.routes.double.filter((r) => !r.hidden && !r.isInternal).length ?? -1) -
(b.generalInfo?.routes.double.filter((r) => !r.hidden && !r.isInternal).length ?? -1);
break; break;
case 'user': case 'user':
+1
View File
@@ -15,6 +15,7 @@ export const useMainStore = defineStore('store', {
region: { id: 'eu', value: 'PL1' }, region: { id: 'eu', value: 'PL1' },
isOffline: false, isOffline: false,
isNewUpdate: false,
dispatcherStatsName: '', dispatcherStatsName: '',
dispatcherStatsStatus: Status.Data.Initialized, dispatcherStatsStatus: Status.Data.Initialized,
+2
View File
@@ -14,6 +14,8 @@ export interface StoreState {
isOffline: boolean; isOffline: boolean;
isNewUpdate: boolean;
dispatcherStatsName: string; dispatcherStatsName: string;
dispatcherStatsData?: API.DispatcherStats.Response; dispatcherStatsData?: API.DispatcherStats.Response;