Évol pour afficher le total de sauts et 1-2 infos
sur le dernier saut
This commit is contained in:
@@ -1,16 +1,16 @@
|
||||
<div>
|
||||
<label style="float: left; width: 130px;">Total jumps :</label>
|
||||
<span>850</span>
|
||||
<label style="float: left; width: 130px;">Total jumps</label>
|
||||
<span>: {{ totalJumps }}</span>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<label style="float: left; width: 130px;">Total cutaways :</label>
|
||||
<span>1</span>
|
||||
<label style="float: left; width: 130px;">Total cutaways</label>
|
||||
<span>: {{ totalCutaways }}</span>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<label style="float: left; width: 130px;">Last jump :</label>
|
||||
<span>5 Février 2020 à Barcelonnette</span>
|
||||
<label style="float: left; width: 130px;">Last jump</label>
|
||||
<span>: {{ lastJump }}</span>
|
||||
</div>
|
||||
|
||||
<div style="display: flex; flex-direction: row; flex-wrap: wrap; margin-top: 15px;">
|
||||
|
||||
@@ -32,17 +32,27 @@ export class SummaryComponent implements OnInit {
|
||||
private _shownStats: Map<StatType, boolean>;
|
||||
public StatType = StatType;
|
||||
|
||||
public totalJumps: number;
|
||||
public totalCutaways: number;
|
||||
public lastJump: string;
|
||||
|
||||
constructor(
|
||||
private serviceApi: StatsService,
|
||||
private serviceComm: ServiceComm
|
||||
private _serviceApi: StatsService,
|
||||
private _serviceComm: ServiceComm
|
||||
) { }
|
||||
|
||||
ngOnInit() {
|
||||
this.initShownStats();
|
||||
|
||||
this.serviceComm.UpdatedComponentTitle('Summary');
|
||||
this._serviceComm.UpdatedComponentTitle('Summary');
|
||||
|
||||
const statsResult = this.serviceApi.getStatsOfJumps();
|
||||
const statsResult = this._serviceApi.getStatsOfJumps();
|
||||
|
||||
statsResult.simpleSummary.subscribe(data => {
|
||||
this.totalJumps = data.totalJumps;
|
||||
this.totalCutaways = data.totalCutaways;
|
||||
this.lastJump = data.lastJump.jumpDate + ' (' + data.lastJump.dropZone.name + ')';
|
||||
});
|
||||
|
||||
statsResult.statsByDz.subscribe(data => {
|
||||
this.dsNbJumpByDz = new MatTableDataSource(data);
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { Observable } from 'rxjs';
|
||||
import { JumpResp } from './jump';
|
||||
|
||||
export enum StatType {
|
||||
ForLastMonth = 1,
|
||||
@@ -11,6 +12,8 @@ export enum StatType {
|
||||
}
|
||||
|
||||
export class StatsResp {
|
||||
public simpleSummary: Observable<SimpleSummary>;
|
||||
|
||||
public statsByDz: Observable<Array<StatsByDzResp>>;
|
||||
public statsByAircraft: Observable<Array<StatsByAircraftResp>>;
|
||||
public statsByGear: Observable<Array<StatsByGearResp>>;
|
||||
@@ -21,6 +24,18 @@ export class StatsResp {
|
||||
public statsForLastMonth: Observable<StatsForLastMonthResp>;
|
||||
}
|
||||
|
||||
export class SimpleSummary {
|
||||
constructor(data: any) {
|
||||
this.totalJumps = data.totalJumps;
|
||||
this.totalCutaways = data.totalCutaways;
|
||||
this.lastJump = new JumpResp(data.lastJump);
|
||||
}
|
||||
|
||||
public totalJumps: number;
|
||||
public totalCutaways: number;
|
||||
public lastJump: JumpResp;
|
||||
}
|
||||
|
||||
export class StatsByDzResp {
|
||||
constructor(data: any) {
|
||||
Object.assign(this, data);
|
||||
|
||||
@@ -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,
|
||||
@@ -11,20 +11,23 @@ import {
|
||||
StatsByGearResp,
|
||||
StatsByYearResp,
|
||||
StatsForLastMonthResp,
|
||||
StatsForLastYearResp
|
||||
} from "../models/stats";
|
||||
StatsForLastYearResp,
|
||||
SimpleSummary
|
||||
} 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) {}
|
||||
constructor(private http: HttpClient) { }
|
||||
|
||||
public getStatsOfJumps(): StatsResp {
|
||||
const resultats = new StatsResp();
|
||||
|
||||
resultats.simpleSummary = this.getSimpleSummary();
|
||||
|
||||
resultats.statsByDz = this.getStatsByDz();
|
||||
resultats.statsByAircraft = this.getStatsByAircraft();
|
||||
resultats.statsByJumpType = this.getStatsByJumpType();
|
||||
@@ -37,6 +40,19 @@ export class StatsService {
|
||||
return resultats;
|
||||
}
|
||||
|
||||
private getSimpleSummary(): Observable<SimpleSummary> {
|
||||
return this.http
|
||||
.get<Array<SimpleSummary>>(`${environment.urlApi}/api/Stats/Simple`, {
|
||||
headers: this.headers
|
||||
})
|
||||
.pipe(
|
||||
map(response => {
|
||||
const stats = new SimpleSummary(response);
|
||||
return stats;
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
private getStatsByDz(): Observable<Array<StatsByDzResp>> {
|
||||
return this.http
|
||||
.get<Array<StatsByDzResp>>(`${environment.urlApi}/api/Stats/ByDz`, {
|
||||
|
||||
Reference in New Issue
Block a user