-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
newui: add demo listing to player details
- Loading branch information
Showing
13 changed files
with
279 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import { ApiRequestParams } from '@/types/api'; | ||
import { DemoApiResponse, DemoStats } from '@/types/demo'; | ||
|
||
import { api } from 'boot/axios'; | ||
|
||
export const DemoApi = { | ||
list: async (steamId: string, params: ApiRequestParams = { limit: 50, offset: 0 }): Promise<DemoApiResponse> => { | ||
const { data } = await api.get<DemoApiResponse>(`player/${steamId}/demos`, { | ||
params, | ||
}); | ||
|
||
return data; | ||
}, | ||
|
||
details: async (demoId: number): Promise<DemoStats> => { | ||
const { data } = await api.get<DemoStats>(`demo/${demoId}/stats/`); | ||
|
||
return data; | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,105 @@ | ||
<script setup lang="ts"></script> | ||
<script setup lang="ts"> | ||
import { now } from 'lodash'; | ||
import { date } from 'quasar'; | ||
import { ref } from 'vue'; | ||
import { DEMO_TYPE_IMAGES } from 'src/constants/demos'; | ||
import { RANKS } from 'src/constants/ranks'; | ||
import { ApiRequestParams } from '@/types/api'; | ||
import { DataTableHeader } from '@/types/dataTable'; | ||
import { DemoResponse } from '@/types/demo'; | ||
import { DemoApi } from 'src/api/demo'; | ||
import { Format } from 'src/utils/formatters'; | ||
import DataTable from 'components/common/DataTable.vue'; | ||
/* ====================== Data ====================== */ | ||
const props = defineProps<{ | ||
steamId: string; | ||
}>(); | ||
const tableRef = ref(); | ||
const columns: DataTableHeader[] = [ | ||
{ label: 'Date', name: 'timestamp', align: 'left', style: 'width: 75px' }, | ||
// { label: 'Type', name: 'type' }, | ||
{ label: 'Rank', name: 'mmRankUpdate' }, | ||
{ label: 'Map', name: 'map' }, | ||
{ label: 'Score', name: 'score' }, | ||
{ label: 'K', name: 'kills' }, | ||
{ label: 'A', name: 'assists' }, | ||
{ label: 'D', name: 'deaths' }, | ||
{ label: 'KDD', name: 'kdd' }, | ||
{ label: 'ADR', name: 'adr' }, | ||
]; | ||
/* ====================== Methods ====================== */ | ||
const getDemos = async ({ limit, offset, orderBy }: ApiRequestParams) => { | ||
const { demos, demoCount } = await DemoApi.list(props.steamId, { ...{ limit, offset, orderBy } }); | ||
return { | ||
results: demos, | ||
count: demoCount, | ||
}; | ||
}; | ||
const formatDate = (timestamp: number) => { | ||
const timestampYear = date.formatDate(timestamp * 1000, 'YYYY'); | ||
const currentYear = date.formatDate(now(), 'YYYY'); | ||
const dateFormat = timestampYear === currentYear ? 'D MMM, H:mm' : 'D MMM YY, H:mm'; | ||
return date.formatDate(timestamp * 1000, dateFormat); | ||
}; | ||
</script> | ||
|
||
<template> | ||
<q-page class=""> </q-page> | ||
<q-page class=""> | ||
<DataTable ref="tableRef" :columns="columns" entityName="demo" :apiCall="getDemos" rowsPerPage="25"> | ||
<template #timestamp="item: DemoResponse"> | ||
{{ formatDate(item.timestamp) }} | ||
</template> | ||
|
||
<template #type="item: DemoResponse"> | ||
<q-img v-if="item.type" :src="DEMO_TYPE_IMAGES[item.type] as string" width="50px" /> | ||
</template> | ||
|
||
<template #mmRankUpdate="{ mmRankUpdate }: DemoResponse"> | ||
<q-img | ||
fit="fill" | ||
class="my-1 rounded" | ||
width="45px" | ||
height="19px" | ||
:src="`images/ranks/${(mmRankUpdate && mmRankUpdate.rankNew) ?? 0}.png`" | ||
> | ||
<q-tooltip class="bg-sky-500/95 text-sm shadow-4 text-black" anchor="top middle" self="bottom middle"> | ||
{{ RANKS[(mmRankUpdate && mmRankUpdate.rankNew) ?? 0] }} | ||
</q-tooltip> | ||
</q-img> | ||
</template> | ||
|
||
<template #score="{ score }: DemoResponse"> | ||
<span | ||
:class="score[0] < score[1] ? 'text-red' : score[0] === score[1] ? 'text-blue-500' : 'text-green-500'" | ||
class="font-semibold" | ||
> | ||
{{ score[0] }} - {{ score[1] }} | ||
</span> | ||
</template> | ||
|
||
<template #kdd="{ kills, deaths }: DemoResponse"> | ||
<span :class="kills - deaths < 0 ? 'text-red' : 'text-green-500'" class="font-semibold"> | ||
{{ kills - deaths }} | ||
</span> | ||
</template> | ||
|
||
<template #adr="{ damage, roundsWithDamageInfo }: DemoResponse"> | ||
{{ Format.number(damage / roundsWithDamageInfo) }} | ||
</template> | ||
</DataTable> | ||
</q-page> | ||
</template> | ||
|
||
<style scoped lang="scss"></style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import { Dictionary } from 'types/common'; | ||
|
||
export const DEMO_TYPES = { | ||
VALVE: 'valve', | ||
ESEA: 'esea', | ||
FACEIT: 'faceit', | ||
CEVO: 'cevo', | ||
ESPORTAL: 'esportal', | ||
CUSTOM: 'custom', | ||
}; | ||
|
||
export const DEMO_TYPE_IMAGES: Dictionary = {}; | ||
DEMO_TYPE_IMAGES[DEMO_TYPES.VALVE] = 'images/demoTypes/valve.png'; | ||
DEMO_TYPE_IMAGES[DEMO_TYPES.ESEA] = 'images/demoTypes/esea.png'; | ||
DEMO_TYPE_IMAGES[DEMO_TYPES.FACEIT] = 'images/demoTypes/faceit.png'; | ||
DEMO_TYPE_IMAGES[DEMO_TYPES.ESPORTAL] = 'images/demoTypes/esportal.png'; | ||
DEMO_TYPE_IMAGES[DEMO_TYPES.CUSTOM] = 'images/demoTypes/custom.png'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
export const RANKS = { | ||
0: 'Unknown', | ||
1: 'Silver I', | ||
2: 'Silver II', | ||
3: 'Silver III', | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.