mirror of
https://github.com/Spythere/stacjownik.git
synced 2026-05-03 05:18:11 +00:00
chore(profile): added level badges for player summary
This commit is contained in:
@@ -0,0 +1,8 @@
|
|||||||
|
export function calculateExpStyles(exp: number, isSupporter = false) {
|
||||||
|
const bgColor = exp > -1 ? (exp < 2 ? '#26B0D9' : `hsl(${-exp * 5 + 100}, 85%, 50%)`) : '#666';
|
||||||
|
|
||||||
|
const fontColor = exp > 14 || exp == -1 ? 'white' : 'black';
|
||||||
|
const boxShadow = isSupporter ? `0 0 6px 2px ${bgColor};` : '';
|
||||||
|
|
||||||
|
return { 'background-color': bgColor, color: fontColor, 'box-shadow': boxShadow };
|
||||||
|
}
|
||||||
@@ -3,37 +3,73 @@
|
|||||||
<div class="view-container" v-if="playerInfo && playerDataStatus == Status.Data.Loaded">
|
<div class="view-container" v-if="playerInfo && playerDataStatus == Status.Data.Loaded">
|
||||||
<div class="profile-sidebar">
|
<div class="profile-sidebar">
|
||||||
<div class="player-summary">
|
<div class="player-summary">
|
||||||
<img
|
<div class="summary-main">
|
||||||
v-if="playerTD2Info"
|
<img
|
||||||
:src="`https://td2.info.pl/index.php?action=dlattach;attach=${playerTD2Info.avatar};type=avatar`"
|
v-if="playerTD2Info"
|
||||||
alt="player image"
|
:src="`https://td2.info.pl/index.php?action=dlattach;attach=${playerTD2Info.avatar};type=avatar`"
|
||||||
height="100"
|
alt="player image"
|
||||||
@error="(e) => ((e.target as any).src = '/images/default-avatar.jpg')"
|
height="120"
|
||||||
/>
|
@error="(e) => ((e.target as any).src = '/images/default-avatar.jpg')"
|
||||||
|
/>
|
||||||
|
|
||||||
<h3>{{ playerName }}</h3>
|
<img class="img-placeholder" height="100" src="/images/default-avatar.jpg" v-else />
|
||||||
|
|
||||||
<p v-if="playerTD2Info != null">{{ playerTD2Info.levels.driver }} poziom maszynisty</p>
|
<div>
|
||||||
<p v-if="playerTD2Info != null">{{ playerTD2Info.levels.dispatcher }} poziom dyżurnego</p>
|
<h2>{{ playerName }}</h2>
|
||||||
|
|
||||||
<div v-if="combinedJournal.length > 0">
|
<div class="player-badges">
|
||||||
<div v-if="playerInfo.currentActivity.dispatcher.length > 0">
|
<div class="badge-container" v-if="playerInfo.driverStats.driverLevel != null">
|
||||||
<b class="text--primary">ONLINE JAKO DR:</b>
|
<span
|
||||||
{{
|
class="level-badge driver"
|
||||||
playerInfo.currentActivity.dispatcher
|
:style="calculateExpStyles(playerInfo.driverStats.driverLevel)"
|
||||||
.map((d) => `${d.stationName} (${d.stationHash})`)
|
>
|
||||||
.join(', ')
|
{{
|
||||||
}}
|
playerInfo.driverStats.driverLevel > 1
|
||||||
|
? playerInfo.driverStats.driverLevel
|
||||||
|
: 'L'
|
||||||
|
}}
|
||||||
|
</span>
|
||||||
|
MASZYNISTA
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div
|
||||||
|
class="badge-container"
|
||||||
|
v-if="playerInfo.dispatcherStats.dispatcherLevel != null"
|
||||||
|
>
|
||||||
|
<span
|
||||||
|
class="level-badge dispatcher"
|
||||||
|
:style="calculateExpStyles(playerInfo.dispatcherStats.dispatcherLevel)"
|
||||||
|
>
|
||||||
|
{{
|
||||||
|
playerInfo.dispatcherStats.dispatcherLevel > 1
|
||||||
|
? playerInfo.dispatcherStats.dispatcherLevel
|
||||||
|
: 'L'
|
||||||
|
}}
|
||||||
|
</span>
|
||||||
|
DYŻURNY RUCHU
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div
|
<div
|
||||||
v-if="
|
class="player-current-activity"
|
||||||
playerInfo.currentActivity.driver && playerInfo.currentActivity.driver.length > 0
|
v-if="playerInfo.currentActivity.dispatcher.length > 0"
|
||||||
"
|
>
|
||||||
>
|
<b class="text--primary">ONLINE JAKO DR:</b>
|
||||||
<b>ONLINE JAKO MASZYNISTA:</b>
|
{{
|
||||||
{{ playerInfo.currentActivity.driver }}
|
playerInfo.currentActivity.dispatcher
|
||||||
</div>
|
.map((d) => `${d.stationName} (${d.stationHash})`)
|
||||||
|
.join(', ')
|
||||||
|
}}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div
|
||||||
|
class="player-current-activity"
|
||||||
|
v-if="playerInfo.currentActivity.driver && playerInfo.currentActivity.driver.length > 0"
|
||||||
|
>
|
||||||
|
<b>ONLINE JAKO MASZYNISTA:</b>
|
||||||
|
{{ playerInfo.currentActivity.driver.trainNo }}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- <p v-if="useMainStore"></p> -->
|
<!-- <p v-if="useMainStore"></p> -->
|
||||||
@@ -168,7 +204,7 @@
|
|||||||
<div><img src="/images/icon-spawn.svg" width="30" alt="spawn icon" /></div>
|
<div><img src="/images/icon-spawn.svg" width="30" alt="spawn icon" /></div>
|
||||||
<div>
|
<div>
|
||||||
<h3 class="text--primary">
|
<h3 class="text--primary">
|
||||||
{{ playerInfo.driverStatsLastMonth.currentDistanceTotal || 0 }}
|
{{ playerInfo.driverStatsLastMonth.currentDistanceTotal?.toFixed(2) || 0 }}
|
||||||
</h3>
|
</h3>
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
@@ -295,6 +331,7 @@ import axios from 'axios';
|
|||||||
import { getCountPercentage } from '../utils/calcUtils';
|
import { getCountPercentage } from '../utils/calcUtils';
|
||||||
import { Status } from '../typings/common';
|
import { Status } from '../typings/common';
|
||||||
import Loading from '../components/Global/Loading.vue';
|
import Loading from '../components/Global/Loading.vue';
|
||||||
|
import { calculateExpStyles } from '../composables/badge';
|
||||||
|
|
||||||
type JournalEntryType = 'Timetable' | 'Dispatcher' | 'IssuedTimetable';
|
type JournalEntryType = 'Timetable' | 'Dispatcher' | 'IssuedTimetable';
|
||||||
|
|
||||||
@@ -375,6 +412,7 @@ const combinedJournal = computed<JournalEntry[]>(() => {
|
|||||||
async function fetchAllData() {
|
async function fetchAllData() {
|
||||||
const playerId = route.query.playerId?.toString();
|
const playerId = route.query.playerId?.toString();
|
||||||
|
|
||||||
|
playerTD2Info.value = null;
|
||||||
playerDataStatus.value = Status.Data.Loading;
|
playerDataStatus.value = Status.Data.Loading;
|
||||||
|
|
||||||
if (!playerId) {
|
if (!playerId) {
|
||||||
@@ -484,6 +522,7 @@ function toggleFilter(filterType: JournalEntryType) {
|
|||||||
|
|
||||||
<style lang="scss" scoped>
|
<style lang="scss" scoped>
|
||||||
@use '../styles/responsive';
|
@use '../styles/responsive';
|
||||||
|
@use '../styles/badge';
|
||||||
|
|
||||||
$tileColor: #181818;
|
$tileColor: #181818;
|
||||||
|
|
||||||
@@ -554,6 +593,31 @@ $tileColor: #181818;
|
|||||||
padding: 1em;
|
padding: 1em;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.summary-main {
|
||||||
|
display: flex;
|
||||||
|
justify-content: center;
|
||||||
|
gap: 1.5em;
|
||||||
|
}
|
||||||
|
|
||||||
|
.player-badges {
|
||||||
|
margin: 0.5em 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.badge-container {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 0.5em;
|
||||||
|
margin: 0.5em 0;
|
||||||
|
|
||||||
|
& > .level-badge {
|
||||||
|
font-size: 1.15em;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.player-current-activity {
|
||||||
|
margin-top: 1em;
|
||||||
|
}
|
||||||
|
|
||||||
.profile-main {
|
.profile-main {
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user