-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
16 changed files
with
306 additions
and
14 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 6 additions & 0 deletions
6
src/app/components/minecraft-head/minecraft-head.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<img | ||
ngSrc="https://minotar.net/avatar/{{ username }}/{{ size }}.png" | ||
[width]="size" | ||
[height]="size" | ||
alt="Slin Minecraft de {{ username}}" | ||
This comment has been minimized.
Sorry, something went wrong. |
||
> |
Empty file.
23 changes: 23 additions & 0 deletions
23
src/app/components/minecraft-head/minecraft-head.component.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import {ComponentFixture, TestBed} from '@angular/core/testing'; | ||
|
||
import {MinecraftHeadComponent} from './minecraft-head.component'; | ||
|
||
describe('MinecraftHeadComponent', () => { | ||
let component: MinecraftHeadComponent; | ||
let fixture: ComponentFixture<MinecraftHeadComponent>; | ||
|
||
beforeEach(async () => { | ||
await TestBed.configureTestingModule({ | ||
imports: [MinecraftHeadComponent] | ||
}) | ||
.compileComponents(); | ||
|
||
fixture = TestBed.createComponent(MinecraftHeadComponent); | ||
component = fixture.componentInstance; | ||
fixture.detectChanges(); | ||
}); | ||
|
||
it('should create', () => { | ||
expect(component).toBeTruthy(); | ||
}); | ||
}); |
18 changes: 18 additions & 0 deletions
18
src/app/components/minecraft-head/minecraft-head.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import {Component, Input} from '@angular/core'; | ||
import {NgOptimizedImage} from "@angular/common"; | ||
|
||
@Component({ | ||
selector: 'minecraft-head', | ||
standalone: true, | ||
imports: [ | ||
NgOptimizedImage | ||
], | ||
templateUrl: './minecraft-head.component.html', | ||
styleUrl: './minecraft-head.component.scss' | ||
}) | ||
export class MinecraftHeadComponent { | ||
|
||
@Input() username: string = ''; | ||
@Input() size: number = 100; | ||
|
||
} |
4 changes: 4 additions & 0 deletions
4
...-account-create-new/user-account-integrations-minecraft-account-create-new.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
<p>user-account-integrations-minecraft-account-create-new works!</p> | ||
<button class="btn btn-danger" (click)="close()"> | ||
test | ||
</button> |
Empty file.
25 changes: 25 additions & 0 deletions
25
...count-create-new/user-account-integrations-minecraft-account-create-new.component.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import {ComponentFixture, TestBed} from '@angular/core/testing'; | ||
|
||
import { | ||
UserAccountIntegrationsMinecraftAccountCreateNewComponent | ||
} from './user-account-integrations-minecraft-account-create-new.component'; | ||
|
||
describe('UserAccountIntegrationsMinecraftAccountCreateNewComponent', () => { | ||
let component: UserAccountIntegrationsMinecraftAccountCreateNewComponent; | ||
let fixture: ComponentFixture<UserAccountIntegrationsMinecraftAccountCreateNewComponent>; | ||
|
||
beforeEach(async () => { | ||
await TestBed.configureTestingModule({ | ||
imports: [UserAccountIntegrationsMinecraftAccountCreateNewComponent] | ||
}) | ||
.compileComponents(); | ||
|
||
fixture = TestBed.createComponent(UserAccountIntegrationsMinecraftAccountCreateNewComponent); | ||
component = fixture.componentInstance; | ||
fixture.detectChanges(); | ||
}); | ||
|
||
it('should create', () => { | ||
expect(component).toBeTruthy(); | ||
}); | ||
}); |
52 changes: 52 additions & 0 deletions
52
...ft-account-create-new/user-account-integrations-minecraft-account-create-new.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
import {Component, Input} from '@angular/core'; | ||
import {ErrorDto, PacifistaWebUserLinkService, UserDTO} from "@funixproductions/funixproductions-requests"; | ||
import {NgbActiveModal} from "@ng-bootstrap/ng-bootstrap"; | ||
import {HttpClient} from "@angular/common/http"; | ||
import NotificationService from "../../../../../../../../services/notifications/services/NotificationService"; | ||
import {environment} from "../../../../../../../../../environments/environment"; | ||
|
||
@Component({ | ||
selector: 'app-user-account-integrations-minecraft-account-create-new', | ||
standalone: true, | ||
imports: [], | ||
templateUrl: './user-account-integrations-minecraft-account-create-new.component.html', | ||
styleUrl: './user-account-integrations-minecraft-account-create-new.component.scss' | ||
}) | ||
export class UserAccountIntegrationsMinecraftAccountCreateNewComponent { | ||
|
||
private readonly linkService: PacifistaWebUserLinkService | ||
|
||
@Input() user?: UserDTO | ||
minecraftUsername: string = '' | ||
errorStr?: string | ||
|
||
constructor(public activeModal: NgbActiveModal, | ||
private notificationService: NotificationService, | ||
http: HttpClient) { | ||
this.linkService = new PacifistaWebUserLinkService(http, environment.production) | ||
} | ||
|
||
createLink(): void { | ||
this.errorStr = undefined | ||
|
||
if (this.minecraftUsername.length === 0) { | ||
this.errorStr = 'Le nom d\'utilisateur Minecraft ne peut pas être vide.'; | ||
return | ||
} | ||
|
||
this.linkService.linkUser(this.minecraftUsername).subscribe({ | ||
next: (link) => { | ||
this.activeModal.close() | ||
this.notificationService.info('Le compte Minecraft a été lié avec succès.') | ||
}, | ||
error: (error: ErrorDto) => { | ||
this.errorStr = error.error | ||
} | ||
}) | ||
} | ||
|
||
close() { | ||
this.activeModal.close() | ||
} | ||
|
||
} |
46 changes: 46 additions & 0 deletions
46
...ntegrations-minecraft-acccount/user-account-integrations-minecraft-account.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
<div class="row justify-content-between"> | ||
<div class="col-10"> | ||
<h2>Compte Minecraft</h2> | ||
</div> | ||
<div class="col-2"> | ||
<button class="btn btn-outline-success" (click)="refresh()"> | ||
<i class="bi bi-arrow-clockwise"></i> | ||
</button> | ||
</div> | ||
</div> | ||
|
||
<div *ngIf="loading; else doneLoading"> | ||
<div class="spinner-border text-light" role="status"> | ||
<span class="visually-hidden">Chargement...</span> | ||
</div> | ||
</div> | ||
<ng-template #doneLoading> | ||
<div *ngIf="link; else notLinked"> | ||
<div class="row"> | ||
<div class="col-2 align-content-center"> | ||
<minecraft-head | ||
[username]="link.minecraftUsername ?? ''" | ||
[size]="64"> | ||
</minecraft-head> | ||
</div> | ||
<div class="col align-content-center"> | ||
<h3>{{ link.minecraftUsername }}</h3> | ||
<button class="btn btn-danger" (click)="unlink()"> | ||
Délier le compte | ||
</button> | ||
</div> | ||
</div> | ||
</div> | ||
<ng-template #notLinked> | ||
<div *ngIf="error; else noErrorOnLink"> | ||
<p style="color: red">Une erreur est survenue veuillez réessayer ou contacter un admin.</p> | ||
</div> | ||
<ng-template #noErrorOnLink> | ||
<p>Vous n'avez pas encore lié votre compte Minecraft.</p> | ||
<button class="btn btn-success" (click)="openCreationModal()"> | ||
<i class="bi bi-link"></i> | ||
Lier le compte Minecraft | ||
</button> | ||
</ng-template> | ||
</ng-template> | ||
</ng-template> |
3 changes: 3 additions & 0 deletions
3
...ntegrations-minecraft-acccount/user-account-integrations-minecraft-account.component.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
h2 { | ||
font-size: 1.5rem; | ||
} |
25 changes: 25 additions & 0 deletions
25
...grations-minecraft-acccount/user-account-integrations-minecraft-account.component.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import {ComponentFixture, TestBed} from '@angular/core/testing'; | ||
|
||
import { | ||
UserAccountIntegrationsMinecraftAccountComponent | ||
} from './user-account-integrations-minecraft-account.component'; | ||
|
||
describe('UserAccountIntegrationsMinecraftAcccountComponent', () => { | ||
let component: UserAccountIntegrationsMinecraftAccountComponent; | ||
let fixture: ComponentFixture<UserAccountIntegrationsMinecraftAccountComponent>; | ||
|
||
beforeEach(async () => { | ||
await TestBed.configureTestingModule({ | ||
imports: [UserAccountIntegrationsMinecraftAccountComponent] | ||
}) | ||
.compileComponents(); | ||
|
||
fixture = TestBed.createComponent(UserAccountIntegrationsMinecraftAccountComponent); | ||
component = fixture.componentInstance; | ||
fixture.detectChanges(); | ||
}); | ||
|
||
it('should create', () => { | ||
expect(component).toBeTruthy(); | ||
}); | ||
}); |
84 changes: 84 additions & 0 deletions
84
...-integrations-minecraft-acccount/user-account-integrations-minecraft-account.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
import {AfterViewInit, Component, Input} from '@angular/core'; | ||
import { | ||
ErrorDto, | ||
PacifistaWebUserLinkDTO, | ||
PacifistaWebUserLinkService, | ||
UserDTO | ||
} from "@funixproductions/funixproductions-requests"; | ||
import {HttpClient} from "@angular/common/http"; | ||
import {environment} from "../../../../../../../../environments/environment"; | ||
import NotificationService from "../../../../../../../services/notifications/services/NotificationService"; | ||
import {NgbModal} from "@ng-bootstrap/ng-bootstrap"; | ||
import { | ||
UserAccountIntegrationsMinecraftAccountCreateNewComponent | ||
} from "./user-account-integrations-minecraft-account-create-new/user-account-integrations-minecraft-account-create-new.component"; | ||
|
||
@Component({ | ||
selector: 'app-user-account-integrations-minecraft-acccount', | ||
templateUrl: './user-account-integrations-minecraft-account.component.html', | ||
styleUrl: './user-account-integrations-minecraft-account.component.scss' | ||
}) | ||
export class UserAccountIntegrationsMinecraftAccountComponent implements AfterViewInit { | ||
|
||
private readonly linkService: PacifistaWebUserLinkService | ||
|
||
@Input() user: UserDTO = new UserDTO() | ||
link?: PacifistaWebUserLinkDTO | ||
|
||
error: boolean = false | ||
loading: boolean = true | ||
|
||
constructor(httpClient: HttpClient, | ||
private notificationService: NotificationService, | ||
private modalService: NgbModal) { | ||
this.linkService = new PacifistaWebUserLinkService(httpClient, environment.production) | ||
} | ||
|
||
ngAfterViewInit(): void { | ||
this.refresh() | ||
} | ||
|
||
refresh() { | ||
this.error = false | ||
this.loading = true | ||
|
||
this.linkService.getCurrentUserLink().subscribe({ | ||
next: (link) => { | ||
this.link = link | ||
this.loading = false | ||
}, | ||
error: (error: ErrorDto) => { | ||
this.link = undefined | ||
|
||
if (error.status !== 404) { | ||
this.error = true | ||
this.notificationService.onErrorRequest(error) | ||
} | ||
this.loading = false | ||
} | ||
}) | ||
} | ||
|
||
unlink(): void { | ||
this.linkService.unlinkUser().subscribe({ | ||
next: () => { | ||
this.link = undefined | ||
this.notificationService.info('Le compte Minecraft a été délié avec succès.') | ||
}, | ||
error: (error: ErrorDto) => { | ||
this.notificationService.onErrorRequest(error) | ||
} | ||
}) | ||
} | ||
|
||
openCreationModal() { | ||
const modalRef = this.modalService.open(UserAccountIntegrationsMinecraftAccountCreateNewComponent, { centered: true}); | ||
modalRef.componentInstance.user = this.user; | ||
modalRef.closed.subscribe({ | ||
next: () => { | ||
this.refresh() | ||
} | ||
}) | ||
} | ||
|
||
} |
2 changes: 1 addition & 1 deletion
2
...r/user-page/components/user-account-integrations/user-account-integrations.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
<p>user-account-integrations works!</p> | ||
<app-user-account-integrations-minecraft-acccount [user]="user"></app-user-account-integrations-minecraft-acccount> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"Slin" au lieu de "skin" (
alt
de l'image)