From 392a6437f850892d9c7cea385195ddfcf1b0f737 Mon Sep 17 00:00:00 2001 From: Spythere Date: Thu, 9 May 2024 17:19:22 +0200 Subject: [PATCH] feature: current users tooltip --- src/components/StationsView/StationTable.vue | 11 ++++- src/components/Tooltip/Tooltip.vue | 3 +- src/components/Tooltip/UsersTooltip.vue | 44 ++++++++++++++++++++ src/scripts/utils/stationFilterUtils.ts | 4 +- src/store/tooltipStore.ts | 3 +- 5 files changed, 59 insertions(+), 6 deletions(-) create mode 100644 src/components/Tooltip/UsersTooltip.vue diff --git a/src/components/StationsView/StationTable.vue b/src/components/StationsView/StationTable.vue index e59eb0e..9059faa 100644 --- a/src/components/StationsView/StationTable.vue +++ b/src/components/StationsView/StationTable.vue @@ -247,8 +247,15 @@ /> - - {{ station.onlineInfo?.currentUsers ?? '-' }} + + {{ + station.onlineInfo?.stationTrains?.length ?? '-' + }} / {{ station.onlineInfo?.maxUsers ?? '-' }} diff --git a/src/components/Tooltip/Tooltip.vue b/src/components/Tooltip/Tooltip.vue index 899ce95..0433a4b 100644 --- a/src/components/Tooltip/Tooltip.vue +++ b/src/components/Tooltip/Tooltip.vue @@ -11,9 +11,10 @@ import DonatorTooltip from './DonatorTooltip.vue'; import VehiclePreviewTooltip from './VehiclePreviewTooltip.vue'; import BaseTooltip from './BaseTooltip.vue'; import SpawnsTooltip from './SpawnsTooltip.vue'; +import UsersTooltip from './UsersTooltip.vue'; export default defineComponent({ - components: { DonatorTooltip, VehiclePreviewTooltip, BaseTooltip, SpawnsTooltip }, + components: { DonatorTooltip, VehiclePreviewTooltip, BaseTooltip, SpawnsTooltip, UsersTooltip }, data() { return { diff --git a/src/components/Tooltip/UsersTooltip.vue b/src/components/Tooltip/UsersTooltip.vue new file mode 100644 index 0000000..3d07f8d --- /dev/null +++ b/src/components/Tooltip/UsersTooltip.vue @@ -0,0 +1,44 @@ + + + + + diff --git a/src/scripts/utils/stationFilterUtils.ts b/src/scripts/utils/stationFilterUtils.ts index 59cfd83..1bc04a1 100644 --- a/src/scripts/utils/stationFilterUtils.ts +++ b/src/scripts/utils/stationFilterUtils.ts @@ -68,8 +68,8 @@ export const sortStations = ( case 'user': diff = - (b.onlineInfo ? b.onlineInfo.currentUsers : -1) - - (a.onlineInfo ? a.onlineInfo.currentUsers : -1); + (b.onlineInfo?.stationTrains ? b.onlineInfo.stationTrains.length : -1) - + (a.onlineInfo?.stationTrains ? a.onlineInfo.stationTrains.length : -1); break; case 'like': diff --git a/src/store/tooltipStore.ts b/src/store/tooltipStore.ts index f03e6c7..7ac18f4 100644 --- a/src/store/tooltipStore.ts +++ b/src/store/tooltipStore.ts @@ -6,7 +6,8 @@ export const tooltipKeys = [ 'DonatorTooltip', 'BaseTooltip', 'VehiclePreviewTooltip', - 'SpawnsTooltip' + 'SpawnsTooltip', + 'UsersTooltip' ] as const; export type TooltipType = (typeof tooltipKeys)[number];