Ajout de la page listant les pièges

This commit is contained in:
Sébastien André
2019-11-23 16:48:52 +01:00
parent b9a29bcd79
commit 3f7966091c
17 changed files with 310 additions and 174 deletions

View File

@@ -8,7 +8,7 @@ namespace skydiveLogs_api.Model
{ {
public int Id { get; set; } public int Id { get; set; }
public string Mame { get; set; } public string Name { get; set; }
public string Manufacturer { get; set; } public string Manufacturer { get; set; }

View File

@@ -1,9 +1,5 @@
using System; using System.Collections.Generic;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using AutoMapper; using AutoMapper;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using skydiveLogs_api.Business.Interface; using skydiveLogs_api.Business.Interface;
using skydiveLogs_api.DataContract; using skydiveLogs_api.DataContract;

Binary file not shown.

View File

@@ -15,13 +15,16 @@
<ul> <ul>
<li><a routerLink="/summary" routerLinkActive="active" (click)="toggleMenu()" skipLocationChange>Summary</a> <li><a routerLink="/summary" routerLinkActive="active" (click)="toggleMenu()" skipLocationChange>Summary</a>
</li> </li>
<li><a routerLink="/jumpsList" routerLinkActive="active" (click)="toggleMenu()" skipLocationChange>List of <li><a routerLink="/jumps" routerLinkActive="active" (click)="toggleMenu()" skipLocationChange>List of
jumps</a></li> jumps</a></li>
<li><a routerLink="/dz" routerLinkActive="active" (click)="toggleMenu()" skipLocationChange>List of DZs</a></li> <li><a routerLink="/dzs" routerLinkActive="active" (click)="toggleMenu()" skipLocationChange>List of DZs</a>
<li><a routerLink="/aircraftList" routerLinkActive="active" (click)="toggleMenu()" skipLocationChange>List of </li>
<li><a routerLink="/aircrafts" routerLinkActive="active" (click)="toggleMenu()" skipLocationChange>List of
aircrafts</a></li> aircrafts</a></li>
<li><a routerLink="/jumpTypeList" routerLinkActive="active" (click)="toggleMenu()" skipLocationChange>List of <li><a routerLink="/jumpTypes" routerLinkActive="active" (click)="toggleMenu()" skipLocationChange>List of
jump types</a></li> jump types</a></li>
<li><a routerLink="/gears" routerLinkActive="active" (click)="toggleMenu()" skipLocationChange>List of
gears</a></li>
<li><a routerLink="/newjump" routerLinkActive="active" (click)="toggleMenu()" skipLocationChange>Add a new <li><a routerLink="/newjump" routerLinkActive="active" (click)="toggleMenu()" skipLocationChange>Add a new
jump</a></li> jump</a></li>
</ul> </ul>

View File

@@ -1,23 +1,24 @@
import { BrowserModule } from '@angular/platform-browser'; import { BrowserModule } from "@angular/platform-browser";
import { NgModule } from '@angular/core'; import { NgModule } from "@angular/core";
import { RouterModule, Routes } from '@angular/router'; import { RouterModule, Routes } from "@angular/router";
import { HttpClientModule, HTTP_INTERCEPTORS } from '@angular/common/http'; import { HttpClientModule, HTTP_INTERCEPTORS } from "@angular/common/http";
import { AppComponent } from './app.component'; import { AppComponent } from "./app.component";
import { SummaryComponent } from './summary/summary.component'; import { SummaryComponent } from "./summary/summary.component";
import { ListOfJumpsComponent } from './list-of-jumps/list-of-jumps.component'; import { ListOfJumpsComponent } from "./list-of-jumps/list-of-jumps.component";
import { ListOfDzsComponent } from './list-of-dzs/list-of-dzs.component'; import { ListOfDzsComponent } from "./list-of-dzs/list-of-dzs.component";
import { NewJumpComponent } from './new-jump/new-jump.component'; import { NewJumpComponent } from "./new-jump/new-jump.component";
import { ListOfAircraftsComponent } from './list-of-aircrafts/list-of-aircrafts.component'; import { ListOfAircraftsComponent } from "./list-of-aircrafts/list-of-aircrafts.component";
import { ListOfJumpTypesComponent } from './list-of-jump-types/list-of-jump-types.component'; import { ListOfJumpTypesComponent } from "./list-of-jump-types/list-of-jump-types.component";
import { ListOfGearsComponent } from "./list-of-gears/list-of-gears.component";
import { DateService } from '../services/date.service'; import { DateService } from "../services/date.service";
import { ServiceApiGet } from '../services/service-api-get.service'; import { ServiceApiGet } from "../services/service-api-get.service";
import { ServiceApiPost } from '../services/service-api-post.service'; import { ServiceApiPost } from "../services/service-api-post.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 } from '@angular/forms'; import { FormsModule } from "@angular/forms";
import { import {
MatPaginatorModule, MatPaginatorModule,
MatTableModule, MatTableModule,
@@ -30,17 +31,18 @@ import {
MatInputModule, MatInputModule,
MatButtonModule, MatButtonModule,
MatIconModule MatIconModule
} from '@angular/material'; } from "@angular/material";
import { RequestCache } from '../services/request-cache.service'; import { RequestCache } from "../services/request-cache.service";
import { CachingInterceptor } from '../services/caching-interceptor.service'; import { CachingInterceptor } from "../services/caching-interceptor.service";
const appRoutes: Routes = [ const appRoutes: Routes = [
{ path: 'summary', component: SummaryComponent }, { path: "summary", component: SummaryComponent },
{ path: 'jumpsList', component: ListOfJumpsComponent }, { path: "jumps", component: ListOfJumpsComponent },
{ path: 'dz', component: ListOfDzsComponent }, { path: "dzs", component: ListOfDzsComponent },
{ path: 'newjump', component: NewJumpComponent }, { path: "newjump", component: NewJumpComponent },
{ path: 'aircraftList', component: ListOfAircraftsComponent }, { path: "aircrafts", component: ListOfAircraftsComponent },
{ path: 'jumpTypeList', component: ListOfJumpTypesComponent } { path: "jumpTypes", component: ListOfJumpTypesComponent },
{ path: "gears", component: ListOfGearsComponent }
]; ];
@NgModule({ @NgModule({
@@ -51,7 +53,8 @@ const appRoutes: Routes = [
ListOfDzsComponent, ListOfDzsComponent,
NewJumpComponent, NewJumpComponent,
ListOfAircraftsComponent, ListOfAircraftsComponent,
ListOfJumpTypesComponent ListOfJumpTypesComponent,
ListOfGearsComponent
], ],
imports: [ imports: [
RouterModule.forRoot( RouterModule.forRoot(
@@ -84,4 +87,4 @@ const appRoutes: Routes = [
], ],
bootstrap: [AppComponent] bootstrap: [AppComponent]
}) })
export class AppModule { } export class AppModule {}

View File

@@ -0,0 +1,3 @@
table {
width: 100%;
}

View File

@@ -0,0 +1,37 @@
<table mat-table [dataSource]="dataSourceTable">
<ng-container matColumnDef="id">
<th mat-header-cell *matHeaderCellDef>ID</th>
<td mat-cell *matCellDef="let element">{{element.id}}</td>
</ng-container>
<ng-container matColumnDef="name">
<th mat-header-cell *matHeaderCellDef>Name</th>
<td mat-cell *matCellDef="let element">{{element.name}} <a href='http://{{element.website}}'>ici</a></td>
</ng-container>
<ng-container matColumnDef="latitude">
<th mat-header-cell *matHeaderCellDef>Latitude</th>
<td mat-cell *matCellDef="let element">{{element.latitude}}</td>
</ng-container>
<ng-container matColumnDef="longitude">
<th mat-header-cell *matHeaderCellDef>Longitude</th>
<td mat-cell *matCellDef="let element">{{element.longitude}}</td>
</ng-container>
<ng-container matColumnDef="address">
<th mat-header-cell *matHeaderCellDef>Address</th>
<td mat-cell *matCellDef="let element"><span [innerHTML]="element.address"></span></td>
</ng-container>
<ng-container matColumnDef="email">
<th mat-header-cell *matHeaderCellDef>E-mail</th>
<td mat-cell *matCellDef="let element">{{element.email}}</td>
</ng-container>
<ng-container matColumnDef="type">
<th mat-header-cell *matHeaderCellDef>Type</th>
<td mat-cell *matCellDef="let element">{{element.type}}</td>
</ng-container>
<tr mat-header-row *matHeaderRowDef="displayedColumns"></tr>
<tr mat-row *matRowDef="let row; columns: displayedColumns;"></tr>
</table>
<mat-paginator [length]="resultsLength" [pageSize]="10"></mat-paginator>

View File

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

View File

@@ -0,0 +1,44 @@
import { Component, OnInit, ViewChild } from "@angular/core";
import { MatPaginator, MatTableDataSource } from "@angular/material";
import { ServiceApiGet } from "../../services/service-api-get.service";
import { ServiceComm } from "../../services/service-comm.service";
import { GearResp } from "../../models/gear";
@Component({
selector: "app-list-of-gears",
templateUrl: "./list-of-gears.component.html",
styleUrls: ["./list-of-gears.component.css"]
})
export class ListOfGearsComponent implements OnInit {
public displayedColumns: Array<string> = [
"id",
"name",
"latitude",
"longitude",
"address",
"email",
"type"
];
public dataSourceTable;
public resultsLength = 0;
@ViewChild(MatPaginator, { static: true }) paginator: MatPaginator;
constructor(
private serviceApi: ServiceApiGet,
private serviceComm: ServiceComm
) {}
ngOnInit() {
this.serviceComm.updatedComponentTitle("List of gears");
this.getListOfGears();
}
getListOfGears() {
this.serviceApi.getListOfGears().subscribe(data => {
this.dataSourceTable = new MatTableDataSource<GearResp>(data);
this.dataSourceTable.paginator = this.paginator;
this.resultsLength = data.length;
});
}
}

View File

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

View File

@@ -0,0 +1,50 @@
import { Observable } from "rxjs";
export class StatsResp {
public statsByDz: Observable<StatsByDzResp>;
public statsByAircraft: Observable<StatsByAircraftResp>;
public statsByRig: Observable<StatsByRigResp>;
public statsByJumpType: Observable<StatsByJumpTypeResp>;
public statsByYear: Observable<StatsByYearResp>;
}
export class StatsByDzResp {
constructor(data: any) {
Object.assign(this, data);
}
public label: string;
public nb: number;
}
export class StatsByAircraftResp {
constructor(data: any) {
Object.assign(this, data);
}
public label: string;
public nb: number;
}
export class StatsByRigResp {
constructor(data: any) {
Object.assign(this, data);
}
public label: string;
public nb: number;
}
export class StatsByJumpTypeResp {
constructor(data: any) {
Object.assign(this, data);
}
public label: string;
public nb: number;
}
export class StatsByYearResp {
constructor(data: any) {
Object.assign(this, data);
}
public label: string;
public nb: number;
}

View File

@@ -1,51 +0,0 @@
import { Observable } from 'rxjs';
export class StatsResp {
public statsByDz: Observable<StatsByDzResp>;
public statsByAircraft: Observable<StatsByAircraftResp>;
public statsByRig: Observable<StatsByRigResp>;
public statsByJumpType: Observable<StatsByJumpTypeResp>;
public statsByYear: Observable<StatsByYearResp>;
}
export class StatsByDzResp {
constructor(data: any) {
Object.assign(this, data);
}
public label: string;
public nb: number;
}
export class StatsByAircraftResp {
constructor(data: any) {
Object.assign(this, data);
}
public label: string;
public nb: number;
}
export class StatsByRigResp {
constructor(data: any) {
Object.assign(this, data);
}
public label: string;
public nb: number;
}
export class StatsByJumpTypeResp {
constructor(data: any) {
Object.assign(this, data);
}
public label: string;
public nb: number;
}
export class StatsByYearResp {
constructor(data: any) {
Object.assign(this, data);
}
public label: string;
public nb: number;
}

View File

@@ -1,12 +1,15 @@
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 { Observable } from "rxjs";
import { map } from 'rxjs/operators'; 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 { DropZoneResp } from '../models/dropzone';
import { JumpResp } from '../models/jump';
import { AircraftResp } from '../models/aircraft';
import { JumpTypeResp } from '../models/jumpType';
import { import {
StatsResp, StatsResp,
StatsByDzResp, StatsByDzResp,
@@ -14,18 +17,18 @@ import {
StatsByJumpTypeResp, StatsByJumpTypeResp,
StatsByRigResp, StatsByRigResp,
StatsByYearResp StatsByYearResp
} from '../models/statsresp'; } from "../models/stats";
import { environment } from '../environments/environment';
@Injectable() @Injectable()
export class ServiceApiGet { export class ServiceApiGet {
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) {}
public getListOfDropZones(): Observable<Array<DropZoneResp>> { public getListOfDropZones(): Observable<Array<DropZoneResp>> {
return this.http.get<Array<DropZoneResp>>(`${environment.urlApi}/api/DropZone`, { return this.http
.get<Array<DropZoneResp>>(`${environment.urlApi}/api/DropZone`, {
headers: this.headers headers: this.headers
}) })
.pipe( .pipe(
@@ -56,6 +59,12 @@ export class ServiceApiGet {
); );
} }
public getListOfGears(): Observable<Array<GearResp>> {
return this.http.get<Array<GearResp>>(`${environment.urlApi}/api/Gear`, {
headers: this.headers
});
}
public getStatsOfJumps(): StatsResp { public getStatsOfJumps(): StatsResp {
const resultat = new StatsResp(); const resultat = new StatsResp();
resultat.statsByDz = this.http.get<StatsByDzResp>( resultat.statsByDz = this.http.get<StatsByDzResp>(