2025-04-11 22:54:58 +00:00
|
|
|
import {Component, OnInit} from '@angular/core';
|
2025-04-11 19:20:02 +00:00
|
|
|
import {HeaderComponent} from "../header/header.component";
|
|
|
|
|
import {HistoryComponent} from './history/history.component';
|
2025-04-11 22:54:58 +00:00
|
|
|
import {HistoryService} from '../../api';
|
|
|
|
|
import {NgForOf, NgIf} from '@angular/common';
|
|
|
|
|
import {FormsModule} from '@angular/forms';
|
2025-04-11 19:20:02 +00:00
|
|
|
|
|
|
|
|
@Component({
|
|
|
|
|
selector: 'app-bans',
|
|
|
|
|
imports: [
|
|
|
|
|
HeaderComponent,
|
2025-04-11 22:54:58 +00:00
|
|
|
HistoryComponent,
|
|
|
|
|
NgIf,
|
|
|
|
|
FormsModule,
|
|
|
|
|
NgForOf
|
2025-04-11 19:20:02 +00:00
|
|
|
],
|
|
|
|
|
templateUrl: './bans.component.html',
|
|
|
|
|
styleUrl: './bans.component.scss'
|
|
|
|
|
})
|
2025-04-11 22:54:58 +00:00
|
|
|
export class BansComponent implements OnInit {
|
|
|
|
|
|
|
|
|
|
constructor(public historyApi: HistoryService) {
|
|
|
|
|
}
|
2025-04-11 19:20:02 +00:00
|
|
|
|
|
|
|
|
public userType: 'player' | 'staff' = "player";
|
|
|
|
|
public punishmentType: 'all' | 'ban' | 'mute' | 'kick' | 'warn' = "all";
|
2025-04-11 22:54:58 +00:00
|
|
|
public names: string[] = [];
|
|
|
|
|
public searchTerm: string = '';
|
|
|
|
|
public filteredNames: string[] = [];
|
|
|
|
|
|
|
|
|
|
ngOnInit() {
|
|
|
|
|
this.historyApi.getUserNames(this.userType, this.punishmentType).subscribe(names => {
|
|
|
|
|
this.names = names;
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public filterNames() {
|
|
|
|
|
if (!this.searchTerm) {
|
|
|
|
|
this.filteredNames = [];
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
this.filteredNames = this.names.filter(name =>
|
|
|
|
|
name.toLowerCase().startsWith(this.searchTerm.toLowerCase())
|
|
|
|
|
).slice(0, 10);
|
|
|
|
|
}
|
2025-04-11 19:20:02 +00:00
|
|
|
|
2025-04-11 22:54:58 +00:00
|
|
|
public selectName(name: string) {
|
|
|
|
|
this.searchTerm = name;
|
|
|
|
|
this.filteredNames = [];
|
|
|
|
|
}
|
2025-04-11 19:20:02 +00:00
|
|
|
}
|