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