From 300e70dcfe1d42fb32befe22c29b5b153f1d6a07 Mon Sep 17 00:00:00 2001 From: Spythere Date: Thu, 15 Aug 2024 15:01:36 +0200 Subject: [PATCH 01/38] chore: journal timetables buttons alignment --- .../JournalTimetables/TimetableDetails.vue | 20 +++++++++++++++++++ .../JournalTimetables/TimetableGeneral.vue | 18 +---------------- 2 files changed, 21 insertions(+), 17 deletions(-) diff --git a/src/components/JournalView/JournalTimetables/TimetableDetails.vue b/src/components/JournalView/JournalTimetables/TimetableDetails.vue index a9964f4..305cbe1 100644 --- a/src/components/JournalView/JournalTimetables/TimetableDetails.vue +++ b/src/components/JournalView/JournalTimetables/TimetableDetails.vue @@ -5,6 +5,15 @@ {{ $t('journal.stock-info') }} Arrow icon + +
@@ -77,9 +86,13 @@ import { PropType, defineComponent } from 'vue'; import StockList from '../../Global/StockList.vue'; import { API } from '../../../typings/api'; +import modalTrainMixin from '../../../mixins/modalTrainMixin'; export default defineComponent({ components: { StockList }, + + mixins: [modalTrainMixin], + props: { showExtraInfo: { type: Boolean, @@ -118,6 +131,12 @@ export default defineComponent({ onImageError(e: Event) { const imageEl = e.target as HTMLImageElement; imageEl.src = '/images/icon-unknown.png'; + }, + + showTimetable(timetable: API.TimetableHistory.Data, target: EventTarget | null) { + if (timetable?.terminated) return; + + this.selectModalTrainById(`${timetable.driverName}${timetable.trainNo}`, target); } } }); @@ -134,6 +153,7 @@ export default defineComponent({ .details-actions { display: flex; + gap: 0.5em; button img { height: 1.25em; diff --git a/src/components/JournalView/JournalTimetables/TimetableGeneral.vue b/src/components/JournalView/JournalTimetables/TimetableGeneral.vue index 47c84ee..ce37587 100644 --- a/src/components/JournalView/JournalTimetables/TimetableGeneral.vue +++ b/src/components/JournalView/JournalTimetables/TimetableGeneral.vue @@ -66,15 +66,6 @@ : `${$t('journal.timetable-abandoned')} ${localeTime(timetable.endDate, $i18n.locale)}` }} - -
@@ -104,14 +95,6 @@ export default defineComponent({ required: true } }, - - methods: { - showTimetable(timetable: API.TimetableHistory.Data, target: EventTarget | null) { - if (timetable?.terminated) return; - - this.selectModalTrainById(`${timetable.driverName}${timetable.trainNo}`, target); - } - } }); @@ -180,6 +163,7 @@ export default defineComponent({ @include smallScreen { .item-general { + flex-direction: column; justify-content: center; } } From cd71c78eb4fd4ab80fa818f2b74df0fa76b8dd85 Mon Sep 17 00:00:00 2001 From: Spythere Date: Sat, 17 Aug 2024 15:51:25 +0200 Subject: [PATCH 02/38] chore: apicache typings --- src/typings/api.ts | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/typings/api.ts b/src/typings/api.ts index dd32033..cebe68c 100644 --- a/src/typings/api.ts +++ b/src/typings/api.ts @@ -4,6 +4,12 @@ export enum APIDataStatus { OK = 'OK', WARNING = 'WARNING' } + +export interface APICache { + lastModified: string; + name: string; +} + export namespace API { export namespace ActiveData { export interface APIStatuses { @@ -11,6 +17,7 @@ export namespace API { trainsAPI: APIDataStatus; dispatchersAPI: APIDataStatus; sceneryRequirementsAPI: APIDataStatus; + caches: APICache[]; } export interface Response { From 58d6a97762f70f514db24687c2ab8c7ed3c279f3 Mon Sep 17 00:00:00 2001 From: Spythere Date: Sat, 17 Aug 2024 15:51:36 +0200 Subject: [PATCH 03/38] fix: twr/skr badges sizing --- .../JournalTimetables/TimetableGeneral.vue | 9 +++---- src/components/TrainsView/TrainInfo.vue | 24 +++++-------------- src/styles/badge.scss | 6 ----- 3 files changed, 9 insertions(+), 30 deletions(-) diff --git a/src/components/JournalView/JournalTimetables/TimetableGeneral.vue b/src/components/JournalView/JournalTimetables/TimetableGeneral.vue index ce37587..53ea5ce 100644 --- a/src/components/JournalView/JournalTimetables/TimetableGeneral.vue +++ b/src/components/JournalView/JournalTimetables/TimetableGeneral.vue @@ -3,10 +3,8 @@ #{{ timetable.id }} - - TWR - SKR - + TWR + SKR , required: true } - }, + } }); @@ -120,7 +118,6 @@ export default defineComponent({ gap: 0.25em; cursor: pointer; - line-height: 2; } .general-time { diff --git a/src/components/TrainsView/TrainInfo.vue b/src/components/TrainsView/TrainInfo.vue index 282c326..2c3b5e9 100644 --- a/src/components/TrainsView/TrainInfo.vue +++ b/src/components/TrainsView/TrainInfo.vue @@ -8,24 +8,12 @@ #{{ train.timetableData.timetableId }} - - - TWR - - - SKR - + + TWR + + + + SKR Date: Sun, 18 Aug 2024 01:43:27 +0200 Subject: [PATCH 04/38] chore: moved station stats to a dropdown --- .../StationsView/StationFilterCard.vue | 83 ++++++---- src/components/StationsView/StationStats.vue | 151 ++++++++++-------- src/components/StationsView/StationTable.vue | 2 +- src/components/TrainsView/TrainStats.vue | 30 +--- src/locales/en.json | 6 +- src/locales/pl.json | 6 +- src/views/StationsView.vue | 8 +- 7 files changed, 155 insertions(+), 131 deletions(-) diff --git a/src/components/StationsView/StationFilterCard.vue b/src/components/StationsView/StationFilterCard.vue index 00663cb..876e3ed 100644 --- a/src/components/StationsView/StationFilterCard.vue +++ b/src/components/StationsView/StationFilterCard.vue @@ -6,30 +6,11 @@

[F] {{ $t('options.filters') }}

- - -
-
+
+
{{ $t('filters.title') }}

@@ -40,6 +21,31 @@
+ +
- +
@@ -269,20 +275,11 @@ export default defineComponent({ }, watch: { - chosenSearchScenery(value: string) { - const chosenStation = this.store.stationList.find(({ name }) => name == value); - - if (chosenStation) { - this.$router.push(`/scenery?station=${chosenStation.name.replace(/ /g, '_')}`); - this.chosenSearchScenery = ''; - } - }, - isVisible(value: boolean) { this.$nextTick(() => { if (value) { - (this.$refs['cardRef'] as HTMLDivElement).focus(); (this.$refs['cardContentRef'] as HTMLDivElement).scrollTop = this.scrollTop; + (this.$refs['cardContentRef'] as HTMLDivElement).focus(); } }); } @@ -300,7 +297,18 @@ export default defineComponent({ handleAuthorsInput() { this.filters['authors'] = this.authors; - // if (this.saveOptions) StorageManager.setStringValue('authors', target.value); + }, + + handleSceneriesInput() { + const chosenStation = this.store.stationList.find( + ({ name }) => name == this.chosenSearchScenery + ); + + if (chosenStation) { + this.$router.push(`/scenery?station=${chosenStation.name.replace(/ /g, '_')}`); + this.chosenSearchScenery = ''; + this.isVisible = false; + } }, subHour() { @@ -329,6 +337,8 @@ export default defineComponent({ }, resetFilters() { + if (this.preventKeyDown) return; + // Reset local model values this.minimumHours = 0; this.authors = ''; @@ -382,6 +392,7 @@ h3.section-header { .card { display: grid; grid-template-rows: 1fr auto; + padding: 1px; } .card_info { @@ -451,8 +462,12 @@ h3.section-header { } } -.card_authors-search { +.card_authors-search, +.card_sceneries-search { margin: 1em 0; + display: flex; + flex-direction: column; + align-items: center; form { display: flex; diff --git a/src/components/StationsView/StationStats.vue b/src/components/StationsView/StationStats.vue index ba8552a..fd6a8fc 100644 --- a/src/components/StationsView/StationStats.vue +++ b/src/components/StationsView/StationStats.vue @@ -1,56 +1,70 @@ @@ -61,11 +75,16 @@ import { useMainStore } from '../../store/mainStore'; export default defineComponent({ data() { return { - mainStore: useMainStore() + mainStore: useMainStore(), + showDropdown: false }; }, methods: { + toggleDropdown() { + this.showDropdown = !this.showDropdown; + }, + calculateFactorStyle() { if (this.uFactor == 0) return ''; @@ -171,26 +190,24 @@ export default defineComponent({ From 80a5b567853188989151ee533d81a57c71f438fa Mon Sep 17 00:00:00 2001 From: Spythere Date: Sun, 18 Aug 2024 23:45:42 +0200 Subject: [PATCH 09/38] feat: router links embeded into timetable stop names --- .../SceneryView/SceneryTimetable.vue | 6 ++ src/components/TrainsView/StopLabel.vue | 7 +- src/components/TrainsView/TrainSchedule.vue | 18 ++--- src/store/mainStore.ts | 69 +++++++++++++++---- src/typings/common.ts | 1 - src/views/SceneryView.vue | 1 + 6 files changed, 77 insertions(+), 25 deletions(-) diff --git a/src/components/SceneryView/SceneryTimetable.vue b/src/components/SceneryView/SceneryTimetable.vue index b14d87c..0e8a171 100644 --- a/src/components/SceneryView/SceneryTimetable.vue +++ b/src/components/SceneryView/SceneryTimetable.vue @@ -214,6 +214,12 @@ export default defineComponent({ this.loadSelectedOption(); }, + watch: { + station() { + this.loadSelectedOption(); + } + }, + setup(props) { const route = useRoute(); const currentURL = computed(() => `${location.origin}${route.fullPath}`); diff --git a/src/components/TrainsView/StopLabel.vue b/src/components/TrainsView/StopLabel.vue index ee800d0..2a4eed8 100644 --- a/src/components/TrainsView/StopLabel.vue +++ b/src/components/TrainsView/StopLabel.vue @@ -3,7 +3,9 @@ class="stop-label" :data-minor="stop.isSBL || (stop.nameRaw.endsWith(', po.') && !stop.duration)" > - + + + { const isExternal = - i > 0 && - stop.arrivalLine != null && - (stop.arrivalLine != arr[i - 1].departureLine || - (stop.arrivalLine == arr[i - 1].departureLine && - !/-|_|(^it\d+)|(^sbl)/gi.test(stop.arrivalLine))); + i < arr.length - 1 && + stop.departureLine === timetablePath[currentPathIndex].departureRouteExt; - if (isExternal) currentSceneryIndex++; - - const sceneryName = this.train.timetableData!.sceneryNames[currentSceneryIndex]; + const sceneryName = timetablePath[currentPathIndex].stationName; const sceneryInfo = this.apiStore.sceneryData.find((st) => st.name == sceneryName); const arrivalLineInfo = sceneryInfo?.routesInfo.find( @@ -189,6 +187,8 @@ export default defineComponent({ (r) => r.routeName == stop.departureLine ); + if (isExternal) currentPathIndex++; + return { nameHtml: stop.stopName, nameRaw: stop.stopNameRAW, diff --git a/src/store/mainStore.ts b/src/store/mainStore.ts index eeabb5a..129e5bb 100644 --- a/src/store/mainStore.ts +++ b/src/store/mainStore.ts @@ -50,14 +50,14 @@ export const useMainStore = defineStore('mainStore', { const timetable = train.timetable; - const sceneryNames = - train.timetable?.sceneries?.map( - (sceneryHash) => - apiStore.activeData?.activeSceneries?.find((st) => st.stationHash === sceneryHash) - ?.stationName ?? - apiStore.sceneryData.find((sd) => sd.hash === sceneryHash)?.name ?? - sceneryHash - ) ?? []; + // const sceneryNames = + // train.timetable?.sceneries?.map( + // (sceneryHash) => + // apiStore.activeData?.activeSceneries?.find((st) => st.stationHash === sceneryHash) + // ?.stationName ?? + // apiStore.sceneryData.find((sd) => sd.hash === sceneryHash)?.name ?? + // sceneryHash + // ) ?? []; const trainObj = { id: train.id, @@ -96,7 +96,7 @@ export const useMainStore = defineStore('mainStore', { followingStops: timetable.stopList, routeDistance: timetable.stopList[timetable.stopList.length - 1].stopDistance, sceneries: timetable.sceneries, - sceneryNames: sceneryNames.reverse(), + // sceneryNames: sceneryNames.reverse(), timetablePath: timetable.path.split(';').map((pathElementString) => { const [arrival, station, departure] = pathElementString.split(','); @@ -169,12 +169,15 @@ export const useMainStore = defineStore('mainStore', { const offlineActiveSceneries = this.trainList.reduce((acc, train) => { if (!train.timetableData) return acc; - train.timetableData.sceneryNames.forEach((name) => { + train.timetableData.timetablePath.forEach((p) => { if ( - acc.findIndex((v) => v.name == name && v.region == train.region) != -1 || + acc.findIndex( + (v) => + (v.name == p.stationName || v.hash == p.stationHash) && v.region == train.region + ) != -1 || apiStore.activeData?.activeSceneries?.findIndex( (sc) => - sc.stationName === name && + (sc.stationName == p.stationName || sc.stationHash == p.stationHash) && sc.region == train.region && Date.now() - sc.lastSeen < 1000 * 60 * 2 ) != -1 @@ -182,7 +185,7 @@ export const useMainStore = defineStore('mainStore', { return acc; acc.push({ - name: name, + name: p.stationName, hash: '', region: train.region, maxUsers: 0, @@ -209,6 +212,46 @@ export const useMainStore = defineStore('mainStore', { }); }); + // train.timetableData.sceneryNames.forEach((name) => { + // if ( + // acc.findIndex((v) => v.name == name && v.region == train.region) != -1 || + // apiStore.activeData?.activeSceneries?.findIndex( + // (sc) => + // sc.stationName === name && + // sc.region == train.region && + // Date.now() - sc.lastSeen < 1000 * 60 * 2 + // ) != -1 + // ) + // return acc; + + // acc.push({ + // name: name, + // hash: '', + // region: train.region, + // maxUsers: 0, + // currentUsers: 0, + // spawns: [], + // dispatcherName: '', + // dispatcherRate: 0, + // dispatcherId: -1, + // dispatcherExp: -1, + // dispatcherIsSupporter: false, + // dispatcherStatus: Status.ActiveDispatcher.FREE, + // dispatcherTimestamp: -1, + + // isOnline: false, + + // stationTrains: [], + // scheduledTrains: [], + + // scheduledTrainCount: { + // all: 0, + // confirmed: 0, + // unconfirmed: 0 + // } + // }); + // }); + return acc; }, [] as ActiveScenery[]); diff --git a/src/typings/common.ts b/src/typings/common.ts index 3731794..a8e049a 100644 --- a/src/typings/common.ts +++ b/src/typings/common.ts @@ -79,7 +79,6 @@ export interface Train { SKR: boolean; routeDistance: number; sceneries: string[]; - sceneryNames: string[]; timetablePath: TimetablePathElement[]; }; } diff --git a/src/views/SceneryView.vue b/src/views/SceneryView.vue index 2653441..a6207ca 100644 --- a/src/views/SceneryView.vue +++ b/src/views/SceneryView.vue @@ -13,6 +13,7 @@ :station="stationInfo" :onlineScenery="onlineSceneryInfo" /> +
From 551b60c733a5ade7cf580e1abc1be09f1749c8e7 Mon Sep 17 00:00:00 2001 From: Spythere Date: Mon, 19 Aug 2024 23:56:15 +0200 Subject: [PATCH 10/38] fix: omitting "po" stops in timetable progress bar --- src/components/StationsView/StationTable.vue | 2 +- src/components/TrainsView/StopLabel.vue | 2 +- src/components/TrainsView/TrainSchedule.vue | 2 +- src/mixins/trainInfoMixin.ts | 4 ++-- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/components/StationsView/StationTable.vue b/src/components/StationsView/StationTable.vue index ddf70bb..47f699a 100644 --- a/src/components/StationsView/StationTable.vue +++ b/src/components/StationsView/StationTable.vue @@ -414,7 +414,7 @@ export default defineComponent({ $rowCol: #424242; .station_table { - height: 85vh; + height: 90vh; max-height: 2000px; min-height: 700px; overflow: auto; diff --git a/src/components/TrainsView/StopLabel.vue b/src/components/TrainsView/StopLabel.vue index 2a4eed8..97cd6df 100644 --- a/src/components/TrainsView/StopLabel.vue +++ b/src/components/TrainsView/StopLabel.vue @@ -1,7 +1,7 @@