New view of list

This commit is contained in:
Sébastien André
2019-10-09 13:10:41 +02:00
parent 11cdcba702
commit 2f59760cc1
15 changed files with 232 additions and 42 deletions

View File

@@ -2,6 +2,8 @@
<a routerLink="/summary" routerLinkActive="active">Summary</a>
<a routerLink="/jumpsList" routerLinkActive="active">List of jumps</a>
<a routerLink="/dz" routerLinkActive="active">List of DZs</a>
<a routerLink="/newjump" routerLinkActive="active">Add a new jumps</a>
<a routerLink="/aircraftList" routerLinkActive="active">List of aircrafts</a>
<a routerLink="/jumpTypeList" routerLinkActive="active">List of jump types</a>
<a routerLink="/newjump" routerLinkActive="active">Add a new jump</a>
</nav>
<router-outlet></router-outlet>

View File

@@ -10,13 +10,17 @@ import { NewJumpComponent } from './new-jump/new-jump.component';
import { ServiceApi } from '../services/serviceApi';
import { HttpClientModule } from '@angular/common/http';
import { ListOfAircraftsComponent } from './list-of-aircrafts/list-of-aircrafts.component';
import { ListOfJumpTypesComponent } from './list-of-jump-types/list-of-jump-types.component';
const appRoutes: Routes = [
{ path: 'summary', component: SummaryComponent },
{ path: 'jumpsList', component: ListOfJumpsComponent },
{ path: 'dz', component: ListOfDzsComponent },
{ path: 'newjump', component: NewJumpComponent }
{ path: 'newjump', component: NewJumpComponent },
{ path: 'aircraftList', component: ListOfAircraftsComponent },
{ path: 'jumpTypeList', component: ListOfJumpTypesComponent }
];
@@ -26,7 +30,9 @@ const appRoutes: Routes = [
SummaryComponent,
ListOfJumpsComponent,
ListOfDzsComponent,
NewJumpComponent
NewJumpComponent,
ListOfAircraftsComponent,
ListOfJumpTypesComponent
],
imports: [
RouterModule.forRoot(

View File

@@ -0,0 +1,10 @@
<p>
list-of-aircrafts works!
</p>
<table>
<tr *ngFor="let aircraft of this.listOfAircrafts; index as i;">
<td>{{ aircraft.id }}</td>
<td>{{ aircraft.name }}</td>
</tr>
</table>

View File

@@ -0,0 +1,25 @@
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { ListOfAircraftsComponent } from './list-of-aircrafts.component';
describe('ListOfAircraftsComponent', () => {
let component: ListOfAircraftsComponent;
let fixture: ComponentFixture<ListOfAircraftsComponent>;
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ ListOfAircraftsComponent ]
})
.compileComponents();
}));
beforeEach(() => {
fixture = TestBed.createComponent(ListOfAircraftsComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});

View File

@@ -0,0 +1,24 @@
import { Component, OnInit } from '@angular/core';
import { AircraftResp } from '../../models/aircraft';
import { ServiceApi } from '../../services/serviceApi';
@Component({
selector: 'app-list-of-aircrafts',
templateUrl: './list-of-aircrafts.component.html',
styleUrls: ['./list-of-aircrafts.component.css']
})
export class ListOfAircraftsComponent implements OnInit {
public listOfAircrafts: Array<AircraftResp> = new Array<AircraftResp>();
constructor(private serviceApi: ServiceApi) {
}
ngOnInit() {
this.getListOfAircrafts();
}
getListOfAircrafts() {
this.serviceApi.getListOfAircrafts()
.subscribe(data => this.listOfAircrafts = data);
}
}

View File

@@ -0,0 +1,10 @@
<p>
list-of-jump-types works!
</p>
<table>
<tr *ngFor="let jumpType of this.listOfJumpTypes; index as i;">
<td>{{ jumpType.id }}</td>
<td>{{ jumpType.name }}</td>
</tr>
</table>

View File

@@ -0,0 +1,25 @@
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { ListOfJumpTypesComponent } from './list-of-jump-types.component';
describe('ListOfJumpTypesComponent', () => {
let component: ListOfJumpTypesComponent;
let fixture: ComponentFixture<ListOfJumpTypesComponent>;
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ ListOfJumpTypesComponent ]
})
.compileComponents();
}));
beforeEach(() => {
fixture = TestBed.createComponent(ListOfJumpTypesComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});

View File

@@ -0,0 +1,24 @@
import { Component, OnInit } from '@angular/core';
import { JumpTypeResp } from '../../models/jumpType';
import { ServiceApi } from '../../services/serviceApi';
@Component({
selector: 'app-list-of-jump-types',
templateUrl: './list-of-jump-types.component.html',
styleUrls: ['./list-of-jump-types.component.css']
})
export class ListOfJumpTypesComponent implements OnInit {
public listOfJumpTypes: Array<JumpTypeResp> = new Array<JumpTypeResp>();
constructor(private serviceApi: ServiceApi) {
}
ngOnInit() {
this.getListOfJumpTypes();
}
getListOfJumpTypes() {
this.serviceApi.getListOfJumpTypes()
.subscribe(data => this.listOfJumpTypes = data);
}
}

View File

@@ -0,0 +1,17 @@
export class AircraftReq {
constructor(data: any) {
Object.assign(this, data);
}
public id: number;
public name: number;
}
export class AircraftResp {
constructor(data: any) {
Object.assign(this, data);
}
public id: number;
public name: number;
}

View File

@@ -3,12 +3,27 @@ export class DropZoneResp {
Object.assign(this, data);
}
public Id: number;
public Latitude: string;
public Longitude: string;
public Name: string;
public Address: string;
public Website: string;
public Email: string;
public Type: Array<string>;
public id: number;
public latitude: string;
public longitude: string;
public name: string;
public address: string;
public website: string;
public email: string;
public type: Array<string>;
}
export class DropZoneReq {
constructor(data: any) {
Object.assign(this, data);
}
public id: number;
public latitude: string;
public longitude: string;
public name: string;
public address: string;
public website: string;
public email: string;
public type: Array<string>;
}

