From 72fbb3628aeb2e932325b3ae70c315630b044ece Mon Sep 17 00:00:00 2001 From: gsd Date: Sat, 10 May 2025 23:33:39 +0300 Subject: [PATCH] fixes 2 --- src/app/app.module.ts | 6 +- .../banlist-page/banlist-search-table.ts | 11 +- .../abstract-search-table.component.ts | 7 +- .../dialogs/simple-action-dialog.component.ts | 249 ++++++++++++++++++ .../profile-page/profile-page.component.html | 29 +- .../servers-page/servers-page.component.html | 33 ++- .../servers-page/servers-page.component.ts | 6 + src/app/services/action.service.ts | 30 ++- src/app/services/auth.service.ts | 2 +- src/styles.scss | 8 + 10 files changed, 340 insertions(+), 41 deletions(-) create mode 100644 src/app/pages/internal-components/dialogs/simple-action-dialog.component.ts diff --git a/src/app/app.module.ts b/src/app/app.module.ts index 3814fa0..38deca5 100644 --- a/src/app/app.module.ts +++ b/src/app/app.module.ts @@ -80,6 +80,8 @@ import { FilesPageComponent } from './admin-pages/files-page/files-page.componen import {FilesSearchTable} from "./admin-pages/files-page/FilesSearchTable"; import {FilesUploader} from "./admin-pages/files-page/FilesUploader"; import {AuthDialogRequest} from "./pages/internal-components/dialogs/AuthDialogRequest"; +import {SimpleActionDialog} from "./pages/internal-components/dialogs/simple-action-dialog.component"; +import {MatTooltipModule} from "@angular/material/tooltip"; registerLocaleData(localeRu, "ru") @@ -122,6 +124,7 @@ registerLocaleData(localeRu, "ru") VipFreeDialog, VipPromocodeDialog, AuthDialogRequest, + SimpleActionDialog, DowngamePageComponent, StatisticPageComponent, AboutPageComponent, @@ -161,7 +164,8 @@ registerLocaleData(localeRu, "ru") MatProgressSpinnerModule, MatDialogModule, MatStepperModule, - MatCheckboxModule + MatCheckboxModule, + MatTooltipModule ], providers: [ {provide: LOCALE_ID, useValue: 'ru' }, diff --git a/src/app/pages/banlist-page/banlist-search-table.ts b/src/app/pages/banlist-page/banlist-search-table.ts index 49ca03b..8a6f100 100644 --- a/src/app/pages/banlist-page/banlist-search-table.ts +++ b/src/app/pages/banlist-page/banlist-search-table.ts @@ -11,6 +11,7 @@ import {MatDialog} from "@angular/material/dialog"; import {MatTableDataSource} from "@angular/material/table"; import {BanViewDialog} from "../internal-components/dialogs/BanViewDialog"; import {AuthDialogRequest} from "../internal-components/dialogs/AuthDialogRequest"; +import {ActionService} from "../../services/action.service"; @Component({ selector: "app-banlist-search-table", @@ -99,11 +100,8 @@ import {AuthDialogRequest} from "../internal-components/dialogs/AuthDialogReques Действие - view_headline - - - - + remove_red_eye + lock_open @@ -135,7 +133,8 @@ export class BanlistSearchTable extends AbstractSearchTable implements A @Input("account_id") //[U:1:%s] - account_id: number | null = null; + account_id: string | number | null = null; @Input("use_query") use_query: boolean = true; @@ -55,7 +55,10 @@ export abstract class AbstractSearchTable implements A if (this.account_id == null || !this.use_query) this.filter.fromQuery(this.route.snapshot.queryParamMap, this.paginator); else - this.filter.addAccountToSearch(`[U:1:${this.account_id}]`); + if (typeof this.account_id == 'number') + this.filter.addAccountToSearch(`[U:1:${this.account_id}]`); + else + this.filter.addAccountToSearch(this.account_id); this.updateData(); this.serverService.servers.subscribe( diff --git a/src/app/pages/internal-components/dialogs/simple-action-dialog.component.ts b/src/app/pages/internal-components/dialogs/simple-action-dialog.component.ts new file mode 100644 index 0000000..e7b23fd --- /dev/null +++ b/src/app/pages/internal-components/dialogs/simple-action-dialog.component.ts @@ -0,0 +1,249 @@ +import {Component, Inject, Input} from "@angular/core"; +import {MAT_DIALOG_DATA} from "@angular/material/dialog"; +import {HttpClient} from "@angular/common/http"; +import {Player} from "../../../entities/servers/Player"; +import {map} from "rxjs"; +import {SteamIDs} from "../../../entities/profile/SteamIDs"; + +@Component({ + selector: 'app-report-create-dialog', + template: ` +
+
+

Что-то пошло не так

+ +

Не выбран режим работы окна

+
+ + + +
+
+

Создать жалобу

+ +

{{response}}

+ + Причина тряски + + + +
+ + + +
+
+

Бан

