Rename the methods

This commit is contained in:
Sébastien ANDRE
2023-06-29 15:59:58 +02:00
parent f789a4269a
commit 8598f4e087
23 changed files with 62 additions and 67 deletions

View File

@@ -26,7 +26,7 @@ export class AircraftService extends BaseService {
return this.serviceCacheApi.get<Array<AircraftResp>>(CacheApiKey.Aircraft, callToApi);
}
public AddAircraft(aircraftName: string, dataImg: string) {
public addAircraft(aircraftName: string, dataImg: string) {
const bodyNewAircraft: AircraftReq = {
id: 0,
name: aircraftName,

View File

@@ -8,7 +8,7 @@ export class DateService {
this.milliSeconInDay = 1000 * 60 * 60 * 24;
}
public AddDays(currentDate: Date, nbDays: number): Date {
public addDays(currentDate: Date, nbDays: number): Date {
const totalMilliSeconds = nbDays * this.milliSeconInDay;
const currentTime = currentDate.getTime();
const tmpDate = new Date(currentDate.getTime());
@@ -18,7 +18,7 @@ export class DateService {
return tmpDate;
}
public DiffBetweenDates(beginDate: Date, endDate: Date): number {
public diffBetweenDates(beginDate: Date, endDate: Date): number {
const diffInTime = endDate.getTime() - beginDate.getTime();
const diffInDays = Math.round(diffInTime / (1000 * 3600 * 24));

View File

@@ -30,7 +30,7 @@ export class DropzoneService extends BaseService {
return this.serviceCacheApi.get<Array<DropZoneResp>>(CacheApiKey.Dropzone, callToApi);
}
public SetFavoriteDropZone(selectedDz: DropZoneResp) {
public setFavoriteDropZone(selectedDz: DropZoneResp) {
selectedDz.isFavorite = true;
this.http.put(`${this.apiUrl}/DropZone/AddToFavorite/${selectedDz.id}`,
@@ -41,7 +41,7 @@ export class DropzoneService extends BaseService {
});
}
public RemoveFavoriteDropZone(selectedDz: DropZoneResp) {
public removeFavoriteDropZone(selectedDz: DropZoneResp) {
selectedDz.isFavorite = false;
this.http.put(`${this.apiUrl}/DropZone/RemoveToFavorite${selectedDz.id}`,
@@ -52,7 +52,7 @@ export class DropzoneService extends BaseService {
});
}
public AddDropZone(latitude: string,
public addDropZone(latitude: string,
longitude: string,
name: string,
address: string,

View File

@@ -19,7 +19,7 @@ export class GearService extends BaseService {
return this.serviceCacheApi.get<Array<GearResp>>(CacheApiKey.Gear, callToApi);
}
public AddGear(name: string,
public addGear(name: string,
manufacturer: string,
minSize: number,
maxSize: number,

View File

@@ -18,7 +18,7 @@ export class ImageService extends BaseService {
});
}
public AddImage(commentImg: string, dataImg: string) {
public addImage(commentImg: string, dataImg: string) {
const bodyNewImage: ImageReq = {
id: 0,
comment: commentImg,

View File

@@ -19,7 +19,7 @@ export class JumpTypeService extends BaseService {
return this.serviceCacheApi.get<Array<JumpTypeResp>>(CacheApiKey.JumpType, callToApi);
}
public AddJumpType(jumptypetName: string) {
public addJumpType(jumptypetName: string) {
const bodyJumpType: JumpTypeReq = {
id: 0,
name: jumptypetName

View File

@@ -1,7 +1,7 @@
import { Injectable } from "@angular/core";
import { HttpClient } from "@angular/common/http";
import { DatePipe } from '@angular/common';
import { forkJoin, Observable, of } from "rxjs";
import { forkJoin, Observable } from "rxjs";
import { map } from "rxjs/operators";
import { JumpResp, JumpReq, Jump } from "../models/jump";
@@ -32,28 +32,26 @@ export class JumpService extends BaseService {
super();
}
public GetListOfJumps(): Observable<Array<Jump>> {
return this.http.get<Array<JumpResp>>(`${this.apiUrl}/Jump`,
{ headers: this.headers })
.pipe(map((response) => {
return this.MapWithDataInCache(response);
}));
public getListOfJumps(): Observable<Array<Jump>> {
return this.http.get<Array<JumpResp>>(`${this.apiUrl}/Jump`, { headers: this.headers })
.pipe(map((response) => {
return this.mapWithDataInCache(response);
}));
}
public GetJumps(beginIndex: number, endIndex: number): Observable<JumpList> {
return this.http.get<JumpListResp>(`${this.apiUrl}/Jump/${beginIndex}/${endIndex}`,
{ headers: this.headers })
.pipe(map((response) => {
let result: JumpList = {
rows: this.MapWithDataInCache(response.rows),
count: response.count
};
public getJumps(beginIndex: number, endIndex: number): Observable<JumpList> {
return this.http.get<JumpListResp>(`${this.apiUrl}/Jump/${beginIndex}/${endIndex}`, { headers: this.headers })
.pipe(map((response) => {
let result: JumpList = {
rows: this.mapWithDataInCache(response.rows),
count: response.count
};
return new JumpList(result);
}));
return new JumpList(result);
}));
}
public AddListOfJump(selectedJumpType: number,
public addListOfJump(selectedJumpType: number,
selectedAircraft: number,
selectedDz: number,
selectedRig: number,
@@ -66,11 +64,11 @@ export class JumpService extends BaseService {
notes: string,
isSpecial: boolean): Observable<any[]> {
this.callsToAdd = new Array<Observable<any>>();
const diffInDays = this.dateService.DiffBetweenDates(beginDate, endDate) + 1;
const diffInDays = this.dateService.diffBetweenDates(beginDate, endDate) + 1;
const countOfJumpsPerDay = Math.trunc(countOfJumps / diffInDays);
for (let i = 1; beginDate.getTime() < endDate.getTime(); i++) {
this.AddJumps(selectedJumpType,
this.addJumps(selectedJumpType,
selectedAircraft,
selectedDz,
selectedRig,
@@ -82,12 +80,12 @@ export class JumpService extends BaseService {
notes,
isSpecial);
beginDate = this.dateService.AddDays(beginDate, 1);
beginDate = this.dateService.addDays(beginDate, 1);
}
const restfJumps = countOfJumps - countOfJumpsPerDay * (diffInDays - 1);
this.AddJumps(selectedJumpType,
this.addJumps(selectedJumpType,
selectedAircraft,
selectedDz,
selectedRig,
@@ -102,16 +100,16 @@ export class JumpService extends BaseService {
return forkJoin(this.callsToAdd);
}
public DeleteJump(item: Jump) {
public deleteJump(item: Jump) {
this.http.delete(`${this.apiUrl}/Jump/${item.id}`,
{ headers: this.headers, })
.subscribe();
}
public UpdateJump(id: number,
isSpecial: boolean,
withCutaway: boolean,
notes: string) {
public updateJump(id: number,
isSpecial: boolean,
withCutaway: boolean,
notes: string) {
const jumpData = {
id: id,
isSpecial: isSpecial,
@@ -125,7 +123,7 @@ export class JumpService extends BaseService {
{ headers: this.headers, });
}
private AddJumps(selectedJumpType: number,
private addJumps(selectedJumpType: number,
selectedAircraft: number,
selectedDz: number,
selectedRig: number,
@@ -157,7 +155,7 @@ export class JumpService extends BaseService {
}
}
private MapWithDataInCache(apiResp: Array<JumpResp>): Array<Jump> {
private mapWithDataInCache(apiResp: Array<JumpResp>): Array<Jump> {
let allDropzones: Array<DropZoneResp>;
this.dropzoneService.getFromCache().subscribe(data => { allDropzones = data; });
let allAircrafts: Array<AircraftResp>;

View File

@@ -15,7 +15,6 @@ export class ServiceCacheApi {
}
public get<T>(key: CacheApiKey, callToApi: Observable<T>) : Observable<T> {
// console.log(`Get/push cache : ${CacheApiKey[key]}`);
const cached = this.cache.get(key);
if (cached) {
@@ -29,12 +28,10 @@ export class ServiceCacheApi {
}
public delete(key: CacheApiKey) {
// console.log(`Delete cache : ${CacheApiKey[key]}`);
this.cache.delete(key);
}
public getByKey<T>(key: CacheApiKey) : Observable<T> {
// console.log(`Get cache by key : ${CacheApiKey[key]}`);
return this.cache.get(key);
}
}