Ajout de variables d'environnement pour
la Prod et le Local (url de l'API)
This commit is contained in:
@@ -1,3 +1,5 @@
|
|||||||
export const environment = {
|
export const environment = {
|
||||||
production: true
|
production: true,
|
||||||
|
urlApi: "https://skydivelogsapi.azurewebsites.net",
|
||||||
|
debugMode: false
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -4,5 +4,7 @@
|
|||||||
// The list of which env maps to which file can be found in `.angular-cli.json`.
|
// The list of which env maps to which file can be found in `.angular-cli.json`.
|
||||||
|
|
||||||
export const environment = {
|
export const environment = {
|
||||||
production: false
|
production: false,
|
||||||
|
urlApi: "http://localhost:5000",
|
||||||
|
debugMode: false
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,24 +1,34 @@
|
|||||||
import { Injectable } from '@angular/core';
|
import { Injectable } from "@angular/core";
|
||||||
import { HttpClient, HttpHeaders } from '@angular/common/http';
|
import { HttpClient, HttpHeaders } from "@angular/common/http";
|
||||||
import { Observable } from 'rxjs';
|
import { Observable } from "rxjs";
|
||||||
import { map } from 'rxjs/operators';
|
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 { 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()
|
@Injectable()
|
||||||
export class ServiceApiGet {
|
export class ServiceApiGet {
|
||||||
private readonly headers = new HttpHeaders({
|
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>> {
|
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(
|
.pipe(
|
||||||
map(response => {
|
map(response => {
|
||||||
const details = response.map(data => new DropZoneResp(data));
|
const details = response.map(data => new DropZoneResp(data));
|
||||||
@@ -28,24 +38,47 @@ export class ServiceApiGet {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public getListOfJumps(): Observable<Array<JumpResp>> {
|
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>> {
|
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>> {
|
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 {
|
public getStatsOfJumps(): StatsResp {
|
||||||
const resultat = new StatsResp();
|
const resultat = new StatsResp();
|
||||||
resultat.statsByDz = this.http.get<StatsByDzResp>('http://localhost:5000/api/Stats/ByDz', { headers: this.headers });
|
resultat.statsByDz = this.http.get<StatsByDzResp>(
|
||||||
resultat.statsByAircraft = this.http.get<StatsByAircraftResp>('http://localhost:5000/api/Stats/ByAircraft', { headers: this.headers });
|
`${environment.urlApi}/api/Stats/ByDz`,
|
||||||
resultat.statsByJumpType = this.http.get<StatsByJumpTypeResp>('http://localhost:5000/api/Stats/ByJumpType', { headers: this.headers });
|
{ 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.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;
|
return resultat;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,17 +1,18 @@
|
|||||||
import { Injectable } from '@angular/core';
|
import { Injectable } from "@angular/core";
|
||||||
import { HttpClient, HttpHeaders } from '@angular/common/http';
|
import { HttpClient, HttpHeaders } from "@angular/common/http";
|
||||||
|
|
||||||
import { JumpReq } from '../models/jump';
|
|
||||||
|
|
||||||
|
import { JumpReq } from "../models/jump";
|
||||||
|
import { environment } from "../environments/environment";
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class ServiceApiPost {
|
export class ServiceApiPost {
|
||||||
private readonly headers = new HttpHeaders({
|
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,
|
selectedAircraft: number,
|
||||||
selectedDz: number,
|
selectedDz: number,
|
||||||
selectedRig: number,
|
selectedRig: number,
|
||||||
@@ -19,8 +20,8 @@ export class ServiceApiPost {
|
|||||||
jumpDate: Date,
|
jumpDate: Date,
|
||||||
defaultExitAltitude: number,
|
defaultExitAltitude: number,
|
||||||
defaultDeployAltitude: number,
|
defaultDeployAltitude: number,
|
||||||
countOfJumps: number) {
|
countOfJumps: number
|
||||||
|
) {
|
||||||
for (let i = 0; i < countOfJumps; i++) {
|
for (let i = 0; i < countOfJumps; i++) {
|
||||||
const bodyNewjump: JumpReq = {
|
const bodyNewjump: JumpReq = {
|
||||||
jumpTypeId: selectedJumpType,
|
jumpTypeId: selectedJumpType,
|
||||||
@@ -30,7 +31,7 @@ export class ServiceApiPost {
|
|||||||
exitAltitude: defaultExitAltitude,
|
exitAltitude: defaultExitAltitude,
|
||||||
deployAltitude: defaultDeployAltitude,
|
deployAltitude: defaultDeployAltitude,
|
||||||
gearId: selectedRig,
|
gearId: selectedRig,
|
||||||
notes: '',
|
notes: "",
|
||||||
id: 0,
|
id: 0,
|
||||||
jumpDate: jumpDate
|
jumpDate: jumpDate
|
||||||
};
|
};
|
||||||
@@ -43,7 +44,8 @@ export class ServiceApiPost {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public AddListOfJump(selectedJumpType: number,
|
public AddListOfJump(
|
||||||
|
selectedJumpType: number,
|
||||||
selectedAircraft: number,
|
selectedAircraft: number,
|
||||||
selectedDz: number,
|
selectedDz: number,
|
||||||
selectedRig: number,
|
selectedRig: number,
|
||||||
@@ -52,15 +54,14 @@ export class ServiceApiPost {
|
|||||||
endDate: Date,
|
endDate: Date,
|
||||||
defaultExitAltitude: number,
|
defaultExitAltitude: number,
|
||||||
defaultDeployAltitude: number,
|
defaultDeployAltitude: number,
|
||||||
countOfJumps: number) {
|
countOfJumps: number
|
||||||
|
) {
|
||||||
const diffInTime = endDate.getTime() - beginDate.getTime();
|
const diffInTime = endDate.getTime() - beginDate.getTime();
|
||||||
const diffInDays = Math.round(diffInTime / (1000 * 3600 * 24));
|
const diffInDays = Math.round(diffInTime / (1000 * 3600 * 24));
|
||||||
|
|
||||||
const countOfJumpsPerDay = Math.trunc(countOfJumps / diffInDays);
|
const countOfJumpsPerDay = Math.trunc(countOfJumps / diffInDays);
|
||||||
let temp: Date = beginDate;
|
let temp: Date = beginDate;
|
||||||
for (let i = 1; temp.getDate() < endDate.getDate(); i++) {
|
for (let i = 1; temp.getDate() < endDate.getDate(); i++) {
|
||||||
|
|
||||||
this.AddJumps(
|
this.AddJumps(
|
||||||
selectedJumpType,
|
selectedJumpType,
|
||||||
selectedAircraft,
|
selectedAircraft,
|
||||||
@@ -76,7 +77,7 @@ export class ServiceApiPost {
|
|||||||
temp.setDate(temp.getDate() + 1);
|
temp.setDate(temp.getDate() + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
const restfJumps = countOfJumps - (countOfJumpsPerDay * (diffInDays - 1));
|
const restfJumps = countOfJumps - countOfJumpsPerDay * (diffInDays - 1);
|
||||||
this.AddJumps(
|
this.AddJumps(
|
||||||
selectedJumpType,
|
selectedJumpType,
|
||||||
selectedAircraft,
|
selectedAircraft,
|
||||||
|
|||||||
Reference in New Issue
Block a user