Merge branch 'master' of https://home.git.sebastienandre.com/sandre/SkydiveLogs
This commit is contained in:
@@ -19,7 +19,7 @@ namespace skydiveLogs_api.Business
|
|||||||
{
|
{
|
||||||
var allJumps = _jumpRepository.GetAll();
|
var allJumps = _jumpRepository.GetAll();
|
||||||
|
|
||||||
return allJumps.GroupBy(j => j.Aircraft.Id,
|
return allJumps.GroupBy(j => j.Aircraft.Name,
|
||||||
j => j,
|
j => j,
|
||||||
(groupby, jumps) => new Statistic
|
(groupby, jumps) => new Statistic
|
||||||
{
|
{
|
||||||
@@ -33,7 +33,7 @@ namespace skydiveLogs_api.Business
|
|||||||
{
|
{
|
||||||
var allJumps = _jumpRepository.GetAll();
|
var allJumps = _jumpRepository.GetAll();
|
||||||
|
|
||||||
return allJumps.GroupBy(j => j.DropZone.Id,
|
return allJumps.GroupBy(j => j.DropZone.Name,
|
||||||
j => j,
|
j => j,
|
||||||
(groupby, jumps) => new Statistic
|
(groupby, jumps) => new Statistic
|
||||||
{
|
{
|
||||||
@@ -47,7 +47,7 @@ namespace skydiveLogs_api.Business
|
|||||||
{
|
{
|
||||||
var allJumps = _jumpRepository.GetAll();
|
var allJumps = _jumpRepository.GetAll();
|
||||||
|
|
||||||
return allJumps.GroupBy(j => j.JumpType.Id,
|
return allJumps.GroupBy(j => j.JumpType.Name,
|
||||||
j => j,
|
j => j,
|
||||||
(groupby, jumps) => new Statistic
|
(groupby, jumps) => new Statistic
|
||||||
{
|
{
|
||||||
@@ -61,7 +61,7 @@ namespace skydiveLogs_api.Business
|
|||||||
{
|
{
|
||||||
var allJumps = _jumpRepository.GetAll();
|
var allJumps = _jumpRepository.GetAll();
|
||||||
|
|
||||||
return allJumps.GroupBy(j => j.Gear.Id,
|
return allJumps.GroupBy(j => j.Gear.Name,
|
||||||
j => j,
|
j => j,
|
||||||
(groupby, jumps) => new Statistic
|
(groupby, jumps) => new Statistic
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import { Component, OnInit } from '@angular/core';
|
import { Component, OnInit } from '@angular/core';
|
||||||
|
import { MatTableDataSource } from '@angular/material';
|
||||||
import { ServiceComm } from '../../services/service-comm.service';
|
import { ServiceComm } from '../../services/service-comm.service';
|
||||||
import { StatsService } from '../../services/stats.service';
|
import { StatsService } from '../../services/stats.service';
|
||||||
|
|
||||||
@@ -22,5 +23,23 @@ export class SummaryComponent implements OnInit {
|
|||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
this.serviceComm.UpdatedComponentTitle('Summary');
|
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);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
import { Observable } from "rxjs";
|
import { Observable } from 'rxjs';
|
||||||
|
|
||||||
export class StatsResp {
|
export class StatsResp {
|
||||||
public statsByDz: Observable<StatsByDzResp>;
|
public statsByDz: Observable<Array<StatsByDzResp>>;
|
||||||
public statsByAircraft: Observable<StatsByAircraftResp>;
|
public statsByAircraft: Observable<Array<StatsByAircraftResp>>;
|
||||||
public statsByRig: Observable<StatsByRigResp>;
|
public statsByGear: Observable<Array<StatsByGearResp>>;
|
||||||
public statsByJumpType: Observable<StatsByJumpTypeResp>;
|
public statsByJumpType: Observable<Array<StatsByJumpTypeResp>>;
|
||||||
public statsByYear: Observable<StatsByYearResp>;
|
public statsByYear: Observable<Array<StatsByYearResp>>;
|
||||||
}
|
}
|
||||||
|
|
||||||
export class StatsByDzResp {
|
export class StatsByDzResp {
|
||||||
@@ -24,7 +24,7 @@ export class StatsByAircraftResp {
|
|||||||
public label: string;
|
public label: string;
|
||||||
public nb: number;
|
public nb: number;
|
||||||
}
|
}
|
||||||
export class StatsByRigResp {
|
export class StatsByGearResp {
|
||||||
constructor(data: any) {
|
constructor(data: any) {
|
||||||
Object.assign(this, data);
|
Object.assign(this, data);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,12 +1,14 @@
|
|||||||
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 { map } from 'rxjs/operators';
|
||||||
import { environment } from '../environments/environment';
|
import { environment } from '../environments/environment';
|
||||||
import {
|
import {
|
||||||
StatsResp,
|
StatsResp,
|
||||||
StatsByDzResp,
|
StatsByDzResp,
|
||||||
StatsByAircraftResp,
|
StatsByAircraftResp,
|
||||||
StatsByJumpTypeResp,
|
StatsByJumpTypeResp,
|
||||||
StatsByRigResp,
|
StatsByGearResp,
|
||||||
StatsByYearResp
|
StatsByYearResp
|
||||||
} from '../models/stats';
|
} from '../models/stats';
|
||||||
|
|
||||||
@@ -20,28 +22,79 @@ export class StatsService {
|
|||||||
constructor(private http: HttpClient) { }
|
constructor(private http: HttpClient) { }
|
||||||
|
|
||||||
public getStatsOfJumps(): StatsResp {
|
public getStatsOfJumps(): StatsResp {
|
||||||
const resultat = new StatsResp();
|
const resultats = new StatsResp();
|
||||||
resultat.statsByDz = this.http.get<StatsByDzResp>(
|
|
||||||
|
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`,
|
`${environment.urlApi}/api/Stats/ByDz`,
|
||||||
{ headers: this.headers }
|
{ headers: this.headers }
|
||||||
);
|
)
|
||||||
resultat.statsByAircraft = this.http.get<StatsByAircraftResp>(
|
.pipe(
|
||||||
|
map(response => {
|
||||||
|
const stats = response.map(data => new StatsByDzResp(data));
|
||||||
|
return stats;
|
||||||
|
})
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
private getStatsByAircraft(): Observable<Array<StatsByAircraftResp>> {
|
||||||
|
return this.http.get<Array<StatsByAircraftResp>>(
|
||||||
`${environment.urlApi}/api/Stats/ByAircraft`,
|
`${environment.urlApi}/api/Stats/ByAircraft`,
|
||||||
{ headers: this.headers }
|
{ headers: this.headers }
|
||||||
);
|
)
|
||||||
resultat.statsByJumpType = this.http.get<StatsByJumpTypeResp>(
|
.pipe(
|
||||||
|
map(response => {
|
||||||
|
const stats = response.map(data => new StatsByAircraftResp(data));
|
||||||
|
return stats;
|
||||||
|
})
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
private getStatsByJumpType(): Observable<Array<StatsByJumpTypeResp>> {
|
||||||
|
return this.http.get<Array<StatsByJumpTypeResp>>(
|
||||||
`${environment.urlApi}/api/Stats/ByJumpType`,
|
`${environment.urlApi}/api/Stats/ByJumpType`,
|
||||||
{ headers: this.headers }
|
{ headers: this.headers }
|
||||||
);
|
)
|
||||||
resultat.statsByRig = this.http.get<StatsByRigResp>(
|
.pipe(
|
||||||
|
map(response => {
|
||||||
|
const stats = response.map(data => new StatsByJumpTypeResp(data));
|
||||||
|
return stats;
|
||||||
|
})
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
private getStatsByGear(): Observable<Array<StatsByGearResp>> {
|
||||||
|
return this.http.get<Array<StatsByGearResp>>(
|
||||||
`${environment.urlApi}/api/Stats/ByGear`,
|
`${environment.urlApi}/api/Stats/ByGear`,
|
||||||
{ headers: this.headers }
|
{ headers: this.headers }
|
||||||
);
|
)
|
||||||
resultat.statsByYear = this.http.get<StatsByYearResp>(
|
.pipe(
|
||||||
|
map(response => {
|
||||||
|
const stats = response.map(data => new StatsByGearResp(data));
|
||||||
|
return stats;
|
||||||
|
})
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
private getStatsByYear(): Observable<Array<StatsByYearResp>> {
|
||||||
|
return this.http.get<Array<StatsByYearResp>>(
|
||||||
`${environment.urlApi}/api/Stats/ByYear`,
|
`${environment.urlApi}/api/Stats/ByYear`,
|
||||||
{ headers: this.headers }
|
{ headers: this.headers }
|
||||||
);
|
)
|
||||||
|
.pipe(
|
||||||
return resultat;
|
map(response => {
|
||||||
|
const stats = response.map(data => new StatsByYearResp(data));
|
||||||
|
return stats;
|
||||||
|
})
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user