Skip to content

Commit b8a0fa3

Browse files
committed
Resolve #15.
Front page is now a more presentable format. Show most recent 3 matches with provided info. Include leaderboards to flex on others.
1 parent 70ebac2 commit b8a0fa3

20 files changed

+169
-8
lines changed

public/img/maps/_unknown.jpg

1010 Bytes
Loading

public/img/maps/de_cache.jpg

199 KB
Loading

public/img/maps/de_dust2.jpg

57.9 KB
Loading

public/img/maps/de_inferno.jpg

141 KB
Loading

public/img/maps/de_mirage.jpg

47.8 KB
Loading

public/img/maps/de_nuke.jpg

97.6 KB
Loading

public/img/maps/de_overpass.jpg

66.6 KB
Loading

public/img/maps/de_train.jpg

65.6 KB
Loading

screenshots/MainPage.png

324 KB
Loading

screenshots/MainPageLoggedIn.png

324 KB
Loading

screenshots/SideMenuLoggedIn.png

238 KB
Loading

screenshots/SideMenuLoggedOut.png

238 KB
Loading

src/components/MatchCard.vue

+94
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
<template>
2+
<v-container>
3+
<v-row v-for="(mtch, idx) in matches" :key="mtch.id">
4+
<v-col
5+
lg="8"
6+
md="12"
7+
sm="12"
8+
xs="12"
9+
offset-lg="2"
10+
class="align-self-center"
11+
>
12+
<v-img
13+
:src="'/img/maps/' + mtch.map_name + '.jpg'"
14+
max-height="225px"
15+
:gradient="gradientCalc"
16+
@error="imageError(idx)"
17+
>
18+
<v-card
19+
color="rgb(128, 128, 128, 0.4)"
20+
:to="'/match/' + mtch.id"
21+
max-height="225px"
22+
>
23+
<v-card-title class="text-uppercase justify-center text-center">
24+
{{ mtch.team1_string }}<br />
25+
VS<br />
26+
{{ mtch.team2_string }}
27+
</v-card-title>
28+
<v-card-subtitle class="text-center">
29+
BO{{ mtch.max_maps }}
30+
</v-card-subtitle>
31+
<v-card-text class="text-center text-h2">
32+
{{ mtch.team1_score }} : {{ mtch.team1_score }}
33+
</v-card-text>
34+
</v-card>
35+
</v-img>
36+
<v-spacer />
37+
</v-col>
38+
</v-row>
39+
</v-container>
40+
</template>
41+
42+
<script>
43+
export default {
44+
data() {
45+
return {
46+
matches: [],
47+
isLoading: true,
48+
deletePending: false,
49+
isThereCancelledMatches: false
50+
};
51+
},
52+
async mounted() {
53+
await this.GetLimitedMatches();
54+
},
55+
methods: {
56+
async GetLimitedMatches() {
57+
try {
58+
let res;
59+
res = await this.GetLimitMatches(3);
60+
if (typeof res == "string") res = [];
61+
else {
62+
res.forEach(async match => {
63+
let mapStats = await this.GetSingleMapStat(match.id, 0);
64+
if (match.max_maps == 1) {
65+
match.team1_score = mapStats.team1_score;
66+
match.team2_score = mapStats.team2_score;
67+
}
68+
match.map_name = mapStats.map_name;
69+
match.img_error = false;
70+
this.matches.push(match);
71+
});
72+
}
73+
} catch (error) {
74+
console.log(error);
75+
} finally {
76+
this.isLoading = false;
77+
}
78+
return;
79+
},
80+
imageError(matchIdx) {
81+
console.log(this.matches[matchIdx].map_name);
82+
this.matches[matchIdx].map_name = '_unknown';
83+
return;
84+
}
85+
},
86+
computed: {
87+
gradientCalc() {
88+
if (!this.$vuetify.theme.dark)
89+
return "to bottom, rgba(255,255,255,.4), rgba(255,255,255,1)";
90+
else return "to bottom, rgba(0,0,0,.4), rgba(0,0,0,1)";
91+
}
92+
}
93+
};
94+
</script>

src/components/Navbar.vue

+4
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,10 @@
3535
active-class="primary--text text--accent-4"
3636
>
3737
<v-list-item index="Home" :to="'/'">
38+
<v-list-item-title>{{ $t("Navbar.Home") }}</v-list-item-title>
39+
</v-list-item>
40+
41+
<v-list-item index="Matches" :to="'/matches'">
3842
<v-list-item-title>{{ $t("Navbar.AllMatches") }}</v-list-item-title>
3943
</v-list-item>
4044

