Mise à jours du dashboard

This commit is contained in:
Julien Gautier
2023-09-14 18:28:02 +02:00
parent 0e6b3ef1c7
commit 92b204c769
41 changed files with 981 additions and 852 deletions
+51 -38
View File
@@ -5,18 +5,19 @@ import { ActivatedRoute, Data, Router } from '@angular/router';
import { Observable, Observer, Subscription } from 'rxjs';
import { take } from 'rxjs/operators';
import { User, Errors, Aeronef, AeronefByImat, AeronefList, Canopy, CanopyBySize, DropZone, DropZoneByOaci } from 'src/app/core/models';
import { User, Errors, Aeronef, AeronefByImat, Canopy, CanopyModelBySize, DropZone, DropZoneByYear } from 'src/app/core/models';
import { AeronefsService, CanopiesService, DropZonesService, UserService } from 'src/app/core/services';
import { ShowAuthedDirective } from 'src/app/components/shared/show-authed.directive';
import { AeronefsComponent, DropZonesComponent, CanopyModelsComponent } from './dashboard-components';
import { AeronefsBarComponent, DropZonesComponent, CanopyModelsComponent, CanopySizesComponent, JumpsByMonthComponent } from './dashboard-components';
//import { JumpsByMonthComponent, AeronefsComponent, AeronefsBarComponent, DropZonesComponent, DropZonesBarComponent, CanopySizesComponent, CanopyModelsComponent} from './dashboard-components';
@Component({
standalone: true,
imports: [
ShowAuthedDirective,
AeronefsBarComponent, DropZonesComponent, CanopyModelsComponent, CanopySizesComponent, JumpsByMonthComponent
//AeronefsComponent, AeronefsBarComponent, DropZonesComponent, DropZonesBarComponent,
//CanopySizesComponent, CanopyModelsComponent, JumpsByMonthComponent,
AeronefsComponent, DropZonesComponent, CanopyModelsComponent, ShowAuthedDirective
],
selector: 'huapp-home',
templateUrl: './home.component.html',
@@ -32,13 +33,15 @@ export class HomeComponent implements OnInit, OnDestroy {
errors!: Errors;
isAuthenticated = false;
canModify = false;
aeronefAggregate!: Array<AeronefByImat>
aeronefs!: Array<Aeronef>;
aeronefsCount = 0;
canopyAggregate!: Array<CanopyBySize>
canopyAggregate!: Array<CanopyModelBySize>
canopies!: Array<Canopy>;
canopiesCount = 0;
dropzoneAggregate!: Array<DropZoneByOaci>
//dropzoneAggregate!: Array<DropZoneByOaci>
dropzoneAggregate!: Array<DropZoneByYear>
dropzones!: Array<DropZone>;
dropzonesCount = 0;
@@ -46,10 +49,10 @@ export class HomeComponent implements OnInit, OnDestroy {
private route: ActivatedRoute,
private router: Router,
private titleService: Title,
private userService: UserService,
private aeronefsService: AeronefsService,
private canopiesService: CanopiesService,
private dropzonesService: DropZonesService,
private userService: UserService
private dropzonesService: DropZonesService
) {
this._resetErrors();
}
@@ -64,51 +67,61 @@ export class HomeComponent implements OnInit, OnDestroy {
this.router.navigateByUrl('/login');
return;
}
const currentUser$: Observable<User> = this.userService.currentUser.pipe(take(1));
const currentUser$: Observable<User> = this.userService.currentUser;
this._currentUser = currentUser$.subscribe((userData: User) => {
this.canModify = userData.role === 'Admin';
});
});
this.loadAeronefs();
this.loadCanopies();
this.loadDropzones();
}
/*
this._loadAeronefs();
this._loadCanopies();
this._loadDropzones();
*/
loadAeronefs() {
const aeronefs$: Observable<Array<AeronefByImat>> = this.aeronefsService.getAllByImat();
this._aeronefs = aeronefs$.subscribe((aggregate: Array<AeronefByImat>) => {
this.aeronefAggregate = aggregate;
this.aeronefsCount = aggregate.length;
console.log(this.aeronefs);
console.log(this.aeronefsCount);
});
}
loadCanopies() {
const canopies$: Observable<Array<CanopyBySize>> = this.canopiesService.getAllBySize();
this._canopies = canopies$.subscribe((aggregate: Array<CanopyBySize>) => {
this.canopyAggregate = aggregate;
this.canopiesCount = aggregate.length;
// console.log(this.canopies);
// console.log(this.canopiesCount);
});
}
loadDropzones() {
const dropzones$: Observable<Array<DropZoneByOaci>> = this.dropzonesService.getAllByOaci();
this._dropzones = dropzones$.subscribe((aggregate: Array<DropZoneByOaci>) => {
this.dropzoneAggregate = aggregate;
this.dropzonesCount = aggregate.length;
// console.log(this.dropzones);
// console.log(this.dropzonesCount);
});
}
ngOnDestroy() {
this._currentUser.unsubscribe();
/*
this._aeronefs.unsubscribe();
this._canopies.unsubscribe();
this._dropzones.unsubscribe();
*/
}
private _resetErrors(): void {
this.errors = { errors: {} };
}
private _loadAeronefs(): void {
const aeronefs$: Observable<Array<AeronefByImat>> = this.aeronefsService.getAllByImat();
this._aeronefs = aeronefs$.subscribe((aggregate: Array<AeronefByImat>) => {
this.aeronefAggregate = aggregate;
this.aeronefsCount = aggregate.length;
console.log(this.aeronefAggregate);
console.log(this.aeronefsCount);
});
}
private _loadCanopies(): void {
const canopies$: Observable<Array<CanopyModelBySize>> = this.canopiesService.getAllModelBySize();
this._canopies = canopies$.subscribe((aggregate: Array<CanopyModelBySize>) => {
this.canopyAggregate = aggregate;
this.canopiesCount = aggregate.length;
console.log(this.canopyAggregate);
console.log(this.canopiesCount);
});
}
private _loadDropzones(): void {
//const dropzones$: Observable<Array<DropZoneByOaci>> = this.dropzonesService.getAllByOaci();
//this._dropzones = dropzones$.subscribe((aggregate: Array<DropZoneByOaci>) => {
const dropzones$: Observable<Array<DropZoneByYear>> = this.dropzonesService.getAllByDate();
this._dropzones = dropzones$.subscribe((aggregate: Array<DropZoneByYear>) => {
this.dropzoneAggregate = aggregate;
this.dropzonesCount = aggregate.length;
console.log(this.dropzoneAggregate);
console.log(this.dropzonesCount);
});
}
}