Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refresh data #120

Merged
merged 6 commits into from
Apr 14, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions src/components/MatchesTable.vue
Original file line number Diff line number Diff line change
@@ -122,11 +122,12 @@ export default {
if (this.$route.path == "/mymatches") res = await this.GetMyMatches();
else if (this.$route.path.includes("team"))
res = await this.GetTeamRecentMatches(this.$route.params.id);
else if (this.$route.path.includes("user"))
else if (this.$route.path.includes("user")) {
if (this.$route.params.id == undefined) {
res = await this.GetUserRecentMatches(this.user.id);
} else res = await this.GetUserRecentMatches(this.$route.params.id);
else if (this.$route.path.includes("season"))
if (res.length == 0)res = await this.GetPlayerStatRecentMatches(this.$route.params.id);
} else if (this.$route.path.includes("season"))
res = await this.GetSeasonRecentMatches(this.$route.params.id);
else res = await this.GetAllMatches();
if (typeof res == "string") res = [];
2 changes: 1 addition & 1 deletion src/components/PlayerStatInfo.vue
Original file line number Diff line number Diff line change
@@ -139,7 +139,7 @@ export default {
});
if (totalRating > 0)
return (totalRating / this.statArray.length).toFixed(2);
return totalRating;
return 0;
},
isKillsLoading() {
if (this.totalKills >= 0) return false;
52 changes: 41 additions & 11 deletions src/components/PlayerStatTable.vue
Original file line number Diff line number Diff line change
@@ -49,13 +49,22 @@
<div
class="text-subtitle-2 mapInfo"
v-if="
arrMapString[index] != null && arrMapString[index].end == null
arrMapString[index] != null && arrMapString[index].end != null
"
align="left"
>
<div class="text-caption" v-if="!isFinished">
{{ $t("PlayerStats.RefreshData", { sec: countDownTimer }) }}
<v-btn
x-small
color="secondary"
@click="refreshStats"
:disabled="countDownTimer >= 55"
>
{{ $t("PlayerStats.RefreshForce") }}
</v-btn>
</div>
<div v-else />
</div>
</v-container>
<v-data-table
@@ -228,24 +237,20 @@ export default {
countDownTimer: 60,
allowRefresh: false,
timeoutId: -1,
isFinished: true,
isFinished: false,
apiUrl: process.env?.VUE_APP_G5V_API_URL || "/api"
};
},
created() {
// Template will contain v-rows/etc like on main Team page.
this.GetMapPlayerStats();
// Grab new data every minute. Since a match is 1:55+40 bomb, a good time would be 1 min.
if (!this.isFinished)
this.playerInterval = setInterval(async () => {
this.isLoading = true;
this.GetMapPlayerStats();
}, 60000);
this.getMapString();
},
beforeDestroy() {
if (!this.isFinished && this.timeoutId != -1)
clearInterval(this.playerInterval);
if (!this.isFinished) {
if (this.timeoutId != -1) clearInterval(this.timeoutId);
if (this.playerInterval != -1) clearInterval(this.playerInterval);
}
},
methods: {
async GetMapPlayerStats() {
@@ -306,7 +311,17 @@ export default {
}
});
});
if (getMatchTeamIds.end_time != null) this.isFinished = false;
if (getMatchTeamIds.end_time != null) this.isFinished = true;
if (!this.isFinished) {
this.playerInterval = setInterval(async () => {
this.isLoading = true;
this.GetMapPlayerStats();
this.countDownTimer = 60;
}, 60000);
this.timeoutId = setInterval(() => {
this.countDownTimer--;
}, 1000);
}
} catch (error) {
console.log("Our error: " + error);
} finally {
@@ -342,6 +357,21 @@ export default {
} catch (error) {
console.log("String error " + error);
}
},
async refreshStats() {
clearInterval(this.timeoutId);
clearInterval(this.playerInterval);
this.countDownTimer = 60;
this.playerInterval = setInterval(async () => {
this.isLoading = true;
this.GetMapPlayerStats();
this.countDownTimer = 60;
}, 60000);
this.timeoutId = setInterval(() => {
this.countDownTimer--;
}, 1000);
this.GetMapPlayerStats();
return;
}
}
};
32 changes: 29 additions & 3 deletions src/components/VetoTable.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
<template>
<v-container class="vetoInfo" fluid v-if="vetoInfo.length > 1">
<div class="text-caption" v-if="isVetoCountdown">
{{ $t("Veto.RefreshData", { sec: countDownTimer }) }}
</div>
<v-data-table
:headers="headers"
:items="vetoInfo"
@@ -129,17 +132,40 @@ export default {
value: "side"
}
],
expanded: []
expanded: [],
mapStats: [],
countdownId: -1,
timerId: -1,
countDownTimer: 10,
isVetoCountdown: false
};
},
mounted() {
this.getVetoInfo();
async created() {
await this.getVetoInfo();
if (this.isVetoCountdown) {
this.countdownId = setInterval(async () => {
this.getVetoInfo();
this.countDownTimer = 10;
}, 10000);
this.timerId = setInterval(async () => {
this.countDownTimer--;
}, 1000);
}
},
beforeDestroy() {
if (this.isVetoCountdown) {
if (this.timerId != -1) clearInterval(this.timerId);
if (this.countdownId != -1) clearInterval(this.countdownId);
}
},
methods: {
async getVetoInfo() {
try {
let vetoRes = await this.GetVetoesOfMatch(this.match_id);
let mapStatRes = await this.GetMapStats(this.match_id);
if (typeof vetoRes != "string") this.vetoInfo = vetoRes;
if (typeof mapStatRes != "string") this.mapStats = mapStatRes;
else this.isVetoCountdown = true;
} catch (error) {
console.log(error);
}
12 changes: 8 additions & 4 deletions src/translations/translations.json
Original file line number Diff line number Diff line change
@@ -144,7 +144,8 @@
"KAST": "KAST",
"ContribScore": "Contribution Score",
"MVP": "MVPs",
"RefreshData": "Data will refresh in {sec} seconds."
"RefreshData": "Stats will refresh in {sec} seconds.",
"RefreshForce": "Force Refresh"
},
"Seasons": {
"Title": "Seasons/Tournaments",
@@ -311,7 +312,8 @@
"TeamHeader": "Team",
"MapHeader": "Map",
"PickBan": "Pick or Ban?",
"SidePick": "Side Picked"
"SidePick": "Side Picked",
"RefreshData": "Veto data will refresh in {sec} seconds."
},
"lang": {
"LanguageName": "English",
@@ -500,7 +502,8 @@
"KAST": "KAST",
"ContribScore": "貢献度",
"MVP": "M V P",
"RefreshData": "データは{sec}秒で更新されます。"
"RefreshData": "統計情報は{sec}秒後に更新されます。",
"RefreshForce": "強制リフレッシュ"
},
"Seasons": {
"Title": "シーズンズ/トーナメント",
@@ -663,7 +666,8 @@
"TeamHeader": "チーム",
"MapHeader": "地図",
"PickBan": "選ぶか禁止するか?",
"SidePick": "サイドピック"
"SidePick": "サイドピック",
"RefreshData": "ベトデータは{sec}秒後に更新されます。"
},
"lang": {
"LanguageName": "日本語",
15 changes: 15 additions & 0 deletions src/utils/api.vue
Original file line number Diff line number Diff line change
@@ -791,6 +791,21 @@ export default {
}
return message;
},
async GetPlayerStatRecentMatches(steamid) {
let res;
let message;
try {
res = await this.axioCall.get(
`${process.env?.VUE_APP_G5V_API_URL ||
"/api"}/playerstats/${steamid}/recent`
);
message = res.data.matches;
} catch (error) {
message = error.response.data.message;
}
console.log(message);
return message;
},
// END PLAYER STATS
// BEGIN MAP STATS
async GetAllMapStats() {
16 changes: 12 additions & 4 deletions src/views/User.vue
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<template>
<v-card class="mx-auto">
<v-container>
<v-card-title v-if="retrievedUser.id != 0">
<v-card-title v-if="retrievedUser.steam_id != 0">
{{ retrievedUser.name }}
<a
:href="
@@ -118,13 +118,13 @@
<v-card-title class="headline">
{{ $t("User.Past5") }}
</v-card-title>
<MatchesTable v-if="retrievedUser.id != ''" :user="retrievedUser" />
<MatchesTable v-if="retrievedUser.steam_id != ''" :user="retrievedUser" />
</v-container>
<v-container v-if="retrievedUser.id == user.id || IsAnyAdmin(user)">
<v-card-title class="headline">
{{ $t("User.UserMaps", { players: retrievedUser.name }) }}
</v-card-title>
<MapList v-if="retrievedUser.id != -1" :user="retrievedUser" />
<MapList v-if="retrievedUser.id > 0" :user="retrievedUser" />
</v-container>
<PasswordResetDialog
v-model="passwordResetDialog"
@@ -181,7 +181,15 @@ export default {
this.user = await this.IsLoggedIn();
if (this.$route.params.id == undefined) this.retrievedUser = this.user;
else this.retrievedUser = await this.GetUserData(this.$route.params.id);
this.userStats = await this.GetUserPlayerStats(this.retrievedUser.steam_id);
if (this.retrievedUser.id === 0) {
this.userStats = await this.GetUserPlayerStats(this.$route.params.id);
this.retrievedUser.name = this.userStats[0].name;
this.retrievedUser.steam_id = this.userStats[0].steam_id;
} else
this.userStats = await this.GetUserPlayerStats(
this.retrievedUser.steam_id
);
if (typeof this.userStats == "string") this.userStats = [];
},
methods: {