Correction sur la mise en cache des
données référentiel et leurs utilisation sur la liste des sauts.
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import { Component, OnInit } from "@angular/core";
|
||||
import { Router } from "@angular/router";
|
||||
import { TranslateService } from "@ngx-translate/core";
|
||||
import { forkJoin, Observable } from 'rxjs';
|
||||
|
||||
import { User } from "../models/user";
|
||||
import { CacheApiKey } from "../models/cache-api-key.enum";
|
||||
@@ -9,6 +10,10 @@ import { AuthenticationService } from "../services/authentication.service";
|
||||
import { ServiceComm } from "../services/service-comm.service";
|
||||
import { ConfigurationHelper } from "../services/configuration-helper";
|
||||
import { ServiceCacheApi } from "../services/service-cache-api.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",
|
||||
@@ -19,37 +24,66 @@ export class AppComponent implements OnInit {
|
||||
public title = "app";
|
||||
public currentUser: User;
|
||||
public version: string;
|
||||
public selectedLanguageFlag: string;
|
||||
|
||||
constructor(private router: Router,
|
||||
private authenticationService: AuthenticationService,
|
||||
private serviceComm: ServiceComm,
|
||||
private serviceCacheApi : ServiceCacheApi,
|
||||
private translateService: TranslateService)
|
||||
private translateService: TranslateService,
|
||||
private serviceApiAircraft : AircraftService,
|
||||
private serviceApiJumpType : JumpTypeService,
|
||||
private serviceApiDropzone : DropzoneService,
|
||||
private serviceApiGear : GearService)
|
||||
{
|
||||
this.authenticationService.currentUser.subscribe(user => {
|
||||
this.currentUser = user;
|
||||
this.translateService.use(user.language);
|
||||
this.authenticationService.alwaysLogin();
|
||||
|
||||
this.authenticationService.currentUser.subscribe(user => {
|
||||
if (user) {
|
||||
this.currentUser = user;
|
||||
this.translateService.addLangs(['en', 'fr']);
|
||||
this.translateService.use(user.language);
|
||||
this.selectedLanguageFlag = user.language;
|
||||
|
||||
this.putToCacheRefDatas().subscribe(() => { console.log("Push to cache the referentiel datas"); });
|
||||
}
|
||||
});
|
||||
|
||||
ConfigurationHelper.settings.subscribe(settings =>
|
||||
{
|
||||
if (settings != null) {
|
||||
this.version = settings.version;
|
||||
}
|
||||
});
|
||||
{
|
||||
if (settings != null) {
|
||||
this.version = settings.version;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
ngOnInit() {
|
||||
this.serviceComm.componentTitle.subscribe(title => (this.title = title));
|
||||
}
|
||||
|
||||
show() {
|
||||
public show() {
|
||||
return this.authenticationService.currentUserValue != undefined;
|
||||
}
|
||||
|
||||
logout() {
|
||||
public logout() {
|
||||
this.serviceCacheApi.delete(CacheApiKey.Dropzone);
|
||||
this.authenticationService.logout();
|
||||
this.router.navigate(["/login"], { skipLocationChange: true });
|
||||
}
|
||||
|
||||
public switchLang(event: any) {
|
||||
this.translateService.use(event.value);
|
||||
this.currentUser.language = event.value;
|
||||
this.authenticationService.currentUserValue = this.currentUser;
|
||||
this.selectedLanguageFlag = event.value;
|
||||
}
|
||||
|
||||
private putToCacheRefDatas(): Observable<any[]> {
|
||||
var aircraftResp = this.serviceApiAircraft.getListOfAircrafts(false);
|
||||
var jumpTypeResp = this.serviceApiJumpType.getListOfJumpTypes();
|
||||
var dzResp = this.serviceApiDropzone.getListOfDropZones(false);
|
||||
var gearResp = this.serviceApiGear.getListOfGears();
|
||||
|
||||
return forkJoin([aircraftResp, jumpTypeResp, dzResp, gearResp]);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user