Fait 3-4 appels d'API sur la home page
pour mettre en cache les données référentielles.
This commit is contained in:
@@ -2,10 +2,16 @@ import { Component, OnInit } from "@angular/core";
|
||||
import { Router } from "@angular/router";
|
||||
|
||||
import { User } from "../models/user";
|
||||
import { RefData } from "../models/ref-data.enum";
|
||||
|
||||
import { AuthenticationService } from "../services/authentication.service";
|
||||
import { ServiceComm } from "../services/service-comm.service";
|
||||
import { ConfigurationHelper } from "../services/configuration-helper";
|
||||
import { ServiceRefData } from "../services/service-ref-data.service";
|
||||
import { AircraftService } from "../services/aircraft.service";
|
||||
import { GearService } from "../services/gear.service";
|
||||
import { JumpTypeService } from "../services/jump-type.service";
|
||||
import { DropzoneService } from "../services/dropzone.service";
|
||||
|
||||
@Component({
|
||||
selector: "app-root",
|
||||
@@ -14,13 +20,18 @@ import { ConfigurationHelper } from "../services/configuration-helper";
|
||||
})
|
||||
export class AppComponent implements OnInit {
|
||||
public title = "app";
|
||||
public showMenu = false;
|
||||
public currentUser: User;
|
||||
public version: string;
|
||||
|
||||
constructor(private router: Router,
|
||||
private authenticationService: AuthenticationService,
|
||||
private serviceComm: ServiceComm) {
|
||||
private serviceComm: ServiceComm,
|
||||
private serviceRefData : ServiceRefData,
|
||||
private serviceApiAircraft : AircraftService,
|
||||
private serviceApiJumpType : JumpTypeService,
|
||||
private serviceApiDropzone : DropzoneService,
|
||||
private serviceApiGear : GearService)
|
||||
{
|
||||
this.authenticationService.currentUser.subscribe(user => { this.currentUser = user; });
|
||||
|
||||
ConfigurationHelper.settings.subscribe(settings =>
|
||||
@@ -33,6 +44,13 @@ export class AppComponent implements OnInit {
|
||||
|
||||
ngOnInit() {
|
||||
this.serviceComm.componentTitle.subscribe(title => (this.title = title));
|
||||
|
||||
if (this.authenticationService.currentUserValue != undefined) {
|
||||
this.serviceApiAircraft.getListOfAircrafts(false).subscribe();
|
||||
this.serviceApiJumpType.getListOfJumpTypes().subscribe();
|
||||
this.serviceApiDropzone.getListOfDropZones(false).subscribe();
|
||||
this.serviceApiGear.getListOfGears().subscribe();
|
||||
}
|
||||
}
|
||||
|
||||
show() {
|
||||
@@ -40,8 +58,8 @@ export class AppComponent implements OnInit {
|
||||
}
|
||||
|
||||
logout() {
|
||||
this.serviceRefData.delete(RefData.Dropzone);
|
||||
this.authenticationService.logout();
|
||||
this.showMenu = !this.showMenu;
|
||||
this.router.navigate(["/login"], { skipLocationChange: true });
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user