From 08273863b7650216e8e01110de2ae8a46f623495 Mon Sep 17 00:00:00 2001 From: Julien Gautier Date: Fri, 6 Oct 2023 01:54:33 +0200 Subject: [PATCH] =?UTF-8?q?---|qcm|=20Mise=20=C3=A0=20jour=20du=20componen?= =?UTF-8?q?t=20'QCM'?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/app/app-routing.module.ts | 4 +++ .../dashboard/dashboard.component.ts | 27 +++++++++---------- .../components/qcm/qcm-resolver.service.ts | 8 +++--- src/app/components/qcm/qcm.component.html | 6 ++++- src/app/components/qcm/qcm.component.ts | 6 +++++ .../shared/layout/full.component.html | 2 +- src/app/components/shared/menu-items.ts | 6 ++--- src/app/core/services/qcm.service.ts | 14 ++++++++++ 8 files changed, 50 insertions(+), 23 deletions(-) diff --git a/src/app/app-routing.module.ts b/src/app/app-routing.module.ts index 31ef6d6..2f432fe 100644 --- a/src/app/app-routing.module.ts +++ b/src/app/app-routing.module.ts @@ -22,6 +22,10 @@ const routes: Routes = [ path: 'profile', loadChildren: () => import('./components/profile/profile.module').then(m => m.ProfileModule) }, + { + path: 'qcm', + loadChildren: () => import('./components/qcm/qcm.module').then(m => m.QCMModule) + }, { path: 'settings', loadChildren: () => import('./components/settings/settings.module').then(m => m.SettingsModule) diff --git a/src/app/components/dashboard/dashboard.component.ts b/src/app/components/dashboard/dashboard.component.ts index 6fcf693..7bdab63 100644 --- a/src/app/components/dashboard/dashboard.component.ts +++ b/src/app/components/dashboard/dashboard.component.ts @@ -37,20 +37,19 @@ export class DashboardComponent implements OnInit, OnDestroy { private _canopies: Subscription = new Subscription(); private _dropzones: Subscription = new Subscription(); */ - title = 'Dashboard'; - errors!: Errors; - isAuthenticated = false; - canModify = false; - - aeronefAggregate!: Array; - aeronefs!: Array; - aeronefsCount = 0; - canopyAggregate!: Array; - canopies!: Array; - canopiesCount = 0; - dropzoneAggregate!: Array; - dropzones!: Array; - dropzonesCount = 0; + public title = 'Dashboard'; + public errors!: Errors; + public isAuthenticated = false; + public canModify = false; + public aeronefAggregate!: Array; + public aeronefs!: Array; + public aeronefsCount = 0; + public canopyAggregate!: Array; + public canopies!: Array; + public canopiesCount = 0; + public dropzoneAggregate!: Array; + public dropzones!: Array; + public dropzonesCount = 0; constructor( private route: ActivatedRoute, diff --git a/src/app/components/qcm/qcm-resolver.service.ts b/src/app/components/qcm/qcm-resolver.service.ts index 31d9a6a..47b6f8d 100644 --- a/src/app/components/qcm/qcm-resolver.service.ts +++ b/src/app/components/qcm/qcm-resolver.service.ts @@ -3,13 +3,13 @@ import { ActivatedRouteSnapshot, Resolve, Router, RouterStateSnapshot } from '@a import { Observable } from 'rxjs'; import { Question } from 'src/app/core/models'; -import { JumpsService } from 'src/app/core/services'; +import { QCMService } from 'src/app/core/services'; import { catchError } from 'rxjs/operators'; @Injectable() export class QCMResolver implements Resolve { constructor( - private _jumpsService: JumpsService, + private _qcmService: QCMService, private router: Router ) { } @@ -18,7 +18,7 @@ export class QCMResolver implements Resolve { state: RouterStateSnapshot ): Observable { - return this._jumpsService.get(route.params['type']) - .pipe(catchError(() => this.router.navigateByUrl('/'))); + return this._qcmService.get(route.params['type']) + .pipe(catchError(() => this.router.navigateByUrl('/dashboard'))); } } diff --git a/src/app/components/qcm/qcm.component.html b/src/app/components/qcm/qcm.component.html index f52e6b6..6959f66 100644 --- a/src/app/components/qcm/qcm.component.html +++ b/src/app/components/qcm/qcm.component.html @@ -1 +1,5 @@ -

qcm works!

+
+

{{title}}

+
+

qcm works!

+
diff --git a/src/app/components/qcm/qcm.component.ts b/src/app/components/qcm/qcm.component.ts index ba8bdd0..418fa33 100644 --- a/src/app/components/qcm/qcm.component.ts +++ b/src/app/components/qcm/qcm.component.ts @@ -19,6 +19,7 @@ export class QCMComponent implements OnInit, OnDestroy { public qcm: QCM = {} as QCM; public currentUser: User = {} as User; public canModify = false; + public title = 'QCM Brevets'; constructor( private route: ActivatedRoute, @@ -31,6 +32,11 @@ export class QCMComponent implements OnInit, OnDestroy { const data$: Observable = this.route.data; this._data = data$.subscribe((data: { qcm: QCM }) => { this.qcm = data.qcm; + if (this.qcm.name == 'bpa') { + this.title = 'QCM du BPA'; + } else { + this.title = `QCM Brevets ${this.qcm.name.toUpperCase()}`; + } }); // Load the current user's data const currentUser$: Observable = this._userService.currentUser; diff --git a/src/app/components/shared/layout/full.component.html b/src/app/components/shared/layout/full.component.html index 055f704..f9ebc64 100755 --- a/src/app/components/shared/layout/full.component.html +++ b/src/app/components/shared/layout/full.component.html @@ -87,7 +87,7 @@
- + {{ menuqcm.name }} diff --git a/src/app/components/shared/menu-items.ts b/src/app/components/shared/menu-items.ts index a5a21e3..5c059b5 100755 --- a/src/app/components/shared/menu-items.ts +++ b/src/app/components/shared/menu-items.ts @@ -16,9 +16,9 @@ const MENUITEMS: Menu[] = [ ]; const MENUQCM: Menu[] = [ - { state: 'qcm/bpa', type: 'link', name: 'BPA', icon: 'rule' }, - { state: 'qcm/c', type: 'link', name: 'Brevet C', icon: 'rule' }, - { state: 'qcm/d', type: 'link', name: 'Brevet D', icon: 'rule' } + { state: 'bpa', type: 'link', name: 'BPA', icon: 'rule' }, + { state: 'c', type: 'link', name: 'Brevet C', icon: 'rule' }, + { state: 'd', type: 'link', name: 'Brevet D', icon: 'rule' } ]; const MENUPANEL: Menu[] = [ diff --git a/src/app/core/services/qcm.service.ts b/src/app/core/services/qcm.service.ts index 187e8d7..d2be433 100644 --- a/src/app/core/services/qcm.service.ts +++ b/src/app/core/services/qcm.service.ts @@ -1,5 +1,19 @@ import { Injectable } from '@angular/core'; +import { Observable } from 'rxjs'; +import { map } from 'rxjs/operators'; + +import { ApiService } from './api.service'; +import { QCM } from 'src/app/core/models'; @Injectable({ providedIn: 'root' }) export class QCMService { + + constructor( + private apiService: ApiService + ) { } + + get(type: string): Observable { + return this.apiService.get(`/qcm/${type}`) + .pipe(map(data => data.qcm)); + } }