diff --git a/package-lock.json b/package-lock.json index 625c313..ea630b9 100644 --- a/package-lock.json +++ b/package-lock.json @@ -21,7 +21,7 @@ "@angular/platform-server": "^17.3.7", "@angular/router": "^17.3.7", "@angular/ssr": "^17.3.6", - "@funixproductions/funixproductions-requests": "^0.1.15", + "@funixproductions/funixproductions-requests": "^0.1.17", "@ng-bootstrap/ng-bootstrap": "^16.0.0", "@popperjs/core": "^2.11.8", "bootstrap": "^5.3.0", @@ -3349,9 +3349,9 @@ } }, "node_modules/@funixproductions/funixproductions-requests": { - "version": "0.1.15", - "resolved": "https://registry.npmjs.org/@funixproductions/funixproductions-requests/-/funixproductions-requests-0.1.15.tgz", - "integrity": "sha512-svqoP3JXzBKgNYrOIekychvX8A4q46sRNN6tXXiFB8QgUMaXzSiw5Mo34RvLQPI7IVYFhOcaPKllmVQhThD1Mw==", + "version": "0.1.17", + "resolved": "https://registry.npmjs.org/@funixproductions/funixproductions-requests/-/funixproductions-requests-0.1.17.tgz", + "integrity": "sha512-OFRAnFf3JnPIGzg8xTWd0/MwIgE5ce6zRyBFEHoAyMY35uRFiUQto2jQtRO4I7y30NT+EzSAT3wE5k+11yB8VA==", "dependencies": { "tslib": "^2.3.0" }, @@ -7422,9 +7422,9 @@ "integrity": "sha512-WMwm9LhRUo+WUaRN+vRuETqG89IgZphVSNkdFgeb6sS/E4OrDIN7t48CAewSHXc6C8lefD8KKfr5vY61brQlow==" }, "node_modules/electron-to-chromium": { - "version": "1.4.773", - "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.4.773.tgz", - "integrity": "sha512-87eHF+h3PlCRwbxVEAw9KtK3v7lWfc/sUDr0W76955AdYTG4bV/k0zrl585Qnj/skRMH2qOSiE+kqMeOQ+LOpw==" + "version": "1.4.774", + "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.4.774.tgz", + "integrity": "sha512-132O1XCd7zcTkzS3FgkAzKmnBuNJjK8WjcTtNuoylj7MYbqw5eXehjQ5OK91g0zm7OTKIPeaAG4CPoRfD9M1Mg==" }, "node_modules/emoji-regex": { "version": "8.0.0", @@ -7610,9 +7610,9 @@ } }, "node_modules/es-module-lexer": { - "version": "1.5.2", - "resolved": "https://registry.npmjs.org/es-module-lexer/-/es-module-lexer-1.5.2.tgz", - "integrity": "sha512-l60ETUTmLqbVbVHv1J4/qj+M8nq7AwMzEcg3kmJDt9dCNrTk+yHcYFf/Kw75pMDwd9mPcIGCG5LcS20SxYRzFA==", + "version": "1.5.3", + "resolved": "https://registry.npmjs.org/es-module-lexer/-/es-module-lexer-1.5.3.tgz", + "integrity": "sha512-i1gCgmR9dCl6Vil6UKPI/trA69s08g/syhiDK9TG0Nf1RJjjFI+AzoWW7sPufzkgYAn861skuCwJa0pIIHYxvg==", "dev": true }, "node_modules/esbuild": { diff --git a/package.json b/package.json index 7ca0d0e..f2ca893 100644 --- a/package.json +++ b/package.json @@ -27,7 +27,7 @@ "@angular/platform-server": "^17.3.7", "@angular/router": "^17.3.7", "@angular/ssr": "^17.3.6", - "@funixproductions/funixproductions-requests": "^0.1.15", + "@funixproductions/funixproductions-requests": "^0.1.17", "@ng-bootstrap/ng-bootstrap": "^16.0.0", "@popperjs/core": "^2.11.8", "bootstrap": "^5.3.0", diff --git a/src/app/components/minecraft-head/minecraft-head.component.html b/src/app/components/minecraft-head/minecraft-head.component.html new file mode 100644 index 0000000..8e2daaf --- /dev/null +++ b/src/app/components/minecraft-head/minecraft-head.component.html @@ -0,0 +1,6 @@ +Slin Minecraft de {{ username}} diff --git a/src/app/components/minecraft-head/minecraft-head.component.scss b/src/app/components/minecraft-head/minecraft-head.component.scss new file mode 100644 index 0000000..e69de29 diff --git a/src/app/components/minecraft-head/minecraft-head.component.spec.ts b/src/app/components/minecraft-head/minecraft-head.component.spec.ts new file mode 100644 index 0000000..236f340 --- /dev/null +++ b/src/app/components/minecraft-head/minecraft-head.component.spec.ts @@ -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; + + beforeEach(async () => { + await TestBed.configureTestingModule({ + imports: [MinecraftHeadComponent] + }) + .compileComponents(); + + fixture = TestBed.createComponent(MinecraftHeadComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/src/app/components/minecraft-head/minecraft-head.component.ts b/src/app/components/minecraft-head/minecraft-head.component.ts new file mode 100644 index 0000000..9dc6bd8 --- /dev/null +++ b/src/app/components/minecraft-head/minecraft-head.component.ts @@ -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; + +} diff --git a/src/app/pages/user/user-page/components/user-account-integrations/components/user-account-integrations-minecraft-acccount/user-account-integrations-minecraft-account-create-new/user-account-integrations-minecraft-account-create-new.component.html b/src/app/pages/user/user-page/components/user-account-integrations/components/user-account-integrations-minecraft-acccount/user-account-integrations-minecraft-account-create-new/user-account-integrations-minecraft-account-create-new.component.html new file mode 100644 index 0000000..a45c674 --- /dev/null +++ b/src/app/pages/user/user-page/components/user-account-integrations/components/user-account-integrations-minecraft-acccount/user-account-integrations-minecraft-account-create-new/user-account-integrations-minecraft-account-create-new.component.html @@ -0,0 +1,4 @@ +

user-account-integrations-minecraft-account-create-new works!

+ diff --git a/src/app/pages/user/user-page/components/user-account-integrations/components/user-account-integrations-minecraft-acccount/user-account-integrations-minecraft-account-create-new/user-account-integrations-minecraft-account-create-new.component.scss b/src/app/pages/user/user-page/components/user-account-integrations/components/user-account-integrations-minecraft-acccount/user-account-integrations-minecraft-account-create-new/user-account-integrations-minecraft-account-create-new.component.scss new file mode 100644 index 0000000..e69de29 diff --git a/src/app/pages/user/user-page/components/user-account-integrations/components/user-account-integrations-minecraft-acccount/user-account-integrations-minecraft-account-create-new/user-account-integrations-minecraft-account-create-new.component.spec.ts b/src/app/pages/user/user-page/components/user-account-integrations/components/user-account-integrations-minecraft-acccount/user-account-integrations-minecraft-account-create-new/user-account-integrations-minecraft-account-create-new.component.spec.ts new file mode 100644 index 0000000..963959f --- /dev/null +++ b/src/app/pages/user/user-page/components/user-account-integrations/components/user-account-integrations-minecraft-acccount/user-account-integrations-minecraft-account-create-new/user-account-integrations-minecraft-account-create-new.component.spec.ts @@ -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; + + beforeEach(async () => { + await TestBed.configureTestingModule({ + imports: [UserAccountIntegrationsMinecraftAccountCreateNewComponent] + }) + .compileComponents(); + + fixture = TestBed.createComponent(UserAccountIntegrationsMinecraftAccountCreateNewComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/src/app/pages/user/user-page/components/user-account-integrations/components/user-account-integrations-minecraft-acccount/user-account-integrations-minecraft-account-create-new/user-account-integrations-minecraft-account-create-new.component.ts b/src/app/pages/user/user-page/components/user-account-integrations/components/user-account-integrations-minecraft-acccount/user-account-integrations-minecraft-account-create-new/user-account-integrations-minecraft-account-create-new.component.ts new file mode 100644 index 0000000..8e8224c --- /dev/null +++ b/src/app/pages/user/user-page/components/user-account-integrations/components/user-account-integrations-minecraft-acccount/user-account-integrations-minecraft-account-create-new/user-account-integrations-minecraft-account-create-new.component.ts @@ -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() + } + +} diff --git a/src/app/pages/user/user-page/components/user-account-integrations/components/user-account-integrations-minecraft-acccount/user-account-integrations-minecraft-account.component.html b/src/app/pages/user/user-page/components/user-account-integrations/components/user-account-integrations-minecraft-acccount/user-account-integrations-minecraft-account.component.html new file mode 100644 index 0000000..4c57b2f --- /dev/null +++ b/src/app/pages/user/user-page/components/user-account-integrations/components/user-account-integrations-minecraft-acccount/user-account-integrations-minecraft-account.component.html @@ -0,0 +1,46 @@ +
+
+

Compte Minecraft

+
+
+ +
+
+ +
+
+ Chargement... +
+
+ +
+
+
+ + +
+
+

{{ link.minecraftUsername }}

+ +
+
+
+ +
+

Une erreur est survenue veuillez réessayer ou contacter un admin.

+
+ +

Vous n'avez pas encore lié votre compte Minecraft.

+ +
+
+
diff --git a/src/app/pages/user/user-page/components/user-account-integrations/components/user-account-integrations-minecraft-acccount/user-account-integrations-minecraft-account.component.scss b/src/app/pages/user/user-page/components/user-account-integrations/components/user-account-integrations-minecraft-acccount/user-account-integrations-minecraft-account.component.scss new file mode 100644 index 0000000..ae50bbe --- /dev/null +++ b/src/app/pages/user/user-page/components/user-account-integrations/components/user-account-integrations-minecraft-acccount/user-account-integrations-minecraft-account.component.scss @@ -0,0 +1,3 @@ +h2 { + font-size: 1.5rem; +} \ No newline at end of file diff --git a/src/app/pages/user/user-page/components/user-account-integrations/components/user-account-integrations-minecraft-acccount/user-account-integrations-minecraft-account.component.spec.ts b/src/app/pages/user/user-page/components/user-account-integrations/components/user-account-integrations-minecraft-acccount/user-account-integrations-minecraft-account.component.spec.ts new file mode 100644 index 0000000..cef1aa7 --- /dev/null +++ b/src/app/pages/user/user-page/components/user-account-integrations/components/user-account-integrations-minecraft-acccount/user-account-integrations-minecraft-account.component.spec.ts @@ -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; + + beforeEach(async () => { + await TestBed.configureTestingModule({ + imports: [UserAccountIntegrationsMinecraftAccountComponent] + }) + .compileComponents(); + + fixture = TestBed.createComponent(UserAccountIntegrationsMinecraftAccountComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/src/app/pages/user/user-page/components/user-account-integrations/components/user-account-integrations-minecraft-acccount/user-account-integrations-minecraft-account.component.ts b/src/app/pages/user/user-page/components/user-account-integrations/components/user-account-integrations-minecraft-acccount/user-account-integrations-minecraft-account.component.ts new file mode 100644 index 0000000..a186feb --- /dev/null +++ b/src/app/pages/user/user-page/components/user-account-integrations/components/user-account-integrations-minecraft-acccount/user-account-integrations-minecraft-account.component.ts @@ -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() + } + }) + } + +} diff --git a/src/app/pages/user/user-page/components/user-account-integrations/user-account-integrations.component.html b/src/app/pages/user/user-page/components/user-account-integrations/user-account-integrations.component.html index 000385d..7e7c4b7 100644 --- a/src/app/pages/user/user-page/components/user-account-integrations/user-account-integrations.component.html +++ b/src/app/pages/user/user-page/components/user-account-integrations/user-account-integrations.component.html @@ -1 +1 @@ -

user-account-integrations works!

+ diff --git a/src/app/pages/user/user.module.ts b/src/app/pages/user/user.module.ts index c306c55..99a0b8a 100644 --- a/src/app/pages/user/user.module.ts +++ b/src/app/pages/user/user.module.ts @@ -31,6 +31,10 @@ import { import { UserAccountInfosPasswordChangeComponent } from "./user-page/components/user-account-infos/components/user-account-infos-password-change/user-account-infos-password-change.component"; +import { + UserAccountIntegrationsMinecraftAccountComponent +} from "./user-page/components/user-account-integrations/components/user-account-integrations-minecraft-acccount/user-account-integrations-minecraft-account.component"; +import {MinecraftHeadComponent} from "../../components/minecraft-head/minecraft-head.component"; @NgModule({ declarations: [ @@ -44,7 +48,8 @@ import { UserAccountIntegrationsComponent, UserAccountInvoicesComponent, UserAccountInfosPersonalDataComponent, - UserAccountInfosPasswordChangeComponent + UserAccountInfosPasswordChangeComponent, + UserAccountIntegrationsMinecraftAccountComponent ], imports: [ CommonModule, @@ -57,7 +62,8 @@ import { SendButtonComponent, InputTextComponent, InputSecretComponent, - InputCheckboxComponent + InputCheckboxComponent, + MinecraftHeadComponent ], providers: [ {