La page des stats avance, on a maintenant

des infos
This commit is contained in:
Sébastien André
2020-01-30 17:42:02 +01:00
parent 72f0b13f34
commit 1d470dc084
4 changed files with 97 additions and 25 deletions

View File

@@ -19,7 +19,7 @@ namespace skydiveLogs_api.Business
{
var allJumps = _jumpRepository.GetAll();
return allJumps.GroupBy(j => j.Aircraft.Id,
return allJumps.GroupBy(j => j.Aircraft.Name,
j => j,
(groupby, jumps) => new Statistic
{
@@ -33,7 +33,7 @@ namespace skydiveLogs_api.Business
{
var allJumps = _jumpRepository.GetAll();
return allJumps.GroupBy(j => j.DropZone.Id,
return allJumps.GroupBy(j => j.DropZone.Name,
j => j,
(groupby, jumps) => new Statistic
{
@@ -47,7 +47,7 @@ namespace skydiveLogs_api.Business
{
var allJumps = _jumpRepository.GetAll();
return allJumps.GroupBy(j => j.JumpType.Id,
return allJumps.GroupBy(j => j.JumpType.Name,
j => j,
(groupby, jumps) => new Statistic
{
@@ -61,7 +61,7 @@ namespace skydiveLogs_api.Business
{
var allJumps = _jumpRepository.GetAll();
return allJumps.GroupBy(j => j.Gear.Id,
return allJumps.GroupBy(j => j.Gear.Name,
j => j,
(groupby, jumps) => new Statistic
{

View File

@@ -1,4 +1,5 @@
import { Component, OnInit } from '@angular/core';
import { MatTableDataSource } from '@angular/material';
import { ServiceComm } from '../../services/service-comm.service';
import { StatsService } from '../../services/stats.service';
@@ -22,5 +23,23 @@ export class SummaryComponent implements OnInit {
ngOnInit() {
this.serviceComm.UpdatedComponentTitle('Summary');
const statsResult = this.serviceApi.getStatsOfJumps();
statsResult.statsByDz.subscribe(data => {
this.dsNbJumpByDz = new MatTableDataSource(data);
});
statsResult.statsByAircraft.subscribe(data => {
this.dsNbJumpByAircraft = new MatTableDataSource(data);
});
statsResult.statsByGear.subscribe(data => {
this.dsNbJumpByGear = new MatTableDataSource(data);
});
statsResult.statsByJumpType.subscribe(data => {
this.dsNbJumpByType = new MatTableDataSource(data);
});
statsResult.statsByYear.subscribe(data => {
this.dsNbJumpByYear = new MatTableDataSource(data);
});
}
}

View File

@@ -1,11 +1,11 @@
import { Observable } from "rxjs";
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>;
public statsByDz: Observable<Array<StatsByDzResp>>;
public statsByAircraft: Observable<Array<StatsByAircraftResp>>;
public statsByGear: Observable<Array<StatsByGearResp>>;
public statsByJumpType: Observable<Array<StatsByJumpTypeResp>>;
public statsByYear: Observable<Array<StatsByYearResp>>;
}
export class StatsByDzResp {
@@ -24,7 +24,7 @@ export class StatsByAircraftResp {
public label: string;
public nb: number;
}
export class StatsByRigResp {
export class StatsByGearResp {
constructor(data: any) {
Object.assign(this, data);
}

View File

@@ -1,12 +1,14 @@
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,
StatsByAircraftResp,
StatsByJumpTypeResp,
StatsByRigResp,
StatsByGearResp,
StatsByYearResp
} from '../models/stats';
@@ -20,28 +22,79 @@ export class StatsService {
constructor(private http: HttpClient) { }
public getStatsOfJumps(): StatsResp {
const resultat = new StatsResp();
resultat.statsByDz = this.http.get<StatsByDzResp>(
const resultats = new StatsResp();
resultats.statsByDz = this.getStatsByDz();
resultats.statsByAircraft = this.getStatsByAircraft();
resultats.statsByJumpType = this.getStatsByJumpType();
resultats.statsByGear = this.getStatsByGear();
resultats.statsByYear = this.getStatsByYear();
return resultats;
}
private getStatsByDz(): Observable<Array<StatsByDzResp>> {
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));
return stats;
})
);
resultat.statsByAircraft = this.http.get<StatsByAircraftResp>(
}
private getStatsByAircraft(): Observable<Array<StatsByAircraftResp>> {
return this.http.get<Array<StatsByAircraftResp>>(
`${environment.urlApi}/api/Stats/ByAircraft`,
{ headers: this.headers }
)
.pipe(
map(response => {
const stats = response.map(data => new StatsByAircraftResp(data));
return stats;
})
);
resultat.statsByJumpType = this.http.get<StatsByJumpTypeResp>(
}
private getStatsByJumpType(): Observable<Array<StatsByJumpTypeResp>> {
return this.http.get<Array<StatsByJumpTypeResp>>(
`${environment.urlApi}/api/Stats/ByJumpType`,
{ headers: this.headers }
)
.pipe(
map(response => {
const stats = response.map(data => new StatsByJumpTypeResp(data));
return stats;
})
);
resultat.statsByRig = this.http.get<StatsByRigResp>(
}
private getStatsByGear(): Observable<Array<StatsByGearResp>> {
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));
return stats;
})
);
resultat.statsByYear = this.http.get<StatsByYearResp>(
}
private getStatsByYear(): Observable<Array<StatsByYearResp>> {
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));
return stats;
})
);
return resultat;
}
}