Correction sur la mise en cache des data ref et
la vérification "AlwaysLogin"
This commit is contained in:
@@ -30,22 +30,14 @@ export class AppComponent implements OnInit {
|
||||
private authenticationService: AuthenticationService,
|
||||
private serviceComm: ServiceComm,
|
||||
private serviceCacheApi : ServiceCacheApi,
|
||||
private translateService: TranslateService,
|
||||
private serviceApiAircraft : AircraftService,
|
||||
private serviceApiJumpType : JumpTypeService,
|
||||
private serviceApiDropzone : DropzoneService,
|
||||
private serviceApiGear : GearService)
|
||||
private translateService: TranslateService)
|
||||
{
|
||||
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"); });
|
||||
}
|
||||
});
|
||||
|
||||
@@ -77,13 +69,4 @@ export class AppComponent implements OnInit {
|
||||
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]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,12 @@
|
||||
import { Component, OnInit } from "@angular/core";
|
||||
import { TranslateService } from "@ngx-translate/core";
|
||||
import { Observable, forkJoin } from "rxjs";
|
||||
|
||||
import { AircraftService } from "../../services/aircraft.service";
|
||||
import { AuthenticationService } from "../../services/authentication.service";
|
||||
import { DropzoneService } from "../../services/dropzone.service";
|
||||
import { GearService } from "../../services/gear.service";
|
||||
import { JumpTypeService } from "../../services/jump-type.service";
|
||||
import { ServiceComm } from "../../services/service-comm.service";
|
||||
|
||||
@Component({
|
||||
@@ -9,11 +16,29 @@ import { ServiceComm } from "../../services/service-comm.service";
|
||||
})
|
||||
export class DefaultComponent implements OnInit {
|
||||
constructor(private serviceComm: ServiceComm,
|
||||
private translateService: TranslateService) {}
|
||||
private translateService: TranslateService,
|
||||
private authenticationService: AuthenticationService,
|
||||
private serviceApiAircraft : AircraftService,
|
||||
private serviceApiJumpType : JumpTypeService,
|
||||
private serviceApiDropzone : DropzoneService,
|
||||
private serviceApiGear : GearService) {}
|
||||
|
||||
ngOnInit() {
|
||||
this.authenticationService.alwaysLogin();
|
||||
|
||||
this.putToCacheRefDatas().subscribe(() => { console.log("Push to cache the referentiel datas"); });
|
||||
|
||||
this.translateService.get("Home").subscribe(
|
||||
data => { this.serviceComm.UpdatedComponentTitle(data); }
|
||||
);
|
||||
}
|
||||
|
||||
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]);
|
||||
}
|
||||
}
|
||||
@@ -15,7 +15,7 @@ export class ServiceCacheApi {
|
||||
}
|
||||
|
||||
public get<T>(key: CacheApiKey, callToApi: Observable<T>) : Observable<T> {
|
||||
console.log(`Get cache : ${CacheApiKey[key]}`);
|
||||
console.log(`Get/push cache : ${CacheApiKey[key]}`);
|
||||
const cached = this.cache.get(key);
|
||||
|
||||
if (cached) {
|
||||
|
||||
Reference in New Issue
Block a user