Découpage en 1 service par composant
This commit is contained in:
@@ -19,10 +19,15 @@ import { NewJumpTypeComponent } from './new-jump-type/new-jump-type.component';
|
|||||||
import { DefaultComponent } from './default/default.component';
|
import { DefaultComponent } from './default/default.component';
|
||||||
|
|
||||||
import { DateService } from '../services/date.service';
|
import { DateService } from '../services/date.service';
|
||||||
import { ServiceApiPut } from '../services/service-api-put.service';
|
|
||||||
import { ServiceApiGet } from '../services/service-api-get.service';
|
import { AircraftService } from '../services/aircraft.service';
|
||||||
import { ServiceApiPost } from '../services/service-api-post.service';
|
import { DropzoneService } from '../services/dropzone.service';
|
||||||
|
import { GearService } from '../services/gear.service';
|
||||||
|
import { JumpService } from '../services/jump.service';
|
||||||
|
import { JumpTypeService } from '../services/jump-type.service';
|
||||||
|
import { StatsService } from '../services/stats.service';
|
||||||
import { ServiceComm } from '../services/service-comm.service';
|
import { ServiceComm } from '../services/service-comm.service';
|
||||||
|
|
||||||
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
|
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
|
||||||
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
|
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
|
||||||
import {
|
import {
|
||||||
@@ -96,9 +101,12 @@ const appRoutes: Routes = [
|
|||||||
],
|
],
|
||||||
exports: [HttpClientModule],
|
exports: [HttpClientModule],
|
||||||
providers: [
|
providers: [
|
||||||
ServiceApiPut,
|
AircraftService,
|
||||||
ServiceApiPost,
|
DropzoneService,
|
||||||
ServiceApiGet,
|
GearService,
|
||||||
|
JumpService,
|
||||||
|
JumpTypeService,
|
||||||
|
StatsService,
|
||||||
ServiceComm,
|
ServiceComm,
|
||||||
DateService,
|
DateService,
|
||||||
RequestCache,
|
RequestCache,
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import { MatPaginator } from '@angular/material/paginator';
|
|||||||
import { MatTableDataSource } from '@angular/material/table';
|
import { MatTableDataSource } from '@angular/material/table';
|
||||||
|
|
||||||
import { AircraftResp } from '../../models/aircraft';
|
import { AircraftResp } from '../../models/aircraft';
|
||||||
import { ServiceApiGet } from '../../services/service-api-get.service';
|
import { AircraftService } from '../../services/aircraft.service';
|
||||||
import { ServiceComm } from '../../services/service-comm.service';
|
import { ServiceComm } from '../../services/service-comm.service';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
@@ -19,7 +19,7 @@ export class ListOfAircraftsComponent implements OnInit {
|
|||||||
public showAddForm: boolean;
|
public showAddForm: boolean;
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private serviceApi: ServiceApiGet,
|
private serviceApi: AircraftService,
|
||||||
private serviceComm: ServiceComm
|
private serviceComm: ServiceComm
|
||||||
) { }
|
) { }
|
||||||
|
|
||||||
|
|||||||
@@ -3,8 +3,7 @@ import { MatPaginator } from '@angular/material/paginator';
|
|||||||
import { MatTableDataSource } from '@angular/material/table';
|
import { MatTableDataSource } from '@angular/material/table';
|
||||||
|
|
||||||
import { DropZoneResp } from '../../models/dropzone';
|
import { DropZoneResp } from '../../models/dropzone';
|
||||||
import { ServiceApiGet } from '../../services/service-api-get.service';
|
import { DropzoneService } from '../../services/dropzone.service';
|
||||||
import { ServiceApiPut } from '../../services/service-api-put.service';
|
|
||||||
import { ServiceComm } from '../../services/service-comm.service';
|
import { ServiceComm } from '../../services/service-comm.service';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
@@ -29,8 +28,7 @@ export class ListOfDzsComponent implements OnInit {
|
|||||||
public showAddForm: boolean;
|
public showAddForm: boolean;
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private serviceApiGet: ServiceApiGet,
|
private serviceApi: DropzoneService,
|
||||||
private serviceApiPut: ServiceApiPut,
|
|
||||||
private serviceComm: ServiceComm
|
private serviceComm: ServiceComm
|
||||||
) { }
|
) { }
|
||||||
|
|
||||||
@@ -40,7 +38,7 @@ export class ListOfDzsComponent implements OnInit {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private getListOfDropZones() {
|
private getListOfDropZones() {
|
||||||
this.serviceApiGet.getListOfDropZones().subscribe(data => {
|
this.serviceApi.getListOfDropZones().subscribe(data => {
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
data.sort((a, b) => (b.isFavorite ? 1 : 0) - (a.isFavorite ? 1 : 0));
|
data.sort((a, b) => (b.isFavorite ? 1 : 0) - (a.isFavorite ? 1 : 0));
|
||||||
this.dataSourceTable = new MatTableDataSource<DropZoneResp>(data);
|
this.dataSourceTable = new MatTableDataSource<DropZoneResp>(data);
|
||||||
@@ -51,11 +49,11 @@ export class ListOfDzsComponent implements OnInit {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public setToFavorite(dropzone: DropZoneResp) {
|
public setToFavorite(dropzone: DropZoneResp) {
|
||||||
dropzone.isFavorite = this.serviceApiPut.SetFavoriteDropZone(dropzone);
|
dropzone.isFavorite = this.serviceApi.SetFavoriteDropZone(dropzone);
|
||||||
}
|
}
|
||||||
|
|
||||||
public removeToFavorite(dropzone: DropZoneResp) {
|
public removeToFavorite(dropzone: DropZoneResp) {
|
||||||
dropzone.isFavorite = this.serviceApiPut.RemoveFavoriteDropZone(dropzone);
|
dropzone.isFavorite = this.serviceApi.RemoveFavoriteDropZone(dropzone);
|
||||||
}
|
}
|
||||||
|
|
||||||
public add() {
|
public add() {
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import { Component, OnInit, ViewChild } from '@angular/core';
|
import { Component, OnInit, ViewChild } from '@angular/core';
|
||||||
import { MatPaginator, MatTableDataSource } from '@angular/material';
|
import { MatPaginator, MatTableDataSource } from '@angular/material';
|
||||||
|
|
||||||
import { ServiceApiGet } from '../../services/service-api-get.service';
|
import { GearService } from '../../services/gear.service';
|
||||||
import { ServiceComm } from '../../services/service-comm.service';
|
import { ServiceComm } from '../../services/service-comm.service';
|
||||||
import { GearResp } from '../../models/gear';
|
import { GearResp } from '../../models/gear';
|
||||||
import { AddAction } from '../../models/add-action.enum';
|
import { AddAction } from '../../models/add-action.enum';
|
||||||
@@ -27,7 +27,7 @@ export class ListOfGearsComponent implements OnInit {
|
|||||||
public showAddForm: boolean;
|
public showAddForm: boolean;
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private serviceApi: ServiceApiGet,
|
private serviceApi: GearService,
|
||||||
private serviceComm: ServiceComm
|
private serviceComm: ServiceComm
|
||||||
) { }
|
) { }
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import { MatPaginator } from '@angular/material/paginator';
|
|||||||
import { MatTableDataSource } from '@angular/material/table';
|
import { MatTableDataSource } from '@angular/material/table';
|
||||||
|
|
||||||
import { JumpTypeResp } from '../../models/jumpType';
|
import { JumpTypeResp } from '../../models/jumpType';
|
||||||
import { ServiceApiGet } from '../../services/service-api-get.service';
|
import { JumpTypeService } from '../../services/jump-type.service';
|
||||||
import { ServiceComm } from '../../services/service-comm.service';
|
import { ServiceComm } from '../../services/service-comm.service';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
@@ -19,7 +19,7 @@ export class ListOfJumpTypesComponent implements OnInit {
|
|||||||
public showAddForm: boolean;
|
public showAddForm: boolean;
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private serviceApi: ServiceApiGet,
|
private serviceApi: JumpTypeService,
|
||||||
private serviceComm: ServiceComm
|
private serviceComm: ServiceComm
|
||||||
) { }
|
) { }
|
||||||
|
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import { MatTableDataSource } from '@angular/material/table';
|
|||||||
|
|
||||||
import { Observable } from 'rxjs';
|
import { Observable } from 'rxjs';
|
||||||
import { JumpResp } from '../../models/jump';
|
import { JumpResp } from '../../models/jump';
|
||||||
import { ServiceApiGet } from '../../services/service-api-get.service';
|
import { JumpService } from '../../services/jump.service';
|
||||||
import { ServiceComm } from '../../services/service-comm.service';
|
import { ServiceComm } from '../../services/service-comm.service';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
@@ -27,7 +27,7 @@ export class ListOfJumpsComponent implements OnInit {
|
|||||||
@ViewChild(MatPaginator, { static: true }) paginator: MatPaginator;
|
@ViewChild(MatPaginator, { static: true }) paginator: MatPaginator;
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private serviceApi: ServiceApiGet,
|
private serviceApi: JumpService,
|
||||||
private serviceComm: ServiceComm
|
private serviceComm: ServiceComm
|
||||||
) { }
|
) { }
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import { Component, OnInit } from '@angular/core';
|
import { Component, OnInit } from '@angular/core';
|
||||||
import { FormControl, FormGroup, Validators } from '@angular/forms';
|
import { FormControl, FormGroup, Validators } from '@angular/forms';
|
||||||
import { ServiceApiPost } from '../../services/service-api-post.service';
|
import { AircraftService } from '../../services/aircraft.service';
|
||||||
import { ServiceComm } from '../../services/service-comm.service';
|
import { ServiceComm } from '../../services/service-comm.service';
|
||||||
import { AddAction } from '../../models/add-action.enum';
|
import { AddAction } from '../../models/add-action.enum';
|
||||||
|
|
||||||
@@ -14,7 +14,7 @@ export class NewAircraftComponent implements OnInit {
|
|||||||
public addForm: FormGroup;
|
public addForm: FormGroup;
|
||||||
|
|
||||||
constructor(private serviceComm: ServiceComm,
|
constructor(private serviceComm: ServiceComm,
|
||||||
private serviceApiPost: ServiceApiPost) {
|
private serviceApi: AircraftService) {
|
||||||
this.addForm = new FormGroup({
|
this.addForm = new FormGroup({
|
||||||
aircraftName: new FormControl('', Validators.required)
|
aircraftName: new FormControl('', Validators.required)
|
||||||
});
|
});
|
||||||
@@ -24,7 +24,7 @@ export class NewAircraftComponent implements OnInit {
|
|||||||
}
|
}
|
||||||
|
|
||||||
onSubmit(formData) {
|
onSubmit(formData) {
|
||||||
this.serviceApiPost.AddAircraft(formData.value.aircraftName);
|
this.serviceApi.AddAircraft(formData.value.aircraftName);
|
||||||
this.serviceComm.RefreshData(AddAction.Aircraft);
|
this.serviceComm.RefreshData(AddAction.Aircraft);
|
||||||
|
|
||||||
this.addForm.reset();
|
this.addForm.reset();
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import { Component, OnInit } from '@angular/core';
|
|||||||
import { FormControl, FormGroup, Validators } from '@angular/forms';
|
import { FormControl, FormGroup, Validators } from '@angular/forms';
|
||||||
|
|
||||||
import { ServiceComm } from '../../services/service-comm.service';
|
import { ServiceComm } from '../../services/service-comm.service';
|
||||||
import { ServiceApiPost } from '../../services/service-api-post.service';
|
import { GearService } from '../../services/gear.service';
|
||||||
import { AddAction } from '../../models/add-action.enum';
|
import { AddAction } from '../../models/add-action.enum';
|
||||||
|
|
||||||
|
|
||||||
@@ -14,7 +14,7 @@ import { AddAction } from '../../models/add-action.enum';
|
|||||||
export class NewGearComponent implements OnInit {
|
export class NewGearComponent implements OnInit {
|
||||||
public addForm: FormGroup;
|
public addForm: FormGroup;
|
||||||
|
|
||||||
constructor(private serviceComm: ServiceComm, private servicePost: ServiceApiPost) {
|
constructor(private serviceComm: ServiceComm, private serviceApi: GearService) {
|
||||||
this.addForm = new FormGroup({
|
this.addForm = new FormGroup({
|
||||||
name: new FormControl('', Validators.required),
|
name: new FormControl('', Validators.required),
|
||||||
manufacturer: new FormControl('', Validators.required),
|
manufacturer: new FormControl('', Validators.required),
|
||||||
@@ -30,7 +30,7 @@ export class NewGearComponent implements OnInit {
|
|||||||
}
|
}
|
||||||
|
|
||||||
onSubmit(formData) {
|
onSubmit(formData) {
|
||||||
this.servicePost.AddGear(
|
this.serviceApi.AddGear(
|
||||||
formData.value.name,
|
formData.value.name,
|
||||||
formData.value.manufacturer,
|
formData.value.manufacturer,
|
||||||
formData.value.minSize,
|
formData.value.minSize,
|
||||||
|
|||||||
@@ -1,12 +1,15 @@
|
|||||||
import { Component, OnInit } from '@angular/core';
|
import { Component, OnInit } from '@angular/core';
|
||||||
import { ServiceComm } from '../../services/service-comm.service';
|
|
||||||
import { ServiceApiGet } from '../../services/service-api-get.service';
|
|
||||||
import { ServiceApiPost } from '../../services/service-api-post.service';
|
|
||||||
import { JumpTypeResp } from '../../models/jumpType';
|
import { JumpTypeResp } from '../../models/jumpType';
|
||||||
import { AircraftResp } from '../../models/aircraft';
|
import { AircraftResp } from '../../models/aircraft';
|
||||||
import { DropZoneResp } from '../../models/dropzone';
|
import { DropZoneResp } from '../../models/dropzone';
|
||||||
import { DateService } from '../../services/date.service';
|
import { DateService } from '../../services/date.service';
|
||||||
import { GearResp } from '../../models/gear';
|
import { GearResp } from '../../models/gear';
|
||||||
|
import { ServiceComm } from '../../services/service-comm.service';
|
||||||
|
import { DropzoneService } from '../../services/dropzone.service';
|
||||||
|
import { AircraftService } from '../../services/aircraft.service';
|
||||||
|
import { JumpService } from '../../services/jump.service';
|
||||||
|
import { JumpTypeService } from '../../services/jump-type.service';
|
||||||
|
import { GearService } from '../../services/gear.service';
|
||||||
import { isNumber } from 'util';
|
import { isNumber } from 'util';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
@@ -33,8 +36,11 @@ export class NewJumpComponent implements OnInit {
|
|||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private serviceComm: ServiceComm,
|
private serviceComm: ServiceComm,
|
||||||
private serviceApiGet: ServiceApiGet,
|
private serviceJump: JumpService,
|
||||||
private serviceApiPost: ServiceApiPost,
|
private serviceJumpType: JumpTypeService,
|
||||||
|
private serviceAircraft: AircraftService,
|
||||||
|
private serviceDropzone: DropzoneService,
|
||||||
|
private serviceGear: GearService,
|
||||||
private dateService: DateService
|
private dateService: DateService
|
||||||
) { }
|
) { }
|
||||||
|
|
||||||
@@ -52,7 +58,7 @@ export class NewJumpComponent implements OnInit {
|
|||||||
}
|
}
|
||||||
|
|
||||||
onFormSubmit() {
|
onFormSubmit() {
|
||||||
this.serviceApiPost.AddListOfJump(
|
this.serviceJump.AddListOfJump(
|
||||||
this.selectedJumpType.id,
|
this.selectedJumpType.id,
|
||||||
this.selectedAircraft.id,
|
this.selectedAircraft.id,
|
||||||
this.selectedDz.id,
|
this.selectedDz.id,
|
||||||
@@ -79,7 +85,7 @@ export class NewJumpComponent implements OnInit {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private getListOfJumpTypes() {
|
private getListOfJumpTypes() {
|
||||||
this.serviceApiGet.getListOfJumpTypes().subscribe(data => {
|
this.serviceJumpType.getListOfJumpTypes().subscribe(data => {
|
||||||
this.listOfJumpType = data;
|
this.listOfJumpType = data;
|
||||||
this.getListOfAircrafts();
|
this.getListOfAircrafts();
|
||||||
this.getListOfDropZones();
|
this.getListOfDropZones();
|
||||||
@@ -88,13 +94,13 @@ export class NewJumpComponent implements OnInit {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private getListOfAircrafts() {
|
private getListOfAircrafts() {
|
||||||
this.serviceApiGet.getListOfAircrafts().subscribe(data => {
|
this.serviceAircraft.getListOfAircrafts().subscribe(data => {
|
||||||
this.listOfAircraft = data;
|
this.listOfAircraft = data;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private getListOfDropZones() {
|
private getListOfDropZones() {
|
||||||
this.serviceApiGet.getListOfDropZones().subscribe(data => {
|
this.serviceDropzone.getListOfDropZones().subscribe(data => {
|
||||||
data.sort((a, b) => (b.isFavorite ? 1 : 0) - (a.isFavorite ? 1 : 0));
|
data.sort((a, b) => (b.isFavorite ? 1 : 0) - (a.isFavorite ? 1 : 0));
|
||||||
this.listOfDropZone = data;
|
this.listOfDropZone = data;
|
||||||
this.listOfFilteredDropZone = data;
|
this.listOfFilteredDropZone = data;
|
||||||
@@ -102,7 +108,7 @@ export class NewJumpComponent implements OnInit {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private getListOfGears() {
|
private getListOfGears() {
|
||||||
this.serviceApiGet.getListOfGears().subscribe(data => {
|
this.serviceGear.getListOfGears().subscribe(data => {
|
||||||
this.listOfGear = data;
|
this.listOfGear = data;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import { Component, OnInit } from '@angular/core';
|
import { Component, OnInit } from '@angular/core';
|
||||||
import { ServiceComm } from '../../services/service-comm.service';
|
import { ServiceComm } from '../../services/service-comm.service';
|
||||||
import { ServiceApiGet } from '../../services/service-api-get.service';
|
import { StatsService } from '../../services/stats.service';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-summary',
|
selector: 'app-summary',
|
||||||
@@ -16,7 +16,7 @@ export class SummaryComponent implements OnInit {
|
|||||||
public dsNbJumpByYear;
|
public dsNbJumpByYear;
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private serviceApi: ServiceApiGet,
|
private serviceApi: StatsService,
|
||||||
private serviceComm: ServiceComm
|
private serviceComm: ServiceComm
|
||||||
) { }
|
) { }
|
||||||
|
|
||||||
|
|||||||
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 { Injectable } from '@angular/core';
|
||||||
import { HttpClient, HttpHeaders } from '@angular/common/http';
|
import { HttpClient, HttpHeaders } from '@angular/common/http';
|
||||||
|
import { Observable } from 'rxjs';
|
||||||
|
import { map } from 'rxjs/operators';
|
||||||
import { environment } from '../environments/environment';
|
import { environment } from '../environments/environment';
|
||||||
import { DateService } from './date.service';
|
|
||||||
import { DropZoneResp } from '../models/dropzone';
|
import { DropZoneResp } from '../models/dropzone';
|
||||||
|
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class ServiceApiPut {
|
export class DropzoneService {
|
||||||
|
|
||||||
private readonly headers = new HttpHeaders({
|
private readonly headers = new HttpHeaders({
|
||||||
'Access-Control-Allow-Origin': environment.urlApi
|
'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 {
|
public SetFavoriteDropZone(selectedDz: DropZoneResp): boolean {
|
||||||
selectedDz.isFavorite = true;
|
selectedDz.isFavorite = true;
|
||||||
@@ -34,4 +48,5 @@ export class ServiceApiPut {
|
|||||||
|
|
||||||
return true;
|
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 { Injectable } from '@angular/core';
|
||||||
import { HttpClient, HttpHeaders } from '@angular/common/http';
|
import { HttpClient, HttpHeaders } from '@angular/common/http';
|
||||||
|
import { Observable } from 'rxjs';
|
||||||
import { JumpReq } from '../models/jump';
|
import { map } from 'rxjs/operators';
|
||||||
import { environment } from '../environments/environment';
|
import { environment } from '../environments/environment';
|
||||||
import { DateService } from './date.service';
|
import { DateService } from './date.service';
|
||||||
import { AircraftReq } from '../models/aircraft';
|
import { JumpResp, JumpReq } from '../models/jump';
|
||||||
import { GearReq } from '../models/gear';
|
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class ServiceApiPost {
|
export class JumpService {
|
||||||
|
|
||||||
private readonly headers = new HttpHeaders({
|
private readonly headers = new HttpHeaders({
|
||||||
'Access-Control-Allow-Origin': environment.urlApi
|
'Access-Control-Allow-Origin': environment.urlApi
|
||||||
});
|
});
|
||||||
|
|
||||||
constructor(private http: HttpClient, private dateService: DateService) { }
|
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(
|
public AddListOfJump(
|
||||||
selectedJumpType: number,
|
selectedJumpType: number,
|
||||||
selectedAircraft: number,
|
selectedAircraft: number,
|
||||||
@@ -93,42 +104,4 @@ export class ServiceApiPost {
|
|||||||
.subscribe(data => console.log(data));
|
.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