From a9ee38dc5157375f963032f1bb515776ed369f8e Mon Sep 17 00:00:00 2001 From: FunixG Date: Wed, 20 Sep 2023 10:28:53 +0200 Subject: [PATCH] refacto pages with modules --- src/app/app-routing.module.ts | 34 +++++++------------ src/app/app.module.ts | 15 +------- src/app/pages/about/about.component.html | 5 --- src/app/pages/about/about.component.spec.ts | 23 ------------- src/app/pages/about/about.component.ts | 19 ----------- src/app/pages/join/join-routing.module.ts | 16 +++++++++ src/app/pages/join/join.module.ts | 16 +++++++++ src/app/pages/legal/cgu/cgu-routing.module.ts | 16 +++++++++ src/app/pages/legal/cgu/cgu.module.ts | 16 +++++++++ src/app/pages/legal/cgv/cgv-routing.module.ts | 16 +++++++++ src/app/pages/legal/cgv/cgv.component.ts | 5 +-- src/app/pages/legal/cgv/cgv.module.ts | 16 +++++++++ .../vote/vote-page/vote-page.component.scss | 0 .../vote-page/vote-page.component.spec.ts | 23 ------------- src/app/pages/vote/vote-routing.module.ts | 16 +++++++++ ...age.component.html => vote.component.html} | 0 .../vote.component.scss} | 0 src/app/pages/vote/vote.component.spec.ts | 23 +++++++++++++ ...te-page.component.ts => vote.component.ts} | 8 ++--- src/app/pages/vote/vote.module.ts | 16 +++++++++ 20 files changed, 171 insertions(+), 112 deletions(-) delete mode 100644 src/app/pages/about/about.component.html delete mode 100644 src/app/pages/about/about.component.spec.ts delete mode 100644 src/app/pages/about/about.component.ts create mode 100644 src/app/pages/join/join-routing.module.ts create mode 100644 src/app/pages/join/join.module.ts create mode 100644 src/app/pages/legal/cgu/cgu-routing.module.ts create mode 100644 src/app/pages/legal/cgu/cgu.module.ts create mode 100644 src/app/pages/legal/cgv/cgv-routing.module.ts create mode 100644 src/app/pages/legal/cgv/cgv.module.ts delete mode 100644 src/app/pages/vote/vote-page/vote-page.component.scss delete mode 100644 src/app/pages/vote/vote-page/vote-page.component.spec.ts create mode 100644 src/app/pages/vote/vote-routing.module.ts rename src/app/pages/vote/{vote-page/vote-page.component.html => vote.component.html} (100%) rename src/app/pages/{about/about.component.scss => vote/vote.component.scss} (100%) create mode 100644 src/app/pages/vote/vote.component.spec.ts rename src/app/pages/vote/{vote-page/vote-page.component.ts => vote.component.ts} (63%) create mode 100644 src/app/pages/vote/vote.module.ts diff --git a/src/app/app-routing.module.ts b/src/app/app-routing.module.ts index 8cf6468..45f0112 100644 --- a/src/app/app-routing.module.ts +++ b/src/app/app-routing.module.ts @@ -1,11 +1,5 @@ import {NgModule} from '@angular/core'; import {RouterModule, Routes} from '@angular/router'; -import {CgvComponent} from "./pages/legal/cgv/cgv.component"; -import {CguComponent} from "./pages/legal/cgu/cgu.component"; -import {AboutComponent} from "./pages/about/about.component"; -import {JoinComponent} from "./pages/join/join.component"; -import {NewsListPageComponent} from "./pages/news/news-list-page/news-list-page.component"; -import {VotePageComponent} from "./pages/vote/vote-page/vote-page.component"; import {AccueilComponent} from "./pages/accueil/accueil.component"; const routes: Routes = [ @@ -15,39 +9,35 @@ const routes: Routes = [ }, { path: 'cgv', - component: CgvComponent + loadChildren: () => import('./pages/legal/cgv/cgv.module').then(m => m.CgvModule) }, { path: 'cgu', - component: CguComponent - }, - { - path: 'about', - component: AboutComponent + loadChildren: () => import('./pages/legal/cgu/cgu.module').then(m => m.CguModule) }, { path: 'join', - component: JoinComponent - }, - { - path: 'news', - component: NewsListPageComponent + loadChildren: () => import('./pages/join/join.module').then(m => m.JoinModule) }, { path: 'vote', - component: VotePageComponent + loadChildren: () => import('./pages/vote/vote.module').then(m => m.VoteModule) }, { - path: 'shop', loadChildren: () => import('./pages/shop/shop.module').then(m => m.ShopModule) + path: 'shop', + loadChildren: () => import('./pages/shop/shop.module').then(m => m.ShopModule) }, { - path: 'user', loadChildren: () => import('./pages/user/user.module').then(m => m.UserModule) + path: 'user', + loadChildren: () => import('./pages/user/user.module').then(m => m.UserModule) }, { - path: 'wiki', loadChildren: () => import('./pages/wiki/wiki.module').then(m => m.WikiModule) + path: 'wiki', + loadChildren: () => import('./pages/wiki/wiki.module').then(m => m.WikiModule) }, { - path: 'news', loadChildren: () => import('./pages/news/news.module').then(m => m.NewsModule) + path: 'news', + loadChildren: () => import('./pages/news/news.module').then(m => m.NewsModule) }, { path: '**', diff --git a/src/app/app.module.ts b/src/app/app.module.ts index 9f1d2d8..a81b67c 100644 --- a/src/app/app.module.ts +++ b/src/app/app.module.ts @@ -6,11 +6,6 @@ import {AppComponent} from './app.component'; import {NavbarComponent} from './components/navbar/navbar.component'; import {FooterComponent} from './components/footer/footer.component'; import {FontAwesomeModule} from "@fortawesome/angular-fontawesome"; -import {CguComponent} from './pages/legal/cgu/cgu.component'; -import {CgvComponent} from './pages/legal/cgv/cgv.component'; -import {AboutComponent} from './pages/about/about.component'; -import {JoinComponent} from './pages/join/join.component'; -import {VotePageComponent} from './pages/vote/vote-page/vote-page.component'; import {HttpClientModule} from "@angular/common/http"; import {NgForOf, NgIf, NgOptimizedImage} from "@angular/common"; import {NewsModule} from "./pages/news/news.module"; @@ -35,17 +30,10 @@ import {AboutAccueilSectionComponent} from "./pages/accueil/components/about/abo AccueilComponent, WelcomeAccueilSectionComponent, - AboutComponent, AboutDetailsAccueilSectionComponent, NewsAccueilSectionComponent, SocialsAccueilSectionComponent, StaffAccueilSectionComponent, - - CguComponent, - CgvComponent, - AboutComponent, - JoinComponent, - VotePageComponent, AboutAccueilSectionComponent ], imports: [ @@ -64,8 +52,7 @@ import {AboutAccueilSectionComponent} from "./pages/accueil/components/about/abo provideClientHydration() ], exports: [ - NotificationComponent, - AboutComponent + NotificationComponent ], bootstrap: [AppComponent] }) diff --git a/src/app/pages/about/about.component.html b/src/app/pages/about/about.component.html deleted file mode 100644 index c9a5930..0000000 --- a/src/app/pages/about/about.component.html +++ /dev/null @@ -1,5 +0,0 @@ -
-

