Replace @Input with input decorator in HistoryComponent
This commit is contained in:
parent
d4b09a500f
commit
8657a33e65
|
|
@ -1,4 +1,4 @@
|
|||
import {Component, EventEmitter, inject, Input, OnChanges, OnInit, Output} from '@angular/core';
|
||||
import {Component, EventEmitter, inject, input, OnChanges, OnInit, Output} from '@angular/core';
|
||||
import {HistoryService, PunishmentHistory} from '@api';
|
||||
import {catchError, map, Observable, shareReplay} from 'rxjs';
|
||||
import {NgOptimizedImage} from '@angular/common';
|
||||
|
|
@ -28,10 +28,10 @@ import {MatIconModule} from '@angular/material/icon';
|
|||
})
|
||||
export class HistoryComponent implements OnInit, OnChanges {
|
||||
|
||||
@Input() userType: 'player' | 'staff' = "player";
|
||||
@Input() punishmentType: 'all' | 'ban' | 'mute' | 'kick' | 'warn' = "all";
|
||||
@Input() page: number = 0;
|
||||
@Input() searchTerm: string = '';
|
||||
userType = input<'player' | 'staff'>("player");
|
||||
punishmentType = input<'all' | 'ban' | 'mute' | 'kick' | 'warn'>("all");
|
||||
page = input<number>(0);
|
||||
searchTerm = input<string>('');
|
||||
|
||||
@Output() pageChange = new EventEmitter<number>();
|
||||
@Output() selectItem = new EventEmitter<SearchParams>();
|
||||
|
|
@ -56,13 +56,13 @@ export class HistoryComponent implements OnInit, OnChanges {
|
|||
|
||||
private reloadHistory(): void {
|
||||
let historyObservable: Observable<PunishmentHistory[]>;
|
||||
if (this.searchTerm.length === 0) {
|
||||
historyObservable = this.historyApi.getHistoryForAll(this.userType, this.punishmentType, this.page);
|
||||
if (this.searchTerm().length === 0) {
|
||||
historyObservable = this.historyApi.getHistoryForAll(this.userType(), this.punishmentType(), this.page());
|
||||
} else {
|
||||
if (this.uuidRegex.test(this.searchTerm)) {
|
||||
historyObservable = this.historyApi.getHistoryForUuid(this.userType, this.punishmentType, this.searchTerm, this.page);
|
||||
if (this.uuidRegex.test(this.searchTerm())) {
|
||||
historyObservable = this.historyApi.getHistoryForUuid(this.userType(), this.punishmentType(), this.searchTerm(), this.page());
|
||||
} else {
|
||||
historyObservable = this.historyApi.getHistoryForUsers(this.userType, this.punishmentType, this.searchTerm, this.page);
|
||||
historyObservable = this.historyApi.getHistoryForUsers(this.userType(), this.punishmentType(), this.searchTerm(), this.page());
|
||||
}
|
||||
}
|
||||
historyObservable.pipe(
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user