Ajout de variables d'environnement pour
la Prod et le Local (url de l'API)
This commit is contained in:
@@ -1,24 +1,34 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { HttpClient, HttpHeaders } from '@angular/common/http';
|
||||
import { Observable } from 'rxjs';
|
||||
import { map } from 'rxjs/operators';
|
||||
|
||||
import { DropZoneResp } from '../models/dropzone';
|
||||
import { JumpResp } from '../models/jump';
|
||||
import { AircraftResp } from '../models/aircraft';
|
||||
import { JumpTypeResp } from '../models/jumpType';
|
||||
import { StatsResp, StatsByDzResp, StatsByAircraftResp, StatsByJumpTypeResp, StatsByRigResp, StatsByYearResp } from '../models/statsresp';
|
||||
import { Injectable } from "@angular/core";
|
||||
import { HttpClient, HttpHeaders } from "@angular/common/http";
|
||||
import { Observable } from "rxjs";
|
||||
import { map } from "rxjs/operators";
|
||||
|
||||
import { DropZoneResp } from "../models/dropzone";
|
||||
import { JumpResp } from "../models/jump";
|
||||
import { AircraftResp } from "../models/aircraft";
|
||||
import { JumpTypeResp } from "../models/jumpType";
|
||||
import {
|
||||
StatsResp,
|
||||
StatsByDzResp,
|
||||
StatsByAircraftResp,
|
||||
StatsByJumpTypeResp,
|
||||
StatsByRigResp,
|
||||
StatsByYearResp
|
||||
} from "../models/statsresp";
|
||||
import { environment } from "../environments/environment";
|
||||
|
||||
@Injectable()
|
||||
export class ServiceApiGet {
|
||||
private readonly headers = new HttpHeaders({
|
||||
'Access-Control-Allow-Origin': 'http://localhost:5000',
|
||||
"Access-Control-Allow-Origin": environment.urlApi
|
||||
});
|
||||
constructor(private http: HttpClient) { }
|
||||
constructor(private http: HttpClient) {}
|
||||
|
||||
public getListOfDropZones(): Observable<Array<DropZoneResp>> {
|
||||
return this.http.get<Array<DropZoneResp>>('http://localhost:5000/api/DropZone', { headers: this.headers })
|
||||
return this.http
|
||||
.get<Array<DropZoneResp>>(`${environment.urlApi}/api/DropZone`, {
|
||||
headers: this.headers
|
||||
})
|
||||
.pipe(
|
||||
map(response => {
|
||||
const details = response.map(data => new DropZoneResp(data));
|
||||
@@ -28,24 +38,47 @@ export class ServiceApiGet {
|
||||
}
|
||||
|
||||
public getListOfJumps(): Observable<Array<JumpResp>> {
|
||||
return this.http.get<Array<JumpResp>>('http://localhost:5000/api/Jump', { headers: this.headers });
|
||||
return this.http.get<Array<JumpResp>>(`${environment.urlApi}/api/Jump`, {
|
||||
headers: this.headers
|
||||
});
|
||||
}
|
||||
|
||||
public getListOfAircrafts(): Observable<Array<AircraftResp>> {
|
||||
return this.http.get<Array<AircraftResp>>('http://localhost:5000/api/Aircraft', { headers: this.headers });
|
||||
return this.http.get<Array<AircraftResp>>(
|
||||
`${environment.urlApi}/api/Aircraft`,
|
||||
{ headers: this.headers }
|
||||
);
|
||||
}
|
||||
|
||||
public getListOfJumpTypes(): Observable<Array<JumpTypeResp>> {
|
||||
return this.http.get<Array<JumpTypeResp>>('http://localhost:5000/api/JumpType', { headers: this.headers });
|
||||
return this.http.get<Array<JumpTypeResp>>(
|
||||
`${environment.urlApi}/api/JumpType`,
|
||||
{ headers: this.headers }
|
||||
);
|
||||
}
|
||||
|
||||
public getStatsOfJumps(): StatsResp {
|
||||
const resultat = new StatsResp();
|
||||
resultat.statsByDz = this.http.get<StatsByDzResp>('http://localhost:5000/api/Stats/ByDz', { headers: this.headers });
|
||||
resultat.statsByAircraft = this.http.get<StatsByAircraftResp>('http://localhost:5000/api/Stats/ByAircraft', { headers: this.headers });
|
||||
resultat.statsByJumpType = this.http.get<StatsByJumpTypeResp>('http://localhost:5000/api/Stats/ByJumpType', { headers: this.headers });
|
||||
resultat.statsByRig = this.http.get<StatsByRigResp>('http://localhost:5000/api/Stats/ByRig', { headers: this.headers });
|
||||
resultat.statsByYear = this.http.get<StatsByYearResp>('http://localhost:5000/api/Stats/ByYear', { headers: this.headers });
|
||||
resultat.statsByDz = this.http.get<StatsByDzResp>(
|
||||
`${environment.urlApi}/api/Stats/ByDz`,
|
||||
{ headers: this.headers }
|
||||
);
|
||||
resultat.statsByAircraft = this.http.get<StatsByAircraftResp>(
|
||||
`${environment.urlApi}/api/Stats/ByAircraft`,
|
||||
{ headers: this.headers }
|
||||
);
|
||||
resultat.statsByJumpType = this.http.get<StatsByJumpTypeResp>(
|
||||
`${environment.urlApi}/api/Stats/ByJumpType`,
|
||||
{ headers: this.headers }
|
||||
);
|
||||
resultat.statsByRig = this.http.get<StatsByRigResp>(
|
||||
`${environment.urlApi}/api/Stats/ByRig`,
|
||||
{ headers: this.headers }
|
||||
);
|
||||
resultat.statsByYear = this.http.get<StatsByYearResp>(
|
||||
`${environment.urlApi}/api/Stats/ByYear`,
|
||||
{ headers: this.headers }
|
||||
);
|
||||
|
||||
return resultat;
|
||||
}
|
||||
|
||||
@@ -1,17 +1,18 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { HttpClient, HttpHeaders } from '@angular/common/http';
|
||||
|
||||
import { JumpReq } from '../models/jump';
|
||||
import { Injectable } from "@angular/core";
|
||||
import { HttpClient, HttpHeaders } from "@angular/common/http";
|
||||
|
||||
import { JumpReq } from "../models/jump";
|
||||
import { environment } from "../environments/environment";
|
||||
|
||||
@Injectable()
|
||||
export class ServiceApiPost {
|
||||
private readonly headers = new HttpHeaders({
|
||||
'Access-Control-Allow-Origin': 'http://localhost:5000',
|
||||
"Access-Control-Allow-Origin": environment.urlApi
|
||||
});
|
||||
constructor(private http: HttpClient) { }
|
||||
constructor(private http: HttpClient) {}
|
||||
|
||||
public AddJumps(selectedJumpType: number,
|
||||
public AddJumps(
|
||||
selectedJumpType: number,
|
||||
selectedAircraft: number,
|
||||
selectedDz: number,
|
||||
selectedRig: number,
|
||||
@@ -19,8 +20,8 @@ export class ServiceApiPost {
|
||||
jumpDate: Date,
|
||||
defaultExitAltitude: number,
|
||||
defaultDeployAltitude: number,
|
||||
countOfJumps: number) {
|
||||
|
||||
countOfJumps: number
|
||||
) {
|
||||
for (let i = 0; i < countOfJumps; i++) {
|
||||
const bodyNewjump: JumpReq = {
|
||||
jumpTypeId: selectedJumpType,
|
||||
@@ -30,7 +31,7 @@ export class ServiceApiPost {
|
||||
exitAltitude: defaultExitAltitude,
|
||||
deployAltitude: defaultDeployAltitude,
|
||||
gearId: selectedRig,
|
||||
notes: '',
|
||||
notes: "",
|
||||
id: 0,
|
||||
jumpDate: jumpDate
|
||||
};
|
||||
@@ -43,7 +44,8 @@ export class ServiceApiPost {
|
||||
}
|
||||
}
|
||||
|
||||
public AddListOfJump(selectedJumpType: number,
|
||||
public AddListOfJump(
|
||||
selectedJumpType: number,
|
||||
selectedAircraft: number,
|
||||
selectedDz: number,
|
||||
selectedRig: number,
|
||||
@@ -52,15 +54,14 @@ export class ServiceApiPost {
|
||||
endDate: Date,
|
||||
defaultExitAltitude: number,
|
||||
defaultDeployAltitude: number,
|
||||
countOfJumps: number) {
|
||||
|
||||
countOfJumps: number
|
||||
) {
|
||||
const diffInTime = endDate.getTime() - beginDate.getTime();
|
||||
const diffInDays = Math.round(diffInTime / (1000 * 3600 * 24));
|
||||
|
||||
const countOfJumpsPerDay = Math.trunc(countOfJumps / diffInDays);
|
||||
let temp: Date = beginDate;
|
||||
for (let i = 1; temp.getDate() < endDate.getDate(); i++) {
|
||||
|
||||
this.AddJumps(
|
||||
selectedJumpType,
|
||||
selectedAircraft,
|
||||
@@ -76,7 +77,7 @@ export class ServiceApiPost {
|
||||
temp.setDate(temp.getDate() + 1);
|
||||
}
|
||||
|
||||
const restfJumps = countOfJumps - (countOfJumpsPerDay * (diffInDays - 1));
|
||||
const restfJumps = countOfJumps - countOfJumpsPerDay * (diffInDays - 1);
|
||||
this.AddJumps(
|
||||
selectedJumpType,
|
||||
selectedAircraft,
|
||||
|
||||
Reference in New Issue
Block a user