Compare commits

..

No commits in common. "905373093ce0dea8cdba6a922e47620f3a7147e6" and "53f67a50752cfb1408711f4e20a4d1511a71b4dd" have entirely different histories.

7 changed files with 9 additions and 63 deletions

View File

@ -15,11 +15,10 @@ import org.springframework.web.bind.annotation.RestController;
import java.util.List;
import java.util.UUID;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.TimeUnit;
@Slf4j
@RestController
@RateLimit(limit = 30, timeValue = 1, timeUnit = TimeUnit.MINUTES)
@RateLimit(limit = 30, timeValue = 1, timeUnit = java.util.concurrent.TimeUnit.SECONDS)
public class HistoryApiController implements HistoryApi {
@Override

View File

@ -76,7 +76,6 @@ public class RateLimitAspect {
.header("X-Rate-Limit-Limit", String.valueOf(limit))
.header("X-Rate-Limit-Remaining", "0")
.header("Retry-After", String.valueOf(nextResetTime.getSeconds()))
.header("Access-Control-Expose-Headers", "Retry-After, X-Rate-Limit-Limit, X-Rate-Limit-Remaining")
.body(String.format("Rate limit exceeded. Try again in %d seconds.", nextResetTime.getSeconds()));
}
}

View File

@ -48,7 +48,7 @@
</div>
<div class="historyTable">
<app-history [userType]="userType" [punishmentType]="punishmentType"
[page]="page" [searchTerm]="finalSearchTerm" (pageChange)="updatePageSize($event)">
[page]="page" [searchTerm]="finalSearchTerm" (pageChange)="pageSize = $event">
</app-history>
</div>
<div class="changePageButtons">

View File

@ -40,14 +40,13 @@ export class BansComponent implements OnInit {
public finalSearchTerm: string = '';
public searchTerm: string = '';
public filteredNames: string[] = [];
public pageSize = 10;
public pageSize = 0;
public historyCount: HistoryCount = {
bans: 0,
mutes: 0,
kicks: 0,
warnings: 0
}
private actualPage: number = 0;
ngOnInit() {
this.historyApi.getUserNames(this.userType, this.punishmentType).subscribe(names => {
@ -109,21 +108,17 @@ export class BansComponent implements OnInit {
if (this.page === this.getMaxPage()) {
return;
}
this.setPage(this.page + 1)
this.setPage(++this.page)
}
public previousPage() {
if (this.page === 0) {
return;
}
this.setPage(this.page - 1)
this.setPage(--this.page)
}
public setPage(page: number) {
if (this.actualPage !== this.page) {
console.warn('Changing page too quickly, the previous page change has not loaded yet');
return;
}
this.pushState();
this.page = page
}
@ -164,13 +159,4 @@ export class BansComponent implements OnInit {
}
return this.page !== compare;
}
public updatePageSize(pageSize: number) {
if (pageSize < 0) {
return;
} else {
this.pageSize = pageSize;
this.actualPage = this.page;
}
}
}

View File

@ -34,7 +34,7 @@
<span>{{ entry.punishedBy }}</span>
</div>
</td>
<td class="historyReason">{{ entry.reason | removeTrailingPeriod }}</td>
<td class="historyReason">{{ entry.reason }}</td>
<td class="historyDate">{{ getPunishmentTime(entry) }}</td>
<td class="historyDate">{{ getExpiredTime(entry) }}</td>
</tr>

View File

@ -1,18 +1,15 @@
import {Component, EventEmitter, Input, OnChanges, OnInit, Output} from '@angular/core';
import {BASE_PATH, HistoryService, PunishmentHistoryInner} from '../../../api';
import {catchError, map, Observable, shareReplay} from 'rxjs';
import {map, Observable, shareReplay} from 'rxjs';
import {NgForOf, NgIf, NgOptimizedImage} from '@angular/common';
import {CookieService} from 'ngx-cookie-service';
import {RemoveTrailingPeriodPipe} from '../../util/RemoveTrailingPeriodPipe';
import {HttpErrorResponse} from '@angular/common/http';
@Component({
selector: 'app-history',
imports: [
NgIf,
NgForOf,
NgOptimizedImage,
RemoveTrailingPeriodPipe
NgOptimizedImage
],
templateUrl: './history.component.html',
styleUrl: './history.component.scss',
@ -39,6 +36,7 @@ export class HistoryComponent implements OnInit, OnChanges {
ngOnChanges(): void {
this.reloadHistory();
this.pageChange.emit(this.history.length);
}
ngOnInit(): void {
@ -59,27 +57,6 @@ export class HistoryComponent implements OnInit, OnChanges {
historyObservable.pipe(
map(history => {
this.history = history;
this.pageChange.emit(this.history.length);
}),
catchError(err => {
this.pageChange.emit(-1);
let retrySeconds = 5;
if (err instanceof HttpErrorResponse) {
const headers = err.headers;
const retryAfterHeader = headers.get('Retry-After');
console.warn(err.error);
if (retryAfterHeader) {
const retryAfter = parseInt(retryAfterHeader || '0', 10);
if (!isNaN(retryAfter) && retryAfter > 0) {
retrySeconds = retryAfter + 1;
}
}
} else {
console.error(err);
}
setTimeout(() => this.reloadHistory(), retrySeconds * 1000);
return this.history;
}),
shareReplay(1)
).subscribe();

View File

@ -1,15 +0,0 @@
import { Pipe, PipeTransform } from '@angular/core';
@Pipe({
name: 'removeTrailingPeriod',
standalone: true
})
export class RemoveTrailingPeriodPipe implements PipeTransform {
transform(value: string): string {
if (!value) {
return value;
}
return value.endsWith('.') ? value.slice(0, -1) : value;
}
}