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> GetStatsForLastMonthByJumpType();
|
||||
|
||||
SimpleSummary GetSimpleSummary();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -159,6 +159,20 @@ namespace skydiveLogs_api.Business
|
||||
.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;
|
||||
}
|
||||
}
|
||||
|
||||
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;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace skydiveLogs_api.Model
|
||||
namespace skydiveLogs_api.Model
|
||||
{
|
||||
public class Statistic
|
||||
{
|
||||
|
||||
@@ -21,6 +21,15 @@ namespace skydiveLogs_api.Controllers
|
||||
_mapper = mapper;
|
||||
}
|
||||
|
||||
[HttpGet("Simple")]
|
||||
[EnableCors]
|
||||
public SimpleSummaryResp Simple()
|
||||
{
|
||||
var result = _statsService.GetSimpleSummary();
|
||||
|
||||
return _mapper.Map<SimpleSummaryResp>(result);
|
||||
}
|
||||
|
||||
[HttpGet("ByDz")]
|
||||
[EnableCors]
|
||||
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.DropZone ,DataContract.DropZoneResp>();
|
||||
CreateMap<Model.Statistic ,DataContract.StatisticResp>();
|
||||
|
||||
CreateMap<Model.SimpleSummary, DataContract.SimpleSummaryResp>();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,8 +3,13 @@
|
||||
}
|
||||
|
||||
.labelTab {
|
||||
margin: 5px;
|
||||
padding: 5px;
|
||||
cursor: pointer;
|
||||
text-decoration: underline;
|
||||
font-weight: bold;
|
||||
background-color: lightgray;
|
||||
}
|
||||
|
||||
.labelTab.selected {
|
||||
background-color: gray !important;
|
||||
}
|
||||
|
||||
@@ -1,26 +1,28 @@
|
||||
<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;">
|
||||
<label (click)="showStats(1)" class="labelTab">Jumps in the last month</label>
|
||||
<label (click)="showStats(2)" class="labelTab">Jumps in the last year</label>
|
||||
<label (click)="showStats(3)" class="labelTab">By DZ</label>
|
||||
<label (click)="showStats(4)" class="labelTab">By aircraft</label>
|
||||
<label (click)="showStats(5)" class="labelTab">By gear</label>
|
||||
<label (click)="showStats(6)" class="labelTab">By jump type</label>
|
||||
<label (click)="showStats(7)" class="labelTab">By year</label>
|
||||
<label (click)="showStats(1)" [ngClass]="statsToShow(1) ? 'labelTab selected': 'labelTab'">Jumps in the last
|
||||
month</label>
|
||||
<label (click)="showStats(2)" [ngClass]="statsToShow(2) ? 'labelTab selected': 'labelTab'">Jumps in the last
|
||||
year</label>
|
||||
<label (click)="showStats(3)" [ngClass]="statsToShow(3) ? 'labelTab selected': 'labelTab'">By DZ</label>
|
||||
<label (click)="showStats(4)" [ngClass]="statsToShow(4) ? 'labelTab selected': 'labelTab'">By aircraft</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 *ngIf="statsToShow(1)">
|
||||
|
||||
@@ -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,13 +11,14 @@ 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) { }
|
||||
@@ -25,6 +26,8 @@ export class StatsService {
|
||||
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