Evol de la page Summary avec

les stats pour la saison en cours
This commit is contained in:
Sébastien André
2020-02-15 22:40:26 +01:00
parent 6e804b1ae4
commit 0eeb0d3e12
6 changed files with 154 additions and 71 deletions

View File

@@ -46,7 +46,7 @@ export class NewJumpComponent implements OnInit {
) {}
ngOnInit() {
this.serviceComm.UpdatedComponentTitle('Add a new jump');
this.serviceComm.UpdatedComponentTitle("Add a new jump");
this.endDate = new Date();
this.beginDate = this.dateService.AddDays(new Date(), -1);
@@ -126,8 +126,8 @@ export class NewJumpComponent implements OnInit {
return data ? data.name : undefined;
}
public onChangeDz(event: DropZoneResp) {
const filterValue = event.name.toLowerCase();
public onChangeDz(event: string) {
const filterValue = event.toLowerCase();
this.listOfFilteredDropZone = this.listOfDropZone;
this.listOfFilteredDropZone = this.listOfFilteredDropZone.filter(option =>

View File

@@ -15,10 +15,50 @@
<div class="paragraph">
<label>Jumps in the last month</label>
<table mat-table [dataSource]="dsJumpForLastMonthByDz">
<ng-container matColumnDef="label">
<td mat-cell *matCellDef="let element">{{element.label}}</td>
</ng-container>
<ng-container matColumnDef="nb">
<td mat-cell *matCellDef="let element">{{element.nb}}</td>
</ng-container>
<tr mat-row *matRowDef="let row; columns: displayedColumns;"></tr>
</table>
<table mat-table [dataSource]="dsJumpForLastMonthByJumpType">
<ng-container matColumnDef="label">
<td mat-cell *matCellDef="let element">{{element.label}}</td>
</ng-container>
<ng-container matColumnDef="nb">
<td mat-cell *matCellDef="let element">{{element.nb}}</td>
</ng-container>
<tr mat-row *matRowDef="let row; columns: displayedColumns;"></tr>
</table>
</div>
<div class="paragraph">
<label>Jumps in the last year</label>
<table mat-table [dataSource]="dsJumpForLastYearByDz">
<ng-container matColumnDef="label">
<td mat-cell *matCellDef="let element">{{element.label}}</td>
</ng-container>
<ng-container matColumnDef="nb">
<td mat-cell *matCellDef="let element">{{element.nb}}</td>
</ng-container>
<tr mat-row *matRowDef="let row; columns: displayedColumns;"></tr>
</table>
<table mat-table [dataSource]="dsJumpForLastYearByJumpType">
<ng-container matColumnDef="label">
<td mat-cell *matCellDef="let element">{{element.label}}</td>
</ng-container>
<ng-container matColumnDef="nb">
<td mat-cell *matCellDef="let element">{{element.nb}}</td>
</ng-container>
<tr mat-row *matRowDef="let row; columns: displayedColumns;"></tr>
</table>
</div>
<div class="paragraph">

View File

@@ -1,21 +1,33 @@
import { Component, OnInit } from '@angular/core';
import { MatTableDataSource } from '@angular/material/table';
import { ServiceComm } from '../../services/service-comm.service';
import { StatsService } from '../../services/stats.service';
import { Component, OnInit } from "@angular/core";
import { MatTableDataSource } from "@angular/material/table";
import { ServiceComm } from "../../services/service-comm.service";
import { StatsService } from "../../services/stats.service";
import {
StatsByDzResp,
StatsByAircraftResp,
StatsByGearResp,
StatsByJumpTypeResp,
StatsByYearResp
} from "../../models/stats";
@Component({
selector: 'app-summary',
templateUrl: './summary.component.html',
styleUrls: ['./summary.component.css']
selector: "app-summary",
templateUrl: "./summary.component.html",
styleUrls: ["./summary.component.css"]
})
export class SummaryComponent implements OnInit {
public displayedColumns: Array<string> = ['label', 'nb'];
public dsNbJumpByDz;
public dsNbJumpByAircraft;
public dsNbJumpByGear;
public dsNbJumpByType;
public dsNbJumpByYear;
public dsNbJumpByDz: MatTableDataSource<StatsByDzResp>;
public dsNbJumpByAircraft: MatTableDataSource<StatsByAircraftResp>;
public dsNbJumpByGear: MatTableDataSource<StatsByGearResp>;
public dsNbJumpByType: MatTableDataSource<StatsByJumpTypeResp>;
public dsNbJumpByYear: MatTableDataSource<StatsByYearResp>;
public dsJumpForLastYearByDz: MatTableDataSource<StatsByDzResp>;
public dsJumpForLastYearByJumpType: MatTableDataSource<StatsByJumpTypeResp>;
public dsJumpForLastMonthByDz: MatTableDataSource<StatsByDzResp>;
public dsJumpForLastMonthByJumpType: MatTableDataSource<StatsByJumpTypeResp>;
private countDatasLoaded: number;
public displayedColumns: Array<string> = ["label", "nb"];
constructor(
private serviceApi: StatsService,
@@ -24,7 +36,7 @@ export class SummaryComponent implements OnInit {
ngOnInit() {
this.countDatasLoaded = 0;
this.serviceComm.UpdatedComponentTitle('Summary');
this.serviceComm.UpdatedComponentTitle("Summary");
const statsResult = this.serviceApi.getStatsOfJumps();
@@ -50,11 +62,17 @@ export class SummaryComponent implements OnInit {
});
statsResult.statsForLastYear.subscribe(data => {
this.dsNbJumpByYear = new MatTableDataSource(data);
this.dsJumpForLastYearByDz = new MatTableDataSource(data.byDz);
this.dsJumpForLastYearByJumpType = new MatTableDataSource(
data.byJumpType
);
this.countDatasLoaded++;
});
statsResult.statsForLastMonth.subscribe(data => {
this.dsNbJumpByYear = new MatTableDataSource(data);
this.dsJumpForLastMonthByDz = new MatTableDataSource(data.byDz);
this.dsJumpForLastMonthByJumpType = new MatTableDataSource(
data.byJumpType
);
this.countDatasLoaded++;
});
}

View File

@@ -1,4 +1,4 @@
import { Observable } from 'rxjs';
import { Observable } from "rxjs";
export class StatsResp {
public statsByDz: Observable<Array<StatsByDzResp>>;
@@ -19,6 +19,7 @@ export class StatsByDzResp {
public label: string;
public nb: number;
}
export class StatsByAircraftResp {
constructor(data: any) {
Object.assign(this, data);
@@ -27,6 +28,7 @@ export class StatsByAircraftResp {
public label: string;
public nb: number;
}
export class StatsByGearResp {
constructor(data: any) {
Object.assign(this, data);
@@ -35,6 +37,7 @@ export class StatsByGearResp {
public label: string;
public nb: number;
}
export class StatsByJumpTypeResp {
constructor(data: any) {
Object.assign(this, data);
@@ -43,6 +46,7 @@ export class StatsByJumpTypeResp {
public label: string;
public nb: number;
}
export class StatsByYearResp {
constructor(data: any) {
Object.assign(this, data);
@@ -52,11 +56,16 @@ export class StatsByYearResp {
public nb: number;
}
export class StatsForLastYearResp {
constructor(data: any) {
Object.assign(this, data);
constructor(
dataByDz: Array<StatsByDzResp>,
dataByJumpType: Array<StatsByJumpTypeResp>
) {
this.byDz = new Array<StatsByDzResp>();
this.byJumpType = new Array<StatsByJumpTypeResp>();
Object.assign(this.byDz, dataByDz);
Object.assign(this.byJumpType, dataByJumpType);
}
public byDz: Array<StatsByDzResp>;
@@ -64,8 +73,15 @@ export class StatsForLastYearResp {
}
export class StatsForLastMonthResp {
constructor(data: any) {
Object.assign(this, data);
constructor(
dataByDz: Array<StatsByDzResp>,
dataByJumpType: Array<StatsByJumpTypeResp>
) {
this.byDz = new Array<StatsByDzResp>();
this.byJumpType = new Array<StatsByJumpTypeResp>();
Object.assign(this.byDz, dataByDz);
Object.assign(this.byJumpType, dataByJumpType);
}
public byDz: Array<StatsByDzResp>;

View File

@@ -1,8 +1,8 @@
import { Injectable } from '@angular/core';
import { HttpClient, HttpHeaders } from '@angular/common/http';
import { Observable } from 'rxjs';
import { map } from 'rxjs/operators';
import { environment } from '../environments/environment';
import { Injectable } from "@angular/core";
import { HttpClient, HttpHeaders } from "@angular/common/http";
import { Observable } from "rxjs";
import { map } from "rxjs/operators";
import { environment } from "../environments/environment";
import {
StatsResp,
StatsByDzResp,
@@ -12,13 +12,12 @@ import {
StatsByYearResp,
StatsForLastMonthResp,
StatsForLastYearResp
} from '../models/stats';
} from "../models/stats";
@Injectable()
export class StatsService {
private readonly headers = new HttpHeaders({
'Access-Control-Allow-Origin': environment.urlApi
"Access-Control-Allow-Origin": environment.urlApi
});
constructor(private http: HttpClient) {}
@@ -39,10 +38,10 @@ export class StatsService {
}
private getStatsByDz(): Observable<Array<StatsByDzResp>> {
return this.http.get<Array<StatsByDzResp>>(
`${environment.urlApi}/api/Stats/ByDz`,
{ headers: this.headers }
)
return this.http
.get<Array<StatsByDzResp>>(`${environment.urlApi}/api/Stats/ByDz`, {
headers: this.headers
})
.pipe(
map(response => {
const stats = response.map(data => new StatsByDzResp(data));
@@ -52,7 +51,8 @@ export class StatsService {
}
private getStatsByAircraft(): Observable<Array<StatsByAircraftResp>> {
return this.http.get<Array<StatsByAircraftResp>>(
return this.http
.get<Array<StatsByAircraftResp>>(
`${environment.urlApi}/api/Stats/ByAircraft`,
{ headers: this.headers }
)
@@ -65,7 +65,8 @@ export class StatsService {
}
private getStatsByJumpType(): Observable<Array<StatsByJumpTypeResp>> {
return this.http.get<Array<StatsByJumpTypeResp>>(
return this.http
.get<Array<StatsByJumpTypeResp>>(
`${environment.urlApi}/api/Stats/ByJumpType`,
{ headers: this.headers }
)
@@ -78,10 +79,10 @@ export class StatsService {
}
private getStatsByGear(): Observable<Array<StatsByGearResp>> {
return this.http.get<Array<StatsByGearResp>>(
`${environment.urlApi}/api/Stats/ByGear`,
{ headers: this.headers }
)
return this.http
.get<Array<StatsByGearResp>>(`${environment.urlApi}/api/Stats/ByGear`, {
headers: this.headers
})
.pipe(
map(response => {
const stats = response.map(data => new StatsByGearResp(data));
@@ -91,10 +92,10 @@ export class StatsService {
}
private getStatsByYear(): Observable<Array<StatsByYearResp>> {
return this.http.get<Array<StatsByYearResp>>(
`${environment.urlApi}/api/Stats/ByYear`,
{ headers: this.headers }
)
return this.http
.get<Array<StatsByYearResp>>(`${environment.urlApi}/api/Stats/ByYear`, {
headers: this.headers
})
.pipe(
map(response => {
const stats = response.map(data => new StatsByYearResp(data));
@@ -103,31 +104,39 @@ export class StatsService {
);
}
private getStatsOfLastYear(): Observable<StatsForLastYearResp> {
return this.http.get<StatsForLastYearResp>(
return this.http
.get<StatsForLastYearResp>(
`${environment.urlApi}/api/Stats/ForLastYear`,
{ headers: this.headers }
)
.pipe(
map(response => {
const stats = response.map(data => new StatsByDzResp(data));
return stats;
const statsByDz = response.byDz.map(data => new StatsByDzResp(data));
const statsByJumpType = response.byJumpType.map(
data => new StatsByDzResp(data)
);
return new StatsForLastYearResp(statsByDz, statsByJumpType);
})
);
}
private getStatsOfLastMonth(): Observable<StatsForLastMonthResp> {
return this.http.get<StatsForLastYearResp>(
return this.http
.get<StatsForLastYearResp>(
`${environment.urlApi}/api/Stats/ForLastMonth`,
{ headers: this.headers }
)
.pipe(
map(response => {
const stats = response.map(data => new StatsByDzResp(data));
return stats;
const statsByDz = response.byDz.map(data => new StatsByDzResp(data));
const statsByJumpType = response.byJumpType.map(
data => new StatsByDzResp(data)
);
return new StatsForLastMonthResp(statsByDz, statsByJumpType);
})
);
}
}