View File

@@ -1,23 +1,31 @@
export class JumpReq {
public Id: number;
public JumpTypeId: number;
public AircraftId: number;
public DropZoneId: number;
public GearId: number;
public ExitAltitude: number;
public DeployAltitude: number;
public WithCutaway: boolean;
public Notes: string;
constructor(data: any) {
Object.assign(this, data);
}
public id: number;
public jumpTypeId: number;
public aircraftId: number;
public dropZoneId: number;
public gearId: number;
public exitAltitude: number;
public deployAltitude: number;
public withCutaway: boolean;
public notes: string;
}
export class JumpResp {
public Id: number;
public JumpTypeId: number;
public AircraftId: number;
public DropZoneId: number;
public GearId: number;
public ExitAltitude: number;
public DeployAltitude: number;
public WithCutaway: boolean;
public Notes: string;
constructor(data: any) {
Object.assign(this, data);
}
public id: number;
public jumpTypeId: number;
public aircraftId: number;
public dropZoneId: number;
public gearId: number;
public exitAltitude: number;
public deployAltitude: number;
public withCutaway: boolean;
public notes: string;
}

View File

@@ -0,0 +1,17 @@
export class JumpTypeReq {
constructor(data: any) {
Object.assign(this, data);
}
public id: number;
public name: number;
}
export class JumpTypeResp {
constructor(data: any) {
Object.assign(this, data);
}
public id: number;
public name: number;
}

View File

@@ -1,20 +1,23 @@
import { Injectable } from '@angular/core';
import { HttpClient, HttpHeaders } from '@angular/common/http';
import { Observable } from 'rxjs/Observable';
import { map } from 'rxjs/operators';
import { DropZoneResp } from '../models/dropzone';
import { JumpResp } from '../models/jump';
import { Observable } from 'rxjs/Observable';
import { tap, map } from 'rxjs/operators';
import { AircraftResp } from '../models/aircraft';
import { JumpTypeResp } from '../models/jumpType';
@Injectable()
export class ServiceApi {
private readonly headers = new HttpHeaders({
'Access-Control-Allow-Origin': 'http://localhost:5000',
});
constructor(private http: HttpClient) { }
public getListOfDropZones(): Observable<Array<DropZoneResp>> {
const headers = new HttpHeaders({
'Access-Control-Allow-Origin': 'http://localhost:5000',
});
return this.http.get<Array<DropZoneResp>>('http://localhost:5000/api/DropZone', { headers: headers })
return this.http.get<Array<DropZoneResp>>('http://localhost:5000/api/DropZone', { headers: this.headers })
.pipe(
map(response => {
const details = response.map(data => new DropZoneResp(data));
@@ -24,10 +27,14 @@ export class ServiceApi {
}
public getListOfJumps(): Observable<Array<JumpResp>> {
const headers = new HttpHeaders({
'Access-Control-Allow-Origin': 'http://localhost:5000',
});
return this.http.get<Array<JumpResp>>('http://localhost:5000/api/Jump', { headers: this.headers });
}
return this.http.get<Array<JumpResp>>('http://localhost:5000/api/Jump', { headers: headers });
public getListOfAircrafts(): Observable<Array<AircraftResp>> {
return this.http.get<Array<AircraftResp>>('http://localhost:5000/api/Aircraft', { headers: this.headers });
}
public getListOfJumpTypes(): Observable<Array<JumpTypeResp>> {
return this.http.get<Array<JumpTypeResp>>('http://localhost:5000/api/JumpType', { headers: this.headers });
}
}