18 changed files with 542 additions and 229 deletions
@ -0,0 +1,54 @@ |
|||||
|
import {SearchFilter} from "./SearchFilter"; |
||||
|
import {MatPaginator} from "@angular/material/paginator"; |
||||
|
import {ParamMap} from "@angular/router"; |
||||
|
|
||||
|
export class BanSearchFilter extends SearchFilter{ |
||||
|
ban_ids: number[]|null = null; |
||||
|
active: boolean|null = null; |
||||
|
admin_ids: string[]|null = null; |
||||
|
|
||||
|
override createQuery(paginator:MatPaginator|undefined): { [p: string]: any } { |
||||
|
let q:{[param: string]: any} = super.createQuery(paginator); |
||||
|
q["ban_ids"] = this.ban_ids?this.ban_ids.join(","):null; |
||||
|
q["active"] = this.active != null? this.active: null; |
||||
|
q["admin_ids"] = this.admin_ids?this.admin_ids.join(","):null; |
||||
|
return q; |
||||
|
} |
||||
|
|
||||
|
override fromQuery(param: ParamMap,paginator:MatPaginator|undefined) { |
||||
|
try {if (param.get("ban_ids")) { // @ts-ignore
|
||||
|
this.message = param.get("ban_ids")?.split(",");}}catch (e) {} |
||||
|
|
||||
|
try {if (param.get("active")) { // @ts-ignore
|
||||
|
this.message = param.get("active");}}catch (e) {} |
||||
|
|
||||
|
try {if (param.get("admin_ids")) { // @ts-ignore
|
||||
|
this.message = param.get("admin_ids")?.split(",");}}catch (e) {} |
||||
|
|
||||
|
super.fromQuery(param, paginator); |
||||
|
} |
||||
|
|
||||
|
|
||||
|
changeBanIdToSearch(prev: number, name: any) { |
||||
|
if (this.ban_ids == null) |
||||
|
this.ban_ids = []; |
||||
|
this.ban_ids = this.ban_ids.filter(v => v !== prev); |
||||
|
if (this.ban_ids.indexOf(name.target.value) == -1) |
||||
|
this.ban_ids.push(name.target.value); |
||||
|
this.updated = true; |
||||
|
} |
||||
|
|
||||
|
addBanIdToSearch(name: number) { |
||||
|
if (this.ban_ids == null) |
||||
|
this.ban_ids = []; |
||||
|
if (this.ban_ids.indexOf(name) == -1) |
||||
|
this.ban_ids.push(name); |
||||
|
this.updated = true; |
||||
|
} |
||||
|
|
||||
|
removeBanIdFromSearch(name: number) { |
||||
|
if (this.ban_ids == null) return; |
||||
|
this.ban_ids = this.ban_ids.filter(v => v !== name); |
||||
|
this.updated = true; |
||||
|
} |
||||
|
} |
@ -1,25 +1,102 @@ |
|||||
<div class="content-in-center-header" style="flex-direction: column;"> |
<div class="content-in-center-header" style="flex-direction: column;"> |
||||
<h1>Бан лист</h1> |
<h1>Бан лист</h1> |
||||
<h3>Скоро и ты сюда попадешь браток {{total==0?'':'как и остальные ' + total + ' карликов'}}</h3> |
<h3>Скоро и ты сюда попадешь браток {{getCount()==undefined?'':'как и остальные ' + getCount() + ' карликов'}}</h3> |
||||
</div> |
</div> |
||||
|
|
||||
<div class="content-in-center"> |
<div class="content-in-center"> |
||||
<div class="content-in-border"> |
<div class="content-in-border"> |
||||
<app-need-auth-to-continue *ngIf="authService.steamdata == null && loading == null"></app-need-auth-to-continue> |
<app-need-auth-to-continue *ngIf="!authService.isAuth()"></app-need-auth-to-continue> |
||||
<div *ngIf="loading == false"> |
<div *ngIf="authService.isAuth"> |
||||
<mat-accordion> |
<div style="padding-bottom: 10px;"> |
||||
<mat-expansion-panel *ngFor="let ban of bans"> |
<mat-chip-list> |
||||
<mat-expansion-panel-header> |
<mat-chip [matMenuTriggerFor]="addFilter">Искать по...</mat-chip> |
||||
<mat-panel-title> |
<mat-menu #addFilter> |
||||
<p>#{{ban.id}} {{ban.player_name}}</p> |
<button mat-menu-item (click)="filter.addAccountToSearch('')">Профилю</button> |
||||
</mat-panel-title> |
<button mat-menu-item [matMenuTriggerFor]="timeSelect">Времени</button> |
||||
<mat-panel-description> |
</mat-menu> |
||||
<p>{{ban.timestamp | date:'dd/MM/YYYY hh:mm:ss'}}</p> |
<mat-menu #timeSelect> |
||||
</mat-panel-description> |
<button mat-menu-item (click)="filter.addEndTimeToSearch()">До ...</button> |
||||
</mat-expansion-panel-header> |
<button mat-menu-item (click)="filter.addBeginTimeToSearch()">После ...</button> |
||||
<p>А хуй знает я еще не приудмал</p> |
</mat-menu> |
||||
</mat-expansion-panel> |
|
||||
</mat-accordion> |
<mat-chip *ngIf="filter.updated" (click)="updateData()">Обновить</mat-chip> |
||||
|
<app-filter-mat-chip-account |
||||
|
[filter]="filter" |
||||
|
></app-filter-mat-chip-account> |
||||
|
<app-filter-mat-chip-date-begin |
||||
|
[filter]="filter"> |
||||
|
</app-filter-mat-chip-date-begin> |
||||
|
<app-filter-mat-chip-date-end |
||||
|
[filter]="filter"> |
||||
|
</app-filter-mat-chip-date-end> |
||||
|
<app-filter-mat-chip-banid |
||||
|
[filter]="filter"> |
||||
|
</app-filter-mat-chip-banid> |
||||
|
</mat-chip-list> |
||||
|
</div> |
||||
|
<div> |
||||
|
<div class="loading-shade" |
||||
|
*ngIf="loading || err"> |
||||
|
<mat-spinner *ngIf="loading"></mat-spinner> |
||||
|
<div class="err" *ngIf="err"> |
||||
|
Слишком много запросов или сервер не отвечает, обнови страницу. |
||||
|
<br> |
||||
|
<button mat-button (click)="err=false; loading=false">Закрыть</button> |
||||
|
</div> |
||||
|
</div> |
||||
|
<table mat-table [dataSource]="dataSource" style="width: 100%"> |
||||
|
<ng-container matColumnDef="id"> |
||||
|
<th mat-header-cell *matHeaderCellDef> ID бана </th> |
||||
|
<td mat-cell *matCellDef="let row" [matMenuTriggerFor]="banIdMenu"> {{row.id}} |
||||
|
<mat-menu #banIdMenu><button mat-menu-item (click)="filter.addBanIdToSearch(row.id)">Искать по ид</button></mat-menu></td> |
||||
|
</ng-container> |
||||
|
<ng-container matColumnDef="player_name"> |
||||
|
<th mat-header-cell *matHeaderCellDef> Имя игрока </th> |
||||
|
<td mat-cell *matCellDef="let row" [matMenuTriggerFor]="accountMenu"> {{row.player_name}} |
||||
|
<mat-menu #accountMenu> |
||||
|
<button mat-menu-item (click)="filter.addAccountToSearch(row.player_name)">Добавить в поиск</button> |
||||
|
<button mat-menu-item (click)="searchPlayer(row.account_id)">Открыть профиль</button> |
||||
|
</mat-menu></td> |
||||
|
</ng-container> |
||||
|
<ng-container matColumnDef="date"> |
||||
|
<th mat-header-cell *matHeaderCellDef> Время </th> |
||||
|
<td mat-cell *matCellDef="let row" [matMenuTriggerFor]="dateMenu"> {{row.timestamp | date:"HH:mm dd/MM/yyyy"}} |
||||
|
<mat-menu #dateMenu> |
||||
|
<button mat-menu-item (click)="filter.addEndTimeToSearch(row.timestamp)">Искать до {{row.timestamp | date:"HH:mm:ss dd/MM/yyyy"}}</button> |
||||
|
<button mat-menu-item (click)="filter.addBeginTimeToSearch(row.timestamp)">Искать после {{row.timestamp | date:"HH:mm:ss dd/MM/yyyy"}}</button> |
||||
|
</mat-menu></td> |
||||
|
</ng-container> |
||||
|
<ng-container matColumnDef="reason"> |
||||
|
<th mat-header-cell *matHeaderCellDef> Причина </th> |
||||
|
<td mat-cell *matCellDef="let row"> {{row.ban_reason}}</td> |
||||
|
</ng-container> |
||||
|
<ng-container matColumnDef="admin_name"> |
||||
|
<th mat-header-cell *matHeaderCellDef> Модератор </th> |
||||
|
<td mat-cell *matCellDef="let row"> {{row.banned_by}}</td> |
||||
|
</ng-container> |
||||
|
<ng-container matColumnDef="action"> |
||||
|
<th mat-header-cell *matHeaderCellDef> Действие </th> |
||||
|
<td mat-cell *matCellDef="let row"> пук</td> |
||||
|
</ng-container> |
||||
|
|
||||
|
|
||||
|
<tr mat-header-row *matHeaderRowDef="displayedColumns"></tr> |
||||
|
<tr mat-row *matRowDef="let row; columns: displayedColumns;"></tr> |
||||
|
|
||||
|
<!-- Row shown when there is no matching data. --> |
||||
|
<div *ngIf="!loading"> |
||||
|
<tr class="mat-row" *matNoDataRow> |
||||
|
<td class="mat-cell" colspan="4">Бан лист пуст</td> |
||||
|
</tr> |
||||
|
</div> |
||||
|
</table> |
||||
|
|
||||
|
<mat-paginator |
||||
|
[pageSizeOptions]="[5, 10, 25, 100]" |
||||
|
[pageSize]="10" |
||||
|
(page)="updateData()" |
||||
|
></mat-paginator> |
||||
|
</div> |
||||
</div> |
</div> |
||||
</div> |
</div> |
||||
</div> |
</div> |
||||
|
@ -0,0 +1,20 @@ |
|||||
|
.loading-shade { |
||||
|
position: absolute; |
||||
|
top: 0; |
||||
|
left: 0; |
||||
|
bottom: 0; |
||||
|
right: 0; |
||||
|
background: rgba(0, 0, 0, 0.15); |
||||
|
z-index: 1; |
||||
|
display: flex; |
||||
|
align-items: center; |
||||
|
justify-content: center; |
||||
|
} |
||||
|
|
||||
|
.err { |
||||
|
max-width: 360px; |
||||
|
text-align: center; |
||||
|
background: white; |
||||
|
border-radius: 15px; |
||||
|
border: 0px solid black; |
||||
|
} |
@ -0,0 +1,28 @@ |
|||||
|
import {Component, Input} from "@angular/core"; |
||||
|
import {BanSearchFilter} from "../../../entities/search/BanSearchFilter"; |
||||
|
|
||||
|
@Component({ |
||||
|
selector: "app-filter-mat-chip-banid", |
||||
|
template: ` |
||||
|
<div *ngIf="filter && filter.ban_ids != null"> |
||||
|
<mat-chip |
||||
|
*ngFor="let acId of filter.ban_ids" |
||||
|
(removed)="filter.removeBanIdFromSearch(acId)" |
||||
|
[matMenuTriggerFor]="profileSearch">Ид: {{acId}} |
||||
|
<button matChipRemove> |
||||
|
<mat-icon>cancel</mat-icon> |
||||
|
</button> |
||||
|
<mat-menu #profileSearch> |
||||
|
<mat-form-field appearance="fill" (click)="$event.stopPropagation()"> |
||||
|
<mat-label>Ид бана без #</mat-label> |
||||
|
<input matInput placeholder="228" type="number" [ngModel]="acId" (change)="filter.changeBanIdToSearch(acId, $event)"> |
||||
|
</mat-form-field> |
||||
|
</mat-menu> |
||||
|
</mat-chip> |
||||
|
</div>` |
||||
|
}) |
||||
|
export class FilterMatChipBanId { |
||||
|
|
||||
|
@Input("filter") |
||||
|
filter: BanSearchFilter|undefined; |
||||
|
} |
@ -0,0 +1,26 @@ |
|||||
|
import {Component, Input} from "@angular/core"; |
||||
|
import {SearchFilter} from "../../../entities/search/SearchFilter"; |
||||
|
import {MessageSearchFilter} from "../../../entities/search/MessageSearchFilter"; |
||||
|
|
||||
|
@Component({ |
||||
|
selector: "app-filter-mat-chip-message", |
||||
|
template: ` |
||||
|
<mat-chip |
||||
|
*ngIf="filter && filter.message!=null" |
||||
|
(removed)="filter.removeMessageFromSearch()" [matMenuTriggerFor]="contentSearch">Сообщение содержит: {{filter.message}} |
||||
|
<button matChipRemove> |
||||
|
<mat-icon>cancel</mat-icon> |
||||
|
</button> |
||||
|
<mat-menu #contentSearch> |
||||
|
<mat-form-field appearance="fill" (click)="$event.stopPropagation()"> |
||||
|
<mat-label>Сообщение содержит...</mat-label> |
||||
|
<input matInput placeholder="люблю россию и путина" [ngModel]="filter.message" (ngModelChange)="filter.addMessageToSearch($event)"> |
||||
|
</mat-form-field> |
||||
|
</mat-menu> |
||||
|
</mat-chip> |
||||
|
` |
||||
|
}) |
||||
|
export class FilterMatChipMessage { |
||||
|
@Input("filter") |
||||
|
filter: MessageSearchFilter|undefined; |
||||
|
} |
@ -0,0 +1,28 @@ |
|||||
|
import {Component, Input} from "@angular/core"; |
||||
|
import {SearchFilter} from "../../../../entities/search/SearchFilter"; |
||||
|
|
||||
|
@Component({ |
||||
|
selector: "app-filter-mat-chip-account", |
||||
|
template: ` |
||||
|
<div *ngIf="filter && filter.accounts != null"> |
||||
|
<mat-chip |
||||
|
*ngFor="let acId of filter.accounts" |
||||
|
(removed)="filter.removeAccountFromSearch(acId)" |
||||
|
[matMenuTriggerFor]="profileSearch">Профиль: {{acId}} |
||||
|
<button matChipRemove> |
||||
|
<mat-icon>cancel</mat-icon> |
||||
|
</button> |
||||
|
<mat-menu #profileSearch> |
||||
|
<mat-form-field appearance="fill" (click)="$event.stopPropagation()"> |
||||
|
<mat-label>Ссылка, имя, все что угодно</mat-label> |
||||
|
<input matInput placeholder="отдыхаем" [ngModel]="acId" (change)="filter.changeAccountToSearch(acId, $event)"> |
||||
|
</mat-form-field> |
||||
|
</mat-menu> |
||||
|
</mat-chip> |
||||
|
</div>` |
||||
|
}) |
||||
|
export class FilterMatChipAccount { |
||||
|
|
||||
|
@Input("filter") |
||||
|
filter: SearchFilter|undefined; |
||||
|
} |
@ -0,0 +1,29 @@ |
|||||
|
import {Component, Input} from "@angular/core"; |
||||
|
import {SearchFilter} from "../../../../entities/search/SearchFilter"; |
||||
|
|
||||
|
@Component({ |
||||
|
selector: "app-filter-mat-chip-date-begin", |
||||
|
template: ` |
||||
|
<mat-chip |
||||
|
*ngIf="filter && filter.begin!=null" |
||||
|
(removed)="filter.removeBeginTimeFromSearch()" |
||||
|
[matMenuTriggerFor]="dateBeginSelect"> |
||||
|
Дата после {{filter.begin | date:"HH:mm dd/MM/yyyy"}} |
||||
|
<button matChipRemove> |
||||
|
<mat-icon>cancel</mat-icon> |
||||
|
</button> |
||||
|
<mat-menu #dateBeginSelect> |
||||
|
<mat-form-field appearance="fill" |
||||
|
(click)="$event.stopPropagation()"> |
||||
|
<mat-label>Дата после</mat-label> |
||||
|
<input matInput type="datetime-local" |
||||
|
[(ngModel)]="filter.begin" |
||||
|
(ngModelChange)="filter.addBeginTimeToSearch($event)"> |
||||
|
</mat-form-field> |
||||
|
</mat-menu> |
||||
|
</mat-chip>` |
||||
|
})//todo mb abstract
|
||||
|
export class FilterMatChipDateBegin { |
||||
|
@Input("filter") |
||||
|
filter: SearchFilter|undefined; |
||||
|
} |
@ -0,0 +1,29 @@ |
|||||
|
import {Component, Input} from "@angular/core"; |
||||
|
import {SearchFilter} from "../../../../entities/search/SearchFilter"; |
||||
|
|
||||
|
@Component( |
||||
|
{ selector: "app-filter-mat-chip-date-end", |
||||
|
template: ` |
||||
|
<mat-chip |
||||
|
*ngIf="filter && filter.end!=null" |
||||
|
(removed)="filter.removeEndTimeFromSearch()" |
||||
|
[matMenuTriggerFor]="dateEndSelect"> |
||||
|
Дата до {{filter.end | date:"HH:mm dd/MM/yyyy"}} |
||||
|
<button matChipRemove> |
||||
|
<mat-icon>cancel</mat-icon> |
||||
|
</button> |
||||
|
<mat-menu #dateEndSelect> |
||||
|
<mat-form-field appearance="fill" |
||||
|
(click)="$event.stopPropagation()"> |
||||
|
<mat-label>Дата после</mat-label> |
||||
|
<input matInput type="datetime-local" |
||||
|
[(ngModel)]="filter.end" |
||||
|
(ngModelChange)="filter.addEndTimeToSearch($event)"> |
||||
|
</mat-form-field> |
||||
|
</mat-menu> |
||||
|
</mat-chip>`} |
||||
|
) |
||||
|
export class FilterMatChipDateEnd { |
||||
|
@Input("filter") |
||||
|
filter: SearchFilter|undefined; |
||||
|
} |
@ -0,0 +1,34 @@ |
|||||
|
import {Component, Input} from "@angular/core"; |
||||
|
import {SearchFilter} from "../../../../entities/search/SearchFilter"; |
||||
|
|
||||
|
@Component({ |
||||
|
selector: "app-filter-mat-chip-server", |
||||
|
template: ` |
||||
|
<mat-chip *ngIf="filter && filter.serverId!=null" |
||||
|
(removed)="filter.removeServerFromSearch()" [matMenuTriggerFor]="serverSelect"> |
||||
|
{{getServerName?getServerName(filter.serverId):filter.serverId}} |
||||
|
<button matChipRemove> |
||||
|
<mat-icon>cancel</mat-icon> |
||||
|
</button> |
||||
|
<mat-menu #serverSelect> |
||||
|
<button mat-menu-item *ngFor="let server of serverList" (click)="filter.addServerToSearch(server.server_id)">{{server.name}}</button> |
||||
|
</mat-menu> |
||||
|
</mat-chip> |
||||
|
` |
||||
|
}) |
||||
|
export class FilterMatChipServer { |
||||
|
@Input("filter") |
||||
|
filter: SearchFilter|undefined; |
||||
|
|
||||
|
@Input("serverList") |
||||
|
serverList:{name: string, server_id: string }[] = [] |
||||
|
|
||||
|
getServerName(server_id: string|null) { |
||||
|
try { |
||||
|
// @ts-ignore
|
||||
|
return this.serverList.filter(s => s.server_id == server_id).pop().name; |
||||
|
} catch (e) { |
||||
|
return "Выбрать сервер"; |
||||
|
} |
||||
|
} |
||||
|
} |
Loading…
Reference in new issue