From a05a751628156290fd11322101b3201fd507c395 Mon Sep 17 00:00:00 2001 From: akastijn Date: Sat, 8 Nov 2025 18:45:03 +0100 Subject: [PATCH] Remove redundant unit tests for `CommunityComponent` and `RanksComponent`, enhance `community.component` with dynamic team member display and toggle functionality, update routing for community links, and set stricter field constraints in team schema. --- .../community/community.component.html | 75 ++++++++++++++++--- .../community/community.component.scss | 34 +++++++-- .../community/community.component.spec.ts | 23 ------ .../altitude/community/community.component.ts | 56 +++++++++++++- .../reference/ranks/ranks.component.html | 15 ++-- .../reference/ranks/ranks.component.spec.ts | 23 ------ .../pages/reference/ranks/ranks.component.ts | 4 +- .../src/main/resources/schemas/team/team.yml | 2 + 8 files changed, 162 insertions(+), 70 deletions(-) delete mode 100644 frontend/src/app/pages/altitude/community/community.component.spec.ts delete mode 100644 frontend/src/app/pages/reference/ranks/ranks.component.spec.ts diff --git a/frontend/src/app/pages/altitude/community/community.component.html b/frontend/src/app/pages/altitude/community/community.component.html index a07eb3e..1163886 100644 --- a/frontend/src/app/pages/altitude/community/community.component.html +++ b/frontend/src/app/pages/altitude/community/community.component.html @@ -9,34 +9,74 @@
-
-

Current Nitro Boosters

+
+

Current Nitro Boosters

+ @for (member of getTeamMembers('discord') | async; track member) { +
+ {{member.name}}'s Minecraft skin +

{{ member.name }}

+

Nitro booster

+
+ }
-
+

Social Media

+ @for (member of getTeamMembers('socialmedia') | async; track member) { +
+ {{member.name}}'s Minecraft skin +

{{ member.name }}

+

Social media

+
+ }

We're currently not looking for more people to help manage our socials.

-
+

Crate Team

+ @for (member of getTeamMembers('crate') | async; track member) { +
+ {{member.name}}'s Minecraft skin +

{{ member.name }}

+

Crate team

+
+ }
-
+

Event Leaders

+ @for (member of getTeamMembers('eventleader') | async; track member) { +
+ {{member.name}}'s Minecraft skin +

{{ member.name }}

+

Event leaders

+
+ }

We're currently not looking for more Event Leaders.

-
+

Event Team

+ @for (member of getTeamMembers('eventteam') | async; track member) { +
+ {{member.name}}'s Minecraft skin +

{{ member.name }}

+

Event team

+
+ }
@@ -47,15 +87,32 @@
-
+

YouTubers & Streamers

+ @for (member of getTeamMembers('youtube') | async; track member) { +
+ {{member.name}}'s Minecraft skin +

{{ member.name }}

+

Youtuber

+
+ } + @for (member of getTeamMembers('twitch') | async; track member) { +
+ {{member.name}}'s Minecraft skin +

{{ member.name }}

+

Streamer

+
+ }
-
+

Requirements:

