From d15b30485a003eaaddbbd327a097422d7a819eec Mon Sep 17 00:00:00 2001 From: gsd <mamu@ebal.net> Date: Mon, 31 Mar 2025 00:07:10 +0300 Subject: [PATCH] =?UTF-8?q?=D0=B1=D0=B0=D0=BD=20=D0=BB=D0=B8=D1=81=D1=82?= =?UTF-8?q?=20=D0=B3=D0=BE=D0=B2=D0=BD=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/app/entities/ban/Ban.ts | 47 ++++++++++++------- src/app/entities/profile/PlayerProfile.ts | 2 +- .../profile-page/profile-page.component.html | 36 ++++++++++++-- .../profile-page/profile-page.component.ts | 31 +++++++++++- src/styles.scss | 4 +- 5 files changed, 95 insertions(+), 25 deletions(-) diff --git a/src/app/entities/ban/Ban.ts b/src/app/entities/ban/Ban.ts index 1bf3e23..44c366a 100644 --- a/src/app/entities/ban/Ban.ts +++ b/src/app/entities/ban/Ban.ts @@ -1,19 +1,34 @@ -export interface Ban { - id: number; - steam_id: string; - account_id: number; - player_name: string; - ban_length: number; - ban_length_seconds: number; - ban_reason: string; - banned_by: string; - banned_by_id: string; - ip: string; - timestamp: Date; - ban_utime: number; - active: boolean; - unbanned_by_id: string; - unbanned_timestamp: Date; +export class Ban { + id: number = 0; + steam_id: string|undefined; + account_id: number|undefined; + player_name: string|undefined; + ban_length: number=0; + ban_length_seconds: number = 0; + ban_reason: string|undefined; + banned_by: string|undefined; + banned_by_id: string|undefined; + ip: string|undefined; + timestamp: Date|undefined; + ban_utime: number = 0; + active: boolean|undefined; + unbanned_by_id: string = ""; + unbanned_timestamp: Date|undefined; admin_info: any; unbanned_admin_info: any; + + static createFakeBanObject(reason: string, id: number = Number.MAX_VALUE) { + const b = new Ban(); + b.id = id; + b.ban_reason = reason; + return b; + } + + unbannedAfterTime(): boolean { + return this.unbanned_by_id == "STEAM_0:0:0"; + } + + unbannedByModerator(): boolean { + return !this.unbannedAfterTime(); + } } diff --git a/src/app/entities/profile/PlayerProfile.ts b/src/app/entities/profile/PlayerProfile.ts index 264fc3c..d45b2b2 100644 --- a/src/app/entities/profile/PlayerProfile.ts +++ b/src/app/entities/profile/PlayerProfile.ts @@ -16,7 +16,7 @@ export class PlayerProfile { play_on: PlayOn|null = null; attached_discords: any[]|null = null; donates: any[]|null = null; - ban_list: any[]|null = null; + ban_list: Ban[]|null = null; killfeed: any|null = null; killfeed_current: any = null; messages: number|null = null; diff --git a/src/app/pages/profile-page/profile-page.component.html b/src/app/pages/profile-page/profile-page.component.html index 2da53f8..5cfce78 100644 --- a/src/app/pages/profile-page/profile-page.component.html +++ b/src/app/pages/profile-page/profile-page.component.html @@ -112,16 +112,44 @@ </mat-list-item> </mat-list> </mat-expansion-panel> - <mat-expansion-panel hideToggle> + <!--История банов--> + <mat-expansion-panel hideToggle (click)="getBanList()"> <mat-expansion-panel-header> <mat-panel-title> История банов </mat-panel-title> </mat-expansion-panel-header> - <div> - <p>Тоже табличку</p> - </div> + <mat-progress-bar *ngIf="profile!=null &&profile.ban_list!=null&&profile.ban_list.length==1&&profile.ban_list[0].id == 0" mode="indeterminate"></mat-progress-bar> + <mat-accordion> + <mat-expansion-panel hideToggle *ngFor="let ban of profile.ban_list" expanded> + <mat-expansion-panel-header *ngIf="ban.id!=0"> + <mat-panel-title> + {{ban.id==getMaxValue()?ban.ban_reason:ban.ban_utime*1000|date}} + </mat-panel-title> + </mat-expansion-panel-header> + <div *ngIf="ban.id !=getMaxValue()" class="container responsive-grid-100"> + <mat-card> + <mat-card-title>#{{ban.id}}</mat-card-title> + <mat-card-subtitle>ид бана</mat-card-subtitle> + </mat-card> + <mat-card> + <mat-card-title>{{ban.ban_reason}}</mat-card-title> + <mat-card-subtitle>причина</mat-card-subtitle> + </mat-card> + <mat-card> + <mat-card-title>{{ban.ban_length>0?ban.ban_length + ' минут':'навсегда мог'}}</mat-card-title> + <mat-card-subtitle>{{ban.ban_length>0?'был':'остаться'}} в бане</mat-card-subtitle> + </mat-card> + <mat-card *ngIf="ban.unbanned_by_id != 'STEAM_0:0:0'"> + <mat-card-title>разбанил модератор</mat-card-title> + <mat-card-subtitle>открыть профиль</mat-card-subtitle> + </mat-card> + </div> + <p *ngIf="ban.id==getMaxValue()">Круто у него это получилось</p> + </mat-expansion-panel> + </mat-accordion> </mat-expansion-panel> + <mat-expansion-panel hideToggle> <mat-expansion-panel-header> <mat-panel-title> diff --git a/src/app/pages/profile-page/profile-page.component.ts b/src/app/pages/profile-page/profile-page.component.ts index 33571cd..4fe61a2 100644 --- a/src/app/pages/profile-page/profile-page.component.ts +++ b/src/app/pages/profile-page/profile-page.component.ts @@ -6,6 +6,7 @@ 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"; +import {Ban} from "../../entities/ban/Ban"; @Component({ selector: 'app-profile-page', @@ -45,7 +46,7 @@ export class ProfilePageComponent implements OnInit { getLastplay() { if (this.profile == null || this.profile.steamids == null) return; if (this.profile.lastplay != null) return; - if (this.profile.lastplay == null) { + else { this.actionService.showSnack("Загрузка данных о последней игре", "Закрыть", 2); this.profile.lastplay = {'loading':{'loading':0}}; this.playerService.getProfile(this.profile.steamids?.steam64, [ProfileRequestData.LAST_PLAY]).subscribe( @@ -59,7 +60,7 @@ export class ProfilePageComponent implements OnInit { getUsertime() { if (this.profile == null || this.profile.steamids == null) return; if (this.profile.gametime != null) return; - if (this.profile.gametime == null) { + else { this.actionService.showSnack("Загрузка данных о проведенном времени на сервере", "Закрыть", 2); this.profile.gametime = {'loading':{'loading':0}}; this.playerService.getProfile(this.profile.steamids?.steam64, [ProfileRequestData.USER_TIME]).subscribe( @@ -69,6 +70,32 @@ export class ProfilePageComponent implements OnInit { ) } } + + getBanList() { + if (this.profile == null || this.profile.steamids == null) return; + if (this.profile.ban_list != null) return; + else { + this.actionService.showSnack("Загрузка данных о прошлых банах"); + this.profile.ban_list = [Ban.createFakeBanObject("", 0)]; + this.playerService.getProfile(this.profile.steamids?.steam64, [ProfileRequestData.BAN_LIST]).subscribe( + (res) => { + if (res.ban_list != undefined) { + if (this.profile != null && res.ban_list.length > 0) { + this.profile.ban_list = [Ban.createFakeBanObject(`Был в бане ${res.ban_list.length} раз`)].concat(res.ban_list); + this.profile.ban_list.sort((b1,b2) => b2.id - b1.id) + } + } else { + // @ts-ignore + this.profile.ban_list = [] + } + } + ) + } + } + + getMaxValue() { + return Number.MAX_VALUE; + } } @Pipe({ diff --git a/src/styles.scss b/src/styles.scss index aa15673..d318603 100644 --- a/src/styles.scss +++ b/src/styles.scss @@ -145,7 +145,7 @@ span { } @media only screen and (min-width: 992px) { - $screen-width: 70%; + $screen-width: 80%; .content-in-center { width: $screen-width; @@ -159,7 +159,7 @@ span { } @media only screen and (min-width: 1200px) { - $screen-width: 66%; + $screen-width: 70%; .content-in-center { width: $screen-width;