chore: subtracting loco weight for "obc. lok." cell

This commit is contained in:
2025-06-22 13:39:29 +02:00
parent 87f173a645
commit 59d694b233
7 changed files with 109 additions and 10 deletions
+21 -2
View File
@@ -4,9 +4,15 @@ import { defineStore } from 'pinia';
import {
DataStatus,
type ActiveDataResponse,
type SceneriesDataResponse
type SceneriesDataResponse,
type VehiclesDataResponse
} from '../types/api.types';
import type { ActiveData, JournalTimetableShort, SceneryData } from '../types/common.types';
import type {
ActiveData,
JournalTimetableShort,
SceneryData,
VehicleData
} from '../types/common.types';
let activeDataInterval = -1;
@@ -17,6 +23,7 @@ export const useApiStore = defineStore('api', {
activeData: null as ActiveData | null,
sceneryData: null as SceneryData[] | null,
vehiclesData: null as VehicleData[] | null,
journalTimetablesData: null as JournalTimetableShort[] | null,
outdatedTimerId: -1,
@@ -57,6 +64,8 @@ export const useApiStore = defineStore('api', {
}, 25000);
this.fetchSceneriesData();
this.fetchVehiclesData();
await this.fetchActiveData();
},
@@ -86,6 +95,16 @@ export const useApiStore = defineStore('api', {
} catch (error) {
console.error(error);
}
},
async fetchVehiclesData() {
try {
const response = (await this.client!.get<VehiclesDataResponse>('/api/getVehicles')).data;
this.vehiclesData = response;
} catch (error) {
console.error(error);
}
}
}
});
+8 -2
View File
@@ -7,6 +7,7 @@ import type {
ViewMode
} from '../types/common.types';
import { getHeadUnits } from '../utils/trainUtils';
import { useVehicleMixin } from '../mixins/useVehicleMixin';
export const useGlobalStore = defineStore('global', {
state: () => ({
@@ -48,6 +49,8 @@ export const useGlobalStore = defineStore('global', {
},
currentTimetableData(): TimetableData | null {
const vehicleUtils = useVehicleMixin();
if (this.viewMode == 'active') {
const selectedTrain = this.selectedActiveTrain;
@@ -55,7 +58,7 @@ export const useGlobalStore = defineStore('global', {
return {
trainNo: selectedTrain.trainNo,
mass: selectedTrain.mass,
mass: vehicleUtils.getLocoLoad(selectedTrain.mass, selectedTrain.stockString),
length: selectedTrain.length,
driverId: selectedTrain.driverId,
driverName: selectedTrain.driverName,
@@ -88,7 +91,10 @@ export const useGlobalStore = defineStore('global', {
return {
journalCreatedAt: new Date(selectedTimetable.createdAt).getTime(),
trainNo: selectedTimetable.trainNo,
mass: selectedTimetable.stockMass,
mass: vehicleUtils.getLocoLoad(
selectedTimetable.stockMass,
selectedTimetable.stockString
),
length: selectedTimetable.stockLength,
driverId: selectedTimetable.driverId,
driverName: selectedTimetable.driverName,