2024-03-09 13:33:12 +00:00
|
|
|
import {Component, OnInit} from '@angular/core';
|
2024-02-23 10:44:44 +00:00
|
|
|
import {Router, RouterLink, RouterOutlet} from "@angular/router";
|
2024-02-17 19:54:56 +00:00
|
|
|
import {UserService} from "../corelib/service/user.service";
|
2024-03-09 13:33:12 +00:00
|
|
|
import {DecimalPipe, NgIf} from '@angular/common';
|
2024-02-23 10:44:44 +00:00
|
|
|
import {FormsModule} from '@angular/forms';
|
2024-03-09 13:33:12 +00:00
|
|
|
import {Observable} from "rxjs";
|
|
|
|
|
import {environment} from "../environments/environment";
|
|
|
|
|
import {LocalCacheService} from "../corelib/service/local-cache.service";
|
|
|
|
|
|
|
|
|
|
interface Statistics {
|
|
|
|
|
total_beatmaps: number;
|
|
|
|
|
total_users: number;
|
|
|
|
|
total_scores: number;
|
|
|
|
|
total_replay_scores: number;
|
|
|
|
|
total_replay_similarity: number;
|
|
|
|
|
total_bans: number;
|
|
|
|
|
}
|
|
|
|
|
|
2024-02-14 16:43:11 +00:00
|
|
|
|
|
|
|
|
@Component({
|
|
|
|
|
selector: 'app-root',
|
2024-02-23 10:44:44 +00:00
|
|
|
standalone: true,
|
2024-03-09 13:33:12 +00:00
|
|
|
imports: [
|
|
|
|
|
RouterLink,
|
|
|
|
|
FormsModule,
|
|
|
|
|
NgIf,
|
|
|
|
|
RouterOutlet,
|
|
|
|
|
DecimalPipe
|
|
|
|
|
],
|
2024-02-14 16:43:11 +00:00
|
|
|
templateUrl: './app.component.html',
|
|
|
|
|
styleUrls: ['./app.component.css']
|
|
|
|
|
})
|
2024-03-09 13:33:12 +00:00
|
|
|
export class AppComponent implements OnInit {
|
2024-02-14 16:43:11 +00:00
|
|
|
|
2024-03-09 13:33:12 +00:00
|
|
|
statistics: Statistics | null = null;
|
2024-02-14 16:43:11 +00:00
|
|
|
term: string = '';
|
|
|
|
|
|
2024-02-17 19:54:56 +00:00
|
|
|
constructor(private router: Router,
|
2024-03-09 13:33:12 +00:00
|
|
|
private localCacheService: LocalCacheService,
|
2024-02-17 19:54:56 +00:00
|
|
|
public userService: UserService
|
2024-03-09 13:33:12 +00:00
|
|
|
) { }
|
|
|
|
|
|
|
|
|
|
ngOnInit(): void {
|
|
|
|
|
this.getStatistics().subscribe((response: Statistics) => {
|
|
|
|
|
this.statistics = response;
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
getStatistics(): Observable<Statistics> {
|
|
|
|
|
return this.localCacheService.fetchData<Statistics>(
|
|
|
|
|
'statistics',
|
|
|
|
|
`${environment.apiUrl}/stats`,
|
|
|
|
|
60
|
|
|
|
|
);
|
2024-02-23 10:44:44 +00:00
|
|
|
}
|
2024-02-14 16:43:11 +00:00
|
|
|
|
|
|
|
|
onSubmit(): void {
|
|
|
|
|
this.router.navigate(['/u/' + this.term])
|
|
|
|
|
.then();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|