---|qcm| Mise à jour du component 'QCM'

This commit is contained in:
Julien Gautier
2023-10-06 01:54:33 +02:00
parent 6f2bdf2b4f
commit 08273863b7
8 changed files with 50 additions and 23 deletions
+4
View File
@@ -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)
@@ -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<AeronefByImat>;
aeronefs!: Array<Aeronef>;
aeronefsCount = 0;
canopyAggregate!: Array<CanopyModelBySize>;
canopies!: Array<Canopy>;
canopiesCount = 0;
dropzoneAggregate!: Array<DropZoneByYear>;
dropzones!: Array<DropZone>;
dropzonesCount = 0;
public title = 'Dashboard';
public errors!: Errors;
public isAuthenticated = false;
public canModify = false;
public aeronefAggregate!: Array<AeronefByImat>;
public aeronefs!: Array<Aeronef>;
public aeronefsCount = 0;
public canopyAggregate!: Array<CanopyModelBySize>;
public canopies!: Array<Canopy>;
public canopiesCount = 0;
public dropzoneAggregate!: Array<DropZoneByYear>;
public dropzones!: Array<DropZone>;
public dropzonesCount = 0;
constructor(
private route: ActivatedRoute,
@@ -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<Question> {
constructor(
private _jumpsService: JumpsService,
private _qcmService: QCMService,
private router: Router
) { }
@@ -18,7 +18,7 @@ export class QCMResolver implements Resolve<Question> {
state: RouterStateSnapshot
): Observable<any> {
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')));
}
}
@@ -1 +1,5 @@
<div class="content">
<h1>{{title}}</h1>
<hr />
<p>qcm works!</p>
</div>
+6
View File
@@ -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<any> = 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<User> = this._userService.currentUser;
@@ -87,7 +87,7 @@
</mat-list-item>
<div *ngIf="showQCMMenu">
<mat-list-item appAccordionLink *ngFor="let menuqcm of menuItems.getMenuQCM()" routerLinkActive="selected" group="{{ menuqcm.state}}">
<a class="ps-4" appAccordionToggle [routerLink]="['/', menuqcm.state]" *ngIf=" menuqcm.type === 'link'">
<a class="ps-4" appAccordionToggle [routerLink]="['/qcm', menuqcm.state]" *ngIf=" menuqcm.type === 'link'">
<mat-icon [fontIcon]="menuqcm.icon" class="mt-0 mr-2"></mat-icon>
<span>{{ menuqcm.name }}</span>
<span class="flex-spacer"></span>
+3 -3
View File
@@ -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[] = [
+14
View File
@@ -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<QCM> {
return this.apiService.get(`/qcm/${type}`)
.pipe(map(data => data.qcm));
}
}