Fix
This commit is contained in:
@@ -5,7 +5,7 @@
|
|||||||
"scripts": {
|
"scripts": {
|
||||||
"ng": "ng",
|
"ng": "ng",
|
||||||
"start": "ng serve",
|
"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",
|
"test": "ng test",
|
||||||
"lint": "ng lint",
|
"lint": "ng lint",
|
||||||
"e2e": "ng e2e"
|
"e2e": "ng e2e"
|
||||||
|
|||||||
@@ -24,6 +24,10 @@ import { DefaultComponent } from "./default/default.component";
|
|||||||
import { LoginComponent } from "./login/login.component";
|
import { LoginComponent } from "./login/login.component";
|
||||||
import { CreateUserComponent } from "./create-user/create-user.component";
|
import { CreateUserComponent } from "./create-user/create-user.component";
|
||||||
import { LoginUserComponent } from "./login-user/login-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 { DateService } from "../services/date.service";
|
||||||
import { AircraftService } from "../services/aircraft.service";
|
import { AircraftService } from "../services/aircraft.service";
|
||||||
@@ -39,6 +43,7 @@ import { ImageService } from "../services/image.service";
|
|||||||
import { ConfigurationHelper } from "../services/configuration-helper";
|
import { ConfigurationHelper } from "../services/configuration-helper";
|
||||||
import { ServiceCacheApi } from "../services/service-cache-api.service";
|
import { ServiceCacheApi } from "../services/service-cache-api.service";
|
||||||
import { TunnelService } from "../services/tunnel.service";
|
import { TunnelService } from "../services/tunnel.service";
|
||||||
|
import { TunnelFlightService } from "../services/tunnel-flight.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";
|
||||||
@@ -65,10 +70,6 @@ import { MatToolbarModule } from '@angular/material/toolbar';
|
|||||||
|
|
||||||
import { JwtAuthInterceptor } from "../interceptor/jwt-auth.interceptor";
|
import { JwtAuthInterceptor } from "../interceptor/jwt-auth.interceptor";
|
||||||
import { ErrorInterceptor } from "../interceptor/error.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 = [
|
const appRoutes: Routes = [
|
||||||
{ path: "", component: DefaultComponent, canActivate: [AuthGuardService] },
|
{ path: "", component: DefaultComponent, canActivate: [AuthGuardService] },
|
||||||
@@ -151,7 +152,7 @@ export function initConfig(configService: ConfigurationHelper) {
|
|||||||
UserProfileComponent,
|
UserProfileComponent,
|
||||||
ListOfImagesComponent,
|
ListOfImagesComponent,
|
||||||
JumpInfosComponent,
|
JumpInfosComponent,
|
||||||
NewTunnelFlightComponent,
|
NewTunnelFlightComponent
|
||||||
],
|
],
|
||||||
imports: [
|
imports: [
|
||||||
RouterModule.forRoot(
|
RouterModule.forRoot(
|
||||||
@@ -195,6 +196,7 @@ export function initConfig(configService: ConfigurationHelper) {
|
|||||||
exports: [HttpClientModule],
|
exports: [HttpClientModule],
|
||||||
providers: [
|
providers: [
|
||||||
TunnelService,
|
TunnelService,
|
||||||
|
TunnelFlightService,
|
||||||
ImageService,
|
ImageService,
|
||||||
AircraftService,
|
AircraftService,
|
||||||
DropzoneService,
|
DropzoneService,
|
||||||
|
|||||||
@@ -5,10 +5,11 @@ import { TranslateService } from '@ngx-translate/core';
|
|||||||
|
|
||||||
import { TunnelResp } from "../../models/tunnel";
|
import { TunnelResp } from "../../models/tunnel";
|
||||||
|
|
||||||
import { DateService } from 'src/services/date.service';
|
import { DateService } from '../../services/date.service';
|
||||||
import { TunnelService } from 'src/services/tunnel.service';
|
import { TunnelService } from '../../services/tunnel.service';
|
||||||
import { ServiceComm } from 'src/services/service-comm.service';
|
import { ServiceComm } from '../../services/service-comm.service';
|
||||||
import { StatsService } from 'src/services/stats.service';
|
import { StatsService } from '../../services/stats.service';
|
||||||
|
import { TunnelFlightService } from "../../services/tunnel-flight.service";
|
||||||
|
|
||||||
export const PICK_FORMATS = {
|
export const PICK_FORMATS = {
|
||||||
parse: { dateInput: 'yy MM dd' },
|
parse: { dateInput: 'yy MM dd' },
|
||||||
@@ -47,6 +48,7 @@ export class NewTunnelFlightComponent implements OnInit {
|
|||||||
|
|
||||||
constructor(private serviceComm: ServiceComm,
|
constructor(private serviceComm: ServiceComm,
|
||||||
private serviceTunnel: TunnelService,
|
private serviceTunnel: TunnelService,
|
||||||
|
private serviceTunnelFlight: TunnelFlightService,
|
||||||
private dateService: DateService,
|
private dateService: DateService,
|
||||||
private translateService: TranslateService,
|
private translateService: TranslateService,
|
||||||
private statsService: StatsService) { }
|
private statsService: StatsService) { }
|
||||||
@@ -67,20 +69,19 @@ export class NewTunnelFlightComponent implements OnInit {
|
|||||||
onFormSubmit() {
|
onFormSubmit() {
|
||||||
this.pendingAddRequest = true;
|
this.pendingAddRequest = true;
|
||||||
|
|
||||||
this.serviceTunnel.AddFlight(this.selectedTunnel.id,
|
this.serviceTunnelFlight.addFlight(this.selectedTunnel.id,
|
||||||
this.beginDate,
|
this.beginDate,
|
||||||
this.minutesOfFlight,
|
this.minutesOfFlight,
|
||||||
this.comments)
|
this.comments)
|
||||||
.subscribe(() => {
|
.subscribe(() => {
|
||||||
this.statsService.resetStats();
|
this.statsService.resetStats();
|
||||||
this.comments = undefined;
|
this.comments = undefined;
|
||||||
|
|
||||||
if (this.resetForm === true) {
|
|
||||||
this.initForm();
|
|
||||||
}
|
|
||||||
this.pendingAddRequest = false;
|
|
||||||
});
|
|
||||||
|
|
||||||
|
if (this.resetForm === true) {
|
||||||
|
this.initForm();
|
||||||
|
}
|
||||||
|
this.pendingAddRequest = false;
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public isValidatedForm(): boolean {
|
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 { Observable } from "rxjs";
|
||||||
import { map } from "rxjs/operators";
|
import { map } from "rxjs/operators";
|
||||||
|
|
||||||
import { TunnelResp, TunnelReq } from "../models/tunnel";
|
import { TunnelResp } from "../models/tunnel";
|
||||||
|
|
||||||
import { BaseService } from "./base.service";
|
import { BaseService } from "./base.service";
|
||||||
import { CacheApiKey } from "../models/cache-api-key.enum";
|
import { CacheApiKey } from "../models/cache-api-key.enum";
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class TunnelService extends BaseService {
|
export class TunnelService extends BaseService {
|
||||||
private datePipe: DatePipe;
|
|
||||||
|
|
||||||
constructor(private http: HttpClient) {
|
constructor(private http: HttpClient) {
|
||||||
super();
|
super();
|
||||||
@@ -22,23 +21,6 @@ export class TunnelService extends BaseService {
|
|||||||
return this.serviceCacheApi.get<Array<TunnelResp>>(CacheApiKey.Gear, callToApi);
|
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> {
|
public getById(id: number) : Observable<TunnelResp> {
|
||||||
return this.serviceCacheApi.getByKey<Array<TunnelResp>>(CacheApiKey.Tunnel)
|
return this.serviceCacheApi.getByKey<Array<TunnelResp>>(CacheApiKey.Tunnel)
|
||||||
.pipe(map(data => {
|
.pipe(map(data => {
|
||||||
|
|||||||
Reference in New Issue
Block a user