Rework folder structure in frontend
Pages are now grouped per group they appear in on in the header (where possible) Utilities used by multiple pages in the project are grouped in folders such as services/pipes/etc
This commit is contained in:
@@ -0,0 +1,53 @@
|
||||
import {Component} from '@angular/core';
|
||||
import {ScrollService} from '@services/scroll.service';
|
||||
import {BASE_PATH, Player, TeamService} from '@api';
|
||||
import {CommonModule, NgOptimizedImage} from '@angular/common';
|
||||
import {HeaderComponent} from '@header/header.component';
|
||||
import {CookieService} from 'ngx-cookie-service';
|
||||
import {map, Observable, shareReplay} from 'rxjs';
|
||||
import {environment} from '@environment';
|
||||
|
||||
@Component({
|
||||
selector: 'app-team',
|
||||
standalone: true,
|
||||
imports: [
|
||||
CommonModule,
|
||||
HeaderComponent,
|
||||
NgOptimizedImage
|
||||
],
|
||||
providers: [
|
||||
CookieService,
|
||||
{provide: BASE_PATH, useValue: environment.apiUrl}
|
||||
],
|
||||
|
||||
templateUrl: './team.component.html',
|
||||
styleUrl: './team.component.scss'
|
||||
})
|
||||
export class TeamComponent {
|
||||
|
||||
private teamMembersCache: { [key: string]: Observable<Player[]> } = {};
|
||||
|
||||
constructor(public scrollService: ScrollService, public teamApi: TeamService) {
|
||||
}
|
||||
|
||||
public getTeamMembers(team: string): Observable<Player[]> {
|
||||
if (!this.teamMembersCache[team]) {
|
||||
this.teamMembersCache[team] = this.teamApi.getTeamMembers(team).pipe(
|
||||
map(res => this.removeDuplicates(res)),
|
||||
shareReplay(1)
|
||||
);
|
||||
}
|
||||
return this.teamMembersCache[team];
|
||||
}
|
||||
|
||||
private removeDuplicates(array: Player[]): Player[] {
|
||||
return array.filter((player, index, self) =>
|
||||
index === self.findIndex((p) => p.uuid === player.uuid)
|
||||
);
|
||||
}
|
||||
|
||||
public getAvatarUrl(entry: Player): string {
|
||||
let uuid = entry.uuid.replace('-', '');
|
||||
return `https://crafatar.com/avatars/${uuid}?overlay`;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user