Browse Source

последние подключение и наиграно времени

master
gsd 4 days ago
parent
commit
3095a5dc59
  1. 9
      src/app/app.module.ts
  2. 4
      src/app/entities/profile/PlayerProfile.ts
  3. 26
      src/app/pages/profile-page/profile-page.component.html
  4. 51
      src/app/pages/profile-page/profile-page.component.ts
  5. 13
      src/app/services/auth.service.ts

9
src/app/app.module.ts

@ -15,7 +15,7 @@ import {MatInputModule} from "@angular/material/input";
import {MatChipsModule} from "@angular/material/chips";
import { ServersPageComponent } from './pages/servers-page/servers-page.component';
import {MatExpansionModule} from "@angular/material/expansion";
import { ProfilePageComponent } from './pages/profile-page/profile-page.component';
import {ProfilePageComponent, ValueServerMapDatePipe} from './pages/profile-page/profile-page.component';
import {NeedAuthToContinue} from "./pages/internal-components/NeedAuthToContinue";
import {MatMenuModule} from "@angular/material/menu";
import {HttpClientModule} from "@angular/common/http";
@ -31,6 +31,8 @@ import {registerLocaleData} from "@angular/common";
import localeRu from "@angular/common/locales/ru";
import {Tf2dataService} from "./services/tf2data.service";
import {MatDividerModule} from "@angular/material/divider";
import {MatListModule} from "@angular/material/list";
import {MatProgressBarModule} from "@angular/material/progress-bar";
registerLocaleData(localeRu, "ru")
@ -61,7 +63,10 @@ registerLocaleData(localeRu, "ru")
MatSnackBarModule,
MatAutocompleteModule,
FormsModule,
MatDividerModule
MatDividerModule,
MatListModule,
MatProgressBarModule,
ValueServerMapDatePipe
],
providers: [
{provide: LOCALE_ID, useValue: 'ru' },

4
src/app/entities/profile/PlayerProfile.ts

@ -7,8 +7,8 @@ import {PlayOn} from "./PlayOn";
export class PlayerProfile {
ban: Ban|null = null;
gametime: {[srv_name: string]: {[map_name: string]: number}} = {};
lastplay: {[srv_name: string]: {[map_name: string]: number}} = {};
gametime: {[srv_name: string]: {[map_name: string]: number}}|null = null;
lastplay: {[srv_name: string]: {[map_name: string]: number}}|null = null;
permition: Permition|null = null;
response_time: {[request: string]: number} = {};
steam_data: SteamData|null = null;

26
src/app/pages/profile-page/profile-page.component.html

@ -76,7 +76,7 @@
<mat-card-title>Сейчас играет</mat-card-title>
<mat-card-subtitle>на {{profile.play_on.server_id}} из {{profile.play_on.country}}</mat-card-subtitle>
</mat-card>
<mat-card *ngIf="profile.play_on != null">
<mat-card *ngIf="profile.play_on != null && authService.isAdmin()">
<mat-card-title>IP адрес</mat-card-title>
<mat-card-subtitle>нажми чтоб скопировать</mat-card-subtitle>
</mat-card>
@ -84,25 +84,33 @@
<!--Сколько наиграно -->
<div>
<mat-accordion>
<mat-expansion-panel hideToggle>
<!--Последняя игра-->
<mat-expansion-panel hideToggle (click)="getLastplay()">
<mat-expansion-panel-header>
<mat-panel-title>
Последние подключение
</mat-panel-title>
</mat-expansion-panel-header>
<div>
<p>ебануть табличку где по серверам выборка когда чел полсдений раз заходил</p>
</div>
<mat-list role="list">
<mat-list-item role="listitem" *ngFor="let lastplay of profile.lastplay | keyvalue">
<mat-progress-bar *ngIf="lastplay.key == 'loading'" mode="indeterminate"></mat-progress-bar>
<p *ngIf="lastplay.key != 'loading'">{{lastplay.key}} - {{lastplay.value | ValueServerMapDate}}</p>
</mat-list-item>
</mat-list>
</mat-expansion-panel>
<mat-expansion-panel hideToggle>
<!--Общий счет наигранного времени -->
<mat-expansion-panel hideToggle (click)="getUsertime()">
<mat-expansion-panel-header>
<mat-panel-title>
Наиграно времени
</mat-panel-title>
</mat-expansion-panel-header>
<div>
<p>ебануть табличку где разпределение по времени </p>
</div>
<mat-list role="list">
<mat-list-item role="listitem" *ngFor="let gametime of profile.gametime | keyvalue">
<mat-progress-bar *ngIf="gametime.key == 'loading'" mode="indeterminate"></mat-progress-bar>
<p *ngIf="gametime.key != 'loading'">{{gametime.key}} - {{gametime.value | ValueServerMapDate:false}} секунд</p>
</mat-list-item>
</mat-list>
</mat-expansion-panel>
<mat-expansion-panel hideToggle>
<mat-expansion-panel-header>

51
src/app/pages/profile-page/profile-page.component.ts

@ -1,10 +1,11 @@
import { Component, OnInit } from '@angular/core';
import {Component, OnInit, Pipe, PipeTransform} from '@angular/core';
import {ActivatedRoute} from "@angular/router";
import {PlayerService} from "../../services/player.service";
import {PlayerProfile} from "../../entities/profile/PlayerProfile";
import {MatSnackBar} from "@angular/material/snack-bar";
import {AuthService} from "../../services/auth.service";
import {ProfileRequestData} from "../../entities/profile/ProfileRequestData";
import {ActionService} from "../../services/action.service";
@Component({
selector: 'app-profile-page',
@ -19,7 +20,8 @@ export class ProfilePageComponent implements OnInit {
constructor(private route: ActivatedRoute,
private playerService: PlayerService,
private snack: MatSnackBar,
public authService: AuthService) { }
public authService: AuthService,
public actionService: ActionService) { }
ngOnInit(): void {
const steam64: string|null = this.route.snapshot.paramMap.get("steam64");
@ -39,4 +41,49 @@ export class ProfilePageComponent implements OnInit {
}, () => this.loading = false
);
}
getLastplay() {
if (this.profile == null || this.profile.steamids == null) return;
if (this.profile.lastplay != null) return;
if (this.profile.lastplay == null) {
this.actionService.showSnack("Загрузка данных о последней игре", "Закрыть", 2);
this.profile.lastplay = {'loading':{'loading':0}};
this.playerService.getProfile(this.profile.steamids?.steam64, [ProfileRequestData.LAST_PLAY]).subscribe(
(res) => {
this.profile != null ? this.profile.lastplay = res.lastplay : undefined;
}, (err) => this.actionService.showSnack("Произошла ошибка во время загрузки")
)
}
}
getUsertime() {
if (this.profile == null || this.profile.steamids == null) return;
if (this.profile.gametime != null) return;
if (this.profile.gametime == null) {
this.actionService.showSnack("Загрузка данных о проведенном времени на сервере", "Закрыть", 2);
this.profile.gametime = {'loading':{'loading':0}};
this.playerService.getProfile(this.profile.steamids?.steam64, [ProfileRequestData.USER_TIME]).subscribe(
(res) => {
this.profile != null ? this.profile.gametime = res.gametime : undefined;
}, (err) => this.actionService.showSnack("Произошла ошибка во время загрузки")
)
}
}
}
@Pipe({
name: "ValueServerMapDate",
standalone: true
})
export class ValueServerMapDatePipe implements PipeTransform {
mapCleaner(name: string): string {
// @ts-ignore
return name.split("/").pop().split(".ugc").shift();
}
transform(value: {[name: string]: number}, createDate: boolean = true, delimiter: string = " - "): any {
const keys = Object.keys(value);
return `${this.mapCleaner(keys[0])}${delimiter}${createDate?(new Date(value[keys[0]]*1000)).toLocaleString():value[keys[0]]}`;
}
}

13
src/app/services/auth.service.ts

@ -3,6 +3,7 @@ import {PlayerService} from "./player.service";
import {ProfileRequestData} from "../entities/profile/ProfileRequestData";
import {SteamData} from "../entities/profile/SteamData";
import {SteamIDs} from "../entities/profile/SteamIDs";
import {Permition} from "../entities/profile/Permition";
@Injectable({
providedIn: 'root'
@ -11,12 +12,14 @@ export class AuthService {
static KEY: string = "steam_ids";
steamdata: SteamData | null = null;
steamIds: SteamIDs | null = null;
permition: Permition | null = null;
constructor(private playerService: PlayerService) {
this.playerService.getProfile(null, [ProfileRequestData.STEAM_DATA])
this.playerService.getProfile(null, [ProfileRequestData.STEAM_DATA, ProfileRequestData.PERMITION])
.subscribe((res) => {
this.steamdata = res.steam_data;
this.steamIds = res.steamids
this.permition = res.permition;
sessionStorage.setItem(AuthService.KEY, JSON.stringify(res.steamids))
})
}
@ -34,4 +37,12 @@ export class AuthService {
isAuth() {
return sessionStorage.getItem(AuthService.KEY) != null;
}
isAdmin() {
return this.permition?.flags.indexOf("z") != -1;
}
isModerator() {
return this.isAdmin() || this.permition?.flags.indexOf("cde") != -1;
}
}

Loading…
Cancel
Save