reworked the sub-navigation on the Match-page

This commit is contained in:
cnachtigall1991
2021-10-15 11:11:38 +02:00
parent a29f4b1f2a
commit 3e9d8c47e3
11 changed files with 244 additions and 332 deletions

View File

@@ -1,5 +1,5 @@
<template> <template>
<div v-if="props.stats" class="player-dmg"> <div class="player-dmg">
<h4 class="text-center mt-3 mb-3">Team 1</h4> <h4 class="text-center mt-3 mb-3">Team 1</h4>
<div id="dmg-chart-1"></div> <div id="dmg-chart-1"></div>
<hr> <hr>
@@ -15,38 +15,28 @@ import {BarChart} from 'echarts/charts';
import {CanvasRenderer} from 'echarts/renderers'; import {CanvasRenderer} from 'echarts/renderers';
import {onMounted} from "vue"; import {onMounted} from "vue";
import {checkStatEmpty, getPlayerArr} from "../utils"; import {checkStatEmpty, getPlayerArr} from "../utils";
import {useStore} from "vuex";
export default { export default {
name: "FlashChart", name: "FlashChart",
props: { setup() {
stats: { const store = useStore()
type: Object,
required: true
}
},
setup(props) {
const teamArr = (stats, team) => {
let arr = []
for (let i = (team - 1) * 5; i < team * 5; i++) {
arr.push(-checkStatEmpty(stats[i].dmg.team))
}
arr.reverse()
return arr
}
const enemyArr = (stats, team) => { const dataArr = (stats, team, prop) => {
if (['team', 'enemy', 'self'].indexOf(prop) > -1) {
let arr = [] let arr = []
for (let i = (team - 1) * 5; i < team * 5; i++) { for (let i = (team - 1) * 5; i < team * 5; i++) {
arr.push({ arr.push({
value: checkStatEmpty(stats[i].dmg.enemy), value: checkStatEmpty(Function('return(function(stats, i){ return stats[i].dmg.' + prop + '})')()(stats, i)) * (prop === 'enemy' ? 1 : -1),
itemStyle: { itemStyle: {
color: getComputedStyle(document.documentElement).getPropertyValue(`--csgo-${stats[i].color}`) color: prop === 'enemy' ? getComputedStyle(document.documentElement).getPropertyValue(`--csgo-${stats[i].color}`) : 'firebrick'
} }
}) })
} }
arr.reverse() arr.reverse()
return arr return arr
} }
}
const optionGen = (stats, team) => { const optionGen = (stats, team) => {
return { return {
@@ -84,14 +74,13 @@ export default {
name: 'Team', name: 'Team',
type: 'bar', type: 'bar',
stack: 'Total', stack: 'Total',
color: 'firebrick',
label: { label: {
show: true, show: true,
}, },
emphasis: { emphasis: {
focus: 'series' focus: 'series'
}, },
data: teamArr(stats, team) data: dataArr(stats, team, 'team')
}, },
{ {
name: 'Enemy', name: 'Enemy',
@@ -104,14 +93,14 @@ export default {
emphasis: { emphasis: {
focus: 'series' focus: 'series'
}, },
data: enemyArr(stats, team) data: dataArr(stats, team, 'enemy')
} }
] ]
} }
} }
onMounted(() => { onMounted(() => {
if (props.stats) { if (store.state.matchDetails.stats) {
echarts.use([ echarts.use([
TooltipComponent, TooltipComponent,
GridComponent, GridComponent,
@@ -122,15 +111,13 @@ export default {
let myChart1 = echarts.init(document.getElementById('dmg-chart-1'), {}, {width: 1000, height: 300}); let myChart1 = echarts.init(document.getElementById('dmg-chart-1'), {}, {width: 1000, height: 300});
let myChart2 = echarts.init(document.getElementById('dmg-chart-2'), {}, {width: 1000, height: 300}); let myChart2 = echarts.init(document.getElementById('dmg-chart-2'), {}, {width: 1000, height: 300});
let option1 = optionGen(props.stats, 1) let option1 = optionGen(store.state.matchDetails.stats, 1)
let option2 = optionGen(props.stats, 2) let option2 = optionGen(store.state.matchDetails.stats, 2)
myChart1.setOption(option1); myChart1.setOption(option1);
myChart2.setOption(option2); myChart2.setOption(option2);
} }
}) })
return {props}
} }
} }
</script> </script>

View File

@@ -1,6 +1,6 @@
<template> <template>
<h4 class="text-center mt-3">Flash-Duration <small class="text-muted">(in s)</small></h4> <h3 class="text-center col-12 mt-3">Flash-Duration <small class="text-muted">(in s)</small></h3>
<div v-if="props.stats" class="player-dmg d-xxl-flex"> <div class="player-dmg d-xxl-flex">
<div class="team-1 mx-5"> <div class="team-1 mx-5">
<h4 class="text-center mt-3 mb-3">Team 1</h4> <h4 class="text-center mt-3 mb-3">Team 1</h4>
<div id="flash-chart-1"></div> <div id="flash-chart-1"></div>
@@ -19,16 +19,13 @@ import {BarChart} from 'echarts/charts';
import {CanvasRenderer} from 'echarts/renderers'; import {CanvasRenderer} from 'echarts/renderers';
import {onMounted} from "vue"; import {onMounted} from "vue";
import {checkStatEmpty, getPlayerArr} from "../utils"; import {checkStatEmpty, getPlayerArr} from "../utils";
import {useStore} from "vuex";
export default { export default {
name: "FlashChart", name: "FlashChart",
props: { setup() {
stats: { const store = useStore()
type: Object,
required: true
},
},
setup(props) {
const durationArr = (stats, team, prop) => { const durationArr = (stats, team, prop) => {
if (['team', 'enemy', 'self'].indexOf(prop) > -1) { if (['team', 'enemy', 'self'].indexOf(prop) > -1) {
let arr = [] let arr = []
@@ -53,11 +50,6 @@ export default {
} }
} }
}, },
legend: {
textStyle: {
color: 'white'
}
},
grid: { grid: {
left: '3%', left: '3%',
right: '4%', right: '4%',
@@ -70,24 +62,24 @@ export default {
}, },
yAxis: { yAxis: {
type: 'category', type: 'category',
data: getPlayerArr(props.stats, id) data: getPlayerArr(store.state.matchDetails.stats, id, true)
}, },
color: color, color: color,
series: [ series: [
{ {
name: 'Enemy', name: 'Enemy',
type: 'bar', type: 'bar',
data: durationArr(props.stats, id, 'enemy'), data: durationArr(store.state.matchDetails.stats, id, 'enemy'),
}, },
{ {
name: 'Team', name: 'Team',
type: 'bar', type: 'bar',
data: durationArr(props.stats, id, 'team'), data: durationArr(store.state.matchDetails.stats, id, 'team'),
}, },
{ {
name: 'Self', name: 'Self',
type: 'bar', type: 'bar',
data: durationArr(props.stats, id, 'self'), data: durationArr(store.state.matchDetails.stats, id, 'self'),
} }
] ]
} }
@@ -96,7 +88,7 @@ export default {
let myChart1, myChart2, option1, option2 let myChart1, myChart2, option1, option2
onMounted(() => { onMounted(() => {
if (props.stats) { if (store.state.matchDetails.stats) {
const color = ['indianred', '#69b13b', 'cornflowerblue'] const color = ['indianred', '#69b13b', 'cornflowerblue']
echarts.use([ echarts.use([
@@ -116,8 +108,6 @@ export default {
myChart2.setOption(option2); myChart2.setOption(option2);
} }
}) })
return {props}
} }
} }
</script> </script>

View File

@@ -1,7 +1,14 @@
<template> <template>
<div class="multi-kills-chart" v-if="props.stats"> <h3 class="text-center col-12 mt-3">Multi-Kills</h3>
<h4 class="text-center">Multi-Kills</h4> <div class="player-dmg d-xxl-flex">
<div id="multi-kills-chart"></div> <div class="team-1 mx-5">
<h4 class="text-center mt-3 mb-3">Team 1</h4>
<div id="multi-kills-chart-1"></div>
</div>
<div class="team-2 mx-5">
<h4 class="text-center mt-3 mb-3">Team 2</h4>
<div id="multi-kills-chart-2"></div>
</div>
</div> </div>
</template> </template>
@@ -11,46 +18,35 @@ import {GridComponent, TooltipComponent, VisualMapComponent} from 'echarts/compo
import {HeatmapChart} from 'echarts/charts'; import {HeatmapChart} from 'echarts/charts';
import {CanvasRenderer} from 'echarts/renderers'; import {CanvasRenderer} from 'echarts/renderers';
import {onMounted} from "vue"; import {onMounted} from "vue";
import {getPlayerArr, checkStatEmpty} from "../utils";
import {useStore} from "vuex";
export default { export default {
name: "FlashChart", name: "FlashChart",
props: { setup() {
stats: { const store = useStore()
type: Object, const multiKills = ['2k', '3k', '4k', '5k']
required: true
}
},
setup(props) {
const teamArr = (stats) => {
let arr = []
for (let i = 0; i < stats.length; i++) {
arr.push(truncate(checkStatEmpty(stats[i].player.name), 15))
}
arr.reverse() const multiKillArr = (stats, team) => {
return arr
}
const multiKillArr = (stats) => {
let arr = [] let arr = []
for (let i = 0; i < stats.length; i++) { for (let i = (team - 1) * 5; i < team * 5; i++) {
for (let j = 0; j < multiKills.length; j++) { for (let j = 0; j < multiKills.length; j++) {
if (j === 0) if (j === 0)
arr.push([i, j, checkStatEmpty(stats[i].multi_kills.duo)]) arr.push([i % 5, j, checkStatEmpty(stats[i].multi_kills.duo)])
if (j === 1) if (j === 1)
arr.push([i, j, checkStatEmpty(stats[i].multi_kills.triple)]) arr.push([i % 5, j, checkStatEmpty(stats[i].multi_kills.triple)])
if (j === 2) if (j === 2)
arr.push([i, j, checkStatEmpty(stats[i].multi_kills.quad)]) arr.push([i % 5, j, checkStatEmpty(stats[i].multi_kills.quad)])
if (j === 3) if (j === 3)
arr.push([i, j, checkStatEmpty(stats[i].multi_kills.pent)]) arr.push([i % 5, j, checkStatEmpty(stats[i].multi_kills.pent)])
} }
} }
return arr return arr
} }
const getMax = (stats) => { const getMax = (stats, team) => {
let max = 0 let max = 0
for (let i = 0; i < stats.length; i++) { for (let i = (team - 1) * 5; i < team * 5; i++) {
if (stats[i].multi_kills.duo > max) if (stats[i].multi_kills.duo > max)
max = stats[i].multi_kills.duo max = stats[i].multi_kills.duo
if (stats[i].multi_kills.triple > max) if (stats[i].multi_kills.triple > max)
@@ -63,41 +59,17 @@ export default {
return max return max
} }
const checkStatEmpty = (stat) => { const optionGen = (team) => {
if (stat)
return stat
}
const truncate = (str, len, ending) => {
if (len == null)
len = 100
if (ending == null)
ending = '..'
if (str.length > len)
return str.substring(0, len - ending.length) + ending
else
return str
}
const multiKills = ['2k', '3k', '4k', '5k']
const player = teamArr(props.stats)
const data = multiKillArr(props.stats)
const max = getMax(props.stats)
const optionGen = (player, data) => {
return { return {
tooltip: { tooltip: {},
position: 'top',
},
grid: { grid: {
height: '50%', height: '65%',
top: '10%' top: '0%',
bottom: '10%'
}, },
xAxis: { xAxis: {
type: 'category', type: 'category',
data: player, data: getPlayerArr(store.state.matchDetails.stats, team, true),
splitArea: { splitArea: {
show: true show: true
}, },
@@ -119,11 +91,11 @@ export default {
}, },
visualMap: { visualMap: {
min: 0, min: 0,
max: max, max: getMax(store.state.matchDetails.stats, team),
calculable: true, calculable: true,
orient: 'horizontal', orient: 'horizontal',
left: 'center', left: 'center',
bottom: '15%', bottom: '5%',
textStyle: { textStyle: {
color: 'white' color: 'white'
} }
@@ -131,7 +103,7 @@ export default {
series: [ series: [
{ {
type: 'heatmap', type: 'heatmap',
data: data, data: multiKillArr(store.state.matchDetails.stats, team),
label: { label: {
fontSize: 14, fontSize: 14,
show: true show: true
@@ -156,14 +128,12 @@ export default {
CanvasRenderer CanvasRenderer
]); ]);
let myChart1 = echarts.init(document.getElementById('multi-kills-chart-1'), {}, {width: 500, height: 500});
let myChart2 = echarts.init(document.getElementById('multi-kills-chart-2'), {}, {width: 500, height: 500});
let myChart = echarts.init(document.getElementById('multi-kills-chart'), {}, {width: 1000, height: 600}); myChart1.setOption(optionGen(1));
let option = optionGen(player, data) myChart2.setOption(optionGen(2));
myChart.setOption(option);
}) })
return {props}
} }
} }
</script> </script>
@@ -174,12 +144,8 @@ export default {
align-items: center; align-items: center;
h4 { h4 {
margin-top: 1rem; margin-top: 7px;
margin-bottom: -40px; color: cornflowerblue;
}
#multi-kills-chart {
margin: 0;
} }
} }
</style> </style>

View File

@@ -1,9 +1,16 @@
<template> <template>
<div class="scoreboard" :class="'team-' + props.team_id"> <div class="scoreboard">
<table> <table v-for="(score, team_id) in store.state.matchDetails.score" :key="team_id + 1"
<caption v-if="props.rounds === 16" :class="props.score === 9 ? 'text-success' : props.score === 8 ? 'text-warning' : 'text-danger'">{{props.score}}</caption> :class="'team-' + (team_id + 1)">
<caption v-if="props.rounds === 30" :class="props.score === 16 ? 'text-success' : props.score === 15 ? 'text-warning' : 'text-danger'">{{props.score}}</caption> <caption v-if="store.state.matchDetails.max_rounds === 16"
<thead> :class="score === 9 ? 'text-success' : score === 8 ? 'text-warning' : 'text-danger'">
{{ score }}
</caption>
<caption v-if="store.state.matchDetails.max_rounds === 30"
:class="score === 16 ? 'text-success' : score === 15 ? 'text-warning' : 'text-danger'">
{{ score }}
</caption>
<thead v-if="team_id === 0">
<tr> <tr>
<th class="player__avatar"></th> <th class="player__avatar"></th>
<th class="player__name"></th> <th class="player__name"></th>
@@ -13,19 +20,22 @@
<th class="player__deaths">D</th> <th class="player__deaths">D</th>
<th class="player__diff cursor__help" title="Kill death difference">+/-</th> <th class="player__diff cursor__help" title="Kill death difference">+/-</th>
<th class="player__kd">K/D</th> <th class="player__kd">K/D</th>
<th class="player__adr cursor__help" title="Average damage per round" v-if="props.parsed">ADR</th> <th v-if="store.state.matchDetails.parsed" class="player__adr cursor__help" title="Average damage per round">
ADR
</th>
<th class="player__hs cursor__help" title="Percentage of kills with a headshot">HS%</th> <th class="player__hs cursor__help" title="Percentage of kills with a headshot">HS%</th>
<th class="player__rating cursor__help" title="Estimated HLTV Rating 1.0">Rating</th> <th class="player__rating cursor__help" title="Estimated HLTV Rating 1.0">Rating</th>
<th class="player__mvp cursor__help" title="Most valuable player">MVP</th> <th class="player__mvp cursor__help" title="Most valuable player">MVP</th>
<th class="player__score">Score</th> <th class="player__score">Score</th>
</tr> </tr>
</thead> </thead>
<tbody v-for="player in props.stats" :key="player.player.steamid64"> <tbody>
<tr v-if="player.team_id === props.team_id" class="player"> <tr v-for="player in store.state.matchDetails.stats" v-show="player.team_id === team_id + 1" :key="player.player.steamid64"
<ScoreTeamPlayer class="player">
:steamid64="player.player.steamid64" <ScoreTeamPlayer v-if="player.team_id === team_id + 1"
:assists="player.assists" :assists="player.assists"
:avatar="player.player.avatar" :avatar="player.player.avatar"
:color="player.color"
:deaths="player.deaths" :deaths="player.deaths"
:dmg="player.dmg?.enemy" :dmg="player.dmg?.enemy"
:hs="player.headshot" :hs="player.headshot"
@@ -37,59 +47,30 @@
:mk_triple="player.multi_kills?.triple" :mk_triple="player.multi_kills?.triple"
:mvp="player.mvp" :mvp="player.mvp"
:name="player.player.name" :name="player.player.name"
:parsed="store.state.matchDetails.parsed"
:player_score="player.score" :player_score="player.score"
:rank="player.rank?.old" :rank="player.rank?.old"
:rounds_played="props.rounds_played" :rounds_played="store.state.matchDetails.score.reduce((a, b) => a + b)"
:color="player.color" :steamid64="player.player.steamid64"
:tracked="player.player.tracked" :tracked="player.player.tracked"
:parsed="props.parsed"
/> />
</tr> </tr>
<tr v-if="team_id === 0" class="hr"></tr>
</tbody> </tbody>
</table> </table>
</div> </div>
<hr v-if="props.team_id === 1">
</template> </template>
<script> <script>
import ScoreTeamPlayer from '@/components/ScoreTeamPlayer.vue' import ScoreTeamPlayer from '@/components/ScoreTeamPlayer.vue'
import {useStore} from "vuex";
export default { export default {
name: 'ScoreTeam', name: 'ScoreTeam',
components: {ScoreTeamPlayer}, components: {ScoreTeamPlayer},
props: { setup() {
stats: { const store = useStore()
type: Object, return {store}
required: true
},
rounds_played: {
type: Number,
required: true,
default: 0
},
team_id: {
type: Number,
required: true,
default: 1
},
score: {
type: Number,
required: true,
default: 0
},
rounds: {
type: Number,
required: true,
default: 0
},
parsed: {
type: Boolean,
required: true,
default: false
}
},
setup(props) {
return {props}
} }
} }
</script> </script>
@@ -108,7 +89,6 @@ table {
text-align: center; text-align: center;
margin-top: 120px; margin-top: 120px;
margin-bottom: -100px; margin-bottom: -100px;
//background: black;
caption { caption {
color: white; color: white;
@@ -130,5 +110,10 @@ table {
.cursor__help { .cursor__help {
cursor: help; cursor: help;
} }
.hr {
height: 20px;;
border-bottom: 1px solid white;
}
} }
</style> </style>

View File

@@ -48,7 +48,7 @@
</template> </template>
<script> <script>
import {GetHLTV_1, GoToPlayer, DisplayRank} from "../utils"; import {DisplayRank, GetHLTV_1, GoToPlayer} from "../utils";
export default { export default {
name: 'ScoreTeamPlayer', name: 'ScoreTeamPlayer',

View File

@@ -1,32 +1,68 @@
import {createRouter, createWebHistory} from 'vue-router' import {createRouter, createWebHistory} from 'vue-router'
function lazyLoad(view) { function lazyLoadView(view) {
return () => import(`@/views/${view}.vue`) return () => import(`@/views/${view}.vue`)
} }
function lazyLoadComponent(view) {
return () => import(`@/components/${view}.vue`)
}
const routes = [ const routes = [
{ {
path: '/', path: '/',
name: 'Home', name: 'Home',
component: lazyLoad('Home') component: lazyLoadView('Home')
}, },
{ {
path: '/player/:id', path: '/player/:id',
name: 'Player', name: 'Player',
component: lazyLoad('Player'), component: lazyLoadView('Player'),
props: true props: true
}, },
{ {
path: '/match/:match_id', path: '/match/:match_id',
name: 'Match', name: 'Match',
component: lazyLoad('Match'), component: lazyLoadView('Match'),
props: true, props: true,
alias: ['/match/:match_id/flashes', '/match/:match_id/utility', '/match/:match_id/damage', '/match/:match_id/details'] children: [
{
path: '',
alias: '/match/:match_id',
components: {
score: lazyLoadComponent('ScoreTeam')
}
},
{
path: 'details',
components: {
score: lazyLoadComponent('MultiKillsChart')
}
},
{
path: 'flashes',
components: {
score: lazyLoadComponent('FlashChart')
}
},
{
path: 'utility',
components: {
score: lazyLoadComponent('UtilityChart')
}
},
{
path: 'damage',
components: {
score: lazyLoadComponent('DamageChart')
}
}
]
}, },
{ {
path: '/explore', path: '/explore',
name: 'Explore', name: 'Explore',
component: lazyLoad('Explore'), component: lazyLoadView('Explore'),
props: true props: true
}, },
{ {

View File

@@ -4,6 +4,7 @@ export default createStore({
state: { state: {
id64: '', id64: '',
vanityUrl: '', vanityUrl: '',
matchDetails: {}
}, },
mutations: { mutations: {
}, },

View File

@@ -35,7 +35,7 @@ export const TrackMe = async (id64, authcode, sharecode) => {
try { try {
const res = await axios const res = await axios
.post(`${process.env.VUE_APP_API_URL}/player/trackme`, `id=${id64}&authcode=${authcode}&sharecode=${sharecode}`) .post(`${API_URL}/player/trackme`, `id=${id64}&authcode=${authcode}&sharecode=${sharecode}`)
if (res.status === 202) { if (res.status === 202) {
status = res.status status = res.status

View File

@@ -31,13 +31,13 @@ export const checkStatEmpty = (stat) => {
return 0 return 0
} }
export const getPlayerArr = (stats, team) => { export const getPlayerArr = (stats, team, color) => {
let arr = [] let arr = []
for (let i = (team - 1) * 5; i < team * 5; i++) { for (let i = (team - 1) * 5; i < team * 5; i++) {
arr.push({ arr.push({
value: truncate(stats[i].player.name, 15), value: truncate(stats[i].player.name, 12),
textStyle: { textStyle: {
color: 'white' color: color ? getComputedStyle(document.documentElement).getPropertyValue(`--csgo-${stats[i].color}`) : 'white'
} }
}) })
} }

View File

@@ -35,89 +35,65 @@
</button> </button>
<div id="matchNav" class="collapse navbar-collapse"> <div id="matchNav" class="collapse navbar-collapse">
<ul class="list-unstyled d-flex m-auto"> <ul class="list-unstyled d-flex m-auto">
<li class="list-item scoreboard active" @click.prevent="ActivateScoreInfo('scoreboard')">Scoreboard</li> <li :class="!data.matchDetails.parsed ? 'disabled' : ''"
<li :class="!data.matchDetails.parsed ? 'disabled' : ''" :title="!data.matchDetails.parsed ? 'This demo has not been parsed' : ''" :title="!data.matchDetails.parsed ? 'This demo has not been parsed' : ''"
class="list-item details" class="list-item nav-item">
@click.prevent="data.matchDetails.parsed ? ActivateScoreInfo('details') : null">Details <router-link :disabled="!data.matchDetails.parsed" :to="'/match/' + data.matchDetails.match_id"
class="nav-link" name="score">Scoreboard
</router-link>
</li> </li>
<li :class="!data.matchDetails.parsed ? 'disabled' : ''" :title="!data.matchDetails.parsed ? 'This demo has not been parsed' : ''" <li :class="!data.matchDetails.parsed ? 'disabled' : ''"
class="list-item flashes" :title="!data.matchDetails.parsed ? 'This demo has not been parsed' : ''"
@click.prevent="data.matchDetails.parsed ? ActivateScoreInfo('flashes') : null">Flashes class="list-item nav-item">
<router-link :disabled="!data.matchDetails.parsed" :to="'/match/' + data.matchDetails.match_id + '/details'"
class="nav-link" name="score">Details
</router-link>
</li> </li>
<li :class="!data.matchDetails.parsed ? 'disabled' : ''" :title="!data.matchDetails.parsed ? 'This demo has not been parsed' : ''" <li :class="!data.matchDetails.parsed ? 'disabled' : ''"
class="list-item utility" :title="!data.matchDetails.parsed ? 'This demo has not been parsed' : ''"
@click.prevent="data.matchDetails.parsed ? ActivateScoreInfo('utility') : null">Utility class="list-item nav-item">
<router-link :disabled="!data.matchDetails.parsed" :to="'/match/' + data.matchDetails.match_id + '/flashes'"
class="nav-link" name="score">Flashes
</router-link>
</li> </li>
<li :class="!data.matchDetails.parsed ? 'disabled' : ''" :title="!data.matchDetails.parsed ? 'This demo has not been parsed' : ''" <!-- <li :class="!data.matchDetails.parsed ? 'disabled' : ''"-->
class="list-item damage" <!-- :title="!data.matchDetails.parsed ? 'This demo has not been parsed' : ''"-->
@click.prevent="data.matchDetails.parsed ? ActivateScoreInfo('damage') : null">Damage <!-- class="list-item nav-item">-->
<!-- <router-link :disabled="!data.matchDetails.parsed" :to="'/match/' + data.matchDetails.match_id + '/utility'"-->
<!-- class="nav-link" name="score">Utility-->
<!-- </router-link>-->
<!-- </li>-->
<li :class="!data.matchDetails.parsed ? 'disabled' : ''"
:title="!data.matchDetails.parsed ? 'This demo has not been parsed' : ''"
class="list-item nav-item">
<router-link :disabled="!data.matchDetails.parsed" :to="'/match/' + data.matchDetails.match_id + '/damage'"
class="nav-link" name="score">Damage
</router-link>
</li> </li>
</ul> </ul>
</div> </div>
</div> </div>
<div v-if="data.score.length === 2 && data.stats" id="scoreWrapper" class="scoreboard"> <div v-if="data.score.length === 2 && data.stats" id="scoreWrapper" class="scoreboard">
<div id="scoreboard" class="active"> <router-view name="score"/>
<ScoreTeam
:parsed="data.matchDetails.parsed"
:rounds="data.matchDetails.max_rounds ? data.matchDetails.max_rounds : data.score[data.matchDetails.match_result - 1] === 16 ? 30 : data.score[data.matchDetails.match_result - 1] === 15 ? 30 : 16"
:rounds_played="data.score.reduce((a, b) => a + b)"
:score="data.score[0]" :stats="data.stats" :team_id="1"/>
<ScoreTeam
:parsed="data.matchDetails.parsed"
:rounds="data.matchDetails.max_rounds ? data.matchDetails.max_rounds : data.score.reduce((a, b) => a + b) >= 16 ? 30 : 16"
:rounds_played="data.score.reduce((a, b) => a + b)"
:score="data.score[1]" :stats="data.stats" :team_id="2"/>
</div>
<div id="flashes">
<FlashChart :stats="data.stats" />
</div>
<div id="utility">
<UtilityChartTotal :stats="data.stats"/>
<UtilityChart v-for="(player, id) in data.stats" :id="id"
:key="player.player.steamid64"
:avatar="player.player.avatar"
:name="player.player.name"
:ud="player.dmg.ud"
/>
</div>
<div id="damage">
<DamageChart :stats="data.stats"/>
</div>
<div id="details">
<MultiKillsChart :stats="data.stats"/>
</div>
</div> </div>
</template> </template>
<script> <script>
import {defineAsyncComponent, onBeforeMount, onMounted, reactive, watch} from "vue"; import {onBeforeMount, onMounted, reactive, watch} from "vue";
import axios from 'axios' import axios from 'axios'
import {DisplayRank, FormatFullDate, GetHLTV_1, GoToPlayer, LoadImage} from "../utils"; import {DisplayRank, FormatFullDate, GetHLTV_1, GoToLink, GoToPlayer, LoadImage} from "../utils";
import router from "../router"; import {useStore} from "vuex";
import {useRoute} from 'vue-router'
const ScoreTeam = defineAsyncComponent(() => import('../components/ScoreTeam'))
const FlashChart = defineAsyncComponent(() => import('../components/FlashChart'))
const UtilityChart = defineAsyncComponent(() => import('../components/UtilityChart'))
const UtilityChartTotal = defineAsyncComponent(() => import('../components/UtilityChartTotal'))
const DamageChart = defineAsyncComponent(() => import('../components/DamageChart'))
const MultiKillsChart = defineAsyncComponent(() => import('../components/MultiKillsChart'))
export default { export default {
name: 'Match', name: 'Match',
props: ['match_id'], props: ['match_id'],
components: {
ScoreTeam,
FlashChart,
UtilityChart,
UtilityChartTotal,
DamageChart,
MultiKillsChart
},
setup(props) { setup(props) {
const store = useStore()
const route = useRoute()
store.state.matchDetails = {}
// Refs // Refs
const data = reactive({ const data = reactive({
playerName: '', playerName: '',
@@ -137,6 +113,8 @@ export default {
data.stats = response.data.stats data.stats = response.data.stats
data.score = response.data.score data.score = response.data.score
store.state.matchDetails = response.data
LoadImage(data.matchDetails.map ? data.matchDetails.map : 'random') LoadImage(data.matchDetails.map ? data.matchDetails.map : 'random')
console.log(response.data) console.log(response.data)
@@ -163,25 +141,6 @@ export default {
data.avgRank = Math.floor(fullRank / count) data.avgRank = Math.floor(fullRank / count)
} }
const ActivateScoreInfo = (id) => {
const activeNavItems = document.querySelector('#matchNav').querySelectorAll('.active')
const newNavItem = document.querySelector(`#matchNav .${id}`)
const activeItems = document.querySelector('#scoreWrapper').querySelectorAll('.active')
const newItem = document.querySelector(`#scoreWrapper #${id}`)
activeNavItems.forEach(item => item.classList.remove('active'))
activeItems.forEach(item => item.classList.remove('active'))
newNavItem.classList.add('active')
newItem.classList.add('active')
if (['flashes', 'utility', 'damage', 'details'].indexOf(id) > -1) {
history.replaceState({}, null, `/match/${data.matchDetails.match_id}/${id}`)
} else if (id === 'scoreboard') {
history.replaceState({}, null, `/match/${data.matchDetails.match_id}`)
}
}
// Watchers // Watchers
watch(() => props.match_id, GetMatch) watch(() => props.match_id, GetMatch)
watch(() => data.stats, GetAvgRank) watch(() => data.stats, GetAvgRank)
@@ -192,15 +151,13 @@ export default {
}) })
onMounted(() => { onMounted(() => {
setTimeout(() => { if (!route.fullPath.match('details' || 'flashes' || 'damage')) {
if (router.currentRoute.value.href.split('/')[3]) { GoToLink(`/match/${props.match_id}`)
ActivateScoreInfo(router.currentRoute.value.href.split('/')[3])
} }
}, 200)
}) })
return { return {
GetMatch, GetAvgRank, ActivateScoreInfo, data, GoToPlayer, GetHLTV_1, DisplayRank, FormatFullDate, LoadImage GetMatch, GetAvgRank, data, GoToPlayer, GetHLTV_1, DisplayRank, FormatFullDate, LoadImage
} }
} }
} }
@@ -235,33 +192,6 @@ export default {
} }
} }
#scoreWrapper {
z-index: 1;
height: 100%;
width: 100%;
max-width: 100vw;
background: linear-gradient(90deg,
rgba(0, 0, 0, 0.6) 0%,
rgba(0, 0, 0, 0.85) 30%,
rgba(0, 0, 0, 0.85) 70%,
rgba(0, 0, 0, .6) 100%
);
#scoreboard, #flashes, #utility, #damage, #details {
display: none;
flex-direction: column;
align-items: center;
}
#scoreboard.active,
#flashes.active,
#utility.active,
#damage.active,
#details.active {
display: flex;
}
}
.nav { .nav {
max-width: 100vw; max-width: 100vw;
background: rgba(0, 0, 0, 0.9); background: rgba(0, 0, 0, 0.9);
@@ -274,8 +204,9 @@ export default {
border-top: 1px solid rgba(255, 255, 255, .2); border-top: 1px solid rgba(255, 255, 255, .2);
border-bottom: 1px solid rgba(255, 255, 255, .2); border-bottom: 1px solid rgba(255, 255, 255, .2);
.list-item { .nav-link {
padding: 10px 10px; text-decoration: none;
color: white;
&:hover { &:hover {
background: var(--bs-info); background: var(--bs-info);
@@ -283,7 +214,7 @@ export default {
} }
} }
.active { .router-link-exact-active {
background: var(--bs-info) background: var(--bs-info)
} }
@@ -296,4 +227,20 @@ export default {
} }
} }
} }
#scoreWrapper {
display: flex;
justify-content: center;
flex-wrap: wrap;
z-index: 1;
height: 100%;
width: 100%;
max-width: 100vw;
background: linear-gradient(90deg,
rgba(0, 0, 0, 0.6) 0%,
rgba(0, 0, 0, 0.85) 30%,
rgba(0, 0, 0, 0.85) 70%,
rgba(0, 0, 0, .6) 100%
);
}
</style> </style>