src/components/TeamLeaderboardTable.vue

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
:headers="headers"
99
:items="teams"
1010
:sort-by="'wins'"
11-
:sort-desc="'wins'"
11+
:sort-desc="['wins']"
1212
ref="TeamLeaderboardTable"
1313
>
1414
<template v-slot:top>

src/router/index.js

+5
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,11 @@ const routes = [
88
name: "Home",
99
component: () => import(/* webpackChunkName: "Home" */ "../views/Home.vue")
1010
},
11+
{
12+
path: "/matches",
13+
name: "Matches",
14+
component: () => import(/* webpackChunkName: "Home" */ "../views/Matches.vue")
15+
},
1116
{
1217
path: "/teams",
1318
name: "Teams",

src/translations/translations.json

+4-2
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@
1414
"MySeasons": "My Seasons",
1515
"Logout": "Logout",
1616
"DarkMode": "Toggle Dark Mode",
17-
"PlayerLeader": "Player Leaderboard"
17+
"PlayerLeader": "Player Leaderboard",
18+
"Home": "Home"
1819
},
1920
"MatchAdmin": {
2021
"AdminTools": "Admin Actions",
@@ -338,7 +339,8 @@
338339
"MySeasons": "私の季節",
339340
"Logout": "ログアウト",
340341
"DarkMode": "ダークモードを切り替えます",
341-
"PlayerLeader": "プレイヤーリーダーボード"
342+
"PlayerLeader": "プレイヤーリーダーボード",
343+
"Home": "ホーム"
342344
},
343345
"MatchAdmin": {
344346
"AdminTools": "管理者ツール",

src/utils/api.vue

+13-2
Original file line numberDiff line numberDiff line change
@@ -339,6 +339,17 @@ export default {
339339
}
340340
return message;
341341
},
342+
async GetLimitMatches(limit) {
343+
let res;
344+
let message;
345+
try {
346+
res = await this.axioCall.get(`/api/matches/limit/${limit}`);
347+
message = res.data.matches;
348+
} catch (error) {
349+
message = error.response.data.message;
350+
}
351+
return message;
352+
},
342353
async GetMyMatches() {
343354
let res;
344355
let message;
@@ -650,11 +661,11 @@ export default {
650661
}
651662
return message;
652663
},
653-
async GetSingleMapStat(matchid, mapid) {
664+
async GetSingleMapStat(matchid, mapnumber) {
654665
let res;
655666
let message;
656667
try {
657-
res = await this.axioCall.get(`/api/mapstats/${matchid}/${mapid}`);
668+
res = await this.axioCall.get(`/api/mapstats/${matchid}/${mapnumber}`);
658669
message = res.data.mapstat;
659670
} catch (error) {
660671
message = error.response.data.message;

src/views/Home.vue

+15-3
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,28 @@
11
<template>
22
<v-container class="home" fluid>
3-
<MatchesTable :user="user" />
3+
<MatchCards />
4+
<v-row>
5+
<v-col cols="6">
6+
<TeamLeaderBoard />
7+
</v-col>
8+
<v-col cols="6">
9+
<PlayerLeaderBoard />
10+
</v-col>
11+
</v-row>
412
</v-container>
513
</template>
614

715
<script>
816
// @ is an alias to /src
9-
import MatchesTable from "@/components/MatchesTable";
17+
import TeamLeaderBoard from "@/components/TeamLeaderboardTable";
18+
import PlayerLeaderBoard from "@/components/PlayerLeaderboardTable";
19+
import MatchCards from "@/components/MatchCard";
1020
export default {
1121
name: "Home",
1222
components: {
13-
MatchesTable
23+
TeamLeaderBoard,
24+
MatchCards,
25+
PlayerLeaderBoard
1426
},
1527
data() {
1628
return {

src/views/Matches.vue

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<template>
2+
<v-container class="home" fluid>
3+
<MatchesTable :user="user" />
4+
</v-container>
5+
</template>
6+
7+
<script>
8+
// @ is an alias to /src
9+
import MatchesTable from "@/components/MatchesTable";
10+
export default {
11+
name: "Home",
12+
components: {
13+
MatchesTable
14+
},
15+
data() {
16+
return {
17+
user: {
18+
admin: false,
19+
steam_id: "",
20+
id: -1,
21+
super_admin: false,
22+
name: "",
23+
small_image: "",
24+
medium_image: "",
25+
large_image: ""
26+
} // should be object from JSON response
27+
};
28+
},
29+
async mounted() {
30+
this.user = await this.IsLoggedIn();
31+
}
32+
};
33+
</script>

0 commit comments

Comments
 (0)