mirror of
https://github.com/Spythere/stacjownik.git
synced 2026-05-03 13:28:11 +00:00
chore(player profile): added typings for player info response object
This commit is contained in:
@@ -115,7 +115,7 @@ export default defineComponent({
|
||||
|
||||
data() {
|
||||
return {
|
||||
historyList: [] as API.TimetableHistory.Response,
|
||||
historyList: [] as API.TimetableHistory.ResponseShort,
|
||||
historyModeList,
|
||||
|
||||
apiStore: useApiStore(),
|
||||
@@ -149,7 +149,7 @@ export default defineComponent({
|
||||
requestFilters['returnType'] = 'short';
|
||||
|
||||
try {
|
||||
const response: API.TimetableHistory.Response = await (
|
||||
const response: API.TimetableHistory.ResponseShort = await (
|
||||
await this.apiStore.client!.get('api/getTimetables', {
|
||||
params: requestFilters
|
||||
})
|
||||
@@ -178,7 +178,7 @@ export default defineComponent({
|
||||
});
|
||||
},
|
||||
|
||||
parseCreatedDate(timetable: API.TimetableHistory.Data, locale: string) {
|
||||
parseCreatedDate(timetable: API.TimetableHistory.DataShort, locale: string) {
|
||||
const createdDate =
|
||||
timetable.createdAt > timetable.beginDate
|
||||
? new Date(timetable.beginDate)
|
||||
|
||||
+67
-48
@@ -27,6 +27,15 @@ export namespace API {
|
||||
}
|
||||
}
|
||||
|
||||
export namespace PlayerActivity {
|
||||
export interface Data {
|
||||
dispatcher: API.ActiveSceneries.Data[];
|
||||
driver: API.ActiveTrains.Data;
|
||||
}
|
||||
|
||||
export type Response = Data;
|
||||
}
|
||||
|
||||
export namespace DispatcherHistory {
|
||||
export type Response = Data[];
|
||||
|
||||
@@ -52,32 +61,25 @@ export namespace API {
|
||||
}
|
||||
|
||||
export namespace DispatcherStats {
|
||||
export interface DistanceStat {
|
||||
routeDistance: number | null;
|
||||
export interface Services {
|
||||
count: number;
|
||||
durationMax: number;
|
||||
durationAvg: number;
|
||||
}
|
||||
|
||||
export interface DurationStat {
|
||||
currentDuration: number | null;
|
||||
export interface IssuedTimetables {
|
||||
count: number;
|
||||
distanceMax: number;
|
||||
distanceAvg: number;
|
||||
distanceSum: number;
|
||||
}
|
||||
|
||||
export interface Count {
|
||||
_all: number;
|
||||
export interface Data {
|
||||
services: Services | null;
|
||||
issuedTimetables: IssuedTimetables | null;
|
||||
}
|
||||
|
||||
export interface Response {
|
||||
services: {
|
||||
count: number;
|
||||
durationMax: number;
|
||||
durationAvg: number;
|
||||
} | null;
|
||||
|
||||
issuedTimetables: {
|
||||
count: number;
|
||||
distanceMax: number;
|
||||
distanceAvg: number;
|
||||
distanceSum: number;
|
||||
} | null;
|
||||
}
|
||||
export type Response = Data;
|
||||
}
|
||||
|
||||
export namespace DriverStats {
|
||||
@@ -102,12 +104,24 @@ export namespace API {
|
||||
routeDistance: number;
|
||||
}
|
||||
|
||||
export interface Response {
|
||||
export interface Data {
|
||||
_sum: SumStats;
|
||||
_count: CountStats;
|
||||
_max: MaxStats;
|
||||
_avg: AvdStats;
|
||||
}
|
||||
|
||||
export type Response = Data;
|
||||
}
|
||||
|
||||
export namespace PlayerInfo {
|
||||
export interface Data {
|
||||
currentActivity: PlayerActivity.Data;
|
||||
dispatcherStats: DispatcherStats.Data;
|
||||
dispatcherStatsLastMonth: DispatcherStats.Data;
|
||||
driverStats: DriverStats.Data;
|
||||
driverStatsLastMonth: DriverStats.Data;
|
||||
}
|
||||
}
|
||||
|
||||
export namespace ActiveSceneries {
|
||||
@@ -211,12 +225,40 @@ export namespace API {
|
||||
}
|
||||
|
||||
export namespace TimetableHistory {
|
||||
export interface Data {
|
||||
id: number;
|
||||
createdAt: string;
|
||||
export interface Data extends DataShort {
|
||||
updatedAt: string;
|
||||
|
||||
timetableId: number;
|
||||
sceneriesString: string;
|
||||
endDate: string;
|
||||
|
||||
scheduledBeginDate: string;
|
||||
scheduledEndDate: string;
|
||||
|
||||
stockString?: string;
|
||||
stockHistory: string[];
|
||||
|
||||
stockMass?: number;
|
||||
stockLength?: number;
|
||||
maxSpeed?: number;
|
||||
|
||||
routeSceneries: string;
|
||||
checkpointArrivals: string[];
|
||||
checkpointDepartures: string[];
|
||||
checkpointArrivalsScheduled: string[];
|
||||
checkpointDeparturesScheduled: string[];
|
||||
checkpointStopTypes: string[];
|
||||
checkpointComments: string[];
|
||||
visitedSceneries: string[];
|
||||
sceneryNames: string[];
|
||||
path: string;
|
||||
warningNotes: string | null;
|
||||
trainMaxSpeed?: number;
|
||||
}
|
||||
|
||||
export interface DataShort {
|
||||
id: number;
|
||||
createdAt: string;
|
||||
trainNo: number;
|
||||
trainCategoryCode: string;
|
||||
|
||||
@@ -229,7 +271,6 @@ export namespace API {
|
||||
route: string;
|
||||
twr: number;
|
||||
skr: number;
|
||||
sceneriesString: string;
|
||||
currentLocation: string[];
|
||||
|
||||
routeDistance: number;
|
||||
@@ -239,10 +280,6 @@ export namespace API {
|
||||
allStopsCount: number;
|
||||
|
||||
beginDate: string;
|
||||
endDate: string;
|
||||
|
||||
scheduledBeginDate: string;
|
||||
scheduledEndDate: string;
|
||||
|
||||
terminated: boolean;
|
||||
fulfilled: boolean;
|
||||
@@ -250,32 +287,14 @@ export namespace API {
|
||||
authorName?: string;
|
||||
authorId?: number;
|
||||
|
||||
stockString?: string;
|
||||
stockHistory: string[];
|
||||
|
||||
stockMass?: number;
|
||||
stockLength?: number;
|
||||
maxSpeed?: number;
|
||||
|
||||
currentSceneryName?: string;
|
||||
currentSceneryHash?: string;
|
||||
routeSceneries: string;
|
||||
checkpointArrivals: string[];
|
||||
checkpointDepartures: string[];
|
||||
checkpointArrivalsScheduled: string[];
|
||||
checkpointDeparturesScheduled: string[];
|
||||
checkpointStopTypes: string[];
|
||||
checkpointComments: string[];
|
||||
visitedSceneries: string[];
|
||||
sceneryNames: string[];
|
||||
path: string;
|
||||
warningNotes: string | null;
|
||||
hasDangerousCargo: boolean;
|
||||
hasExtraDeliveries: boolean;
|
||||
trainMaxSpeed?: number;
|
||||
}
|
||||
|
||||
export type Response = Data[];
|
||||
export type ResponseShort = DataShort[];
|
||||
}
|
||||
|
||||
export namespace DailyStats {
|
||||
|
||||
@@ -220,6 +220,7 @@ export interface CheckpointTrain {
|
||||
export type Vehicle = API.VehiclesData.VehicleObject;
|
||||
export type VehicleGroup = API.VehiclesData.VehicleGroupObject;
|
||||
|
||||
// Train Tooltip Info
|
||||
export interface TooltipUserTrain {
|
||||
driverName: string;
|
||||
trainNo: number;
|
||||
@@ -240,4 +241,4 @@ export interface TooltipTrainInfo {
|
||||
headVehicleName: string;
|
||||
stockCount: number;
|
||||
trainTimetableCategory?: string;
|
||||
}
|
||||
}
|
||||
@@ -19,10 +19,13 @@
|
||||
<p>Stacjosponsor od 01.01.2024</p>
|
||||
</div>
|
||||
|
||||
<div class="player-stats">
|
||||
<div class="player-stats" v-if="playerInfo">
|
||||
<div class="stats-showcase">
|
||||
<div>
|
||||
<div>245 / 250 (95.55%)</div>
|
||||
<div>
|
||||
{{ playerInfo.driverStats._count.fulfilled }} /
|
||||
{{ playerInfo.driverStats._count._all }} (95.55%)
|
||||
</div>
|
||||
<div>ROZKŁADÓW JAZDY</div>
|
||||
</div>
|
||||
|
||||
@@ -85,12 +88,37 @@
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { computed, ref } from 'vue';
|
||||
import { computed, onMounted, ref, watch } from 'vue';
|
||||
import { useRoute } from 'vue-router';
|
||||
import { useApiStore } from '../store/apiStore';
|
||||
import { API } from '../typings/api';
|
||||
|
||||
const apiStore = useApiStore();
|
||||
const route = useRoute();
|
||||
|
||||
const playerId = computed(() => route.params.id);
|
||||
const playerInfo = ref<API.PlayerInfo.Data | null>(null);
|
||||
|
||||
onMounted(() => {
|
||||
fetchPlayerInfoData();
|
||||
});
|
||||
|
||||
async function fetchPlayerInfoData() {
|
||||
const playerId = route.params.id.toString();
|
||||
|
||||
if (!apiStore.client || !playerId) return;
|
||||
|
||||
try {
|
||||
const response = await apiStore.client.get<API.PlayerInfo.Data>('api/getPlayerInfo', {
|
||||
params: {
|
||||
playerId: playerId
|
||||
}
|
||||
});
|
||||
|
||||
playerInfo.value = response.data;
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
}
|
||||
}
|
||||
// const playerName = ref('');
|
||||
</script>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user