From 5a75685b0a29465793b374c6aa7f86413f0fdd5c Mon Sep 17 00:00:00 2001 From: Tykayn Date: Thu, 10 Jun 2021 10:52:32 +0200 Subject: [PATCH] refacto routing with pass --- src/app/app.component.ts | 14 ++++++++- src/app/app.module.ts | 1 - .../components/header/header.component.html | 23 ++++++++++----- src/app/core/services/poll.service.ts | 2 +- .../consultation-routing.module.ts | 7 +++-- .../consultation/consultation.component.html | 8 ++--- .../consultation/consultation.component.ts | 29 +++++++------------ src/app/routes-framadate.ts | 7 +---- 8 files changed, 49 insertions(+), 42 deletions(-) diff --git a/src/app/app.component.ts b/src/app/app.component.ts index c531c688..4f862d41 100644 --- a/src/app/app.component.ts +++ b/src/app/app.component.ts @@ -6,7 +6,7 @@ import { environment } from '../environments/environment'; import { Theme } from './core/enums/theme.enum'; import { LanguageService } from './core/services/language.service'; import { ThemeService } from './core/services/theme.service'; -import { NavigationEnd, Router, RouterOutlet } from '@angular/router'; +import { NavigationEnd, Route, Router, RouterOutlet } from '@angular/router'; import { slideInAnimation } from './shared/animations/main'; import { FramaKeyboardShortcuts } from './shared/shortcuts/main'; import { ShortcutEventOutput, ShortcutInput } from 'ng-keyboard-shortcuts'; @@ -36,7 +36,19 @@ export class AppComponent implements OnInit, OnDestroy, AfterViewInit { private languageService: LanguageService // private mockingService: MockingService ) {} + printpath(parent: string, config: Route[]) { + for (let i = 0; i < config.length; i++) { + const route = config[i]; + console.info(parent + '/' + route.path); + if (route.children) { + const currentPath = route.path ? parent + '/' + route.path : parent; + this.printpath(currentPath, route.children); + } + } + } + ngOnInit(): void { + this.printpath('', this.router.config); this.router.events.subscribe((evt) => { if (!(evt instanceof NavigationEnd)) { return; diff --git a/src/app/app.module.ts b/src/app/app.module.ts index 8480e7d3..27923488 100644 --- a/src/app/app.module.ts +++ b/src/app/app.module.ts @@ -30,7 +30,6 @@ import { CipheringComponent } from './features/shared/components/ui/static-pages import { ErrorsListComponent } from './features/shared/components/ui/form/errors-list/errors-list.component'; import { KeyboardShortcutsModule } from 'ng-keyboard-shortcuts'; import { AdministrationModule } from './features/administration/administration.module'; -import { ShortcutsHelpComponent } from './features/shared/components/ui/shortcuts-help/shortcuts-help.component'; registerLocaleData(localeEn, 'en-EN'); registerLocaleData(localeFr, 'fr-FR'); diff --git a/src/app/core/components/header/header.component.html b/src/app/core/components/header/header.component.html index 06c39466..8010fc3d 100644 --- a/src/app/core/components/header/header.component.html +++ b/src/app/core/components/header/header.component.html @@ -61,13 +61,9 @@ voici des liens de démonstration issus des fixtures Doctrine de date-poll-api.
- + - le-titre-de-demo-oh-oh + demo + administrer le sondage + + aujourdhui-ou-demain + + + + citron diff --git a/src/app/core/services/poll.service.ts b/src/app/core/services/poll.service.ts index 939fc5bd..42e55394 100644 --- a/src/app/core/services/poll.service.ts +++ b/src/app/core/services/poll.service.ts @@ -104,7 +104,7 @@ export class PollService implements Resolve { this.titleService.setTitle(`☑️ ${poll.title} - ${environment.appTitle}`); } else { this.toastService.display(`sondage ${custom_url} non trouvé`); - this.router.navigate(['page-not-found']); + // this.router.navigate(['page-not-found']); } } else { this.toastService.display(`sondage sans custom url : ${custom_url}`); diff --git a/src/app/features/consultation/consultation-routing.module.ts b/src/app/features/consultation/consultation-routing.module.ts index 110fcbe8..8bba5525 100644 --- a/src/app/features/consultation/consultation-routing.module.ts +++ b/src/app/features/consultation/consultation-routing.module.ts @@ -2,14 +2,17 @@ import { NgModule } from '@angular/core'; import { RouterModule, Routes } from '@angular/router'; import { ConsultationComponent } from './consultation.component'; +import { WipTodoComponent } from '../../shared/components/ui/wip-todo/wip-todo.component'; const routes: Routes = [ + { path: 'secure/:pass_hash', component: ConsultationComponent }, + { path: '', component: ConsultationComponent, children: [ - { path: '/', component: ConsultationComponent }, - { path: '/:pass_hash', component: ConsultationComponent }, + { path: 'simple', component: WipTodoComponent }, + { path: 'table', component: WipTodoComponent }, ], }, ]; diff --git a/src/app/features/consultation/consultation.component.html b/src/app/features/consultation/consultation.component.html index d8b94e9e..ac34e85c 100644 --- a/src/app/features/consultation/consultation.component.html +++ b/src/app/features/consultation/consultation.component.html @@ -19,6 +19,8 @@
+ + @@ -115,10 +117,8 @@