From 04a6e47a0ac98dc2bc4036070a3249fa999f1f6a Mon Sep 17 00:00:00 2001 From: iamBadgers Date: Sat, 25 May 2024 12:00:02 -0700 Subject: [PATCH] clean up the game detail page. --- backend/src/app.ts | 20 +++---- frontend/src/vues/CharacterDetails.vue | 4 +- frontend/src/vues/CharacterList.vue | 2 +- frontend/src/vues/GameDetails.vue | 72 ++++++++++++++++++++------ frontend/src/vues/GameList.vue | 29 +++++++++-- frontend/src/vues/GameTable.vue | 45 +++++++--------- frontend/src/vues/ServerStats.vue | 10 ++++ 7 files changed, 125 insertions(+), 57 deletions(-) diff --git a/backend/src/app.ts b/backend/src/app.ts index 31f890e..34a069b 100644 --- a/backend/src/app.ts +++ b/backend/src/app.ts @@ -91,9 +91,7 @@ app.post('/api/serverstats/rolestats', jsonParser, async (req, res) => { picks.forEach((character, characterNum) => { const role = character.dataValues.role // Count role application - pickedCharacterCount.set( - role, (pickedCharacterCount.get(role) || 0) + 1 - ) + pickedCharacterCount.set(role, (pickedCharacterCount.get(role) || 0) + 1) }) appls.forEach((character, characterNum) => { @@ -105,9 +103,7 @@ app.post('/api/serverstats/rolestats', jsonParser, async (req, res) => { } activeCharacters.get(role).add(charId) // Count role application - appedCharacterCount.set( - role, (appedCharacterCount.get(role) || 0) + 1 - ) + appedCharacterCount.set(role, (appedCharacterCount.get(role) || 0) + 1) }) }) @@ -130,7 +126,7 @@ app.post('/api/serverstats/rolestats', jsonParser, async (req, res) => { result[roleName] = { apps: appedCharacterCount.get(roleName) || 0, picks: pickedCharacterCount.get(roleName) || 0, - active: activeCharacters.has(roleName) ?activeCharacters.get(roleName).size : 0 + active: activeCharacters.has(roleName) ? activeCharacters.get(roleName).size : 0 } }) @@ -195,7 +191,10 @@ app.get('/api/game/:gameId', async (req, res) => { }) app.post('/api/game/:gameId/apps', async (req, res) => { - const apps = await App.findAll({ where: { gameId: req.params['gameId'] } }) + const apps = await App.findAll({ + include: [{ model: Character, as: 'appliedCharacter' }], + where: { gameId: req.params['gameId'] } + }) res.send(apps) }) @@ -205,7 +204,10 @@ app.post('/api/character/:characterId/apps', async (req, res) => { }) app.post('/api/game/:gameId/picks', async (req, res) => { - const picks = await Pick.findAll({ where: { gameId: req.params['gameId'] } }) + const picks = await Pick.findAll({ + include: [{ model: Character, as: 'pickedCharacter' }], + where: { gameId: req.params['gameId'] } + }) res.send(picks) }) diff --git a/frontend/src/vues/CharacterDetails.vue b/frontend/src/vues/CharacterDetails.vue index cace6b1..6c8dc38 100644 --- a/frontend/src/vues/CharacterDetails.vue +++ b/frontend/src/vues/CharacterDetails.vue @@ -11,11 +11,11 @@
Last Game: {{ lastPlayedPostDate }}
-

Games Played

+

{{ games.played.length }} Games Played

-

Games Applied

+

{{ games.applied.length }} Games Applied

diff --git a/frontend/src/vues/CharacterList.vue b/frontend/src/vues/CharacterList.vue index 7d64d83..0d0d124 100644 --- a/frontend/src/vues/CharacterList.vue +++ b/frontend/src/vues/CharacterList.vue @@ -88,7 +88,7 @@ let debounce = null watch(filtervalue, (newFilter, oldFilter) => { debounce = clearTimeout(debounce) debounce = setTimeout(() => { - router.replace({query: {page: route.query.page, filter: newFilter}}) + router.replace({ query: { page: route.query.page, filter: newFilter } }) }, 500) }) diff --git a/frontend/src/vues/GameDetails.vue b/frontend/src/vues/GameDetails.vue index 497c2c6..f4ca039 100644 --- a/frontend/src/vues/GameDetails.vue +++ b/frontend/src/vues/GameDetails.vue @@ -6,7 +6,13 @@

GameMaster: {{ game.gamemaster }}

-
+
+
+

Picks

+
+ {{ pick.pickedCharacter.playerName }} as {{ pick.characterName }} +
+

Payout

{{ game.payoutEB }} eb
@@ -14,18 +20,33 @@
{{ game.payoutLoot }}
-
-

Picks

-
- {{ pick.characterName }} -
-
+ +
+
-
-

Apps

-
- {{ app.characterName }} -
+
+
+
+

{{ picks.length }} Character Picks

+ + + + +
+
+

{{ apps.length }} Character Apps

+ + + +
@@ -43,8 +64,12 @@ } .result-box { - margin: 10px; - margin-top: 40px; + margin: 20px; + margin-top: 20px; +} + +.character-list { + margin: 20px; } @@ -55,10 +80,24 @@ import axios from 'axios' const route = useRoute() +const pickHeaders = [ + { title: 'ID', align: 'start', key: 'characterId' }, + { title: 'Character', align: 'start', key: 'characterName' }, + { title: 'Status', align: 'start', key: 'pickedCharacter.status' }, + { title: 'Player', align: 'start', key: 'pickedCharacter.playerName' } +] + +const appHeaders = [ + { title: 'ID', align: 'start', key: 'characterId' }, + { title: 'Character', align: 'start', key: 'characterName' }, + { title: 'Status', align: 'start', key: 'appliedCharacter.status' }, + { title: 'Player', align: 'start', key: 'appliedCharacter.playerName' } +] + const gameId = ref(route.params.gameId) const game = ref({}) -const picks = ref({}) -const apps = ref({}) +const picks = ref([]) +const apps = ref([]) loadGameDetails() @@ -85,5 +124,6 @@ async function loadPicks() { async function loadApps() { const response = await axios.post(`/api/game/${gameId.value}/apps`) apps.value = response.data + console.log(apps.value) } diff --git a/frontend/src/vues/GameList.vue b/frontend/src/vues/GameList.vue index 3851f34..f08145a 100644 --- a/frontend/src/vues/GameList.vue +++ b/frontend/src/vues/GameList.vue @@ -6,7 +6,30 @@ v-model="filtervalue" >
- + + + + ID + Title + Staus + Post Date + + + + + + {{ game.id }} + + + {{ game.title }} + + {{ game.status }} + + {{ new Date(game.postdate * 1000).toISOString().split('T')[0] }} + + + { @@ -73,7 +96,7 @@ let debounce = null watch(filtervalue, (newFilter, oldFilter) => { debounce = clearTimeout(debounce) debounce = setTimeout(() => { - router.replace({query: {page: route.query.page, filter: newFilter}}) + router.replace({ query: { page: route.query.page, filter: newFilter } }) }, 500) }) diff --git a/frontend/src/vues/GameTable.vue b/frontend/src/vues/GameTable.vue index e47ecdf..973c9b4 100644 --- a/frontend/src/vues/GameTable.vue +++ b/frontend/src/vues/GameTable.vue @@ -1,33 +1,26 @@ diff --git a/frontend/src/vues/ServerStats.vue b/frontend/src/vues/ServerStats.vue index f08f8b8..9677e1d 100644 --- a/frontend/src/vues/ServerStats.vue +++ b/frontend/src/vues/ServerStats.vue @@ -96,6 +96,9 @@ import { onMounted, watch, ref } from 'vue' import Chart from 'chart.js/auto' import axios from 'axios' +const route = useRoute() +const router = useRouter() + const dateSelect = ref(-1) const dateItems = buildDateItems() @@ -184,6 +187,7 @@ function updateChart(stats, tag) { } watch(dateSelect, async (newValue, oldValue) => { + router.replace({ query: { monthId: dateSelect.value } }) loadData() }) @@ -196,6 +200,12 @@ watch(chartSelect, async (newValue, oldValue) => { }) onMounted(async () => { + console.log(dateItems) + if (!route.query.monthId) { + router.replace({ query: { monthId: -1 } }) + } else { + dateSelect.value = Number(route.query.monthId) + } loadData() chart = new Chart(document.getElementById('piechart'), { type: 'pie',