mirror of
https://github.com/Spythere/stacjownik.git
synced 2026-05-04 22:08:12 +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() {
|
data() {
|
||||||
return {
|
return {
|
||||||
historyList: [] as API.TimetableHistory.Response,
|
historyList: [] as API.TimetableHistory.ResponseShort,
|
||||||
historyModeList,
|
historyModeList,
|
||||||
|
|
||||||
apiStore: useApiStore(),
|
apiStore: useApiStore(),
|
||||||
@@ -149,7 +149,7 @@ export default defineComponent({
|
|||||||
requestFilters['returnType'] = 'short';
|
requestFilters['returnType'] = 'short';
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const response: API.TimetableHistory.Response = await (
|
const response: API.TimetableHistory.ResponseShort = await (
|
||||||
await this.apiStore.client!.get('api/getTimetables', {
|
await this.apiStore.client!.get('api/getTimetables', {
|
||||||
params: requestFilters
|
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 =
|
const createdDate =
|
||||||
timetable.createdAt > timetable.beginDate
|
timetable.createdAt > timetable.beginDate
|
||||||
? new Date(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 namespace DispatcherHistory {
|
||||||
export type Response = Data[];
|
export type Response = Data[];
|
||||||
|
|
||||||
@@ -52,32 +61,25 @@ export namespace API {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export namespace DispatcherStats {
|
export namespace DispatcherStats {
|
||||||
export interface DistanceStat {
|
export interface Services {
|
||||||
routeDistance: number | null;
|
count: number;
|
||||||
|
durationMax: number;
|
||||||
|
durationAvg: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface DurationStat {
|
export interface IssuedTimetables {
|
||||||
currentDuration: number | null;
|
count: number;
|
||||||
|
distanceMax: number;
|
||||||
|
distanceAvg: number;
|
||||||
|
distanceSum: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface Count {
|
export interface Data {
|
||||||
_all: number;
|
services: Services | null;
|
||||||
|
issuedTimetables: IssuedTimetables | null;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface Response {
|
export type Response = Data;
|
||||||
services: {
|
|
||||||
count: number;
|
|
||||||
durationMax: number;
|
|
||||||
durationAvg: number;
|
|
||||||
} | null;
|
|
||||||
|
|
||||||
issuedTimetables: {
|
|
||||||
count: number;
|
|
||||||
distanceMax: number;
|
|
||||||
distanceAvg: number;
|
|
||||||
distanceSum: number;
|
|
||||||
} | null;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export namespace DriverStats {
|
export namespace DriverStats {
|
||||||
@@ -102,12 +104,24 @@ export namespace API {
|
|||||||
routeDistance: number;
|
routeDistance: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface Response {
|
export interface Data {
|
||||||
_sum: SumStats;
|
_sum: SumStats;
|
||||||
_count: CountStats;
|
_count: CountStats;
|
||||||
_max: MaxStats;
|
_max: MaxStats;
|
||||||
_avg: AvdStats;
|
_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 {
|
export namespace ActiveSceneries {
|
||||||
@@ -211,12 +225,40 @@ export namespace API {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export namespace TimetableHistory {
|
export namespace TimetableHistory {
|
||||||
export interface Data {
|
export interface Data extends DataShort {
|
||||||
id: number;
|
|
||||||
createdAt: string;
|
|
||||||
updatedAt: string;
|
updatedAt: string;
|
||||||
|
|
||||||
timetableId: number;
|
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;
|
trainNo: number;
|
||||||
trainCategoryCode: string;
|
trainCategoryCode: string;
|
||||||
|
|
||||||
@@ -229,7 +271,6 @@ export namespace API {
|
|||||||
route: string;
|
route: string;
|
||||||
twr: number;
|
twr: number;
|
||||||
skr: number;
|
skr: number;
|
||||||
sceneriesString: string;
|
|
||||||
currentLocation: string[];
|
currentLocation: string[];
|
||||||
|
|
||||||
routeDistance: number;
|
routeDistance: number;
|
||||||
@@ -239,10 +280,6 @@ export namespace API {
|
|||||||
allStopsCount: number;
|
allStopsCount: number;
|
||||||
|
|
||||||
beginDate: string;
|
beginDate: string;
|
||||||
endDate: string;
|
|
||||||
|
|
||||||
scheduledBeginDate: string;
|
|
||||||
scheduledEndDate: string;
|
|
||||||
|
|
||||||
terminated: boolean;
|
terminated: boolean;
|
||||||
fulfilled: boolean;
|
fulfilled: boolean;
|
||||||
@@ -250,32 +287,14 @@ export namespace API {
|
|||||||
authorName?: string;
|
authorName?: string;
|
||||||
authorId?: number;
|
authorId?: number;
|
||||||
|
|
||||||
stockString?: string;
|
|
||||||
stockHistory: string[];
|
|
||||||
|
|
||||||
stockMass?: number;
|
|
||||||
stockLength?: number;
|
|
||||||
maxSpeed?: number;
|
|
||||||
|
|
||||||
currentSceneryName?: string;
|
currentSceneryName?: string;
|
||||||
currentSceneryHash?: 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;
|
hasDangerousCargo: boolean;
|
||||||
hasExtraDeliveries: boolean;
|
hasExtraDeliveries: boolean;
|
||||||
trainMaxSpeed?: number;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export type Response = Data[];
|
export type Response = Data[];
|
||||||
|
export type ResponseShort = DataShort[];
|
||||||
}
|
}
|
||||||
|
|
||||||
export namespace DailyStats {
|
export namespace DailyStats {
|
||||||
|
|||||||
@@ -220,6 +220,7 @@ export interface CheckpointTrain {
|
|||||||
export type Vehicle = API.VehiclesData.VehicleObject;
|
export type Vehicle = API.VehiclesData.VehicleObject;
|
||||||
export type VehicleGroup = API.VehiclesData.VehicleGroupObject;
|
export type VehicleGroup = API.VehiclesData.VehicleGroupObject;
|
||||||
|
|
||||||
|
// Train Tooltip Info
|
||||||
export interface TooltipUserTrain {
|
export interface TooltipUserTrain {
|
||||||
driverName: string;
|
driverName: string;
|
||||||
trainNo: number;
|
trainNo: number;
|
||||||
@@ -240,4 +241,4 @@ export interface TooltipTrainInfo {
|
|||||||
headVehicleName: string;
|
headVehicleName: string;
|
||||||
stockCount: number;
|
stockCount: number;
|
||||||
trainTimetableCategory?: string;
|
trainTimetableCategory?: string;
|
||||||
}
|
}
|
||||||
@@ -19,10 +19,13 @@
|
|||||||
<p>Stacjosponsor od 01.01.2024</p>
|
<p>Stacjosponsor od 01.01.2024</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="player-stats">
|
<div class="player-stats" v-if="playerInfo">
|
||||||
<div class="stats-showcase">
|
<div class="stats-showcase">
|
||||||
<div>
|
<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>ROZKŁADÓW JAZDY</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -85,12 +88,37 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { computed, ref } from 'vue';
|
import { computed, onMounted, ref, watch } from 'vue';
|
||||||
import { useRoute } from 'vue-router';
|
import { useRoute } from 'vue-router';
|
||||||
|
import { useApiStore } from '../store/apiStore';
|
||||||
|
import { API } from '../typings/api';
|
||||||
|
|
||||||
|
const apiStore = useApiStore();
|
||||||
const route = useRoute();
|
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('');
|
// const playerName = ref('');
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user