import {AfterViewInit, ChangeDetectorRef, Component, OnInit, ViewChild} from '@angular/core'; import {AuthService} from "../../services/auth.service"; import {MatTableDataSource} from "@angular/material/table"; import {MatPaginator, MatPaginatorIntl} from "@angular/material/paginator"; import {MatSort} from "@angular/material/sort"; import {Message} from "../../entities/profile/Message"; import {MessageService} from "../../services/message.service"; import {AbstractSearchTable} from "../internal-components/abstract-search-table.component"; import {SearchFilter} from "../../entities/search/SearchFilter"; import {ServerService} from "../../services/server.service"; import {MessageSearchFilter} from "../../entities/search/MessageSearchFilter"; import {PlayerService} from "../../services/player.service"; import {Router} from "@angular/router"; @Component({ selector: 'app-messages-page', templateUrl: './messages-page.component.html', styleUrls: ['./messages-page.component.scss'] }) export class MessagesPageComponent extends AbstractSearchTable { displayedColumns: string[] = ['account_name', 'date', 'message', 'serverName']; constructor(public authService: AuthService, private messageService: MessageService, protected override serverService: ServerService, private playerService: PlayerService, private router: Router) { super(serverService); super.filter = new MessageSearchFilter(); } getMessages(): boolean { this.filter.updated = false; this.messageService.getMessages(this.filter, this.paginator).subscribe( (res) => { this.dataSource = new MatTableDataSource(res.data); } ) return true; } override updateData() { this.getMessages(); } addMessageToSearch(name: string) { this.filter.message = name; this.filter.updated = true; } removeMessageFromSearch() { this.filter.message = null; this.filter.updated = true; } searchPlayer(search: string) { if (search.length == 0) { return; } if (!this.authService.isAuth()) { return; } this.playerService.searchProfile(search).subscribe( (res) => { if (res.steam64 != null) this.router.navigate(['profile', res.steam64]) }, (err) => {} ) } }