Découpage en 1 service par composant
This commit is contained in:
35
Front/skydivelogs-app/src/services/aircraft.service.ts
Normal file
35
Front/skydivelogs-app/src/services/aircraft.service.ts
Normal file
@@ -0,0 +1,35 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { HttpClient, HttpHeaders } from '@angular/common/http';
|
||||
import { Observable } from 'rxjs';
|
||||
import { environment } from '../environments/environment';
|
||||
import { AircraftResp, AircraftReq } from '../models/aircraft';
|
||||
|
||||
@Injectable()
|
||||
export class AircraftService {
|
||||
|
||||
private readonly headers = new HttpHeaders({
|
||||
'Access-Control-Allow-Origin': environment.urlApi
|
||||
});
|
||||
constructor(private http: HttpClient) { }
|
||||
|
||||
public getListOfAircrafts(): Observable<Array<AircraftResp>> {
|
||||
return this.http.get<Array<AircraftResp>>(
|
||||
`${environment.urlApi}/api/Aircraft`,
|
||||
{ headers: this.headers }
|
||||
);
|
||||
}
|
||||
|
||||
public AddAircraft(aircraftName: string) {
|
||||
const bodyNewAircraft: AircraftReq = {
|
||||
id: 0,
|
||||
name: aircraftName
|
||||
};
|
||||
|
||||
this.http
|
||||
.post(`${environment.urlApi}/api/Aircraft`, bodyNewAircraft, {
|
||||
headers: this.headers
|
||||
})
|
||||
.subscribe(data => console.log(data));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,17 +1,31 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { HttpClient, HttpHeaders } from '@angular/common/http';
|
||||
|
||||
import { Observable } from 'rxjs';
|
||||
import { map } from 'rxjs/operators';
|
||||
import { environment } from '../environments/environment';
|
||||
import { DateService } from './date.service';
|
||||
import { DropZoneResp } from '../models/dropzone';
|
||||
|
||||
|
||||
@Injectable()
|
||||
export class ServiceApiPut {
|
||||
export class DropzoneService {
|
||||
|
||||
private readonly headers = new HttpHeaders({
|
||||
'Access-Control-Allow-Origin': environment.urlApi
|
||||
});
|
||||
constructor(private http: HttpClient) { }
|
||||
|
||||
constructor(private http: HttpClient, private dateService: DateService) { }
|
||||
public getListOfDropZones(): Observable<Array<DropZoneResp>> {
|
||||
return this.http
|
||||
.get<Array<DropZoneResp>>(`${environment.urlApi}/api/DropZone`, {
|
||||
headers: this.headers
|
||||
})
|
||||
.pipe(
|
||||
map(response => {
|
||||
const details = response.map(data => new DropZoneResp(data));
|
||||
return details;
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
public SetFavoriteDropZone(selectedDz: DropZoneResp): boolean {
|
||||
selectedDz.isFavorite = true;
|
||||
@@ -34,4 +48,5 @@ export class ServiceApiPut {
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
47
Front/skydivelogs-app/src/services/gear.service.ts
Normal file
47
Front/skydivelogs-app/src/services/gear.service.ts
Normal file
@@ -0,0 +1,47 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { HttpClient, HttpHeaders } from '@angular/common/http';
|
||||
import { Observable } from 'rxjs';
|
||||
import { environment } from '../environments/environment';
|
||||
import { GearResp, GearReq } from '../models/gear';
|
||||
|
||||
|
||||
@Injectable()
|
||||
export class GearService {
|
||||
|
||||
private readonly headers = new HttpHeaders({
|
||||
'Access-Control-Allow-Origin': environment.urlApi
|
||||
});
|
||||
constructor(private http: HttpClient) { }
|
||||
|
||||
public getListOfGears(): Observable<Array<GearResp>> {
|
||||
return this.http.get<Array<GearResp>>(`${environment.urlApi}/api/Gear`, {
|
||||
headers: this.headers
|
||||
});
|
||||
}
|
||||
|
||||
public AddGear(name: string,
|
||||
manufacturer: string,
|
||||
minSize: number,
|
||||
maxSize: number,
|
||||
aad: string,
|
||||
mainCanopy: string,
|
||||
reserveCanopy: string) {
|
||||
const bodyNewGear: GearReq = {
|
||||
id: 0,
|
||||
name: name,
|
||||
manufacturer: manufacturer,
|
||||
minSize: minSize,
|
||||
maxSize: maxSize,
|
||||
aad: aad,
|
||||
mainCanopy: mainCanopy,
|
||||
reserveCanopy: reserveCanopy
|
||||
};
|
||||
|
||||
this.http
|
||||
.post(`${environment.urlApi}/api/Gear`, bodyNewGear, {
|
||||
headers: this.headers
|
||||
})
|
||||
.subscribe(data => console.log(data));
|
||||
}
|
||||
|
||||
}
|
||||
21
Front/skydivelogs-app/src/services/jump-type.service.ts
Normal file
21
Front/skydivelogs-app/src/services/jump-type.service.ts
Normal file
@@ -0,0 +1,21 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { HttpClient, HttpHeaders } from '@angular/common/http';
|
||||
import { Observable } from 'rxjs';
|
||||
import { environment } from '../environments/environment';
|
||||
import { JumpTypeResp } from '../models/jumpType';
|
||||
|
||||
@Injectable()
|
||||
export class JumpTypeService {
|
||||
|
||||
private readonly headers = new HttpHeaders({
|
||||
'Access-Control-Allow-Origin': environment.urlApi
|
||||
});
|
||||
constructor(private http: HttpClient) { }
|
||||
|
||||
public getListOfJumpTypes(): Observable<Array<JumpTypeResp>> {
|
||||
return this.http.get<Array<JumpTypeResp>>(
|
||||
`${environment.urlApi}/api/JumpType`,
|
||||
{ headers: this.headers }
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1,20 +1,31 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { HttpClient, HttpHeaders } from '@angular/common/http';
|
||||
|
||||
import { JumpReq } from '../models/jump';
|
||||
import { Observable } from 'rxjs';
|
||||
import { map } from 'rxjs/operators';
|
||||
import { environment } from '../environments/environment';
|
||||
import { DateService } from './date.service';
|
||||
import { AircraftReq } from '../models/aircraft';
|
||||
import { GearReq } from '../models/gear';
|
||||
import { JumpResp, JumpReq } from '../models/jump';
|
||||
|
||||
@Injectable()
|
||||
export class ServiceApiPost {
|
||||
export class JumpService {
|
||||
|
||||
private readonly headers = new HttpHeaders({
|
||||
'Access-Control-Allow-Origin': environment.urlApi
|
||||
});
|
||||
|
||||
constructor(private http: HttpClient, private dateService: DateService) { }
|
||||
|
||||
public getListOfJumps(): Observable<Array<JumpResp>> {
|
||||
return this.http.get<Array<JumpResp>>(`${environment.urlApi}/api/Jump`, {
|
||||
headers: this.headers
|
||||
})
|
||||
.pipe(
|
||||
map(response => {
|
||||
const details = response.map(data => new JumpResp(data));
|
||||
return details;
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
public AddListOfJump(
|
||||
selectedJumpType: number,
|
||||
selectedAircraft: number,
|
||||
@@ -93,42 +104,4 @@ export class ServiceApiPost {
|
||||
.subscribe(data => console.log(data));
|
||||
}
|
||||
}
|
||||
|
||||
public AddAircraft(aircraftName: string) {
|
||||
const bodyNewAircraft: AircraftReq = {
|
||||
id: 0,
|
||||
name: aircraftName
|
||||
};
|
||||
|
||||
this.http
|
||||
.post(`${environment.urlApi}/api/Aircraft`, bodyNewAircraft, {
|
||||
headers: this.headers
|
||||
})
|
||||
.subscribe(data => console.log(data));
|
||||
}
|
||||
|
||||
public AddGear(name: string,
|
||||
manufacturer: string,
|
||||
minSize: number,
|
||||
maxSize: number,
|
||||
aad: string,
|
||||
mainCanopy: string,
|
||||
reserveCanopy: string) {
|
||||
const bodyNewGear: GearReq = {
|
||||
id: 0,
|
||||
name: name,
|
||||
manufacturer: manufacturer,
|
||||
minSize: minSize,
|
||||
maxSize: maxSize,
|
||||
aad: aad,
|
||||
mainCanopy: mainCanopy,
|
||||
reserveCanopy: reserveCanopy
|
||||
};
|
||||
|
||||
this.http
|
||||
.post(`${environment.urlApi}/api/Gear`, bodyNewGear, {
|
||||
headers: this.headers
|
||||
})
|
||||
.subscribe(data => console.log(data));
|
||||
}
|
||||
}
|
||||
@@ -1,99 +0,0 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { HttpClient, HttpHeaders } from '@angular/common/http';
|
||||
import { Observable } from 'rxjs';
|
||||
import { map } from 'rxjs/operators';
|
||||
import { environment } from '../environments/environment';
|
||||
|
||||
import { DropZoneResp } from '../models/dropzone';
|
||||
import { JumpResp } from '../models/jump';
|
||||
import { AircraftResp } from '../models/aircraft';
|
||||
import { JumpTypeResp } from '../models/jumpType';
|
||||
import { GearResp } from '../models/gear';
|
||||
|
||||
import {
|
||||
StatsResp,
|
||||
StatsByDzResp,
|
||||
StatsByAircraftResp,
|
||||
StatsByJumpTypeResp,
|
||||
StatsByRigResp,
|
||||
StatsByYearResp
|
||||
} from '../models/stats';
|
||||
|
||||
@Injectable()
|
||||
export class ServiceApiGet {
|
||||
private readonly headers = new HttpHeaders({
|
||||
'Access-Control-Allow-Origin': environment.urlApi
|
||||
});
|
||||
constructor(private http: HttpClient) { }
|
||||
|
||||
public getListOfDropZones(): Observable<Array<DropZoneResp>> {
|
||||
return this.http
|
||||
.get<Array<DropZoneResp>>(`${environment.urlApi}/api/DropZone`, {
|
||||
headers: this.headers
|
||||
})
|
||||
.pipe(
|
||||
map(response => {
|
||||
const details = response.map(data => new DropZoneResp(data));
|
||||
return details;
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
public getListOfJumps(): Observable<Array<JumpResp>> {
|
||||
return this.http.get<Array<JumpResp>>(`${environment.urlApi}/api/Jump`, {
|
||||
headers: this.headers
|
||||
})
|
||||
.pipe(
|
||||
map(response => {
|
||||
const details = response.map(data => new JumpResp(data));
|
||||
return details;
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
public getListOfAircrafts(): Observable<Array<AircraftResp>> {
|
||||
return this.http.get<Array<AircraftResp>>(
|
||||
`${environment.urlApi}/api/Aircraft`,
|
||||
{ headers: this.headers }
|
||||
);
|
||||
}
|
||||
|
||||
public getListOfJumpTypes(): Observable<Array<JumpTypeResp>> {
|
||||
return this.http.get<Array<JumpTypeResp>>(
|
||||
`${environment.urlApi}/api/JumpType`,
|
||||
{ headers: this.headers }
|
||||
);
|
||||
}
|
||||
|
||||
public getListOfGears(): Observable<Array<GearResp>> {
|
||||
return this.http.get<Array<GearResp>>(`${environment.urlApi}/api/Gear`, {
|
||||
headers: this.headers
|
||||
});
|
||||
}
|
||||
|
||||
public getStatsOfJumps(): StatsResp {
|
||||
const resultat = new StatsResp();
|
||||
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;
|
||||
}
|
||||
}
|
||||
47
Front/skydivelogs-app/src/services/stats.service.ts
Normal file
47
Front/skydivelogs-app/src/services/stats.service.ts
Normal file
@@ -0,0 +1,47 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { HttpClient, HttpHeaders } from '@angular/common/http';
|
||||
import { environment } from '../environments/environment';
|
||||
import {
|
||||
StatsResp,
|
||||
StatsByDzResp,
|
||||
StatsByAircraftResp,
|
||||
StatsByJumpTypeResp,
|
||||
StatsByRigResp,
|
||||
StatsByYearResp
|
||||
} from '../models/stats';
|
||||
|
||||
@Injectable()
|
||||
export class StatsService {
|
||||
|
||||
private readonly headers = new HttpHeaders({
|
||||
'Access-Control-Allow-Origin': environment.urlApi
|
||||
});
|
||||
|
||||
constructor(private http: HttpClient) { }
|
||||
|
||||
public getStatsOfJumps(): StatsResp {
|
||||
const resultat = new StatsResp();
|
||||
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;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user