Fix
This commit is contained in:
@@ -5,7 +5,7 @@
|
||||
"scripts": {
|
||||
"ng": "ng",
|
||||
"start": "ng serve",
|
||||
"build": "ng build --configuration production --build-optimizer --aot=true --optimization=true --progress=true --sourceMap=false",
|
||||
"build": "ng build --configuration production --build-optimizer=true --aot=true --optimization=true --progress=true",
|
||||
"test": "ng test",
|
||||
"lint": "ng lint",
|
||||
"e2e": "ng e2e"
|
||||
|
||||
@@ -24,6 +24,10 @@ import { DefaultComponent } from "./default/default.component";
|
||||
import { LoginComponent } from "./login/login.component";
|
||||
import { CreateUserComponent } from "./create-user/create-user.component";
|
||||
import { LoginUserComponent } from "./login-user/login-user.component";
|
||||
import { UserProfileComponent } from "./user-profile/user-profile.component";
|
||||
import { ListOfImagesComponent } from "./list-of-images/list-of-images.component";
|
||||
import { JumpInfosComponent } from './jump-infos/jump-infos.component';
|
||||
import { NewTunnelFlightComponent } from './new-tunnel-flight/new-tunnel-flight.component';
|
||||
|
||||
import { DateService } from "../services/date.service";
|
||||
import { AircraftService } from "../services/aircraft.service";
|
||||
@@ -39,6 +43,7 @@ import { ImageService } from "../services/image.service";
|
||||
import { ConfigurationHelper } from "../services/configuration-helper";
|
||||
import { ServiceCacheApi } from "../services/service-cache-api.service";
|
||||
import { TunnelService } from "../services/tunnel.service";
|
||||
import { TunnelFlightService } from "../services/tunnel-flight.service";
|
||||
|
||||
import { BrowserAnimationsModule } from "@angular/platform-browser/animations";
|
||||
import { FormsModule, ReactiveFormsModule } from "@angular/forms";
|
||||
@@ -65,10 +70,6 @@ import { MatToolbarModule } from '@angular/material/toolbar';
|
||||
|
||||
import { JwtAuthInterceptor } from "../interceptor/jwt-auth.interceptor";
|
||||
import { ErrorInterceptor } from "../interceptor/error.interceptor";
|
||||
import { UserProfileComponent } from "./user-profile/user-profile.component";
|
||||
import { ListOfImagesComponent } from "./list-of-images/list-of-images.component";
|
||||
import { JumpInfosComponent } from './jump-infos/jump-infos.component';
|
||||
import { NewTunnelFlightComponent } from './new-tunnel-flight/new-tunnel-flight.component';
|
||||
|
||||
const appRoutes: Routes = [
|
||||
{ path: "", component: DefaultComponent, canActivate: [AuthGuardService] },
|
||||
@@ -151,7 +152,7 @@ export function initConfig(configService: ConfigurationHelper) {
|
||||
UserProfileComponent,
|
||||
ListOfImagesComponent,
|
||||
JumpInfosComponent,
|
||||
NewTunnelFlightComponent,
|
||||
NewTunnelFlightComponent
|
||||
],
|
||||
imports: [
|
||||
RouterModule.forRoot(
|
||||
@@ -195,6 +196,7 @@ export function initConfig(configService: ConfigurationHelper) {
|
||||
exports: [HttpClientModule],
|
||||
providers: [
|
||||
TunnelService,
|
||||
TunnelFlightService,
|
||||
ImageService,
|
||||
AircraftService,
|
||||
DropzoneService,
|
||||
|
||||
@@ -5,10 +5,11 @@ import { TranslateService } from '@ngx-translate/core';
|
||||
|
||||
import { TunnelResp } from "../../models/tunnel";
|
||||
|
||||
import { DateService } from 'src/services/date.service';
|
||||
import { TunnelService } from 'src/services/tunnel.service';
|
||||
import { ServiceComm } from 'src/services/service-comm.service';
|
||||
import { StatsService } from 'src/services/stats.service';
|
||||
import { DateService } from '../../services/date.service';
|
||||
import { TunnelService } from '../../services/tunnel.service';
|
||||
import { ServiceComm } from '../../services/service-comm.service';
|
||||
import { StatsService } from '../../services/stats.service';
|
||||
import { TunnelFlightService } from "../../services/tunnel-flight.service";
|
||||
|
||||
export const PICK_FORMATS = {
|
||||
parse: { dateInput: 'yy MM dd' },
|
||||
@@ -47,6 +48,7 @@ export class NewTunnelFlightComponent implements OnInit {
|
||||
|
||||
constructor(private serviceComm: ServiceComm,
|
||||
private serviceTunnel: TunnelService,
|
||||
private serviceTunnelFlight: TunnelFlightService,
|
||||
private dateService: DateService,
|
||||
private translateService: TranslateService,
|
||||
private statsService: StatsService) { }
|
||||
@@ -67,20 +69,19 @@ export class NewTunnelFlightComponent implements OnInit {
|
||||
onFormSubmit() {
|
||||
this.pendingAddRequest = true;
|
||||
|
||||
this.serviceTunnel.AddFlight(this.selectedTunnel.id,
|
||||
this.beginDate,
|
||||
this.minutesOfFlight,
|
||||
this.comments)
|
||||
.subscribe(() => {
|
||||
this.statsService.resetStats();
|
||||
this.comments = undefined;
|
||||
|
||||
if (this.resetForm === true) {
|
||||
this.initForm();
|
||||
}
|
||||
this.pendingAddRequest = false;
|
||||
});
|
||||
this.serviceTunnelFlight.addFlight(this.selectedTunnel.id,
|
||||
this.beginDate,
|
||||
this.minutesOfFlight,
|
||||
this.comments)
|
||||
.subscribe(() => {
|
||||
this.statsService.resetStats();
|
||||
this.comments = undefined;
|
||||
|
||||
if (this.resetForm === true) {
|
||||
this.initForm();
|
||||
}
|
||||
this.pendingAddRequest = false;
|
||||
});
|
||||
}
|
||||
|
||||
public isValidatedForm(): boolean {
|
||||
|
||||
11
Front/skydivelogs-app/src/models/tunnel-flight.ts
Normal file
11
Front/skydivelogs-app/src/models/tunnel-flight.ts
Normal file
@@ -0,0 +1,11 @@
|
||||
export class TunnelFlightReq {
|
||||
constructor(data: any) {
|
||||
Object.assign(this, data);
|
||||
}
|
||||
|
||||
public id: number;
|
||||
public tunnelId: number;
|
||||
public nbMinutes: number;
|
||||
public notes: string;
|
||||
public flightDate: string;
|
||||
}
|
||||
33
Front/skydivelogs-app/src/services/tunnel-flight.service.ts
Normal file
33
Front/skydivelogs-app/src/services/tunnel-flight.service.ts
Normal file
@@ -0,0 +1,33 @@
|
||||
import { Injectable } from "@angular/core";
|
||||
import { DatePipe } from "@angular/common";
|
||||
import { HttpClient } from "@angular/common/http";
|
||||
|
||||
import { TunnelFlightReq } from "../models/tunnel-flight";
|
||||
|
||||
import { BaseService } from "./base.service";
|
||||
|
||||
@Injectable()
|
||||
export class TunnelFlightService extends BaseService {
|
||||
private datePipe: DatePipe;
|
||||
|
||||
constructor(private http: HttpClient) {
|
||||
super();
|
||||
}
|
||||
|
||||
public addFlight(selectedTunnel: number,
|
||||
flightDate: Date,
|
||||
nbMinutes: number,
|
||||
comment: string)
|
||||
{
|
||||
|
||||
const bodyNewFlight: TunnelFlightReq = {
|
||||
id: 0,
|
||||
tunnelId: selectedTunnel,
|
||||
flightDate: this.datePipe.transform(flightDate, "yyyy-MM-dd"),
|
||||
notes: comment,
|
||||
nbMinutes: nbMinutes
|
||||
};
|
||||
|
||||
return this.http.post(`${this.apiUrl}/TunnelFlight`, bodyNewFlight, { headers: this.headers});
|
||||
}
|
||||
}
|
||||
@@ -4,14 +4,13 @@ import { HttpClient } from "@angular/common/http";
|
||||
import { Observable } from "rxjs";
|
||||
import { map } from "rxjs/operators";
|
||||
|
||||
import { TunnelResp, TunnelReq } from "../models/tunnel";
|
||||
import { TunnelResp } from "../models/tunnel";
|
||||
|
||||
import { BaseService } from "./base.service";
|
||||
import { CacheApiKey } from "../models/cache-api-key.enum";
|
||||
|
||||
@Injectable()
|
||||
export class TunnelService extends BaseService {
|
||||
private datePipe: DatePipe;
|
||||
|
||||
constructor(private http: HttpClient) {
|
||||
super();
|
||||
@@ -22,23 +21,6 @@ export class TunnelService extends BaseService {
|
||||
return this.serviceCacheApi.get<Array<TunnelResp>>(CacheApiKey.Gear, callToApi);
|
||||
}
|
||||
|
||||
public AddFlight(selectedTunnel: number,
|
||||
flightDate: Date,
|
||||
nbMinutes: number,
|
||||
comment: string)
|
||||
{
|
||||
|
||||
const bodyNewFlight: TunnelReq = {
|
||||
id: 0,
|
||||
tunnelId: selectedTunnel,
|
||||
flightDate: this.datePipe.transform(flightDate, "yyyy-MM-dd"),
|
||||
comment: comment,
|
||||
nbMinutes: nbMinutes
|
||||
};
|
||||
|
||||
return this.http.post(`${this.apiUrl}/Tunnel`, bodyNewFlight, { headers: this.headers});
|
||||
}
|
||||
|
||||
public getById(id: number) : Observable<TunnelResp> {
|
||||
return this.serviceCacheApi.getByKey<Array<TunnelResp>>(CacheApiKey.Tunnel)
|
||||
.pipe(map(data => {
|
||||
|
||||
Reference in New Issue
Block a user