Browse Source

profile view

master
gsd 1 year ago
parent
commit
80331e1f45
  1. 18
      src/App.vue
  2. 16
      src/api/GlobalApi.js
  3. 41
      src/api/PlayerApi.js
  4. 0
      src/components/Others/AuthWindow.vue
  5. 42
      src/components/Others/ProfileViewer.vue
  6. 106
      src/components/TabsMenuElements/ProfileView/Components/ProfileContainer.vue
  7. 66
      src/components/TabsMenuElements/ProfileView/ProfileView.vue
  8. 8
      src/components/TabsMenuElements/ServersView/Components/PlayerExtendedInfo.vue
  9. 2
      src/components/VipView/Components/VipBuyDialog.vue
  10. 1
      src/main.js

18
src/App.vue

@ -19,6 +19,8 @@ import MdDrawer from "vue-material/dist/components/MdDrawer";
import MdButton from "vue-material/dist/components/MdButton";
import MdProgress from "vue-material/dist/components/MdProgress";
import MdSnackbar from "vue-material/dist/components/MdSnackbar";
import MdMenu from "vue-material/dist/components/MdMenu";
import MdList from "vue-material/dist/components/MdList";
Vue.use(MdTabs);
Vue.use(MdIcon);
@ -28,6 +30,8 @@ Vue.use(MdDrawer);
Vue.use(MdButton);
Vue.use(MdProgress);
Vue.use(MdSnackbar);
Vue.use(MdMenu);
Vue.use(MdList);
import TabsMenu from "@/components/TabsMenu.vue";
import LoaderPage from "@/components/Others/LoaderPage.vue";
@ -195,4 +199,18 @@ a {
.clickable:hover {
cursor: pointer;
}
.md-menu-content-container {
color: black;
background-color: #e0eddd;
border: 3px solid black;
}
.md-scrollbar::-webkit-scrollbar-thumb {
background-color: #fd8846 !important;
}
.md-scrollbar::-webkit-scrollbar-corner {
background-color: black !important;
}
</style>

16
src/api/GlobalApi.js

@ -36,6 +36,15 @@ export default class GlobalApi {
document.title = "Факты 13";
}
getHumanServerName(server) {
for (const mode in this.stats['servers']) {
for (const srv in this.stats['servers'][mode]) {
if (this.stats['servers'][mode][srv]['key'] === server) return this.stats['servers'][mode][srv]['name'];
}
}
return "неизвестный";
}
async fillThis(value) {
console.log(`[API] load: ${value}`);
this.load_stages.add(value);
@ -64,6 +73,7 @@ export default class GlobalApi {
'n':[]
};
for (let srv in response) {
response[srv]['key'] = srv;
if (response[srv]['status'] == false) srvs.n.push(response[srv]);
else if (response[srv]['player_count'] > 0) srvs.w.push(response[srv]);
else srvs.e.push(response[srv]);
@ -136,6 +146,8 @@ export default class GlobalApi {
h = divmod(h, 24)[1];
//бля простите я тупой
let total_h = divmod(u_time, 60 * 60);
if (!s & !m & !h & !d) {
return "не играл";
}
@ -145,9 +157,9 @@ export default class GlobalApi {
if (!d) {
return time;
} else if (d < 2) {
return `${h} ч\n`;
return `${h} ч`;
} else {
return `${h} ч\n(${n} н ${d} д ${h} ч`;
return `${total_h[0]} ч (${n} н ${d} д ${h} ч)`;
}
}
}

41
src/api/PlayerApi.js

@ -5,7 +5,9 @@ export default class PlayerApi {
permition: null,
steam_data: null,
ban: null,
steamids: null
steamids: null,
gametime: {},
lastplay: {}
}
discord = null;
@ -18,6 +20,43 @@ export default class PlayerApi {
}
}
getGametimeTotal(player) {
if (player === undefined) player = this.store;
let t = 0;
for (const srv in player.gametime) {
for (const map_name in player.gametime[srv]) {
t += player.gametime[srv][map_name];
}
}
return t;
}
getGametime(api, player) {
if (player === undefined) player = this.store;
let t = [];
let total_on_server = [0];
for (const srv in player.gametime) {
total_on_server = [0];
for (const map_name in player.gametime[srv]) {
total_on_server[0] += player.gametime[srv][map_name];
}
t.push([api.getHumanServerName(srv), total_on_server[0]]);
}
return t;
}
getLastplayList(player) {
if (player === undefined) player = this.store;
let t = [];
for (const srv in player.lastplay) {
for (const map_name in player.lastplay[srv]) {
t.push([map_name.replace("workshop/", "").split(".ugc")[0], new Date(player.lastplay[srv][map_name] * 1000).toLocaleDateString()]);
}
}
return t;
}
async loadFull() {
return axios.get(`/api/profile/current`)
.then(response => {

0
src/components/TabsMenuElements/ProfileView/AuthWindow.vue → src/components/Others/AuthWindow.vue

42
src/components/Others/ProfileViewer.vue

@ -0,0 +1,42 @@
<template>
<md-dialog :md-active.sync="showProfileDialog">
<div class="md-layout md-alignment-bottom-center">
<div class="md-layout-item md-size-50 md-small-size-100 md-alignment-bottom-center rounded-only">
<ProfileContainer :player="player"/>
<h1 v-if="loading">Загрузка</h1>
</div>
</div>
</md-dialog>
</template>
<script>
import ProfileContainer from "@/components/TabsMenuElements/ProfileView/Components/ProfileContainer.vue";
import axios from "axios";
export default {
name: "ProfileViewer",
components: {ProfileContainer},
props: {
steam64: String
},
data: () => ({
player: null,
loading: false,
showProfileDialog: false
}),
methods: {
getPlayer() {
this.showProfileDialog = true;
this.loading = true;
axios.get("/api/profile?steam64=" + this.steam64).then(response => {
if (response.status === 200) this.player = response.data;
else console.log("not permition");
}).catch(() => {
console.log("not permition");
this.showProfileDialog = false;
this.loading = false;
})
}
}
}
</script>

106
src/components/TabsMenuElements/ProfileView/Components/ProfileContainer.vue

@ -0,0 +1,106 @@
<template>
<div>
<div class="md-layout md-alignment-top-center" v-if="player !== null">
<div :class="`md-layout-item md-size-${f_size} md-small-size-100`">
<h4 style="margin: 10% 0%">{{player !== null && player['steam_data'] !== null?player['steam_data']['nickname']:'игрок'}}</h4>
<hr>
<div v-if="player['ban'] !== null">
<p class="profile-text" style="display: inline">Статус Бана: </p>
<p class="profile-text" style="color: brown">Забанен</p>
<p class="profile-text">Выдал бан: русский путин</p>
<p class="profile-text">Дата окончания бана: 14.88.1488</p>
</div>
<div v-if="player['permition'] === null">
<p class="profile-text" style="display: inline">Статус VIP : </p>
<p class="profile-text" style="color: crimson"> слыш купи</p>
</div>
<div v-else>
<p class="profile-text" style="display: inline">Статус {{player['permition']['status']}} : </p>
<p class="profile-text" style="color: green; display: inline" v-if="player['permition']['status'] === 'VIP'"> Куплен</p>
<p class="profile-text" v-else style="color: #fd8846; display: inline">Имеется</p>
<p class="profile-text">Дата окончания : </p>
<p class="profile-text" v-if="player['permition']['amount'] === 0" style="display: inline">Навсегда</p>
<p class="profile-text" v-else style="display: inline">22.22.2032</p>
</div>
<hr>
<md-menu md-direction="bottom-start" md-size="auto">
<md-button class="md-raised" style="color: #131213; font-family: tf2build; background: #fd8846" md-menu-trigger>Статистика по картам</md-button>
<md-menu-content>
<md-menu-item v-for="g in getPlayerGametime()" :key="g[0]+'g'">{{g[0]}} - {{timeFormat(g[1])}}</md-menu-item>
</md-menu-content>
</md-menu>
<br>
<md-menu md-direction="bottom-start" md-size="auto">
<md-button class="md-raised" style="color: #131213; font-family: tf2build; background: #fd8846" md-menu-trigger>Последние игры</md-button>
<md-menu-content>
<md-menu-item v-for="l in getLastPlay()" :key="l[0]+'l'">{{l[0]}} - {{l[1]}}</md-menu-item>
</md-menu-content>
</md-menu>
</div>
<div :class="`md-layout-item md-size-${f_size} md-small-size-100`">
<div style="justify-content: right; display: flex">
<img :src="getAvatar()" style="border-radius: 15px;">
</div>
<p class="profile-text" style="text-align: right">Убийств : 20</p>
<p class="profile-text" style="text-align: right">Смертей : 543</p>
<p class="profile-text" style="text-align: right">Наиграно : {{getTotalPlaytime()}}</p>
<div style="justify-content: right; display: flex">
<DiscordSvg :h="'10%'" :w="'40'" style="margin-left: 5%"/>
<SteamSvg :h="'10%'" :w="'40'" style="margin-left: 5%"/>
</div>
</div>
<br>
<hr width="50%">
<div>
<p>ban history</p>
<p>buy history</p>
</div>
</div>
</div>
</template>
<script>
import DiscordSvg from "@/components/Others/CustomSvg/DiscordSvg.vue";
import SteamSvg from "@/components/Others/CustomSvg/SteamSvg.vue";
export default {
name: "ProfileContainer",
components: {SteamSvg, DiscordSvg},
props: {
player: Object,
f_size: {
type: Number,
default: 45
},
},
methods: {
getAvatar() {
try {
return this.player.steam_data['avatar'];
} catch (err) {
return require('@/assets/profile-user.svg');
}
},
getPlayerGametime() {
return this.$API.player.getGametime(this.$API, this.player);
},
timeFormat(seconds) {
return this.$API.UNIX2FACTI_TIME(seconds);
},
getTotalPlaytime() {
return this.timeFormat(this.$API.player.getGametimeTotal(this.player));
},
getLastPlay() {
return this.$API.player.getLastplayList(this.player);
}
}
}
</script>
<style>
.profile-text {
text-align: left;
color: #131213;
font-size: 1.5em;
}
</style>

66
src/components/TabsMenuElements/ProfileView/ProfileView.vue

@ -1,66 +1,22 @@
<template>
<md-tab id="profileView" :md-icon="require('@/assets/profile-user.svg')">
<div class="md-layout md-alignment-bottom-center">
<CharacterImage :size="10" :img_src="require(`@/assets/images/characters/pyro.png`)" :audio_src="require(`@/assets/sounds/alertmgs.mp3`)"/>
<CharacterImage :size="10" :img_src="require(`@/assets/images/characters/pyro.png`)" :audio_src="require(`@/assets/sounds/alertmgs.mp3`)" :hide_if_small="true"/>
</div>
<div class="md-layout md-alignment-bottom-center">
<div class="md-layout-item md-size-25 md-alignment-bottom-center rounded-and-colored" >
<div class="md-layout-item md-size-25 md-small-size-100 md-alignment-bottom-center rounded-and-colored" >
<h3 style="text-align: center; margin: 4% 0%">Профиль</h3>
</div>
</div>
<div class="md-layout md-alignment-bottom-center">
<div class="md-layout-item md-size-50 md-alignment-bottom-center rounded-only">
<div class="md-layout-item md-size-50 md-small-size-100 md-alignment-bottom-center rounded-only">
<br>
<hr width="50%">
<div v-if="this.$API.player.auth('steam') === false" class="clickable">
<h2 class="auth-button" v-on:click="openAW()">АВТОРИЗОВАТЬСЯ</h2>
</div>
<div v-else>
<div style="justify-content: center; display: flex; max-width: 80%; margin-left: 10%; padding-top: 5%">
<div style="max-width: 50%; float: left; margin: 0% 5%">
<h4>{{this.$API.player.store['steam_data']['nickname']}}</h4>
<hr>
<div v-if="this.$API.player.store['ban'] !== null">
<p style="display: inline">Статус Бана: </p>
<p style="color: brown">Забанен</p>
<p>Выдал бан: русский путин</p>
<p>Дата окончания бана: 14.88.1488</p>
</div>
<div v-if="this.$API.player.store['permition'] === null">
<p style="display: inline">Статус VIP : </p>
<p style="color: crimson"> слыш купи</p>
</div>
<div v-else>
<p style="display: inline">Статус {{this.$API.player.store['permition']['status']}} : </p>
<p style="color: green; display: inline" v-if="this.$API.player.store['permition']['status'] === 'VIP'"> Куплен</p>
<p v-else style="color: #fd8846; display: inline">Имеется</p>
<p>Дата окончания : </p>
<p v-if="this.$API.player.store['permition']['amount'] === 0" style="display: inline">Навсегда</p>
<p v-else style="display: inline">22.22.2032</p>
</div>
<hr>
<p>Статистикаf:</p>
<p>anus - 12:43:44</p>
</div>
<div style="max-width: 50%; float: left; margin: 0% 5%">
<div style="justify-content: right; display: flex">
<img :src="getAvatar()" style="border-radius: 15px;">
</div>
<p>Убийств : 20</p>
<p>Смертей : 543</p>
<p>Наиграно : globalapi.unixtime</p>
<div style="justify-content: right; display: flex">
<DiscordSvg :h="'10%'" :w="'40'" style="margin-left: 5%"/>
<SteamSvg :h="'10%'" :w="'40'" style="margin-left: 5%"/>
</div>
</div>
</div>
</div>
<br>
<hr width="50%">
<div>
<p>ban history</p>
<p>buy history</p>
<ProfileContainer :player="$API.player.store"/>
</div>
</div>
</div>
@ -70,9 +26,8 @@
<script>
import CharacterImage from "@/components/Others/CharacterImage.vue";
import AuthWindow from "@/components/TabsMenuElements/ProfileView/AuthWindow.vue";
import DiscordSvg from "@/components/Others/CustomSvg/DiscordSvg.vue";
import SteamSvg from "@/components/Others/CustomSvg/SteamSvg.vue";
import AuthWindow from "@/components/Others/AuthWindow.vue";
import ProfileContainer from "@/components/TabsMenuElements/ProfileView/Components/ProfileContainer.vue";
export default {
name: 'ProfileView',
props: {
@ -80,15 +35,8 @@ export default {
type: String
}
},
components: {SteamSvg, DiscordSvg, AuthWindow, CharacterImage},
components: {ProfileContainer, AuthWindow, CharacterImage},
methods: {
getAvatar() {
try {
return this.$API.player.store.steam_data['avatar'];
} catch (err) {
return require('@/assets/profile-user.svg');
}
},
openAW() {
console.log('open auth window');
this.$refs.aw.showAuthDialog = true;

8
src/components/TabsMenuElements/ServersView/Components/PlayerExtendedInfo.vue

@ -33,15 +33,20 @@
<md-button v-if="showPlayerDialog && this.$API.admin.permition.kick" class="md-raised" style="color: #131213; font-family: tf2build; background: darkcyan">кикнуть</md-button>
<md-button v-if="showPlayerDialog && this.$API.admin.permition.ban" class="md-raised" style="color: #131213; font-family: tf2build; background: brown">забанить</md-button>
<md-button v-if="showPlayerDialog && this.$API.admin.permition.mute" style="color: #131213; font-family: tf2build; background: lightgreen">замьютить</md-button>
<md-button v-if="showPlayerDialog && this.$API.admin.permition.mute" style="color: #131213; font-family: tf2build; background: #fdecc1" v-on:click="showProfile()">информация</md-button>
</div>
</div>
</div>
<ProfileViewer ref="pv" :steam64="player['steam']['steam64']"/>
</md-dialog>
</template>
<script>
import ProfileViewer from "@/components/Others/ProfileViewer.vue";
export default {
name: 'PlayerExtendedInfo',
components: {ProfileViewer},
props: {
player: Object
},
@ -53,6 +58,9 @@ export default {
methods: {
closePEI() {
this.showPlayerDialog = false;
},
showProfile() {
this.$refs.pv.getPlayer();
}
}
}

2
src/components/VipView/Components/VipBuyDialog.vue

@ -57,7 +57,7 @@
import QiwiSvg from "@/components/Others/CustomSvg/QiwiSvg.vue";
import SteamSvg from "@/components/Others/CustomSvg/SteamSvg.vue";
import FreeSvg from "@/components/Others/CustomSvg/FreeSvg.vue";
import AuthWindow from "@/components/TabsMenuElements/ProfileView/AuthWindow.vue";
import AuthWindow from "@/components/Others/AuthWindow.vue";
export default {
name: 'VipBuyDialog',

1
src/main.js

@ -4,6 +4,7 @@ import GlobalApi from './api/GlobalApi'
Vue.config.productionTip = false
Vue.prototype.$API = Vue.observable(new GlobalApi());
Vue.material.locale.dateFormat = 'dd/MM/yyyy';
new Vue({
render: h => h(App),

Loading…
Cancel
Save