From f2a789175686d91703ef96d204fd116ce6fc38cf Mon Sep 17 00:00:00 2001 From: Antoine PRONNIER <44138938+FunixG@users.noreply.github.com> Date: Wed, 20 Sep 2023 16:15:17 +0200 Subject: [PATCH] Seo upgrades (#32) * wip seo upgrade, need fixing sitemap.xml * fix loading lib http on server side * fix loading seo sub class * fix all --- package-lock.json | 17 ++++- package.json | 1 + server.ts | 10 +-- src/app/app.component.ts | 2 +- .../notification/notification.component.ts | 4 +- .../pacifista-page/pacifista-page.ts | 65 +++++++++++++++++++ src/app/pages/accueil/accueil.component.ts | 13 +++- .../news/news-accueil-section.component.ts | 26 ++++++-- src/app/pages/join/join.component.ts | 17 +++-- src/app/pages/legal/cgu/cgu.component.ts | 17 +++-- src/app/pages/legal/cgv/cgv.component.ts | 17 +++-- .../news/news-card/news-card.component.ts | 4 +- .../news-list-page.component.html | 2 +- .../news-list-page.component.ts | 45 ++++++++----- .../news/news-page/news-page.component.ts | 50 ++++++++++---- .../shop-article-modal.component.html | 0 .../shop-article-modal.component.scss | 0 .../shop-article-modal.component.spec.ts | 4 +- .../shop-article-modal.component.ts | 4 +- .../shop-article/shop-article.component.html | 0 .../shop-article/shop-article.component.scss | 0 .../shop-article.component.spec.ts | 4 +- .../shop-article/shop-article.component.ts | 4 +- .../shop-articles.component.html | 0 .../shop-articles.component.scss | 2 +- .../shop-articles.component.spec.ts | 4 +- .../shop-articles/shop-articles.component.ts | 10 +-- .../shop-basket-little.component.html | 0 .../shop-basket-little.component.scss | 5 ++ .../shop-basket-little.component.spec.ts | 4 +- .../shop-basket-little.component.ts | 2 +- .../shop-categories.component.html | 0 .../shop-categories.component.scss | 0 .../shop-categories.component.spec.ts | 4 +- .../shop-categories.component.ts | 8 +-- .../shop-basket-little.component.scss | 5 -- .../shop-checkout/shop-checkout.component.ts | 16 ++++- src/app/pages/shop/shop.component.ts | 16 ++++- src/app/pages/shop/shop.module.ts | 10 +-- .../user-forgot-password.component.ts | 16 ++++- .../user/user-login/user-login.component.ts | 42 ++++++++---- .../user/user-page/user-page.component.ts | 34 +++++++--- .../user-register/user-register.component.ts | 32 ++++++--- src/app/pages/vote/vote.component.ts | 17 +++-- src/app/pages/wiki/wiki.component.ts | 16 ++++- src/app/services/core/http/dtos/ApiDTO.ts | 5 -- .../services/core/http/dtos/PaginatedDTO.ts | 16 ----- .../core/http/services/CrudHttpClient.ts | 61 ----------------- .../core/http/services/FunixProdHttpClient.ts | 28 -------- .../services/core/http/utils/QueryBuilder.ts | 46 ------------- .../users/dtos/UserCreationDTO.ts | 10 --- .../users/dtos/UserDTO.ts | 15 ----- .../users/dtos/UserLoginDTO.ts | 7 -- .../users/dtos/UserTokenDTO.ts | 8 --- .../users/services/UserService.ts | 40 ------------ .../entities/NotificationToast.ts | 0 .../notifications/enums/NotificationType.ts | 0 .../services/NotificationService.ts | 0 .../pacifista-api/news/dtos/NewsDTO.ts | 13 ---- .../news/services/NewsService.ts | 15 ----- .../shop/categories/dtos/ShopCategoryDTO.ts | 5 -- .../shop/categories/dtos/ShopItemDTO.ts | 9 --- src/index.html | 15 ++--- src/sitemap.xml | 41 +++++++----- 64 files changed, 428 insertions(+), 455 deletions(-) create mode 100644 src/app/components/pacifista-page/pacifista-page.ts rename src/app/pages/shop/{ => components}/shop-articles/shop-article-modal/shop-article-modal.component.html (100%) rename src/app/pages/shop/{ => components}/shop-articles/shop-article-modal/shop-article-modal.component.scss (100%) rename src/app/pages/shop/{ => components}/shop-articles/shop-article-modal/shop-article-modal.component.spec.ts (78%) rename src/app/pages/shop/{ => components}/shop-articles/shop-article-modal/shop-article-modal.component.ts (75%) rename src/app/pages/shop/{ => components}/shop-articles/shop-article/shop-article.component.html (100%) rename src/app/pages/shop/{ => components}/shop-articles/shop-article/shop-article.component.scss (100%) rename src/app/pages/shop/{ => components}/shop-articles/shop-article/shop-article.component.spec.ts (79%) rename src/app/pages/shop/{ => components}/shop-articles/shop-article/shop-article.component.ts (81%) rename src/app/pages/shop/{ => components}/shop-articles/shop-articles.component.html (100%) rename src/app/pages/shop/{ => components}/shop-articles/shop-articles.component.scss (82%) rename src/app/pages/shop/{ => components}/shop-articles/shop-articles.component.spec.ts (79%) rename src/app/pages/shop/{ => components}/shop-articles/shop-articles.component.ts (75%) rename src/app/pages/shop/{ => components}/shop-basket-little/shop-basket-little.component.html (100%) create mode 100644 src/app/pages/shop/components/shop-basket-little/shop-basket-little.component.scss rename src/app/pages/shop/{ => components}/shop-basket-little/shop-basket-little.component.spec.ts (78%) rename src/app/pages/shop/{ => components}/shop-basket-little/shop-basket-little.component.ts (82%) rename src/app/pages/shop/{ => components}/shop-categories/shop-categories.component.html (100%) rename src/app/pages/shop/{ => components}/shop-categories/shop-categories.component.scss (100%) rename src/app/pages/shop/{ => components}/shop-categories/shop-categories.component.spec.ts (78%) rename src/app/pages/shop/{ => components}/shop-categories/shop-categories.component.ts (56%) delete mode 100644 src/app/pages/shop/shop-basket-little/shop-basket-little.component.scss delete mode 100644 src/app/services/core/http/dtos/ApiDTO.ts delete mode 100644 src/app/services/core/http/dtos/PaginatedDTO.ts delete mode 100644 src/app/services/core/http/services/CrudHttpClient.ts delete mode 100644 src/app/services/core/http/services/FunixProdHttpClient.ts delete mode 100644 src/app/services/core/http/utils/QueryBuilder.ts delete mode 100644 src/app/services/funixproductions-api/users/dtos/UserCreationDTO.ts delete mode 100644 src/app/services/funixproductions-api/users/dtos/UserDTO.ts delete mode 100644 src/app/services/funixproductions-api/users/dtos/UserLoginDTO.ts delete mode 100644 src/app/services/funixproductions-api/users/dtos/UserTokenDTO.ts delete mode 100644 src/app/services/funixproductions-api/users/services/UserService.ts rename src/app/services/{core => }/notifications/entities/NotificationToast.ts (100%) rename src/app/services/{core => }/notifications/enums/NotificationType.ts (100%) rename src/app/services/{core => }/notifications/services/NotificationService.ts (100%) delete mode 100644 src/app/services/pacifista-api/news/dtos/NewsDTO.ts delete mode 100644 src/app/services/pacifista-api/news/services/NewsService.ts delete mode 100644 src/app/services/pacifista-api/shop/categories/dtos/ShopCategoryDTO.ts delete mode 100644 src/app/services/pacifista-api/shop/categories/dtos/ShopItemDTO.ts diff --git a/package-lock.json b/package-lock.json index bf2765e..69a0e06 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "pacifista-website", - "version": "0.0.3", + "version": "0.0.6", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "pacifista-website", - "version": "0.0.3", + "version": "0.0.6", "dependencies": { "@angular/animations": "^16.1.5", "@angular/common": "^16.1.5", @@ -22,6 +22,7 @@ "@fortawesome/free-brands-svg-icons": "^6.4.0", "@fortawesome/free-regular-svg-icons": "^6.4.0", "@fortawesome/free-solid-svg-icons": "^6.4.0", + "@funixproductions/funixproductions-requests": "^0.0.3", "@ng-bootstrap/ng-bootstrap": "^15.1.0", "@nguniversal/express-engine": "^16.1.2", "@popperjs/core": "^2.11.8", @@ -2805,6 +2806,18 @@ "node": ">=6" } }, + "node_modules/@funixproductions/funixproductions-requests": { + "version": "0.0.3", + "resolved": "https://registry.npmjs.org/@funixproductions/funixproductions-requests/-/funixproductions-requests-0.0.3.tgz", + "integrity": "sha512-fYojiUQh9eOIisjD5o60H15dUsF+LmuGWKUlKMiPqUfjU12cJOyMwQB/58npyxiebiNxyB0RchH7z8DETiEUsg==", + "dependencies": { + "tslib": "^2.3.0" + }, + "peerDependencies": { + "@angular/common": "^16.1.0", + "@angular/core": "^16.1.0" + } + }, "node_modules/@isaacs/cliui": { "version": "8.0.2", "resolved": "https://registry.npmjs.org/@isaacs/cliui/-/cliui-8.0.2.tgz", diff --git a/package.json b/package.json index 152712d..3c1972d 100644 --- a/package.json +++ b/package.json @@ -28,6 +28,7 @@ "@fortawesome/free-brands-svg-icons": "^6.4.0", "@fortawesome/free-regular-svg-icons": "^6.4.0", "@fortawesome/free-solid-svg-icons": "^6.4.0", + "@funixproductions/funixproductions-requests": "^0.0.3", "@ng-bootstrap/ng-bootstrap": "^15.1.0", "@nguniversal/express-engine": "^16.1.2", "@popperjs/core": "^2.11.8", diff --git a/server.ts b/server.ts index 496256f..e9c49b2 100644 --- a/server.ts +++ b/server.ts @@ -1,12 +1,12 @@ import 'zone.js/node'; -import { APP_BASE_HREF } from '@angular/common'; -import { ngExpressEngine } from '@nguniversal/express-engine'; +import {APP_BASE_HREF} from '@angular/common'; +import {ngExpressEngine} from '@nguniversal/express-engine'; import * as express from 'express'; -import { existsSync } from 'fs'; -import { join } from 'path'; +import {existsSync} from 'fs'; +import {join} from 'path'; -import { AppServerModule } from './src/main.server'; +import {AppServerModule} from './src/main.server'; // The Express app is exported so that it can be used by serverless Functions. export function app(): express.Express { diff --git a/src/app/app.component.ts b/src/app/app.component.ts index 81efcfa..7836a79 100644 --- a/src/app/app.component.ts +++ b/src/app/app.component.ts @@ -1,5 +1,5 @@ import {Component, OnDestroy} from '@angular/core'; -import NotificationService from "./services/core/notifications/services/NotificationService"; +import NotificationService from "./services/notifications/services/NotificationService"; @Component({ selector: 'app-root', diff --git a/src/app/components/notification/notification.component.ts b/src/app/components/notification/notification.component.ts index 699d8fe..2003fe6 100644 --- a/src/app/components/notification/notification.component.ts +++ b/src/app/components/notification/notification.component.ts @@ -1,6 +1,6 @@ import {Component} from '@angular/core'; -import NotificationService from "../../services/core/notifications/services/NotificationService"; -import {NotificationType} from "../../services/core/notifications/enums/NotificationType"; +import NotificationService from "../../services/notifications/services/NotificationService"; +import {NotificationType} from "../../services/notifications/enums/NotificationType"; import {IconDefinition} from "@fortawesome/free-regular-svg-icons"; import {faCheckCircle, faExclamationTriangle, faInfoCircle} from "@fortawesome/free-solid-svg-icons"; diff --git a/src/app/components/pacifista-page/pacifista-page.ts b/src/app/components/pacifista-page/pacifista-page.ts new file mode 100644 index 0000000..d80e8fe --- /dev/null +++ b/src/app/components/pacifista-page/pacifista-page.ts @@ -0,0 +1,65 @@ +import {Component, OnInit} from "@angular/core"; +import {Title} from "@angular/platform-browser"; + +@Component({ template: ''}) +export abstract class PacifistaPage implements OnInit { + + protected title: string = ''; + protected canonicalPath: string = ''; + protected pageDescription: string = "Bienvenue sur Pacifista, le serveur Minecraft français survie créatif en 1.19 ! Rejoignez une communauté bienveillante, profitez d'un staff attentif et découvrez nos plugins faits maison."; + protected pageImage: string = 'https://pacifista.fr/assets/img/pacifista-logo.webp'; + + /** + * seo + * @param titleService the titleServiceManager + * @param doc Inject(DOCUMENT) private doc: Document + */ + constructor(protected titleService: Title, + private doc: Document) { + } + + ngOnInit(): void { + this.updateTitle(); + this.updateCanonicalPath(); + this.updateMetaTags(); + this.onPageInit(); + } + + protected onPageInit() { + } + + private updateTitle(): void { + const prefix = this.title.length > 0 ? this.title + ' - ' : ''; + this.titleService.setTitle(prefix + 'Pacifista Minecraft - Serveur Minecraft Survie Creatif Français en 1.19'); + } + + private updateCanonicalPath(): void { + const canonical = this.doc.createElement('link'); + canonical.setAttribute('rel', 'canonical'); + canonical.setAttribute('href', 'https://pacifista.fr/' + this.canonicalPath); + this.doc.head.appendChild(canonical); + } + + private updateMetaTags(): void { + this.setMetaTag('description', this.pageDescription) + + this.setMetaTag('og:title', this.titleService.getTitle()); + this.setMetaTag('og:description', this.pageDescription); + this.setMetaTag('og:image', this.pageImage); + this.setMetaTag('og:url', 'https://pacifista.fr/' + this.canonicalPath); + + this.setMetaTag('twitter:title', this.titleService.getTitle()); + this.setMetaTag('twitter:description', this.pageDescription); + this.setMetaTag('twitter:image', this.pageImage); + this.setMetaTag('twitter:url', 'https://pacifista.fr/' + this.canonicalPath); + } + + private setMetaTag(name: string, content: string): void { + const meta = this.doc.createElement('meta'); + meta.setAttribute('name', name); + meta.setAttribute('property', name); + meta.setAttribute('content', content); + this.doc.head.appendChild(meta); + } + +} diff --git a/src/app/pages/accueil/accueil.component.ts b/src/app/pages/accueil/accueil.component.ts index 0d5b6e7..a66044f 100644 --- a/src/app/pages/accueil/accueil.component.ts +++ b/src/app/pages/accueil/accueil.component.ts @@ -1,9 +1,18 @@ -import {Component} from '@angular/core'; +import {Component, Inject} from '@angular/core'; +import {Title} from "@angular/platform-browser"; +import {PacifistaPage} from "../../components/pacifista-page/pacifista-page"; +import {DOCUMENT} from "@angular/common"; @Component({ selector: 'app-accueil', templateUrl: './accueil.component.html', styleUrls: ['./accueil.component.scss'] }) -export class AccueilComponent { +export class AccueilComponent extends PacifistaPage { + + constructor(title: Title, + @Inject(DOCUMENT) doc: Document) { + super(title, doc); + } + } diff --git a/src/app/pages/accueil/components/news/news-accueil-section.component.ts b/src/app/pages/accueil/components/news/news-accueil-section.component.ts index 68e529f..ca558f9 100644 --- a/src/app/pages/accueil/components/news/news-accueil-section.component.ts +++ b/src/app/pages/accueil/components/news/news-accueil-section.component.ts @@ -1,7 +1,13 @@ -import {AfterViewInit, Component} from '@angular/core'; -import NewsDTO from "../../../../services/pacifista-api/news/dtos/NewsDTO"; -import NewsService from "../../../../services/pacifista-api/news/services/NewsService"; -import {PageOption} from "../../../../services/core/http/dtos/PaginatedDTO"; +import {AfterViewInit, Component, Inject, PLATFORM_ID} from '@angular/core'; +import { + PacifistaNewsDTO, + PacifistaNewsService, + PageOption, + QueryBuilder +} from "@funixproductions/funixproductions-requests"; +import {HttpClient} from "@angular/common/http"; +import {environment} from "../../../../../environments/environment"; +import {isPlatformBrowser} from "@angular/common"; @Component({ selector: 'news-section', @@ -10,18 +16,24 @@ import {PageOption} from "../../../../services/core/http/dtos/PaginatedDTO"; }) export class NewsAccueilSectionComponent implements AfterViewInit { - newsList: NewsDTO[] = []; + private readonly newsService: PacifistaNewsService; + + newsList: PacifistaNewsDTO[] = []; totalNews: number = 0; - constructor(private newsService: NewsService) { + constructor(@Inject(PLATFORM_ID) private platfomId: Object, + httpClient: HttpClient) { + this.newsService = new PacifistaNewsService(httpClient, environment.production); } ngAfterViewInit(): void { + if (!isPlatformBrowser(this.platfomId)) return; + const pageOption = new PageOption(); pageOption.elemsPerPage = 3; pageOption.sort = 'createdAt:desc'; - this.newsService.find(pageOption, null).subscribe(newsList => { + this.newsService.find(pageOption, new QueryBuilder()).subscribe(newsList => { this.newsList = newsList.content; this.totalNews = newsList.totalElementsDatabase; }); diff --git a/src/app/pages/join/join.component.ts b/src/app/pages/join/join.component.ts index 54cca14..a4a83b8 100644 --- a/src/app/pages/join/join.component.ts +++ b/src/app/pages/join/join.component.ts @@ -1,19 +1,22 @@ -import { Component } from '@angular/core'; +import {Component, Inject} from '@angular/core'; import {Title} from "@angular/platform-browser"; +import {PacifistaPage} from "../../components/pacifista-page/pacifista-page"; +import {DOCUMENT} from "@angular/common"; @Component({ selector: 'app-join', templateUrl: './join.component.html', styleUrls: ['./join.component.scss'] }) -export class JoinComponent { +export class JoinComponent extends PacifistaPage { - constructor(private titleService: Title) { - const title: string = titleService.getTitle(); + protected override readonly title: string = 'Se connecter' + protected override readonly canonicalPath: string = 'join' + protected override readonly pageDescription: string = 'Découvrez comment rejoindre Pacifista en 1.19 : votre guide pour jouer sur notre serveur Minecraft survie, créatif français !'; - if (!title.startsWith("Nous rejoindre")) { - titleService.setTitle('Nous rejoindre - ' + title); - } + constructor(title: Title, + @Inject(DOCUMENT) doc: Document) { + super(title, doc); } } diff --git a/src/app/pages/legal/cgu/cgu.component.ts b/src/app/pages/legal/cgu/cgu.component.ts index a874379..ace6504 100644 --- a/src/app/pages/legal/cgu/cgu.component.ts +++ b/src/app/pages/legal/cgu/cgu.component.ts @@ -1,19 +1,22 @@ -import { Component } from '@angular/core'; +import {Component, Inject} from '@angular/core'; import {Title} from "@angular/platform-browser"; +import {PacifistaPage} from "../../../components/pacifista-page/pacifista-page"; +import {DOCUMENT} from "@angular/common"; @Component({ selector: 'app-cgu', templateUrl: './cgu.component.html', styleUrls: ['./cgu.component.scss'] }) -export class CguComponent { +export class CguComponent extends PacifistaPage { - constructor(private titleService: Title) { - const title: string = titleService.getTitle(); + protected override readonly title: string = "CGU"; + protected override readonly canonicalPath: string = "cgu"; + protected override readonly pageDescription: string = "Conditions générales d'utilisation de Pacifista."; - if (!title.startsWith("CGU")) { - titleService.setTitle('CGU - ' + title); - } + constructor(title: Title, + @Inject(DOCUMENT) doc: Document) { + super(title, doc); } } diff --git a/src/app/pages/legal/cgv/cgv.component.ts b/src/app/pages/legal/cgv/cgv.component.ts index a029724..9e9f009 100644 --- a/src/app/pages/legal/cgv/cgv.component.ts +++ b/src/app/pages/legal/cgv/cgv.component.ts @@ -1,19 +1,22 @@ -import {Component} from '@angular/core'; +import {Component, Inject} from '@angular/core'; import {Title} from "@angular/platform-browser"; +import {PacifistaPage} from "../../../components/pacifista-page/pacifista-page"; +import {DOCUMENT} from "@angular/common"; @Component({ selector: 'app-cgv', templateUrl: './cgv.component.html', styleUrls: ['./cgv.component.scss'] }) -export class CgvComponent { +export class CgvComponent extends PacifistaPage { - constructor(private titleService: Title) { - const title: string = titleService.getTitle(); + protected override readonly title: string = 'CGV'; + protected override readonly canonicalPath: string = 'cgv'; + protected override readonly pageDescription: string = 'Conditions générales de vente de Pacifista.'; - if (!title.startsWith("CGV")) { - titleService.setTitle('CGV - ' + title); - } + constructor(title: Title, + @Inject(DOCUMENT) doc: Document) { + super(title, doc); } } diff --git a/src/app/pages/news/news-card/news-card.component.ts b/src/app/pages/news/news-card/news-card.component.ts index eb87d4a..844f58f 100644 --- a/src/app/pages/news/news-card/news-card.component.ts +++ b/src/app/pages/news/news-card/news-card.component.ts @@ -1,6 +1,6 @@ import {Component, Input} from '@angular/core'; import {faClock, faComments, faThumbsUp, faUser} from '@fortawesome/free-solid-svg-icons'; -import NewsDTO from "../../../services/pacifista-api/news/dtos/NewsDTO"; +import {PacifistaNewsDTO} from "@funixproductions/funixproductions-requests"; @Component({ selector: 'app-news-card', @@ -14,6 +14,6 @@ export class NewsCardComponent { protected readonly faThumbsUp = faThumbsUp; protected readonly faComment = faComments; - @Input() news: NewsDTO = new NewsDTO(); + @Input() news: PacifistaNewsDTO = new PacifistaNewsDTO(); } diff --git a/src/app/pages/news/news-list-page/news-list-page.component.html b/src/app/pages/news/news-list-page/news-list-page.component.html index d7759e2..cfcebc1 100644 --- a/src/app/pages/news/news-list-page/news-list-page.component.html +++ b/src/app/pages/news/news-list-page/news-list-page.component.html @@ -3,7 +3,7 @@
Voici les news du serveur Minecraft Pacifista.
- Vous pouvez aussi les retrouver sur notre
Un super grade (à rédiger)
"; article.logoUrl = "https://pacifista.fr/app/webroot/img/shop/grades/Badge-Elite.png" - const article2 = new ShopItemDTO(); + const article2 = new PacifistaShopArticleDTO(); article2.price = 19.99; article2.name = "Grade légendaire"; article2.description = "Le grade le plus cool du serveur !"; diff --git a/src/app/pages/shop/shop-basket-little/shop-basket-little.component.html b/src/app/pages/shop/components/shop-basket-little/shop-basket-little.component.html similarity index 100% rename from src/app/pages/shop/shop-basket-little/shop-basket-little.component.html rename to src/app/pages/shop/components/shop-basket-little/shop-basket-little.component.html diff --git a/src/app/pages/shop/components/shop-basket-little/shop-basket-little.component.scss b/src/app/pages/shop/components/shop-basket-little/shop-basket-little.component.scss new file mode 100644 index 0000000..6945947 --- /dev/null +++ b/src/app/pages/shop/components/shop-basket-little/shop-basket-little.component.scss @@ -0,0 +1,5 @@ +@import "src/app/pages/shop/shop.component"; + +.basket-div { + padding: 7%; +} diff --git a/src/app/pages/shop/shop-basket-little/shop-basket-little.component.spec.ts b/src/app/pages/shop/components/shop-basket-little/shop-basket-little.component.spec.ts similarity index 78% rename from src/app/pages/shop/shop-basket-little/shop-basket-little.component.spec.ts rename to src/app/pages/shop/components/shop-basket-little/shop-basket-little.component.spec.ts index 4912987..cdeed73 100644 --- a/src/app/pages/shop/shop-basket-little/shop-basket-little.component.spec.ts +++ b/src/app/pages/shop/components/shop-basket-little/shop-basket-little.component.spec.ts @@ -1,6 +1,6 @@ -import { ComponentFixture, TestBed } from '@angular/core/testing'; +import {ComponentFixture, TestBed} from '@angular/core/testing'; -import { ShopBasketLittleComponent } from './shop-basket-little.component'; +import {ShopBasketLittleComponent} from './shop-basket-little.component'; describe('ShopBasketLittleComponent', () => { let component: ShopBasketLittleComponent; diff --git a/src/app/pages/shop/shop-basket-little/shop-basket-little.component.ts b/src/app/pages/shop/components/shop-basket-little/shop-basket-little.component.ts similarity index 82% rename from src/app/pages/shop/shop-basket-little/shop-basket-little.component.ts rename to src/app/pages/shop/components/shop-basket-little/shop-basket-little.component.ts index cd97360..383f2b5 100644 --- a/src/app/pages/shop/shop-basket-little/shop-basket-little.component.ts +++ b/src/app/pages/shop/components/shop-basket-little/shop-basket-little.component.ts @@ -1,4 +1,4 @@ -import { Component } from '@angular/core'; +import {Component} from '@angular/core'; @Component({ selector: 'app-shop-basket-little', diff --git a/src/app/pages/shop/shop-categories/shop-categories.component.html b/src/app/pages/shop/components/shop-categories/shop-categories.component.html similarity index 100% rename from src/app/pages/shop/shop-categories/shop-categories.component.html rename to src/app/pages/shop/components/shop-categories/shop-categories.component.html diff --git a/src/app/pages/shop/shop-categories/shop-categories.component.scss b/src/app/pages/shop/components/shop-categories/shop-categories.component.scss similarity index 100% rename from src/app/pages/shop/shop-categories/shop-categories.component.scss rename to src/app/pages/shop/components/shop-categories/shop-categories.component.scss diff --git a/src/app/pages/shop/shop-categories/shop-categories.component.spec.ts b/src/app/pages/shop/components/shop-categories/shop-categories.component.spec.ts similarity index 78% rename from src/app/pages/shop/shop-categories/shop-categories.component.spec.ts rename to src/app/pages/shop/components/shop-categories/shop-categories.component.spec.ts index 120c36e..3eff087 100644 --- a/src/app/pages/shop/shop-categories/shop-categories.component.spec.ts +++ b/src/app/pages/shop/components/shop-categories/shop-categories.component.spec.ts @@ -1,6 +1,6 @@ -import { ComponentFixture, TestBed } from '@angular/core/testing'; +import {ComponentFixture, TestBed} from '@angular/core/testing'; -import { ShopCategoriesComponent } from './shop-categories.component'; +import {ShopCategoriesComponent} from './shop-categories.component'; describe('ShopCategoriesComponent', () => { let component: ShopCategoriesComponent; diff --git a/src/app/pages/shop/shop-categories/shop-categories.component.ts b/src/app/pages/shop/components/shop-categories/shop-categories.component.ts similarity index 56% rename from src/app/pages/shop/shop-categories/shop-categories.component.ts rename to src/app/pages/shop/components/shop-categories/shop-categories.component.ts index 53567be..9282eaa 100644 --- a/src/app/pages/shop/shop-categories/shop-categories.component.ts +++ b/src/app/pages/shop/components/shop-categories/shop-categories.component.ts @@ -1,5 +1,5 @@ -import { Component } from '@angular/core'; -import ShopCategoryDTO from "../../../services/pacifista-api/shop/categories/dtos/ShopCategoryDTO"; +import {Component} from '@angular/core'; +import {PacifistaShopCategoryDTO} from "@funixproductions/funixproductions-requests"; @Component({ selector: 'app-shop-categories', @@ -8,10 +8,10 @@ import ShopCategoryDTO from "../../../services/pacifista-api/shop/categories/dto }) export class ShopCategoriesComponent { - categoriesList: ShopCategoryDTO[] = []; + categoriesList: PacifistaShopCategoryDTO[] = []; constructor() { - const gradesCategory = new ShopCategoryDTO(); + const gradesCategory = new PacifistaShopCategoryDTO(); gradesCategory.name = "Grades"; this.categoriesList.push(gradesCategory); diff --git a/src/app/pages/shop/shop-basket-little/shop-basket-little.component.scss b/src/app/pages/shop/shop-basket-little/shop-basket-little.component.scss deleted file mode 100644 index 507a491..0000000 --- a/src/app/pages/shop/shop-basket-little/shop-basket-little.component.scss +++ /dev/null @@ -1,5 +0,0 @@ -@import "../shop.component"; - -.basket-div { - padding: 7%; -} diff --git a/src/app/pages/shop/shop-checkout/shop-checkout.component.ts b/src/app/pages/shop/shop-checkout/shop-checkout.component.ts index 6443695..b73029d 100644 --- a/src/app/pages/shop/shop-checkout/shop-checkout.component.ts +++ b/src/app/pages/shop/shop-checkout/shop-checkout.component.ts @@ -1,10 +1,22 @@ -import { Component } from '@angular/core'; +import {Component, Inject} from '@angular/core'; +import {PacifistaPage} from "../../../components/pacifista-page/pacifista-page"; +import {Title} from "@angular/platform-browser"; +import {DOCUMENT} from "@angular/common"; @Component({ selector: 'app-shop-checkout', templateUrl: './shop-checkout.component.html', styleUrls: ['./shop-checkout.component.scss'] }) -export class ShopCheckoutComponent { +export class ShopCheckoutComponent extends PacifistaPage { + + protected override readonly title: string = "Boutique - Panier"; + protected override readonly canonicalPath: string = "shop/checkout"; + protected override readonly pageDescription: string = "Boutique de Pacifista. Soutenez le serveur minecraft avec des avantages uniques !"; + + constructor(title: Title, + @Inject(DOCUMENT) doc: Document) { + super(title, doc); + } } diff --git a/src/app/pages/shop/shop.component.ts b/src/app/pages/shop/shop.component.ts index 8adda28..f8d365f 100644 --- a/src/app/pages/shop/shop.component.ts +++ b/src/app/pages/shop/shop.component.ts @@ -1,10 +1,22 @@ -import { Component } from '@angular/core'; +import {Component, Inject} from '@angular/core'; +import {PacifistaPage} from "../../components/pacifista-page/pacifista-page"; +import {Title} from "@angular/platform-browser"; +import {DOCUMENT} from "@angular/common"; @Component({ selector: 'app-shop', templateUrl: './shop.component.html', styleUrls: ['./shop.component.scss'] }) -export class ShopComponent { +export class ShopComponent extends PacifistaPage { + + protected override readonly title: string = "Boutique"; + protected override readonly canonicalPath: string = "shop"; + protected override readonly pageDescription: string = "Boutique de Pacifista. Soutenez le serveur minecraft avec des avantages uniques !"; + + constructor(title: Title, + @Inject(DOCUMENT) doc: Document) { + super(title, doc); + } } diff --git a/src/app/pages/shop/shop.module.ts b/src/app/pages/shop/shop.module.ts index 8f8da33..c2e1992 100644 --- a/src/app/pages/shop/shop.module.ts +++ b/src/app/pages/shop/shop.module.ts @@ -3,13 +3,13 @@ import {CommonModule} from '@angular/common'; import {ShopRoutingModule} from './shop-routing.module'; import {ShopComponent} from './shop.component'; -import {ShopCategoriesComponent} from './shop-categories/shop-categories.component'; -import {ShopArticlesComponent} from './shop-articles/shop-articles.component'; +import {ShopCategoriesComponent} from './components/shop-categories/shop-categories.component'; +import {ShopArticlesComponent} from './components/shop-articles/shop-articles.component'; import {FontAwesomeModule} from "@fortawesome/angular-fontawesome"; -import {ShopArticleComponent} from './shop-articles/shop-article/shop-article.component'; -import {ShopArticleModalComponent} from './shop-articles/shop-article-modal/shop-article-modal.component'; +import {ShopArticleComponent} from './components/shop-articles/shop-article/shop-article.component'; +import {ShopArticleModalComponent} from './components/shop-articles/shop-article-modal/shop-article-modal.component'; import {ShopCheckoutComponent} from './shop-checkout/shop-checkout.component'; -import {ShopBasketLittleComponent} from './shop-basket-little/shop-basket-little.component'; +import {ShopBasketLittleComponent} from './components/shop-basket-little/shop-basket-little.component'; @NgModule({ declarations: [ diff --git a/src/app/pages/user/user-forgot-password/user-forgot-password.component.ts b/src/app/pages/user/user-forgot-password/user-forgot-password.component.ts index 95aef79..7368e28 100644 --- a/src/app/pages/user/user-forgot-password/user-forgot-password.component.ts +++ b/src/app/pages/user/user-forgot-password/user-forgot-password.component.ts @@ -1,14 +1,26 @@ -import { Component } from '@angular/core'; +import {Component, Inject} from '@angular/core'; +import {PacifistaPage} from "../../../components/pacifista-page/pacifista-page"; +import {Title} from "@angular/platform-browser"; +import {DOCUMENT} from "@angular/common"; @Component({ selector: 'app-user-forgot-password', templateUrl: './user-forgot-password.component.html', styleUrls: ['./user-forgot-password.component.scss'] }) -export class UserForgotPasswordComponent { +export class UserForgotPasswordComponent extends PacifistaPage { + + protected override title: string = 'Mot de passe oublié'; + protected override canonicalPath: string = 'user/forgotpassword'; + protected override pageDescription: string = 'Page de récupération de mot de passe.'; email: string = ''; + constructor(title: Title, + @Inject(DOCUMENT) doc: Document) { + super(title, doc); + } + sendRequestReset() { } diff --git a/src/app/pages/user/user-login/user-login.component.ts b/src/app/pages/user/user-login/user-login.component.ts index f61e30a..436c6ce 100644 --- a/src/app/pages/user/user-login/user-login.component.ts +++ b/src/app/pages/user/user-login/user-login.component.ts @@ -1,28 +1,44 @@ -import {Component} from '@angular/core'; -import UserService from "../../../services/funixproductions-api/users/services/UserService"; +import {Component, Inject} from '@angular/core'; import {ReCaptchaV3Service} from "ng-recaptcha"; import {Router} from "@angular/router"; -import UserLoginDTO from "../../../services/funixproductions-api/users/dtos/UserLoginDTO"; -import UserTokenDTO from "../../../services/funixproductions-api/users/dtos/UserTokenDTO"; -import NotificationService from "../../../services/core/notifications/services/NotificationService"; -import FunixProdHttpClient from "../../../services/core/http/services/FunixProdHttpClient"; -import NotificationToast from "../../../services/core/notifications/entities/NotificationToast"; +import NotificationService from "../../../services/notifications/services/NotificationService"; +import { + FunixprodHttpClient, + UserAuthService, + UserLoginDTO, + UserTokenDTO +} from "@funixproductions/funixproductions-requests"; +import {Title} from "@angular/platform-browser"; +import {HttpClient} from "@angular/common/http"; +import {PacifistaPage} from "../../../components/pacifista-page/pacifista-page"; +import {environment} from "../../../../environments/environment"; +import {DOCUMENT} from "@angular/common"; @Component({ selector: 'app-user-login', templateUrl: './user-login.component.html', styleUrls: ['./user-login.component.scss'] }) -export class UserLoginComponent { +export class UserLoginComponent extends PacifistaPage { + + protected override title: string = 'Connexion'; + protected override canonicalPath: string = 'user/login'; + protected override pageDescription: string = 'Connexion sur le site de Pacifista. Page de connexion.'; username: string = ''; password: string = ''; stayLogin: boolean = false; - constructor(private userAuthService: UserService, - private reCaptchaService: ReCaptchaV3Service, + private userAuthService: UserAuthService; + + constructor(private reCaptchaService: ReCaptchaV3Service, private router: Router, - private notificationService: NotificationService) { + private notificationService: NotificationService, + titleService: Title, + @Inject(DOCUMENT) doc: Document, + httpClient: HttpClient) { + super(titleService, doc); + this.userAuthService = new UserAuthService(httpClient, environment.production); } login(): void { @@ -35,10 +51,10 @@ export class UserLoginComponent { this.userAuthService.login(loginRequest, token).subscribe({ next: (loginDto: UserTokenDTO) => { if (loginDto.token) { - localStorage.setItem(FunixProdHttpClient.LOCAL_STORAGE_KEY_AUTH, loginDto.token); + localStorage.setItem(FunixprodHttpClient.accessTokenLocalStorageName, loginDto.token); this.router.navigate(['user']) } else { - this.notificationService.show(new NotificationToast('Erreur', 'Une erreur est survenue lors de la connexion')); + this.notificationService.error('Une erreur est survenue lors de la connexion'); } }, error: err => { diff --git a/src/app/pages/user/user-page/user-page.component.ts b/src/app/pages/user/user-page/user-page.component.ts index 209234a..e8011a0 100644 --- a/src/app/pages/user/user-page/user-page.component.ts +++ b/src/app/pages/user/user-page/user-page.component.ts @@ -1,26 +1,42 @@ -import {Component, OnInit} from '@angular/core'; -import UserService from "../../../services/funixproductions-api/users/services/UserService"; +import {Component, Inject, PLATFORM_ID} from '@angular/core'; import {Router} from "@angular/router"; -import {UserDTO} from "../../../services/funixproductions-api/users/dtos/UserDTO"; -import { faSearch } from '@fortawesome/free-solid-svg-icons'; +import {faSearch} from '@fortawesome/free-solid-svg-icons'; +import {PacifistaPage} from "../../../components/pacifista-page/pacifista-page"; +import {UserAuthService, UserDTO} from "@funixproductions/funixproductions-requests"; +import {Title} from "@angular/platform-browser"; +import {environment} from "../../../../environments/environment"; +import {HttpClient} from "@angular/common/http"; +import {DOCUMENT, isPlatformBrowser} from "@angular/common"; @Component({ selector: 'app-user-page', templateUrl: './user-page.component.html', styleUrls: ['./user-page.component.scss'] }) -export class UserPageComponent implements OnInit { +export class UserPageComponent extends PacifistaPage { + + protected override title: string = 'Profil'; + protected override canonicalPath: string = 'user'; + protected override pageDescription: string = 'Page de profil utilisateur.'; protected readonly faSearch = faSearch; + private readonly authService: UserAuthService; user?: UserDTO; - constructor(private userService: UserService, - private router: Router) { + constructor(private router: Router, + @Inject(PLATFORM_ID) private platfomId: Object, + title: Title, + @Inject(DOCUMENT) doc: Document, + httpClient: HttpClient) { + super(title, doc); + this.authService = new UserAuthService(httpClient, environment.production); } - ngOnInit(): void { - this.userService.currentUser().subscribe({ + protected override onPageInit() { + if (!isPlatformBrowser(this.platfomId)) return; + + this.authService.currentUser().subscribe({ next: value => { this.user = value; }, diff --git a/src/app/pages/user/user-register/user-register.component.ts b/src/app/pages/user/user-register/user-register.component.ts index 9e8054a..4c222ef 100644 --- a/src/app/pages/user/user-register/user-register.component.ts +++ b/src/app/pages/user/user-register/user-register.component.ts @@ -1,15 +1,24 @@ -import { Component } from '@angular/core'; +import {Component, Inject} from '@angular/core'; import {Router} from "@angular/router"; -import UserService from "../../../services/funixproductions-api/users/services/UserService"; import {ReCaptchaV3Service} from "ng-recaptcha"; -import UserCreationDTO from "../../../services/funixproductions-api/users/dtos/UserCreationDTO"; +import {UserAuthService, UserCreationDTO} from "@funixproductions/funixproductions-requests"; +import {PacifistaPage} from "../../../components/pacifista-page/pacifista-page"; +import {Title} from "@angular/platform-browser"; +import {HttpClient} from "@angular/common/http"; +import {environment} from "../../../../environments/environment"; +import NotificationService from "../../../services/notifications/services/NotificationService"; +import {DOCUMENT} from "@angular/common"; @Component({ selector: 'app-user-register', templateUrl: './user-register.component.html', styleUrls: ['./user-register.component.scss'] }) -export class UserRegisterComponent { +export class UserRegisterComponent extends PacifistaPage { + + protected override title: string = 'Inscription'; + protected override canonicalPath: string = 'user/register'; + protected override pageDescription: string = 'Inscription sur le site de Pacifista. Page de création de compte.'; username: string = ''; email: string = ''; @@ -18,9 +27,16 @@ export class UserRegisterComponent { acceptCgu: boolean = false; acceptCgv: boolean = false; - constructor(private userAuthService: UserService, - private reCaptchaService: ReCaptchaV3Service, - private router: Router) { + private readonly userAuthService: UserAuthService; + + constructor(private reCaptchaService: ReCaptchaV3Service, + private router: Router, + private notificationService: NotificationService, + titleService: Title, + @Inject(DOCUMENT) doc: Document, + httpClient: HttpClient) { + super(titleService, doc); + this.userAuthService = new UserAuthService(httpClient, environment.production); } register(): void { @@ -38,7 +54,7 @@ export class UserRegisterComponent { this.router.navigate(['user', 'login']); }, error: err => { - //todo popup error + this.notificationService.onErrorRequest(err, 'Erreur lors de la création de compte.'); } } ) diff --git a/src/app/pages/vote/vote.component.ts b/src/app/pages/vote/vote.component.ts index ae4fe31..9631341 100644 --- a/src/app/pages/vote/vote.component.ts +++ b/src/app/pages/vote/vote.component.ts @@ -1,19 +1,22 @@ -import {Component} from '@angular/core'; +import {Component, Inject} from '@angular/core'; import {Title} from "@angular/platform-browser"; +import {PacifistaPage} from "../../components/pacifista-page/pacifista-page"; +import {DOCUMENT} from "@angular/common"; @Component({ selector: 'app-vote-page', templateUrl: './vote.component.html', styleUrls: ['./vote.component.scss'] }) -export class VoteComponent { +export class VoteComponent extends PacifistaPage { - constructor(private titleService: Title) { - const title: string = titleService.getTitle(); + protected override readonly title: string = "Voter"; + protected override readonly canonicalPath: string = "vote"; + protected override readonly pageDescription: string = "Votez pour Pacifista et recevez des récompenses en jeu. Aidez-nous à faire connaître le serveur !"; - if (!title.startsWith("Voter")) { - titleService.setTitle('Voter - ' + title); - } + constructor(title: Title, + @Inject(DOCUMENT) doc: Document) { + super(title, doc); } } diff --git a/src/app/pages/wiki/wiki.component.ts b/src/app/pages/wiki/wiki.component.ts index 2e22d3c..18020b8 100644 --- a/src/app/pages/wiki/wiki.component.ts +++ b/src/app/pages/wiki/wiki.component.ts @@ -1,10 +1,22 @@ -import { Component } from '@angular/core'; +import {Component, Inject} from '@angular/core'; +import {PacifistaPage} from "../../components/pacifista-page/pacifista-page"; +import {Title} from "@angular/platform-browser"; +import {DOCUMENT} from "@angular/common"; @Component({ selector: 'app-wiki', templateUrl: './wiki.component.html', styleUrls: ['./wiki.component.scss'] }) -export class WikiComponent { +export class WikiComponent extends PacifistaPage { + + protected override readonly title: string = "Wiki"; + protected override readonly canonicalPath: string = "wiki"; + protected override readonly pageDescription: string = "Wiki de Pacifista. Retrouvez toutes les informations sur le serveur minecraft et comment jouer ! Claims, Créatif, Métiers, Jobs et bien plus !"; + + constructor(title: Title, + @Inject(DOCUMENT) doc: Document) { + super(title, doc); + } } diff --git a/src/app/services/core/http/dtos/ApiDTO.ts b/src/app/services/core/http/dtos/ApiDTO.ts deleted file mode 100644 index 062250a..0000000 --- a/src/app/services/core/http/dtos/ApiDTO.ts +++ /dev/null @@ -1,5 +0,0 @@ -export default abstract class ApiDTO { - id?: string; - createdAt?: Date; - updatedAt?: Date; -} diff --git a/src/app/services/core/http/dtos/PaginatedDTO.ts b/src/app/services/core/http/dtos/PaginatedDTO.ts deleted file mode 100644 index 63cf545..0000000 --- a/src/app/services/core/http/dtos/PaginatedDTO.ts +++ /dev/null @@ -1,16 +0,0 @@ -import ApiDTO from "./ApiDTO"; - -export class Paginated