+ +

{{response}}

+ + Причина бана + + + + Длительность бана в минутах, 0 - навсегда + + + +
+ + + +
+
+

Кикаем игрока

+ +

{{response}}

+ + Причина кика + + + +
+ + + +
+
+

Выключаем микрофон

+ +

{{response}}

+ +
+ + + +
+
+

Разбанить игрока

+ +

{{response}}

+ +
+ + + +
+
+ ` +}) +export class SimpleActionDialog { + text: string = ""; + number: number = 0; + response: string = "Введи причину, чем она понятнее тем лучше"; + loading: boolean = false; + + constructor(@Inject(MAT_DIALOG_DATA) public data: { + steamIds: SteamIDs, + mode: string + }, + private http: HttpClient) {} + + sendReport() { + this.response = 'Отправляем....' + this.loading = true; + this.http.post(`api/profile/current/report?steam64=${this.data.steamIds.steam64}&text=${this.text}`, {}) + .pipe(map(res => Number.parseInt(`${res}`))) + .subscribe( + (res) => { + if (res > 0) this.response = 'Репорт успешно отослан' + else if (res < 0) this.response = `Перед другим репортом нужно подождать ${res*-1} секунд`; + else this.response = 'Произошла ошибка, нельзя опубликовать жалобу'; + this.loading = false; + }, + (error) => { + if (error.status == 406) this.response = 'Ты в бане, жалобу отправить нельзя!' + else this.response = 'Неизвестная ошибка, терпи...'; + this.loading = false; + }) + } + + sendKick() { + this.response = "Кикаем..."; + this.loading = true; + this.http.post(`api/admin/kick?steam64=${this.data.steamIds.steam64}`, {}) + .subscribe( + (res) => { + this.loading = false; + this.response = 'Успешно кикнут'; + }, (err) => { + switch (err.status) { + case 404: { + this.response = "Такого игрока уже нет на сервере"; + break; + } + default: { + this.response = "Неизвестная ошибка, ты новичек??"; + break; + } + } + this.loading = false; + } + ) + } + + sendMute() { + this.response = "Выключаем микрофон..."; + this.loading = true; + this.http.post(`api/admin/mute?steam64=${this.data.steamIds.steam64}`, {}) + .subscribe( + (res) => { + this.loading = false; + this.response = 'Успешно выключен микрофон'; + }, (err) => { + switch (err.status) { + case 404: { + this.response = "Такого игрока уже нет на сервере"; + break; + } + default: { + this.response = "Неизвестная ошибка, ты новичек??"; + break; + } + } + this.loading = false; + } + ) + } + + sendUnban() { + this.response = "Пробуем разбанить"; + this.loading = true; + this.http.delete(`api/admin/ban?steam64=${this.data.steamIds.steam64}`, {}) + .subscribe( + (res) => { + this.loading = false; + this.response = 'Успешно разбанил'; + }, (err) => { + switch (err.status) { + case 404: { + this.response = "А такого бана нет"; + break; + } + default: { + this.response = "Неизвестная ошибка, ты новичек??"; + break; + } + } + this.loading = false; + } + ) + } + + sendBan() { + this.response = "Баним..."; + this.loading = true; + this.http.post(`api/admin/ban?steam64=${this.data.steamIds.steam64}&ban_length=${this.number}&ban_reason=${this.text}`, {}) + .subscribe( + (res) => { + this.loading = false; + }, + (err) => { + switch (err.status) { + case 201: { + this.response = 'Успешно забанен!'; + break; + } + case 202: { + this.response = 'Уже в бане, нельзя забанить повторно'; + break; + } + case 406: { + this.response = 'Чел... Он слишком крут для тебя'; + break; + } + default: { + this.response = 'Неизвестная ошибка, ты новичек??'; + break; + } + } + this.loading = false; + } + ) + } +} diff --git a/src/app/pages/profile-page/profile-page.component.html b/src/app/pages/profile-page/profile-page.component.html index e4e5b1a..5fe206c 100644 --- a/src/app/pages/profile-page/profile-page.component.html +++ b/src/app/pages/profile-page/profile-page.component.html @@ -3,9 +3,9 @@

Профиль

Здесь можно увидеть профиль игрока на наших серверах с подробной информации о нем

-
-

{{profile.steam_data.nickname}}

-

Открыть профиль в стиме

+
+

{{profile.steam_data != null?profile.steam_data.nickname:'Просмотр профиля'}}

+

Открыть профиль в стиме

Загрузка данных о профиле

@@ -23,16 +23,19 @@ {{profile.steam_data.nickname}}
-

Steam64: {{profile.steamids.steam64}}

-

Steam3: {{profile.steamids.steam3}}

-

Steam2: {{profile.steamids.steam2}}

+

Steam64: {{profile.steamids.steam64}}

+

Steam3: {{profile.steamids.steam3}}

+

Steam2: {{profile.steamids.steam2}}

- - - - + + + + + + + @@ -131,15 +134,13 @@ - + Репорты с участием игрока -
-

Табличку с репортом

-
+
diff --git a/src/app/pages/servers-page/servers-page.component.html b/src/app/pages/servers-page/servers-page.component.html index 056f332..d6d7994 100644 --- a/src/app/pages/servers-page/servers-page.component.html +++ b/src/app/pages/servers-page/servers-page.component.html @@ -5,6 +5,11 @@
+
+

Подгрузка серверов

+ +
+ @@ -52,18 +57,18 @@ Текущая карта Подключиться через Steam Адрес сервера {{server.value.ip}} - + Скачать карту из воркшопа @@ -124,36 +129,36 @@
-

{{player.steam.steam2}}

-

{{player.steam.steam3}}

-

{{player.steam.steam64}}

+

{{player.steam.steam2}}

+

{{player.steam.steam3}}

+

{{player.steam.steam64}}

- Открыть профиль на сайте - Открыть профиль в стиме - + Пожаловаться на игрока который играет
-
- +
+ Забанить - + Кикнуть - + Кинуть в мут
diff --git a/src/app/pages/servers-page/servers-page.component.ts b/src/app/pages/servers-page/servers-page.component.ts index 747ec51..5028582 100644 --- a/src/app/pages/servers-page/servers-page.component.ts +++ b/src/app/pages/servers-page/servers-page.component.ts @@ -5,6 +5,9 @@ import {KeyValue} from "@angular/common"; import {ActionService} from "../../services/action.service"; import {Tf2dataService} from "../../services/tf2data.service"; import {AuthService} from "../../services/auth.service"; +import {Player} from "../../entities/servers/Player"; +import {MatDialog} from "@angular/material/dialog"; +import {SimpleActionDialog} from "../internal-components/dialogs/simple-action-dialog.component"; @Component({ selector: 'app-servers-page', @@ -62,4 +65,7 @@ export class ServersPageComponent implements OnInit { return name.split("workshop/").pop().split(".ugc").shift() } + serversExists():boolean { + return Object.keys(this.servers).length > 0; + } } diff --git a/src/app/services/action.service.ts b/src/app/services/action.service.ts index 85a4a84..cf8cda4 100644 --- a/src/app/services/action.service.ts +++ b/src/app/services/action.service.ts @@ -1,6 +1,11 @@ import { Injectable } from '@angular/core'; import {MatSnackBar, MatSnackBarRef} from "@angular/material/snack-bar"; import {Router} from "@angular/router"; +import {Player} from "../entities/servers/Player"; +import {SimpleActionDialog} from "../pages/internal-components/dialogs/simple-action-dialog.component"; +import {MatDialog} from "@angular/material/dialog"; +import {SteamIDs} from "../entities/profile/SteamIDs"; +import {PlayerService} from "./player.service"; @Injectable({ providedIn: 'root' @@ -8,10 +13,17 @@ import {Router} from "@angular/router"; export class ActionService { constructor(private snack: MatSnackBar, - private router: Router) { } + private router: Router, + private dialog: MatDialog, + private playerService: PlayerService) { } + + public copyToClipboard(text:string|null, show_snack: boolean = false):boolean { + if (text != null) + navigator.clipboard.writeText(text); + + if (show_snack) + this.showSnack('Скопировано в буфер обмена'); - public copyToClipboard(text:string):boolean { - navigator.clipboard.writeText(text); return true; } @@ -31,4 +43,16 @@ export class ActionService { window.open(url, "_blank"); return true; } + + //todo abst + simpleAction(steamIds: SteamIDs|null, mode: 'report'|'ban'|'kick'|'mute'|'unban') { + if (steamIds != null) + this.dialog.open(SimpleActionDialog, {data:{steamIds, mode}, minWidth:'500px'}); + } + + simpleActionWithSearch(steam: string, mode:string) { + this.playerService.searchProfile(steam).subscribe( + (steamIds) => this.dialog.open(SimpleActionDialog, {data:{steamIds, mode}, minWidth:'500px'}) + ); + } } diff --git a/src/app/services/auth.service.ts b/src/app/services/auth.service.ts index 2a189a2..c8a468b 100644 --- a/src/app/services/auth.service.ts +++ b/src/app/services/auth.service.ts @@ -54,7 +54,7 @@ export class AuthService { login() { sessionStorage.removeItem(AuthService.KEY); - window.open(`api/auth/login?subdomain=${location.hostname.split(".").shift()}`) + window.open(`api/auth/login?subdomain=${location.hostname.split(".").shift()}`, "_self") } logout() { diff --git a/src/styles.scss b/src/styles.scss index ace12d6..117d752 100644 --- a/src/styles.scss +++ b/src/styles.scss @@ -393,3 +393,11 @@ span { .mat-dialog-content { padding-bottom: 1% !important; } + +.clickable { + cursor: pointer +} + +mat-card + .clickable:hover { + background: linear-gradient(to top, #f2a998, #e65e11);; +}