Ajout dans la page "Summary" d'un onglet pour avoir les stats "ByYearByJumpType" (début)
This commit is contained in:
@@ -1,32 +1,41 @@
|
||||
<div class="content">
|
||||
<div class="paragraph">
|
||||
<label class="left160">{{ 'Summary_TotalJumps' | translate }}</label>
|
||||
<label class="left160">{{ "Summary_TotalJumps" | translate }}</label>
|
||||
<span>: {{ totalJumps }}</span>
|
||||
</div>
|
||||
|
||||
<div class="paragraph">
|
||||
<label class="left160">{{ 'Summary_TotalCutaways' | translate }}</label>
|
||||
<label class="left160">{{ "Summary_TotalCutaways" | translate }}</label>
|
||||
<span>: {{ totalCutaways }}</span>
|
||||
</div>
|
||||
|
||||
<div class="paragraph">
|
||||
<label class="left160">{{ 'Summary_LastJump' | translate }}</label>
|
||||
<label class="left160">{{ "Summary_LastJump" | translate }}</label>
|
||||
<span>: {{ lastJump }}</span>
|
||||
</div>
|
||||
|
||||
<div class="paragraph" style="margin-top: 20px;">
|
||||
<label class="left160">{{ 'Summary_Refresh' | translate }}</label>
|
||||
<mat-icon aria-hidden="false" aria-label="Force the refresh of the stats" style="cursor: pointer;"
|
||||
(click)='refreshStats()'>cached</mat-icon>
|
||||
<div class="paragraph" style="margin-top: 20px">
|
||||
<label class="left160">{{ "Summary_Refresh" | translate }}</label>
|
||||
<mat-icon
|
||||
aria-hidden="false"
|
||||
aria-label="Force the refresh of the stats"
|
||||
style="cursor: pointer"
|
||||
(click)="refreshStats()"
|
||||
>cached</mat-icon
|
||||
>
|
||||
</div>
|
||||
|
||||
<mat-tab-group mat-align-tabs="left" animationDuration="0ms"
|
||||
(selectedIndex)="0" (selectedTabChange)="onTabChanged($event);">
|
||||
<mat-tab-group
|
||||
mat-align-tabs="left"
|
||||
animationDuration="0ms"
|
||||
(selectedIndex)="(0)"
|
||||
(selectedTabChange)="onTabChanged($event)"
|
||||
>
|
||||
<mat-tab label="{{ 'Summary_LastMonth_Title' | translate }}">
|
||||
<ng-template matTabContent>
|
||||
<div class="containerFlex">
|
||||
<fieldset class="contentFlex">
|
||||
<legend>{{ 'Summary_LastMonth_ByDz' | translate }}</legend>
|
||||
<legend>{{ "Summary_LastMonth_ByDz" | translate }}</legend>
|
||||
<table mat-table [dataSource]="dsJumpForLastMonthByDz">
|
||||
<ng-container matColumnDef="label">
|
||||
<td mat-cell *matCellDef="let element">{{ element.label }}</td>
|
||||
@@ -34,11 +43,11 @@
|
||||
<ng-container matColumnDef="nb">
|
||||
<td mat-cell *matCellDef="let element">{{ element.nb }}</td>
|
||||
</ng-container>
|
||||
<tr mat-row *matRowDef="let row; columns: displayedColumns;"></tr>
|
||||
<tr mat-row *matRowDef="let row; columns: displayedColumns"></tr>
|
||||
</table>
|
||||
</fieldset>
|
||||
<fieldset class="contentFlex">
|
||||
<legend>{{ 'Summary_LastMonth_ByJumpType' | translate }}</legend>
|
||||
<legend>{{ "Summary_LastMonth_ByJumpType" | translate }}</legend>
|
||||
<table mat-table [dataSource]="dsJumpForLastMonthByJumpType">
|
||||
<ng-container matColumnDef="label">
|
||||
<td mat-cell *matCellDef="let element">{{ element.label }}</td>
|
||||
@@ -46,7 +55,7 @@
|
||||
<ng-container matColumnDef="nb">
|
||||
<td mat-cell *matCellDef="let element">{{ element.nb }}</td>
|
||||
</ng-container>
|
||||
<tr mat-row *matRowDef="let row; columns: displayedColumns;"></tr>
|
||||
<tr mat-row *matRowDef="let row; columns: displayedColumns"></tr>
|
||||
</table>
|
||||
</fieldset>
|
||||
</div>
|
||||
@@ -57,7 +66,7 @@
|
||||
<ng-template matTabContent>
|
||||
<div class="containerFlex">
|
||||
<fieldset class="contentFlex">
|
||||
<legend>{{ 'Summary_LastYear_ByDz' | translate }}</legend>
|
||||
<legend>{{ "Summary_LastYear_ByDz" | translate }}</legend>
|
||||
<table mat-table [dataSource]="dsJumpForLastYearByDz">
|
||||
<ng-container matColumnDef="label">
|
||||
<td mat-cell *matCellDef="let element">{{ element.label }}</td>
|
||||
@@ -65,11 +74,11 @@
|
||||
<ng-container matColumnDef="nb">
|
||||
<td mat-cell *matCellDef="let element">{{ element.nb }}</td>
|
||||
</ng-container>
|
||||
<tr mat-row *matRowDef="let row; columns: displayedColumns;"></tr>
|
||||
<tr mat-row *matRowDef="let row; columns: displayedColumns"></tr>
|
||||
</table>
|
||||
</fieldset>
|
||||
<fieldset class="contentFlex">
|
||||
<legend>{{ 'Summary_LastYear_ByJumpType' | translate }}</legend>
|
||||
<legend>{{ "Summary_LastYear_ByJumpType" | translate }}</legend>
|
||||
<table mat-table [dataSource]="dsJumpForLastYearByJumpType">
|
||||
<ng-container matColumnDef="label">
|
||||
<td mat-cell *matCellDef="let element">{{ element.label }}</td>
|
||||
@@ -77,7 +86,7 @@
|
||||
<ng-container matColumnDef="nb">
|
||||
<td mat-cell *matCellDef="let element">{{ element.nb }}</td>
|
||||
</ng-container>
|
||||
<tr mat-row *matRowDef="let row; columns: displayedColumns;"></tr>
|
||||
<tr mat-row *matRowDef="let row; columns: displayedColumns"></tr>
|
||||
</table>
|
||||
</fieldset>
|
||||
</div>
|
||||
@@ -93,7 +102,7 @@
|
||||
<ng-container matColumnDef="nb">
|
||||
<td mat-cell *matCellDef="let element">{{ element.nb }}</td>
|
||||
</ng-container>
|
||||
<tr mat-row *matRowDef="let row; columns: displayedColumns;"></tr>
|
||||
<tr mat-row *matRowDef="let row; columns: displayedColumns"></tr>
|
||||
</table>
|
||||
</ng-template>
|
||||
</mat-tab>
|
||||
@@ -107,7 +116,7 @@
|
||||
<ng-container matColumnDef="nb">
|
||||
<td mat-cell *matCellDef="let element">{{ element.nb }}</td>
|
||||
</ng-container>
|
||||
<tr mat-row *matRowDef="let row; columns: displayedColumns;"></tr>
|
||||
<tr mat-row *matRowDef="let row; columns: displayedColumns"></tr>
|
||||
</table>
|
||||
</ng-template>
|
||||
</mat-tab>
|
||||
@@ -121,7 +130,7 @@
|
||||
<ng-container matColumnDef="nb">
|
||||
<td mat-cell *matCellDef="let element">{{ element.nb }}</td>
|
||||
</ng-container>
|
||||
<tr mat-row *matRowDef="let row; columns: displayedColumns;"></tr>
|
||||
<tr mat-row *matRowDef="let row; columns: displayedColumns"></tr>
|
||||
</table>
|
||||
</ng-template>
|
||||
</mat-tab>
|
||||
@@ -135,7 +144,7 @@
|
||||
<ng-container matColumnDef="nb">
|
||||
<td mat-cell *matCellDef="let element">{{ element.nb }}</td>
|
||||
</ng-container>
|
||||
<tr mat-row *matRowDef="let row; columns: displayedColumns;"></tr>
|
||||
<tr mat-row *matRowDef="let row; columns: displayedColumns"></tr>
|
||||
</table>
|
||||
</ng-template>
|
||||
</mat-tab>
|
||||
@@ -149,7 +158,21 @@
|
||||
<ng-container matColumnDef="nb">
|
||||
<td mat-cell *matCellDef="let element">{{ element.nb }}</td>
|
||||
</ng-container>
|
||||
<tr mat-row *matRowDef="let row; columns: displayedColumns;"></tr>
|
||||
<tr mat-row *matRowDef="let row; columns: displayedColumns"></tr>
|
||||
</table>
|
||||
</ng-template>
|
||||
</mat-tab>
|
||||
|
||||
<mat-tab label="{{ 'Summary_ByYearByJumpType_Title' | translate }}">
|
||||
<ng-template matTabContent>
|
||||
<table mat-table [dataSource]="dsNbJumpByYearByJumpType">
|
||||
<ng-container matColumnDef="label">
|
||||
<td mat-cell *matCellDef="let element">{{ element.label }}</td>
|
||||
</ng-container>
|
||||
<ng-container matColumnDef="nb">
|
||||
<td mat-cell *matCellDef="let element">{{ element.nb }}</td>
|
||||
</ng-container>
|
||||
<tr mat-row *matRowDef="let row; columns: displayedColumns"></tr>
|
||||
</table>
|
||||
</ng-template>
|
||||
</mat-tab>
|
||||
|
||||
@@ -1,41 +1,48 @@
|
||||
import { Component, OnInit, ViewChild } from '@angular/core';
|
||||
import { MatTableDataSource } from '@angular/material/table';
|
||||
import { MatTabChangeEvent, MatTabGroup } from '@angular/material/tabs';
|
||||
import { TranslateService } from '@ngx-translate/core';
|
||||
import { DatePipe } from '@angular/common';
|
||||
import { Component, OnInit, ViewChild } from "@angular/core";
|
||||
import { MatTableDataSource } from "@angular/material/table";
|
||||
import { MatTabChangeEvent, MatTabGroup } from "@angular/material/tabs";
|
||||
import { TranslateService } from "@ngx-translate/core";
|
||||
import { DatePipe } from "@angular/common";
|
||||
|
||||
import { ServiceComm } from '../../services/service-comm.service';
|
||||
import { StatsService } from '../../services/stats.service';
|
||||
import { StatsByDzResp, StatsByAircraftResp, StatsByGearResp,
|
||||
StatsByJumpTypeResp, StatsByYearResp } from '../../models/stats';
|
||||
import { ServiceComm } from "../../services/service-comm.service";
|
||||
import { StatsService } from "../../services/stats.service";
|
||||
import {
|
||||
StatsByDzResp,
|
||||
StatsByAircraftResp,
|
||||
StatsByGearResp,
|
||||
StatsByJumpTypeResp,
|
||||
StatsByYearResp,
|
||||
} from "../../models/stats";
|
||||
|
||||
@Component({
|
||||
selector: 'app-summary',
|
||||
templateUrl: './summary.component.html',
|
||||
styleUrls: ['./summary.component.css']
|
||||
selector: "app-summary",
|
||||
templateUrl: "./summary.component.html",
|
||||
styleUrls: ["./summary.component.css"],
|
||||
})
|
||||
|
||||
export class SummaryComponent implements OnInit {
|
||||
public dsNbJumpByDz: MatTableDataSource<StatsByDzResp>;
|
||||
public dsNbJumpByAircraft: MatTableDataSource<StatsByAircraftResp>;
|
||||
public dsNbJumpByGear: MatTableDataSource<StatsByGearResp>;
|
||||
public dsNbJumpByType: MatTableDataSource<StatsByJumpTypeResp>;
|
||||
public dsNbJumpByYear: MatTableDataSource<StatsByYearResp>;
|
||||
public dsNbJumpByYearByJumpType: MatTableDataSource<StatsByYearResp>;
|
||||
public dsJumpForLastYearByDz: MatTableDataSource<StatsByDzResp>;
|
||||
public dsJumpForLastYearByJumpType: MatTableDataSource<StatsByJumpTypeResp>;
|
||||
public dsJumpForLastMonthByDz: MatTableDataSource<StatsByDzResp>;
|
||||
public dsJumpForLastMonthByJumpType: MatTableDataSource<StatsByJumpTypeResp>;
|
||||
|
||||
public displayedColumns: Array<string> = ['label', 'nb'];
|
||||
public displayedColumns: Array<string> = ["label", "nb"];
|
||||
|
||||
public totalJumps: number;
|
||||
public totalCutaways: number;
|
||||
public lastJump: string;
|
||||
@ViewChild(MatTabGroup) tabGroup: MatTabGroup;
|
||||
|
||||
constructor(private serviceApi: StatsService,
|
||||
constructor(
|
||||
private serviceApi: StatsService,
|
||||
private serviceComm: ServiceComm,
|
||||
private translateService: TranslateService) { }
|
||||
private translateService: TranslateService
|
||||
) {}
|
||||
|
||||
ngOnInit() {
|
||||
this.serviceComm.forceTranslateTitle.subscribe((data) => {
|
||||
@@ -45,22 +52,25 @@ export class SummaryComponent implements OnInit {
|
||||
});
|
||||
this.updateTitle();
|
||||
|
||||
this.serviceApi.getSimpleSummary()
|
||||
.subscribe(data => {
|
||||
this.serviceApi.getSimpleSummary().subscribe((data) => {
|
||||
this.totalJumps = data.totalJumps;
|
||||
this.totalCutaways = data.totalCutaways;
|
||||
|
||||
const datepipe: DatePipe = new DatePipe('en-US')
|
||||
let formattedDate = datepipe.transform(data.lastJump.jumpDate, 'EEEE dd MMMM YYYY')
|
||||
this.lastJump = formattedDate + ' (' + data.lastJump.dropZone.name + ')';
|
||||
const datepipe: DatePipe = new DatePipe("en-US");
|
||||
let formattedDate = datepipe.transform(
|
||||
data.lastJump.jumpDate,
|
||||
"EEEE dd MMMM YYYY"
|
||||
);
|
||||
this.lastJump = formattedDate + " (" + data.lastJump.dropZone.name + ")";
|
||||
});
|
||||
|
||||
this.serviceApi.getStatsOfLastMonth()
|
||||
.subscribe(data => {
|
||||
this.serviceApi.getStatsOfLastMonth().subscribe((data) => {
|
||||
data.byDz.sort((a, b) => b.nb - a.nb);
|
||||
this.dsJumpForLastMonthByDz = new MatTableDataSource(data.byDz);
|
||||
data.byJumpType.sort((a, b) => b.nb - a.nb);
|
||||
this.dsJumpForLastMonthByJumpType = new MatTableDataSource(data.byJumpType);
|
||||
this.dsJumpForLastMonthByJumpType = new MatTableDataSource(
|
||||
data.byJumpType
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -72,64 +82,67 @@ export class SummaryComponent implements OnInit {
|
||||
public onTabChanged(event: MatTabChangeEvent) {
|
||||
switch (event.index) {
|
||||
case 0:
|
||||
this.serviceApi.getStatsOfLastMonth()
|
||||
.subscribe(data => {
|
||||
this.serviceApi.getStatsOfLastMonth().subscribe((data) => {
|
||||
data.byDz.sort((a, b) => b.nb - a.nb);
|
||||
this.dsJumpForLastMonthByDz = new MatTableDataSource(data.byDz);
|
||||
data.byJumpType.sort((a, b) => b.nb - a.nb);
|
||||
this.dsJumpForLastMonthByJumpType = new MatTableDataSource(data.byJumpType);
|
||||
this.dsJumpForLastMonthByJumpType = new MatTableDataSource(
|
||||
data.byJumpType
|
||||
);
|
||||
});
|
||||
break;
|
||||
case 1:
|
||||
this.serviceApi.getStatsOfLastYear()
|
||||
.subscribe(data => {
|
||||
this.serviceApi.getStatsOfLastYear().subscribe((data) => {
|
||||
data.byDz.sort((a, b) => b.nb - a.nb);
|
||||
this.dsJumpForLastYearByDz = new MatTableDataSource(data.byDz);
|
||||
data.byJumpType.sort((a, b) => b.nb - a.nb);
|
||||
this.dsJumpForLastYearByJumpType = new MatTableDataSource(data.byJumpType);
|
||||
this.dsJumpForLastYearByJumpType = new MatTableDataSource(
|
||||
data.byJumpType
|
||||
);
|
||||
});
|
||||
break;
|
||||
case 2:
|
||||
this.serviceApi.getStatsByDz()
|
||||
.subscribe(data => {
|
||||
this.serviceApi.getStatsByDz().subscribe((data) => {
|
||||
data.sort((a, b) => b.nb - a.nb);
|
||||
this.dsNbJumpByDz = new MatTableDataSource(data);
|
||||
});
|
||||
break;
|
||||
case 3:
|
||||
this.serviceApi.getStatsByAircraft()
|
||||
.subscribe(data => {
|
||||
this.serviceApi.getStatsByAircraft().subscribe((data) => {
|
||||
data.sort((a, b) => b.nb - a.nb);
|
||||
this.dsNbJumpByAircraft = new MatTableDataSource(data);
|
||||
});
|
||||
break;
|
||||
case 4:
|
||||
this.serviceApi.getStatsByGear()
|
||||
.subscribe(data => {
|
||||
this.serviceApi.getStatsByGear().subscribe((data) => {
|
||||
data.sort((a, b) => b.nb - a.nb);
|
||||
this.dsNbJumpByGear = new MatTableDataSource(data);
|
||||
});
|
||||
break;
|
||||
case 5:
|
||||
this.serviceApi.getStatsByJumpType()
|
||||
.subscribe(data => {
|
||||
this.serviceApi.getStatsByJumpType().subscribe((data) => {
|
||||
data.sort((a, b) => b.nb - a.nb);
|
||||
this.dsNbJumpByType = new MatTableDataSource(data);
|
||||
});
|
||||
break;
|
||||
case 6:
|
||||
this.serviceApi.getStatsByYear()
|
||||
.subscribe(data => {
|
||||
this.serviceApi.getStatsByYear().subscribe((data) => {
|
||||
data.sort((a, b) => b.label.localeCompare(a.label));
|
||||
this.dsNbJumpByYear = new MatTableDataSource(data);
|
||||
});
|
||||
break;
|
||||
case 7:
|
||||
this.serviceApi.getStatsByYearByJumpType().subscribe((data) => {
|
||||
data.sort((a, b) => b.label.localeCompare(a.label));
|
||||
this.dsNbJumpByYearByJumpType = new MatTableDataSource(data);
|
||||
});
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private updateTitle() {
|
||||
this.translateService.get("Summary_Title").subscribe(
|
||||
data => { this.serviceComm.updatedComponentTitle(data); }
|
||||
);
|
||||
this.translateService.get("Summary_Title").subscribe((data) => {
|
||||
this.serviceComm.updatedComponentTitle(data);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -100,6 +100,7 @@
|
||||
"Summary_ByGear_Title": "By gear",
|
||||
"Summary_ByJumpType_Title": "By jump type",
|
||||
"Summary_ByYear_Title": "By year",
|
||||
"Summary_ByYearByJumpType_Title": "By year and by type",
|
||||
|
||||
"NewJump_GoToJump": "View the jumps",
|
||||
"NewJump_ResetForm": "Reset form after adding",
|
||||
|
||||
@@ -100,6 +100,7 @@
|
||||
"Summary_ByGear_Title": "Par piège",
|
||||
"Summary_ByJumpType_Title": "Par type de saut",
|
||||
"Summary_ByYear_Title": "Par an",
|
||||
"Summary_ByYear_Title": "Par an et par type",
|
||||
|
||||
"NewJump_GoToJump": "Voir les sauts",
|
||||
"NewJump_ResetForm": "Reset du formulaire après l'ajout",
|
||||
|
||||
@@ -12,5 +12,6 @@ export enum CacheApiKey {
|
||||
StatsOfLastYear,
|
||||
StatsOfLastMonth,
|
||||
StatsByYear,
|
||||
Tunnel
|
||||
Tunnel,
|
||||
StatsByYearByJumpType,
|
||||
}
|
||||
|
||||
@@ -1,15 +1,14 @@
|
||||
import { Observable } from 'rxjs';
|
||||
import { Jump, JumpResp } from './jump';
|
||||
import { Observable } from "rxjs";
|
||||
import { Jump, JumpResp } from "./jump";
|
||||
|
||||
export class StatsResp {
|
||||
public simpleSummary: Observable<SimpleSummary>;
|
||||
|
||||
public statsByDz: Observable<Array<StatsByDzResp>>;
|
||||
public statsByAircraft: Observable<Array<StatsByAircraftResp>>;
|
||||
public statsByGear: Observable<Array<StatsByGearResp>>;
|
||||
public statsByJumpType: Observable<Array<StatsByJumpTypeResp>>;
|
||||
public statsByYear: Observable<Array<StatsByYearResp>>;
|
||||
|
||||
public statsByYearByJumpType: Observable<Array<StatsByYearByJumpTypeResp>>;
|
||||
public statsForLastYear: Observable<StatsForLastYearResp>;
|
||||
public statsForLastMonth: Observable<StatsForLastMonthResp>;
|
||||
}
|
||||
@@ -81,9 +80,21 @@ export class StatsByYearResp {
|
||||
public nb: number;
|
||||
}
|
||||
|
||||
export class StatsByYearByJumpTypeResp {
|
||||
constructor(data: any) {
|
||||
Object.assign(this, data);
|
||||
}
|
||||
|
||||
public label: string;
|
||||
public label2: string;
|
||||
public nb: number;
|
||||
}
|
||||
|
||||
export class StatsForLastYearResp {
|
||||
constructor(dataByDz: Array<StatsByDzResp>,
|
||||
dataByJumpType: Array<StatsByJumpTypeResp>) {
|
||||
constructor(
|
||||
dataByDz: Array<StatsByDzResp>,
|
||||
dataByJumpType: Array<StatsByJumpTypeResp>
|
||||
) {
|
||||
this.byDz = new Array<StatsByDzResp>();
|
||||
this.byJumpType = new Array<StatsByJumpTypeResp>();
|
||||
|
||||
@@ -96,8 +107,10 @@ export class StatsForLastYearResp {
|
||||
}
|
||||
|
||||
export class StatsForLastMonthResp {
|
||||
constructor(dataByDz: Array<StatsByDzResp>,
|
||||
dataByJumpType: Array<StatsByJumpTypeResp>) {
|
||||
constructor(
|
||||
dataByDz: Array<StatsByDzResp>,
|
||||
dataByJumpType: Array<StatsByJumpTypeResp>
|
||||
) {
|
||||
this.byDz = new Array<StatsByDzResp>();
|
||||
this.byJumpType = new Array<StatsByJumpTypeResp>();
|
||||
|
||||
|
||||
@@ -1,28 +1,38 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { HttpClient } from '@angular/common/http';
|
||||
import { Observable } from 'rxjs';
|
||||
import { map } from 'rxjs/operators';
|
||||
import { Injectable } from "@angular/core";
|
||||
import { HttpClient } from "@angular/common/http";
|
||||
import { Observable } from "rxjs";
|
||||
import { map } from "rxjs/operators";
|
||||
|
||||
import { StatsByDzResp, StatsByAircraftResp, StatsByJumpTypeResp,
|
||||
StatsByGearResp, StatsByYearResp, StatsForLastMonthResp,
|
||||
StatsForLastYearResp, SimpleSummary, SimpleSummaryResp } from '../models/stats';
|
||||
import {
|
||||
StatsByDzResp,
|
||||
StatsByAircraftResp,
|
||||
StatsByJumpTypeResp,
|
||||
StatsByGearResp,
|
||||
StatsByYearResp,
|
||||
StatsByYearByJumpTypeResp,
|
||||
StatsForLastMonthResp,
|
||||
StatsForLastYearResp,
|
||||
SimpleSummary,
|
||||
SimpleSummaryResp,
|
||||
} from "../models/stats";
|
||||
|
||||
import { BaseService } from './base.service';
|
||||
import { BaseService } from "./base.service";
|
||||
import { DropzoneService } from "./dropzone.service";
|
||||
import { AircraftService } from "./aircraft.service";
|
||||
import { JumpTypeService } from "./jump-type.service";
|
||||
import { GearService } from "./gear.service";
|
||||
import { CacheApiKey } from '../models/cache-api-key.enum';
|
||||
import { Jump } from '../models/jump';
|
||||
|
||||
import { CacheApiKey } from "../models/cache-api-key.enum";
|
||||
import { Jump } from "../models/jump";
|
||||
|
||||
@Injectable()
|
||||
export class StatsService extends BaseService {
|
||||
constructor(private http: HttpClient,
|
||||
constructor(
|
||||
private http: HttpClient,
|
||||
private dropzoneService: DropzoneService,
|
||||
private aircraftService: AircraftService,
|
||||
private jumpTypeService: JumpTypeService,
|
||||
private gearService: GearService) {
|
||||
private gearService: GearService
|
||||
) {
|
||||
super();
|
||||
}
|
||||
|
||||
@@ -35,20 +45,35 @@ export class StatsService extends BaseService {
|
||||
this.serviceCacheApi.delete(CacheApiKey.StatsByYear);
|
||||
this.serviceCacheApi.delete(CacheApiKey.StatsOfLastYear);
|
||||
this.serviceCacheApi.delete(CacheApiKey.StatsOfLastMonth);
|
||||
this.serviceCacheApi.delete(CacheApiKey.StatsByYearByJumpType);
|
||||
}
|
||||
|
||||
public resetStats() {
|
||||
this.http.get(`${this.apiUrl}/Stats/Reset`, { headers: this.headers }).subscribe();
|
||||
this.http
|
||||
.get(`${this.apiUrl}/Stats/Reset`, { headers: this.headers })
|
||||
.subscribe();
|
||||
}
|
||||
|
||||
public getSimpleSummary(): Observable<SimpleSummary> {
|
||||
let callToApi = this.http.get<SimpleSummaryResp>(`${this.apiUrl}/Stats/Simple`, { headers: this.headers })
|
||||
.pipe(map(response => {
|
||||
let callToApi = this.http
|
||||
.get<SimpleSummaryResp>(`${this.apiUrl}/Stats/Simple`, {
|
||||
headers: this.headers,
|
||||
})
|
||||
.pipe(
|
||||
map((response) => {
|
||||
let tmp = new Jump(response.lastJump);
|
||||
this.dropzoneService.getById(response.lastJump.dropZoneId).subscribe((d)=> tmp.dropZone = d );
|
||||
this.aircraftService.getById(response.lastJump.aircraftId).subscribe((d)=> tmp.aircraft = d );
|
||||
this.jumpTypeService.getById(response.lastJump.jumpTypeId).subscribe((d)=> tmp.jumpType = d );
|
||||
this.gearService.getById(response.lastJump.gearId).subscribe((d)=> tmp.gear = d );
|
||||
this.dropzoneService
|
||||
.getById(response.lastJump.dropZoneId)
|
||||
.subscribe((d) => (tmp.dropZone = d));
|
||||
this.aircraftService
|
||||
.getById(response.lastJump.aircraftId)
|
||||
.subscribe((d) => (tmp.aircraft = d));
|
||||
this.jumpTypeService
|
||||
.getById(response.lastJump.jumpTypeId)
|
||||
.subscribe((d) => (tmp.jumpType = d));
|
||||
this.gearService
|
||||
.getById(response.lastJump.gearId)
|
||||
.subscribe((d) => (tmp.gear = d));
|
||||
|
||||
let stats = new SimpleSummary(response);
|
||||
stats.lastJump = tmp;
|
||||
@@ -56,98 +81,172 @@ export class StatsService extends BaseService {
|
||||
})
|
||||
);
|
||||
|
||||
return this.serviceCacheApi.get<SimpleSummary>(CacheApiKey.SimpleSummary, callToApi);
|
||||
return this.serviceCacheApi.get<SimpleSummary>(
|
||||
CacheApiKey.SimpleSummary,
|
||||
callToApi
|
||||
);
|
||||
}
|
||||
|
||||
public getStatsByDz(): Observable<Array<StatsByDzResp>> {
|
||||
let callToApi = this.http.get<Array<StatsByDzResp>>(`${this.apiUrl}/Stats/ByDz`, { headers: this.headers })
|
||||
let callToApi = this.http
|
||||
.get<Array<StatsByDzResp>>(`${this.apiUrl}/Stats/ByDz`, {
|
||||
headers: this.headers,
|
||||
})
|
||||
.pipe(
|
||||
map(response => {
|
||||
const stats = response.map(data => new StatsByDzResp(data));
|
||||
map((response) => {
|
||||
const stats = response.map((data) => new StatsByDzResp(data));
|
||||
return stats;
|
||||
})
|
||||
);
|
||||
|
||||
return this.serviceCacheApi.get<Array<StatsByDzResp>>(CacheApiKey.StatsByDz, callToApi);
|
||||
return this.serviceCacheApi.get<Array<StatsByDzResp>>(
|
||||
CacheApiKey.StatsByDz,
|
||||
callToApi
|
||||
);
|
||||
}
|
||||
|
||||
public getStatsByAircraft(): Observable<Array<StatsByAircraftResp>> {
|
||||
let callToApi = this.http.get<Array<StatsByAircraftResp>>(`${this.apiUrl}/Stats/ByAircraft`, { headers: this.headers })
|
||||
let callToApi = this.http
|
||||
.get<Array<StatsByAircraftResp>>(`${this.apiUrl}/Stats/ByAircraft`, {
|
||||
headers: this.headers,
|
||||
})
|
||||
.pipe(
|
||||
map(response => {
|
||||
const stats = response.map(data => new StatsByAircraftResp(data));
|
||||
map((response) => {
|
||||
const stats = response.map((data) => new StatsByAircraftResp(data));
|
||||
return stats;
|
||||
})
|
||||
);
|
||||
|
||||
return this.serviceCacheApi.get<Array<StatsByAircraftResp>>(CacheApiKey.StatsByAircraft, callToApi);
|
||||
return this.serviceCacheApi.get<Array<StatsByAircraftResp>>(
|
||||
CacheApiKey.StatsByAircraft,
|
||||
callToApi
|
||||
);
|
||||
}
|
||||
|
||||
public getStatsByJumpType(): Observable<Array<StatsByJumpTypeResp>> {
|
||||
let callToApi = this.http.get<Array<StatsByJumpTypeResp>>(`${this.apiUrl}/Stats/ByJumpType`,{ headers: this.headers })
|
||||
let callToApi = this.http
|
||||
.get<Array<StatsByJumpTypeResp>>(`${this.apiUrl}/Stats/ByJumpType`, {
|
||||
headers: this.headers,
|
||||
})
|
||||
.pipe(
|
||||
map(response => {
|
||||
const stats = response.map(data => new StatsByJumpTypeResp(data));
|
||||
map((response) => {
|
||||
const stats = response.map((data) => new StatsByJumpTypeResp(data));
|
||||
return stats;
|
||||
})
|
||||
);
|
||||
|
||||
return this.serviceCacheApi.get<Array<StatsByJumpTypeResp>>(CacheApiKey.StatsByJumpType, callToApi);
|
||||
return this.serviceCacheApi.get<Array<StatsByJumpTypeResp>>(
|
||||
CacheApiKey.StatsByJumpType,
|
||||
callToApi
|
||||
);
|
||||
}
|
||||
|
||||
public getStatsByGear(): Observable<Array<StatsByGearResp>> {
|
||||
let callToApi = this.http.get<Array<StatsByGearResp>>(`${this.apiUrl}/Stats/ByGear`, { headers: this.headers })
|
||||
let callToApi = this.http
|
||||
.get<Array<StatsByGearResp>>(`${this.apiUrl}/Stats/ByGear`, {
|
||||
headers: this.headers,
|
||||
})
|
||||
.pipe(
|
||||
map(response => {
|
||||
const stats = response.map(data => new StatsByGearResp(data));
|
||||
map((response) => {
|
||||
const stats = response.map((data) => new StatsByGearResp(data));
|
||||
return stats;
|
||||
})
|
||||
);
|
||||
|
||||
return this.serviceCacheApi.get<Array<StatsByGearResp>>(CacheApiKey.StatsByGear, callToApi);
|
||||
return this.serviceCacheApi.get<Array<StatsByGearResp>>(
|
||||
CacheApiKey.StatsByGear,
|
||||
callToApi
|
||||
);
|
||||
}
|
||||
|
||||
public getStatsByYear(): Observable<Array<StatsByYearResp>> {
|
||||
let callToApi = this.http.get<Array<StatsByYearResp>>(`${this.apiUrl}/Stats/ByYear`, { headers: this.headers })
|
||||
let callToApi = this.http
|
||||
.get<Array<StatsByYearResp>>(`${this.apiUrl}/Stats/ByYear`, {
|
||||
headers: this.headers,
|
||||
})
|
||||
.pipe(
|
||||
map(response => {
|
||||
const stats = response.map(data => new StatsByYearResp(data));
|
||||
map((response) => {
|
||||
const stats = response.map((data) => new StatsByYearResp(data));
|
||||
return stats;
|
||||
})
|
||||
);
|
||||
|
||||
return this.serviceCacheApi.get<Array<StatsByYearResp>>(CacheApiKey.StatsByYear, callToApi);
|
||||
return this.serviceCacheApi.get<Array<StatsByYearResp>>(
|
||||
CacheApiKey.StatsByYear,
|
||||
callToApi
|
||||
);
|
||||
}
|
||||
|
||||
public getStatsOfLastYear(): Observable<StatsForLastYearResp> {
|
||||
let callToApi = this.http.get<StatsForLastYearResp>(`${this.apiUrl}/Stats/ForLastYear`, { headers: this.headers })
|
||||
let callToApi = this.http
|
||||
.get<StatsForLastYearResp>(`${this.apiUrl}/Stats/ForLastYear`, {
|
||||
headers: this.headers,
|
||||
})
|
||||
.pipe(
|
||||
map(response => {
|
||||
const statsByDz = response.byDz.map(data => new StatsByDzResp(data));
|
||||
map((response) => {
|
||||
const statsByDz = response.byDz.map(
|
||||
(data) => new StatsByDzResp(data)
|
||||
);
|
||||
const statsByJumpType = response.byJumpType.map(
|
||||
data => new StatsByDzResp(data)
|
||||
(data) => new StatsByDzResp(data)
|
||||
);
|
||||
|
||||
return new StatsForLastYearResp(statsByDz, statsByJumpType);
|
||||
})
|
||||
);
|
||||
|
||||
return this.serviceCacheApi.get<StatsForLastYearResp>(CacheApiKey.StatsOfLastYear, callToApi);
|
||||
return this.serviceCacheApi.get<StatsForLastYearResp>(
|
||||
CacheApiKey.StatsOfLastYear,
|
||||
callToApi
|
||||
);
|
||||
}
|
||||
|
||||
public getStatsOfLastMonth(): Observable<StatsForLastMonthResp> {
|
||||
let callToApi = this.http.get<StatsForLastYearResp>(`${this.apiUrl}/Stats/ForLastMonth`, { headers: this.headers })
|
||||
let callToApi = this.http
|
||||
.get<StatsForLastYearResp>(`${this.apiUrl}/Stats/ForLastMonth`, {
|
||||
headers: this.headers,
|
||||
})
|
||||
.pipe(
|
||||
map(response => {
|
||||
const statsByDz = response.byDz.map(data => new StatsByDzResp(data));
|
||||
map((response) => {
|
||||
const statsByDz = response.byDz.map(
|
||||
(data) => new StatsByDzResp(data)
|
||||
);
|
||||
const statsByJumpType = response.byJumpType.map(
|
||||
data => new StatsByDzResp(data)
|
||||
(data) => new StatsByDzResp(data)
|
||||
);
|
||||
|
||||
return new StatsForLastMonthResp(statsByDz, statsByJumpType);
|
||||
})
|
||||
);
|
||||
|
||||
return this.serviceCacheApi.get<StatsForLastMonthResp>(CacheApiKey.StatsOfLastMonth, callToApi);
|
||||
return this.serviceCacheApi.get<StatsForLastMonthResp>(
|
||||
CacheApiKey.StatsOfLastMonth,
|
||||
callToApi
|
||||
);
|
||||
}
|
||||
|
||||
public getStatsByYearByJumpType(): Observable<
|
||||
Array<StatsByYearByJumpTypeResp>
|
||||
> {
|
||||
let callToApi = this.http
|
||||
.get<Array<StatsByYearByJumpTypeResp>>(
|
||||
`${this.apiUrl}/Stats/ByYearByJumpType`,
|
||||
{
|
||||
headers: this.headers,
|
||||
}
|
||||
)
|
||||
.pipe(
|
||||
map((response) => {
|
||||
const stats = response.map(
|
||||
(data) => new StatsByYearByJumpTypeResp(data)
|
||||
);
|
||||
return stats;
|
||||
})
|
||||
);
|
||||
|
||||
return this.serviceCacheApi.get<Array<StatsByYearByJumpTypeResp>>(
|
||||
CacheApiKey.StatsByYear,
|
||||
callToApi
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user