diff --git a/frontend/src/app/pages/altitude/community/community.component.scss b/frontend/src/app/pages/altitude/community/community.component.scss index 402b822..c3b5c9f 100644 --- a/frontend/src/app/pages/altitude/community/community.component.scss +++ b/frontend/src/app/pages/altitude/community/community.component.scss @@ -1,12 +1,32 @@ -.customContainer { - width: 80%; - max-width: 1020px; - margin: auto; - padding: 80px 0; +.sectionTitle { + flex: 0 0 100%; + text-align: center; + padding-bottom: 20px; + font-size: 2em; +} + +.member { + width: 33%; + min-width: 250px; + padding-bottom: 50px; text-align: center; } -.hide { - display: none !important; +.member img { + padding-bottom: 15px; } +.member p { + font-family: 'opensans-bold', sans-serif; +} + +.teamContainer { + padding: 50px 0 0 0; + justify-content: center; +} + +.requirementSection { + display: flex; + justify-content: center; + padding-bottom: 30px; +} diff --git a/frontend/src/app/pages/altitude/community/community.component.spec.ts b/frontend/src/app/pages/altitude/community/community.component.spec.ts deleted file mode 100644 index 1f3aa65..0000000 --- a/frontend/src/app/pages/altitude/community/community.component.spec.ts +++ /dev/null @@ -1,23 +0,0 @@ -import { ComponentFixture, TestBed } from '@angular/core/testing'; - -import { CommunityComponent } from './community.component'; - -describe('CommunityComponent', () => { - let component: CommunityComponent; - let fixture: ComponentFixture; - - beforeEach(async () => { - await TestBed.configureTestingModule({ - imports: [CommunityComponent] - }) - .compileComponents(); - - fixture = TestBed.createComponent(CommunityComponent); - component = fixture.componentInstance; - fixture.detectChanges(); - }); - - it('should create', () => { - expect(component).toBeTruthy(); - }); -}); diff --git a/frontend/src/app/pages/altitude/community/community.component.ts b/frontend/src/app/pages/altitude/community/community.component.ts index 7a067cd..9cba7b4 100644 --- a/frontend/src/app/pages/altitude/community/community.component.ts +++ b/frontend/src/app/pages/altitude/community/community.component.ts @@ -1,14 +1,66 @@ -import {Component} from '@angular/core'; +import {Component, inject} from '@angular/core'; import {HeaderComponent} from "@header/header.component"; +import {map, Observable, shareReplay} from 'rxjs'; +import {Player, TeamService} from '@api'; +import {ScrollService} from '@services/scroll.service'; +import {AsyncPipe, NgOptimizedImage} from '@angular/common'; @Component({ selector: 'app-community', imports: [ - HeaderComponent + HeaderComponent, + AsyncPipe, + NgOptimizedImage ], templateUrl: './community.component.html', styleUrl: './community.component.scss' }) export class CommunityComponent { + private teamMembersCache: { [key: string]: Observable } = {}; + protected scrollService: ScrollService = inject(ScrollService) + protected teamService: TeamService = inject(TeamService) + + public getTeamMembers(team: string): Observable { + if (!this.teamMembersCache[team]) { + this.teamMembersCache[team] = this.teamService.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`; + } + + public toggledSections: string[] = []; + + public isToggled(section: string) { + return this.toggledSections.includes(section); + } + + public toggleSection(section: string) { + if (this.isToggled(section)) { + this.toggledSections = this.toggledSections.filter(s => s !== section); + } else { + this.toggledSections.push(section); + } + } + + public getTextForSection(section: string) { + if (this.isToggled(section)) { + return 'Hide Requirements...'; + } else { + return 'Show Requirements...'; + } + } } diff --git a/frontend/src/app/pages/reference/ranks/ranks.component.html b/frontend/src/app/pages/reference/ranks/ranks.component.html index e49c11c..27810fb 100644 --- a/frontend/src/app/pages/reference/ranks/ranks.component.html +++ b/frontend/src/app/pages/reference/ranks/ranks.component.html @@ -197,27 +197,32 @@ [Social Media] - See requirements on the Community page + See requirements on the Community page + /record
/ptime
/pweather [Streamer] - See requirements on the Community page + See requirements on the Community page + /record
/ptime
/pweather [YouTube] - See requirements on the Community page + See requirements on the Community page + /record
/ptime
/pweather [Event Leader] - See requirements on the Community page + See requirements on the Community page + Build perms on event server [Event Team] - See requirements on the Community page + See requirements on the Community page + Build perms on event server diff --git a/frontend/src/app/pages/reference/ranks/ranks.component.spec.ts b/frontend/src/app/pages/reference/ranks/ranks.component.spec.ts deleted file mode 100644 index 27029d5..0000000 --- a/frontend/src/app/pages/reference/ranks/ranks.component.spec.ts +++ /dev/null @@ -1,23 +0,0 @@ -import { ComponentFixture, TestBed } from '@angular/core/testing'; - -import { RanksComponent } from './ranks.component'; - -describe('RanksComponent', () => { - let component: RanksComponent; - let fixture: ComponentFixture; - - beforeEach(async () => { - await TestBed.configureTestingModule({ - imports: [RanksComponent] - }) - .compileComponents(); - - fixture = TestBed.createComponent(RanksComponent); - component = fixture.componentInstance; - fixture.detectChanges(); - }); - - it('should create', () => { - expect(component).toBeTruthy(); - }); -}); diff --git a/frontend/src/app/pages/reference/ranks/ranks.component.ts b/frontend/src/app/pages/reference/ranks/ranks.component.ts index 6699cab..d8c1ec2 100644 --- a/frontend/src/app/pages/reference/ranks/ranks.component.ts +++ b/frontend/src/app/pages/reference/ranks/ranks.component.ts @@ -1,10 +1,12 @@ import {Component} from '@angular/core'; import {HeaderComponent} from "@header/header.component"; +import {RouterLink} from '@angular/router'; @Component({ selector: 'app-ranks', imports: [ - HeaderComponent + HeaderComponent, + RouterLink ], templateUrl: './ranks.component.html', styleUrl: './ranks.component.scss' diff --git a/open_api/src/main/resources/schemas/team/team.yml b/open_api/src/main/resources/schemas/team/team.yml index 23872c8..53f70e1 100644 --- a/open_api/src/main/resources/schemas/team/team.yml +++ b/open_api/src/main/resources/schemas/team/team.yml @@ -12,6 +12,8 @@ getTeam: description: The group name of the team schema: type: string + example: owner + maxLength: 32 responses: '200': description: successful operation