A propos de Pacifista

- -

A rédiger

-
diff --git a/src/app/pages/about/about.component.spec.ts b/src/app/pages/about/about.component.spec.ts deleted file mode 100644 index 7e3a2ca..0000000 --- a/src/app/pages/about/about.component.spec.ts +++ /dev/null @@ -1,23 +0,0 @@ -import { ComponentFixture, TestBed } from '@angular/core/testing'; - -import { AboutComponent } from './about.component'; - -describe('AboutComponent', () => { - let component: AboutComponent; - let fixture: ComponentFixture; - - beforeEach(async () => { - await TestBed.configureTestingModule({ - declarations: [ AboutComponent ] - }) - .compileComponents(); - - fixture = TestBed.createComponent(AboutComponent); - component = fixture.componentInstance; - fixture.detectChanges(); - }); - - it('should create', () => { - expect(component).toBeTruthy(); - }); -}); diff --git a/src/app/pages/about/about.component.ts b/src/app/pages/about/about.component.ts deleted file mode 100644 index 6788a34..0000000 --- a/src/app/pages/about/about.component.ts +++ /dev/null @@ -1,19 +0,0 @@ -import { Component } from '@angular/core'; -import {Title} from "@angular/platform-browser"; - -@Component({ - selector: 'app-about', - templateUrl: './about.component.html', - styleUrls: ['./about.component.scss'] -}) -export class AboutComponent { - - constructor(private titleService: Title) { - const title: string = titleService.getTitle(); - - if (!title.startsWith("A propos")) { - titleService.setTitle('A propos - ' + title); - } - } - -} diff --git a/src/app/pages/join/join-routing.module.ts b/src/app/pages/join/join-routing.module.ts new file mode 100644 index 0000000..4c22152 --- /dev/null +++ b/src/app/pages/join/join-routing.module.ts @@ -0,0 +1,16 @@ +import {NgModule} from '@angular/core'; +import {RouterModule, Routes} from "@angular/router"; +import {JoinComponent} from "./join.component"; + +const routes: Routes = [ + { + path: '', + component: JoinComponent + } +]; + +@NgModule({ + imports: [RouterModule.forChild(routes)], + exports: [RouterModule] +}) +export class JoinRoutingModule { } diff --git a/src/app/pages/join/join.module.ts b/src/app/pages/join/join.module.ts new file mode 100644 index 0000000..e198291 --- /dev/null +++ b/src/app/pages/join/join.module.ts @@ -0,0 +1,16 @@ +import {NgModule} from '@angular/core'; +import {CommonModule} from '@angular/common'; +import {JoinComponent} from "./join.component"; +import {JoinRoutingModule} from "./join-routing.module"; + + +@NgModule({ + declarations: [ + JoinComponent + ], + imports: [ + CommonModule, + JoinRoutingModule + ] +}) +export class JoinModule { } diff --git a/src/app/pages/legal/cgu/cgu-routing.module.ts b/src/app/pages/legal/cgu/cgu-routing.module.ts new file mode 100644 index 0000000..16c88c7 --- /dev/null +++ b/src/app/pages/legal/cgu/cgu-routing.module.ts @@ -0,0 +1,16 @@ +import {NgModule} from '@angular/core'; +import {RouterModule, Routes} from "@angular/router"; +import {CguComponent} from "./cgu.component"; + +const routes: Routes = [ + { + path: '', + component: CguComponent + } +]; + +@NgModule({ + imports: [RouterModule.forChild(routes)], + exports: [RouterModule] +}) +export class CguRoutingModule { } diff --git a/src/app/pages/legal/cgu/cgu.module.ts b/src/app/pages/legal/cgu/cgu.module.ts new file mode 100644 index 0000000..6078107 --- /dev/null +++ b/src/app/pages/legal/cgu/cgu.module.ts @@ -0,0 +1,16 @@ +import {NgModule} from '@angular/core'; +import {CommonModule} from '@angular/common'; +import {CguComponent} from "./cgu.component"; +import {CguRoutingModule} from "./cgu-routing.module"; + + +@NgModule({ + declarations: [ + CguComponent + ], + imports: [ + CommonModule, + CguRoutingModule + ] +}) +export class CguModule { } diff --git a/src/app/pages/legal/cgv/cgv-routing.module.ts b/src/app/pages/legal/cgv/cgv-routing.module.ts new file mode 100644 index 0000000..1794e7d --- /dev/null +++ b/src/app/pages/legal/cgv/cgv-routing.module.ts @@ -0,0 +1,16 @@ +import {NgModule} from '@angular/core'; +import {RouterModule, Routes} from "@angular/router"; +import {CgvComponent} from "./cgv.component"; + +const routes: Routes = [ + { + path: '', + component: CgvComponent + } +]; + +@NgModule({ + imports: [RouterModule.forChild(routes)], + exports: [RouterModule] +}) +export class CgvRoutingModule { } diff --git a/src/app/pages/legal/cgv/cgv.component.ts b/src/app/pages/legal/cgv/cgv.component.ts index a9a8d60..a029724 100644 --- a/src/app/pages/legal/cgv/cgv.component.ts +++ b/src/app/pages/legal/cgv/cgv.component.ts @@ -1,4 +1,4 @@ -import { Component } from '@angular/core'; +import {Component} from '@angular/core'; import {Title} from "@angular/platform-browser"; @Component({ @@ -13,6 +13,7 @@ export class CgvComponent { if (!title.startsWith("CGV")) { titleService.setTitle('CGV - ' + title); - } } + } + } } diff --git a/src/app/pages/legal/cgv/cgv.module.ts b/src/app/pages/legal/cgv/cgv.module.ts new file mode 100644 index 0000000..e2cf7e0 --- /dev/null +++ b/src/app/pages/legal/cgv/cgv.module.ts @@ -0,0 +1,16 @@ +import {NgModule} from '@angular/core'; +import {CommonModule} from '@angular/common'; +import {CgvComponent} from "./cgv.component"; +import {CgvRoutingModule} from "./cgv-routing.module"; + + +@NgModule({ + declarations: [ + CgvComponent + ], + imports: [ + CommonModule, + CgvRoutingModule + ] +}) +export class CgvModule { } diff --git a/src/app/pages/vote/vote-page/vote-page.component.scss b/src/app/pages/vote/vote-page/vote-page.component.scss deleted file mode 100644 index e69de29..0000000 diff --git a/src/app/pages/vote/vote-page/vote-page.component.spec.ts b/src/app/pages/vote/vote-page/vote-page.component.spec.ts deleted file mode 100644 index 6d8fe69..0000000 --- a/src/app/pages/vote/vote-page/vote-page.component.spec.ts +++ /dev/null @@ -1,23 +0,0 @@ -import { ComponentFixture, TestBed } from '@angular/core/testing'; - -import { VotePageComponent } from './vote-page.component'; - -describe('VotePageComponent', () => { - let component: VotePageComponent; - let fixture: ComponentFixture; - - beforeEach(async () => { - await TestBed.configureTestingModule({ - declarations: [ VotePageComponent ] - }) - .compileComponents(); - - fixture = TestBed.createComponent(VotePageComponent); - component = fixture.componentInstance; - fixture.detectChanges(); - }); - - it('should create', () => { - expect(component).toBeTruthy(); - }); -}); diff --git a/src/app/pages/vote/vote-routing.module.ts b/src/app/pages/vote/vote-routing.module.ts new file mode 100644 index 0000000..e6563ca --- /dev/null +++ b/src/app/pages/vote/vote-routing.module.ts @@ -0,0 +1,16 @@ +import {NgModule} from '@angular/core'; +import {RouterModule, Routes} from "@angular/router"; +import {VoteComponent} from "./vote.component"; + +const routes: Routes = [ + { + path: '', + component: VoteComponent + } +]; + +@NgModule({ + imports: [RouterModule.forChild(routes)], + exports: [RouterModule] +}) +export class VoteRoutingModule { } diff --git a/src/app/pages/vote/vote-page/vote-page.component.html b/src/app/pages/vote/vote.component.html similarity index 100% rename from src/app/pages/vote/vote-page/vote-page.component.html rename to src/app/pages/vote/vote.component.html diff --git a/src/app/pages/about/about.component.scss b/src/app/pages/vote/vote.component.scss similarity index 100% rename from src/app/pages/about/about.component.scss rename to src/app/pages/vote/vote.component.scss diff --git a/src/app/pages/vote/vote.component.spec.ts b/src/app/pages/vote/vote.component.spec.ts new file mode 100644 index 0000000..b7c7e95 --- /dev/null +++ b/src/app/pages/vote/vote.component.spec.ts @@ -0,0 +1,23 @@ +import {ComponentFixture, TestBed} from '@angular/core/testing'; + +import {VoteComponent} from './vote.component'; + +describe('VotePageComponent', () => { + let component: VoteComponent; + let fixture: ComponentFixture; + + beforeEach(async () => { + await TestBed.configureTestingModule({ + declarations: [ VoteComponent ] + }) + .compileComponents(); + + fixture = TestBed.createComponent(VoteComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/src/app/pages/vote/vote-page/vote-page.component.ts b/src/app/pages/vote/vote.component.ts similarity index 63% rename from src/app/pages/vote/vote-page/vote-page.component.ts rename to src/app/pages/vote/vote.component.ts index ed0f410..ae4fe31 100644 --- a/src/app/pages/vote/vote-page/vote-page.component.ts +++ b/src/app/pages/vote/vote.component.ts @@ -1,12 +1,12 @@ -import { Component } from '@angular/core'; +import {Component} from '@angular/core'; import {Title} from "@angular/platform-browser"; @Component({ selector: 'app-vote-page', - templateUrl: './vote-page.component.html', - styleUrls: ['./vote-page.component.scss'] + templateUrl: './vote.component.html', + styleUrls: ['./vote.component.scss'] }) -export class VotePageComponent { +export class VoteComponent { constructor(private titleService: Title) { const title: string = titleService.getTitle(); diff --git a/src/app/pages/vote/vote.module.ts b/src/app/pages/vote/vote.module.ts new file mode 100644 index 0000000..703acb4 --- /dev/null +++ b/src/app/pages/vote/vote.module.ts @@ -0,0 +1,16 @@ +import {NgModule} from '@angular/core'; +import {CommonModule} from '@angular/common'; +import {VoteComponent} from "./vote.component"; +import {VoteRoutingModule} from "./vote-routing.module"; + + +@NgModule({ + declarations: [ + VoteComponent + ], + imports: [ + CommonModule, + VoteRoutingModule + ] +}) +export class VoteModule { }