Merge branch 'master' of https://home.git.sebastienandre.com/sandre/SkydiveLogs
This commit is contained in:
@@ -22,5 +22,7 @@ namespace skydiveLogs_api.Business.Interface
|
|||||||
IEnumerable<Statistic> GetStatsForLastMonthByDz();
|
IEnumerable<Statistic> GetStatsForLastMonthByDz();
|
||||||
|
|
||||||
IEnumerable<Statistic> GetStatsForLastMonthByJumpType();
|
IEnumerable<Statistic> GetStatsForLastMonthByJumpType();
|
||||||
|
|
||||||
|
SimpleSummary GetSimpleSummary();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -159,6 +159,20 @@ namespace skydiveLogs_api.Business
|
|||||||
.ToList();
|
.ToList();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public SimpleSummary GetSimpleSummary()
|
||||||
|
{
|
||||||
|
var allJumps = _jumpRepository.GetAll();
|
||||||
|
|
||||||
|
var lastJump = allJumps.OrderByDescending(j => j.JumpDate).FirstOrDefault();
|
||||||
|
|
||||||
|
return new SimpleSummary
|
||||||
|
{
|
||||||
|
LastJump = lastJump,
|
||||||
|
TotalJumps = allJumps.Count(),
|
||||||
|
TotalCutaways = allJumps.Where(j => j.WithCutaway).Count()
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
private readonly IJumpRepository _jumpRepository;
|
private readonly IJumpRepository _jumpRepository;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
11
Back/skydiveLogs-api.Model/SimpleSummary.cs
Normal file
11
Back/skydiveLogs-api.Model/SimpleSummary.cs
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
namespace skydiveLogs_api.Model
|
||||||
|
{
|
||||||
|
public class SimpleSummary
|
||||||
|
{
|
||||||
|
public int TotalJumps { get; set; }
|
||||||
|
|
||||||
|
public int TotalCutaways { get; set; }
|
||||||
|
|
||||||
|
public Jump LastJump { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,8 +1,4 @@
|
|||||||
using System;
|
namespace skydiveLogs_api.Model
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Text;
|
|
||||||
|
|
||||||
namespace skydiveLogs_api.Model
|
|
||||||
{
|
{
|
||||||
public class Statistic
|
public class Statistic
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -21,6 +21,15 @@ namespace skydiveLogs_api.Controllers
|
|||||||
_mapper = mapper;
|
_mapper = mapper;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[HttpGet("Simple")]
|
||||||
|
[EnableCors]
|
||||||
|
public SimpleSummaryResp Simple()
|
||||||
|
{
|
||||||
|
var result = _statsService.GetSimpleSummary();
|
||||||
|
|
||||||
|
return _mapper.Map<SimpleSummaryResp>(result);
|
||||||
|
}
|
||||||
|
|
||||||
[HttpGet("ByDz")]
|
[HttpGet("ByDz")]
|
||||||
[EnableCors]
|
[EnableCors]
|
||||||
public IEnumerable<StatisticResp> ByDz()
|
public IEnumerable<StatisticResp> ByDz()
|
||||||
|
|||||||
11
Back/skydiveLogs-api/DataContract/SimpleSummaryResp.cs
Normal file
11
Back/skydiveLogs-api/DataContract/SimpleSummaryResp.cs
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
namespace skydiveLogs_api.DataContract
|
||||||
|
{
|
||||||
|
public class SimpleSummaryResp
|
||||||
|
{
|
||||||
|
public int TotalJumps { get; set; }
|
||||||
|
|
||||||
|
public int TotalCutaways { get; set; }
|
||||||
|
|
||||||
|
public JumpResp LastJump { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -18,6 +18,8 @@ namespace skydiveLogs_api.Mapper
|
|||||||
CreateMap<Model.Aircraft ,DataContract.AircraftResp>();
|
CreateMap<Model.Aircraft ,DataContract.AircraftResp>();
|
||||||
CreateMap<Model.DropZone ,DataContract.DropZoneResp>();
|
CreateMap<Model.DropZone ,DataContract.DropZoneResp>();
|
||||||
CreateMap<Model.Statistic ,DataContract.StatisticResp>();
|
CreateMap<Model.Statistic ,DataContract.StatisticResp>();
|
||||||
|
|
||||||
|
CreateMap<Model.SimpleSummary, DataContract.SimpleSummaryResp>();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,8 +3,13 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
.labelTab {
|
.labelTab {
|
||||||
margin: 5px;
|
padding: 5px;
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
text-decoration: underline;
|
text-decoration: underline;
|
||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
|
background-color: lightgray;
|
||||||
|
}
|
||||||
|
|
||||||
|
.labelTab.selected {
|
||||||
|
background-color: gray !important;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,26 +1,28 @@
|
|||||||
<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;">
|
||||||
<label (click)="showStats(1)" class="labelTab">Jumps in the last month</label>
|
<label (click)="showStats(1)" [ngClass]="statsToShow(1) ? 'labelTab selected': 'labelTab'">Jumps in the last
|
||||||
<label (click)="showStats(2)" class="labelTab">Jumps in the last year</label>
|
month</label>
|
||||||
<label (click)="showStats(3)" class="labelTab">By DZ</label>
|
<label (click)="showStats(2)" [ngClass]="statsToShow(2) ? 'labelTab selected': 'labelTab'">Jumps in the last
|
||||||
<label (click)="showStats(4)" class="labelTab">By aircraft</label>
|
year</label>
|
||||||
<label (click)="showStats(5)" class="labelTab">By gear</label>
|
<label (click)="showStats(3)" [ngClass]="statsToShow(3) ? 'labelTab selected': 'labelTab'">By DZ</label>
|
||||||
<label (click)="showStats(6)" class="labelTab">By jump type</label>
|
<label (click)="showStats(4)" [ngClass]="statsToShow(4) ? 'labelTab selected': 'labelTab'">By aircraft</label>
|
||||||
<label (click)="showStats(7)" class="labelTab">By year</label>
|
<label (click)="showStats(5)" [ngClass]="statsToShow(5) ? 'labelTab selected': 'labelTab'">By gear</label>
|
||||||
|
<label (click)="showStats(6)" [ngClass]="statsToShow(6) ? 'labelTab selected': 'labelTab'">By jump type</label>
|
||||||
|
<label (click)="showStats(7)" [ngClass]="statsToShow(7) ? 'labelTab selected': 'labelTab'">By year</label>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div *ngIf="statsToShow(1)">
|
<div *ngIf="statsToShow(1)">
|
||||||
|
|||||||
@@ -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