É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>
|
<div>
|
||||||
<label style="float: left; width: 130px;">Total jumps :</label>
|
<label style="float: left; width: 130px;">Total jumps</label>
|
||||||
<span>850</span>
|
<span>: {{ totalJumps }}</span>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div>
|
<div>
|
||||||
<label style="float: left; width: 130px;">Total cutaways :</label>
|
<label style="float: left; width: 130px;">Total cutaways</label>
|
||||||
<span>1</span>
|
<span>: {{ totalCutaways }}</span>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div>
|
<div>
|
||||||
<label style="float: left; width: 130px;">Last jump :</label>
|
<label style="float: left; width: 130px;">Last jump</label>
|
||||||
<span>5 Février 2020 à Barcelonnette</span>
|
<span>: {{ lastJump }}</span>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div style="display: flex; flex-direction: row; flex-wrap: wrap; margin-top: 15px;">
|
<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>;
|
private _shownStats: Map<StatType, boolean>;
|
||||||
public StatType = StatType;
|
public StatType = StatType;
|
||||||
|
|
||||||
|
public totalJumps: number;
|
||||||
|
public totalCutaways: number;
|
||||||
|
public lastJump: string;
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private serviceApi: StatsService,
|
private _serviceApi: StatsService,
|
||||||
private serviceComm: ServiceComm
|
private _serviceComm: ServiceComm
|
||||||
) { }
|
) { }
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
this.initShownStats();
|
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 => {
|
statsResult.statsByDz.subscribe(data => {
|
||||||
this.dsNbJumpByDz = new MatTableDataSource(data);
|
this.dsNbJumpByDz = new MatTableDataSource(data);
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import { Observable } from 'rxjs';
|
import { Observable } from 'rxjs';
|
||||||
|
import { JumpResp } from './jump';
|
||||||
|
|
||||||
export enum StatType {
|
export enum StatType {
|
||||||
ForLastMonth = 1,
|
ForLastMonth = 1,
|
||||||
@@ -11,6 +12,8 @@ export enum StatType {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export class StatsResp {
|
export class StatsResp {
|
||||||
|
public simpleSummary: Observable<SimpleSummary>;
|
||||||
|
|
||||||
public statsByDz: Observable<Array<StatsByDzResp>>;
|
public statsByDz: Observable<Array<StatsByDzResp>>;
|
||||||
public statsByAircraft: Observable<Array<StatsByAircraftResp>>;
|
public statsByAircraft: Observable<Array<StatsByAircraftResp>>;
|
||||||
public statsByGear: Observable<Array<StatsByGearResp>>;
|
public statsByGear: Observable<Array<StatsByGearResp>>;
|
||||||
@@ -21,6 +24,18 @@ export class StatsResp {
|
|||||||
public statsForLastMonth: Observable<StatsForLastMonthResp>;
|
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 {
|
export class StatsByDzResp {
|
||||||
constructor(data: any) {
|
constructor(data: any) {
|
||||||
Object.assign(this, data);
|
Object.assign(this, data);
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
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 { environment } from '../environments/environment';
|
||||||
import {
|
import {
|
||||||
StatsResp,
|
StatsResp,
|
||||||
StatsByDzResp,
|
StatsByDzResp,
|
||||||
@@ -11,20 +11,23 @@ import {
|
|||||||
StatsByGearResp,
|
StatsByGearResp,
|
||||||
StatsByYearResp,
|
StatsByYearResp,
|
||||||
StatsForLastMonthResp,
|
StatsForLastMonthResp,
|
||||||
StatsForLastYearResp
|
StatsForLastYearResp,
|
||||||
} from "../models/stats";
|
SimpleSummary
|
||||||
|
} from '../models/stats';
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class StatsService {
|
export class StatsService {
|
||||||
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 getStatsOfJumps(): StatsResp {
|
public getStatsOfJumps(): StatsResp {
|
||||||
const resultats = new StatsResp();
|
const resultats = new StatsResp();
|
||||||
|
|
||||||
|
resultats.simpleSummary = this.getSimpleSummary();
|
||||||
|
|
||||||
resultats.statsByDz = this.getStatsByDz();
|
resultats.statsByDz = this.getStatsByDz();
|
||||||
resultats.statsByAircraft = this.getStatsByAircraft();
|
resultats.statsByAircraft = this.getStatsByAircraft();
|
||||||
resultats.statsByJumpType = this.getStatsByJumpType();
|
resultats.statsByJumpType = this.getStatsByJumpType();
|
||||||
@@ -37,6 +40,19 @@ export class StatsService {
|
|||||||
return resultats;
|
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>> {
|
private getStatsByDz(): Observable<Array<StatsByDzResp>> {
|
||||||
return this.http
|
return this.http
|
||||||
.get<Array<StatsByDzResp>>(`${environment.urlApi}/api/Stats/ByDz`, {
|
.get<Array<StatsByDzResp>>(`${environment.urlApi}/api/Stats/ByDz`, {
|
||||||
|
|||||||
Reference in New Issue
Block a user