Ajout du cache sur les appels pour les stats
Et appel à l'API sur l'affichage de l'onglet
This commit is contained in:
@@ -2,12 +2,12 @@ import { Component, OnInit } from "@angular/core";
|
|||||||
import { Router } from "@angular/router";
|
import { Router } from "@angular/router";
|
||||||
|
|
||||||
import { User } from "../models/user";
|
import { User } from "../models/user";
|
||||||
import { RefData } from "../models/ref-data.enum";
|
import { CacheApiKey } from "../models/cache-api-key.enum";
|
||||||
|
|
||||||
import { AuthenticationService } from "../services/authentication.service";
|
import { AuthenticationService } from "../services/authentication.service";
|
||||||
import { ServiceComm } from "../services/service-comm.service";
|
import { ServiceComm } from "../services/service-comm.service";
|
||||||
import { ConfigurationHelper } from "../services/configuration-helper";
|
import { ConfigurationHelper } from "../services/configuration-helper";
|
||||||
import { ServiceRefData } from "../services/service-ref-data.service";
|
import { ServiceCacheApi } from "../services/service-cache-api.service";
|
||||||
import { AircraftService } from "../services/aircraft.service";
|
import { AircraftService } from "../services/aircraft.service";
|
||||||
import { GearService } from "../services/gear.service";
|
import { GearService } from "../services/gear.service";
|
||||||
import { JumpTypeService } from "../services/jump-type.service";
|
import { JumpTypeService } from "../services/jump-type.service";
|
||||||
@@ -26,7 +26,7 @@ export class AppComponent implements OnInit {
|
|||||||
constructor(private router: Router,
|
constructor(private router: Router,
|
||||||
private authenticationService: AuthenticationService,
|
private authenticationService: AuthenticationService,
|
||||||
private serviceComm: ServiceComm,
|
private serviceComm: ServiceComm,
|
||||||
private serviceRefData : ServiceRefData,
|
private serviceCacheApi : ServiceCacheApi,
|
||||||
private serviceApiAircraft : AircraftService,
|
private serviceApiAircraft : AircraftService,
|
||||||
private serviceApiJumpType : JumpTypeService,
|
private serviceApiJumpType : JumpTypeService,
|
||||||
private serviceApiDropzone : DropzoneService,
|
private serviceApiDropzone : DropzoneService,
|
||||||
@@ -58,7 +58,7 @@ export class AppComponent implements OnInit {
|
|||||||
}
|
}
|
||||||
|
|
||||||
logout() {
|
logout() {
|
||||||
this.serviceRefData.delete(RefData.Dropzone);
|
this.serviceCacheApi.delete(CacheApiKey.Dropzone);
|
||||||
this.authenticationService.logout();
|
this.authenticationService.logout();
|
||||||
this.router.navigate(["/login"], { skipLocationChange: true });
|
this.router.navigate(["/login"], { skipLocationChange: true });
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ import { RequestCache } from "../services/request-cache.service";
|
|||||||
import { AuthGuardService } from "../services/auth-guard.service";
|
import { AuthGuardService } from "../services/auth-guard.service";
|
||||||
import { ImageService } from "../services/image.service";
|
import { ImageService } from "../services/image.service";
|
||||||
import { ConfigurationHelper } from "../services/configuration-helper";
|
import { ConfigurationHelper } from "../services/configuration-helper";
|
||||||
import { ServiceRefData } from "../services/service-ref-data.service";
|
import { ServiceCacheApi } from "../services/service-cache-api.service";
|
||||||
|
|
||||||
import { BrowserAnimationsModule } from "@angular/platform-browser/animations";
|
import { BrowserAnimationsModule } from "@angular/platform-browser/animations";
|
||||||
import { FormsModule, ReactiveFormsModule } from "@angular/forms";
|
import { FormsModule, ReactiveFormsModule } from "@angular/forms";
|
||||||
@@ -183,7 +183,7 @@ export function initConfig(configService: ConfigurationHelper) {
|
|||||||
RequestCache,
|
RequestCache,
|
||||||
ConfigurationHelper,
|
ConfigurationHelper,
|
||||||
DatePipe,
|
DatePipe,
|
||||||
ServiceRefData,
|
ServiceCacheApi,
|
||||||
{ provide: APP_INITIALIZER, useFactory: initConfig, deps: [ConfigurationHelper], multi: true },
|
{ provide: APP_INITIALIZER, useFactory: initConfig, deps: [ConfigurationHelper], multi: true },
|
||||||
{ provide: HTTP_INTERCEPTORS, useClass: JwtAuthInterceptor, multi: true },
|
{ provide: HTTP_INTERCEPTORS, useClass: JwtAuthInterceptor, multi: true },
|
||||||
{ provide: HTTP_INTERCEPTORS, useClass: ErrorInterceptor, multi: true }
|
{ provide: HTTP_INTERCEPTORS, useClass: ErrorInterceptor, multi: true }
|
||||||
|
|||||||
@@ -33,10 +33,6 @@
|
|||||||
margin-bottom: 10px;
|
margin-bottom: 10px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.mat-tab-group {
|
|
||||||
margin-top: 20px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.containerFlex {
|
.containerFlex {
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-wrap: wrap;
|
flex-wrap: wrap;
|
||||||
|
|||||||
@@ -11,126 +11,146 @@
|
|||||||
|
|
||||||
<div class="paragraph">
|
<div class="paragraph">
|
||||||
<label class="left130">Last jump</label>
|
<label class="left130">Last jump</label>
|
||||||
<span>: {{ lastJump }}</span>
|
<span>: {{ lastJump | date: 'yyyy-MM-dd' }}</span>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<mat-tab-group mat-align-tabs="left" animationDuration="0ms">
|
<div class="paragraph" style="margin-top: 20px;">
|
||||||
|
<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"
|
||||||
|
(selectedTabChange)="onTabChanged($event);">
|
||||||
<mat-tab label="Jumps in the last month">
|
<mat-tab label="Jumps in the last month">
|
||||||
<div class="containerFlex">
|
<ng-template matTabContent>
|
||||||
<fieldset class="contentFlex">
|
<div class="containerFlex">
|
||||||
<legend>By DZ</legend>
|
<fieldset class="contentFlex">
|
||||||
<table mat-table [dataSource]="dsJumpForLastMonthByDz">
|
<legend>By DZ</legend>
|
||||||
<ng-container matColumnDef="label">
|
<table mat-table [dataSource]="dsJumpForLastMonthByDz">
|
||||||
<td mat-cell *matCellDef="let element">{{element.label}}</td>
|
<ng-container matColumnDef="label">
|
||||||
</ng-container>
|
<td mat-cell *matCellDef="let element">{{element.label}}</td>
|
||||||
<ng-container matColumnDef="nb">
|
</ng-container>
|
||||||
<td mat-cell *matCellDef="let element">{{element.nb}}</td>
|
<ng-container matColumnDef="nb">
|
||||||
</ng-container>
|
<td mat-cell *matCellDef="let element">{{element.nb}}</td>
|
||||||
<tr mat-row *matRowDef="let row; columns: displayedColumns;"></tr>
|
</ng-container>
|
||||||
</table>
|
<tr mat-row *matRowDef="let row; columns: displayedColumns;"></tr>
|
||||||
</fieldset>
|
</table>
|
||||||
<fieldset class="contentFlex">
|
</fieldset>
|
||||||
<legend>By jump type</legend>
|
<fieldset class="contentFlex">
|
||||||
<table mat-table [dataSource]="dsJumpForLastMonthByJumpType">
|
<legend>By jump type</legend>
|
||||||
<ng-container matColumnDef="label">
|
<table mat-table [dataSource]="dsJumpForLastMonthByJumpType">
|
||||||
<td mat-cell *matCellDef="let element">{{element.label}}</td>
|
<ng-container matColumnDef="label">
|
||||||
</ng-container>
|
<td mat-cell *matCellDef="let element">{{element.label}}</td>
|
||||||
<ng-container matColumnDef="nb">
|
</ng-container>
|
||||||
<td mat-cell *matCellDef="let element">{{element.nb}}</td>
|
<ng-container matColumnDef="nb">
|
||||||
</ng-container>
|
<td mat-cell *matCellDef="let element">{{element.nb}}</td>
|
||||||
<tr mat-row *matRowDef="let row; columns: displayedColumns;"></tr>
|
</ng-container>
|
||||||
</table>
|
<tr mat-row *matRowDef="let row; columns: displayedColumns;"></tr>
|
||||||
</fieldset>
|
</table>
|
||||||
</div>
|
</fieldset>
|
||||||
|
</div>
|
||||||
|
</ng-template>
|
||||||
</mat-tab>
|
</mat-tab>
|
||||||
|
|
||||||
<mat-tab label="Jumps in the last year">
|
<mat-tab label="Jumps in the last year">
|
||||||
<div class="containerFlex">
|
<ng-template matTabContent>
|
||||||
<fieldset class="contentFlex">
|
<div class="containerFlex">
|
||||||
<legend>By DZ</legend>
|
<fieldset class="contentFlex">
|
||||||
<table mat-table [dataSource]="dsJumpForLastYearByDz">
|
<legend>By DZ</legend>
|
||||||
<ng-container matColumnDef="label">
|
<table mat-table [dataSource]="dsJumpForLastYearByDz">
|
||||||
<td mat-cell *matCellDef="let element">{{element.label}}</td>
|
<ng-container matColumnDef="label">
|
||||||
</ng-container>
|
<td mat-cell *matCellDef="let element">{{element.label}}</td>
|
||||||
<ng-container matColumnDef="nb">
|
</ng-container>
|
||||||
<td mat-cell *matCellDef="let element">{{element.nb}}</td>
|
<ng-container matColumnDef="nb">
|
||||||
</ng-container>
|
<td mat-cell *matCellDef="let element">{{element.nb}}</td>
|
||||||
<tr mat-row *matRowDef="let row; columns: displayedColumns;"></tr>
|
</ng-container>
|
||||||
</table>
|
<tr mat-row *matRowDef="let row; columns: displayedColumns;"></tr>
|
||||||
</fieldset>
|
</table>
|
||||||
<fieldset class="contentFlex">
|
</fieldset>
|
||||||
<legend>By jump type</legend>
|
<fieldset class="contentFlex">
|
||||||
<table mat-table [dataSource]="dsJumpForLastYearByJumpType">
|
<legend>By jump type</legend>
|
||||||
<ng-container matColumnDef="label">
|
<table mat-table [dataSource]="dsJumpForLastYearByJumpType">
|
||||||
<td mat-cell *matCellDef="let element">{{element.label}}</td>
|
<ng-container matColumnDef="label">
|
||||||
</ng-container>
|
<td mat-cell *matCellDef="let element">{{element.label}}</td>
|
||||||
<ng-container matColumnDef="nb">
|
</ng-container>
|
||||||
<td mat-cell *matCellDef="let element">{{element.nb}}</td>
|
<ng-container matColumnDef="nb">
|
||||||
</ng-container>
|
<td mat-cell *matCellDef="let element">{{element.nb}}</td>
|
||||||
<tr mat-row *matRowDef="let row; columns: displayedColumns;"></tr>
|
</ng-container>
|
||||||
</table>
|
<tr mat-row *matRowDef="let row; columns: displayedColumns;"></tr>
|
||||||
</fieldset>
|
</table>
|
||||||
</div>
|
</fieldset>
|
||||||
|
</div>
|
||||||
|
</ng-template>
|
||||||
</mat-tab>
|
</mat-tab>
|
||||||
|
|
||||||
<mat-tab label="By DZ">
|
<mat-tab label="By DZ">
|
||||||
<table mat-table [dataSource]="dsNbJumpByDz">
|
<ng-template matTabContent>
|
||||||
<ng-container matColumnDef="label">
|
<table mat-table [dataSource]="dsNbJumpByDz">
|
||||||
<td mat-cell *matCellDef="let element">{{element.label}}</td>
|
<ng-container matColumnDef="label">
|
||||||
</ng-container>
|
<td mat-cell *matCellDef="let element">{{element.label}}</td>
|
||||||
<ng-container matColumnDef="nb">
|
</ng-container>
|
||||||
<td mat-cell *matCellDef="let element">{{element.nb}}</td>
|
<ng-container matColumnDef="nb">
|
||||||
</ng-container>
|
<td mat-cell *matCellDef="let element">{{element.nb}}</td>
|
||||||
<tr mat-row *matRowDef="let row; columns: displayedColumns;"></tr>
|
</ng-container>
|
||||||
</table>
|
<tr mat-row *matRowDef="let row; columns: displayedColumns;"></tr>
|
||||||
|
</table>
|
||||||
|
</ng-template>
|
||||||
</mat-tab>
|
</mat-tab>
|
||||||
|
|
||||||
<mat-tab label="By aircraft">
|
<mat-tab label="By aircraft">
|
||||||
<table mat-table [dataSource]="dsNbJumpByAircraft">
|
<ng-template matTabContent>
|
||||||
<ng-container matColumnDef="label">
|
<table mat-table [dataSource]="dsNbJumpByAircraft">
|
||||||
<td mat-cell *matCellDef="let element">{{element.label}}</td>
|
<ng-container matColumnDef="label">
|
||||||
</ng-container>
|
<td mat-cell *matCellDef="let element">{{element.label}}</td>
|
||||||
<ng-container matColumnDef="nb">
|
</ng-container>
|
||||||
<td mat-cell *matCellDef="let element">{{element.nb}}</td>
|
<ng-container matColumnDef="nb">
|
||||||
</ng-container>
|
<td mat-cell *matCellDef="let element">{{element.nb}}</td>
|
||||||
<tr mat-row *matRowDef="let row; columns: displayedColumns;"></tr>
|
</ng-container>
|
||||||
</table>
|
<tr mat-row *matRowDef="let row; columns: displayedColumns;"></tr>
|
||||||
|
</table>
|
||||||
|
</ng-template>
|
||||||
</mat-tab>
|
</mat-tab>
|
||||||
|
|
||||||
<mat-tab label="By gear">
|
<mat-tab label="By gear">
|
||||||
<table mat-table [dataSource]="dsNbJumpByGear">
|
<ng-template matTabContent>
|
||||||
<ng-container matColumnDef="label">
|
<table mat-table [dataSource]="dsNbJumpByGear">
|
||||||
<td mat-cell *matCellDef="let element">{{element.label}}</td>
|
<ng-container matColumnDef="label">
|
||||||
</ng-container>
|
<td mat-cell *matCellDef="let element">{{element.label}}</td>
|
||||||
<ng-container matColumnDef="nb">
|
</ng-container>
|
||||||
<td mat-cell *matCellDef="let element">{{element.nb}}</td>
|
<ng-container matColumnDef="nb">
|
||||||
</ng-container>
|
<td mat-cell *matCellDef="let element">{{element.nb}}</td>
|
||||||
<tr mat-row *matRowDef="let row; columns: displayedColumns;"></tr>
|
</ng-container>
|
||||||
</table>
|
<tr mat-row *matRowDef="let row; columns: displayedColumns;"></tr>
|
||||||
|
</table>
|
||||||
|
</ng-template>
|
||||||
</mat-tab>
|
</mat-tab>
|
||||||
|
|
||||||
<mat-tab label="By jump type">
|
<mat-tab label="By jump type">
|
||||||
<table mat-table [dataSource]="dsNbJumpByType">
|
<ng-template matTabContent>
|
||||||
<ng-container matColumnDef="label">
|
<table mat-table [dataSource]="dsNbJumpByType">
|
||||||
<td mat-cell *matCellDef="let element">{{element.label}}</td>
|
<ng-container matColumnDef="label">
|
||||||
</ng-container>
|
<td mat-cell *matCellDef="let element">{{element.label}}</td>
|
||||||
<ng-container matColumnDef="nb">
|
</ng-container>
|
||||||
<td mat-cell *matCellDef="let element">{{element.nb}}</td>
|
<ng-container matColumnDef="nb">
|
||||||
</ng-container>
|
<td mat-cell *matCellDef="let element">{{element.nb}}</td>
|
||||||
<tr mat-row *matRowDef="let row; columns: displayedColumns;"></tr>
|
</ng-container>
|
||||||
</table>
|
<tr mat-row *matRowDef="let row; columns: displayedColumns;"></tr>
|
||||||
|
</table>
|
||||||
|
</ng-template>
|
||||||
</mat-tab>
|
</mat-tab>
|
||||||
|
|
||||||
<mat-tab label="By year">
|
<mat-tab label="By year">
|
||||||
<table mat-table [dataSource]="dsNbJumpByYear">
|
<ng-template matTabContent>
|
||||||
<ng-container matColumnDef="label">
|
<table mat-table [dataSource]="dsNbJumpByYear">
|
||||||
<td mat-cell *matCellDef="let element">{{element.label}}</td>
|
<ng-container matColumnDef="label">
|
||||||
</ng-container>
|
<td mat-cell *matCellDef="let element">{{element.label}}</td>
|
||||||
<ng-container matColumnDef="nb">
|
</ng-container>
|
||||||
<td mat-cell *matCellDef="let element">{{element.nb}}</td>
|
<ng-container matColumnDef="nb">
|
||||||
</ng-container>
|
<td mat-cell *matCellDef="let element">{{element.nb}}</td>
|
||||||
<tr mat-row *matRowDef="let row; columns: displayedColumns;"></tr>
|
</ng-container>
|
||||||
</table>
|
<tr mat-row *matRowDef="let row; columns: displayedColumns;"></tr>
|
||||||
|
</table>
|
||||||
|
</ng-template>
|
||||||
</mat-tab>
|
</mat-tab>
|
||||||
</mat-tab-group>
|
</mat-tab-group>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -1,15 +1,10 @@
|
|||||||
import { Component, OnInit } from '@angular/core';
|
import { Component, OnInit, ViewChild } from '@angular/core';
|
||||||
import { MatTableDataSource } from '@angular/material/table';
|
import { MatTableDataSource } from '@angular/material/table';
|
||||||
|
import { MatTabChangeEvent, MatTabGroup } from '@angular/material/tabs';
|
||||||
import { ServiceComm } from '../../services/service-comm.service';
|
import { ServiceComm } from '../../services/service-comm.service';
|
||||||
import { StatsService } from '../../services/stats.service';
|
import { StatsService } from '../../services/stats.service';
|
||||||
import {
|
import { StatsByDzResp, StatsByAircraftResp, StatsByGearResp,
|
||||||
StatsByDzResp,
|
StatsByJumpTypeResp, StatsByYearResp } from '../../models/stats';
|
||||||
StatsByAircraftResp,
|
|
||||||
StatsByGearResp,
|
|
||||||
StatsByJumpTypeResp,
|
|
||||||
StatsByYearResp,
|
|
||||||
StatType
|
|
||||||
} from '../../models/stats';
|
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-summary',
|
selector: 'app-summary',
|
||||||
@@ -29,86 +24,91 @@ export class SummaryComponent implements OnInit {
|
|||||||
public dsJumpForLastMonthByJumpType: MatTableDataSource<StatsByJumpTypeResp>;
|
public dsJumpForLastMonthByJumpType: MatTableDataSource<StatsByJumpTypeResp>;
|
||||||
|
|
||||||
public displayedColumns: Array<string> = ['label', 'nb'];
|
public displayedColumns: Array<string> = ['label', 'nb'];
|
||||||
private _shownStats: Map<StatType, boolean>;
|
|
||||||
public StatType = StatType;
|
|
||||||
|
|
||||||
public totalJumps: number;
|
public totalJumps: number;
|
||||||
public totalCutaways: number;
|
public totalCutaways: number;
|
||||||
public lastJump: string;
|
public lastJump: string;
|
||||||
|
@ViewChild(MatTabGroup) tabGroup: MatTabGroup;
|
||||||
constructor(
|
|
||||||
private _serviceApi: StatsService,
|
constructor(private serviceApi: StatsService,
|
||||||
private _serviceComm: ServiceComm
|
private serviceComm: ServiceComm) { }
|
||||||
) { }
|
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
this.initShownStats();
|
this.serviceComm.UpdatedComponentTitle('Summary');
|
||||||
|
|
||||||
this._serviceComm.UpdatedComponentTitle('Summary');
|
this.serviceApi.getSimpleSummary()
|
||||||
|
.subscribe(data => {
|
||||||
|
this.totalJumps = data.totalJumps;
|
||||||
|
this.totalCutaways = data.totalCutaways;
|
||||||
|
this.lastJump = data.lastJump.jumpDate + ' (' + data.lastJump.dropZone.name + ')';
|
||||||
|
});
|
||||||
|
|
||||||
const statsResult = this._serviceApi.getStatsOfJumps();
|
this.serviceApi.getStatsOfLastMonth()
|
||||||
|
.subscribe(data => {
|
||||||
statsResult.simpleSummary.subscribe(data => {
|
this.dsJumpForLastMonthByDz = new MatTableDataSource(data.byDz);
|
||||||
this.totalJumps = data.totalJumps;
|
this.dsJumpForLastMonthByJumpType = new MatTableDataSource(
|
||||||
this.totalCutaways = data.totalCutaways;
|
data.byJumpType
|
||||||
this.lastJump = data.lastJump.jumpDate + ' (' + data.lastJump.dropZone.name + ')';
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
statsResult.statsByDz.subscribe(data => {
|
this.tabGroup.selectedIndex = 0;
|
||||||
this.dsNbJumpByDz = new MatTableDataSource(data);
|
|
||||||
});
|
|
||||||
statsResult.statsByAircraft.subscribe(data => {
|
|
||||||
this.dsNbJumpByAircraft = new MatTableDataSource(data);
|
|
||||||
});
|
|
||||||
statsResult.statsByGear.subscribe(data => {
|
|
||||||
this.dsNbJumpByGear = new MatTableDataSource(data);
|
|
||||||
});
|
|
||||||
statsResult.statsByJumpType.subscribe(data => {
|
|
||||||
this.dsNbJumpByType = new MatTableDataSource(data);
|
|
||||||
});
|
|
||||||
statsResult.statsByYear.subscribe(data => {
|
|
||||||
this.dsNbJumpByYear = new MatTableDataSource(data);
|
|
||||||
});
|
|
||||||
|
|
||||||
statsResult.statsForLastYear.subscribe(data => {
|
|
||||||
this.dsJumpForLastYearByDz = new MatTableDataSource(data.byDz);
|
|
||||||
this.dsJumpForLastYearByJumpType = new MatTableDataSource(
|
|
||||||
data.byJumpType
|
|
||||||
);
|
|
||||||
});
|
|
||||||
statsResult.statsForLastMonth.subscribe(data => {
|
|
||||||
this.dsJumpForLastMonthByDz = new MatTableDataSource(data.byDz);
|
|
||||||
this.dsJumpForLastMonthByJumpType = new MatTableDataSource(
|
|
||||||
data.byJumpType
|
|
||||||
);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public showStats(statsToShow: StatType) {
|
public refreshStats() {
|
||||||
this._shownStats.set(StatType.ForLastMonth, false);
|
this.serviceApi.deleteAllCache();
|
||||||
this._shownStats.set(StatType.ForLastYear, false);
|
this.tabGroup.selectedIndex = 0;
|
||||||
this._shownStats.set(StatType.ByDz, false);
|
|
||||||
this._shownStats.set(StatType.ByAircraft, false);
|
|
||||||
this._shownStats.set(StatType.ByGear, false);
|
|
||||||
this._shownStats.set(StatType.ByJumpType, false);
|
|
||||||
this._shownStats.set(StatType.ByYear, false);
|
|
||||||
|
|
||||||
this._shownStats.set(statsToShow, true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private initShownStats() {
|
public onTabChanged(event: MatTabChangeEvent) {
|
||||||
this._shownStats = new Map<StatType, boolean>();
|
switch (event.index) {
|
||||||
|
case 0:
|
||||||
this._shownStats.set(StatType.ForLastMonth, false);
|
this.serviceApi.getStatsOfLastMonth()
|
||||||
this._shownStats.set(StatType.ForLastYear, false);
|
.subscribe(data => {
|
||||||
this._shownStats.set(StatType.ByDz, false);
|
this.dsJumpForLastMonthByDz = new MatTableDataSource(data.byDz);
|
||||||
this._shownStats.set(StatType.ByAircraft, false);
|
this.dsJumpForLastMonthByJumpType = new MatTableDataSource(
|
||||||
this._shownStats.set(StatType.ByGear, false);
|
data.byJumpType
|
||||||
this._shownStats.set(StatType.ByJumpType, false);
|
);
|
||||||
this._shownStats.set(StatType.ByYear, true);
|
});
|
||||||
}
|
break;
|
||||||
|
case 1:
|
||||||
public statsToShow(statsToShow: StatType): boolean {
|
this.serviceApi.getStatsOfLastYear()
|
||||||
return this._shownStats.get(statsToShow);
|
.subscribe(data => {
|
||||||
|
this.dsJumpForLastYearByDz = new MatTableDataSource(data.byDz);
|
||||||
|
this.dsJumpForLastYearByJumpType = new MatTableDataSource(
|
||||||
|
data.byJumpType
|
||||||
|
);
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
this.serviceApi.getStatsByDz()
|
||||||
|
.subscribe(data => {
|
||||||
|
this.dsNbJumpByDz = new MatTableDataSource(data);
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
case 3:
|
||||||
|
this.serviceApi.getStatsByAircraft()
|
||||||
|
.subscribe(data => {
|
||||||
|
this.dsNbJumpByAircraft = new MatTableDataSource(data);
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
case 4:
|
||||||
|
this.serviceApi.getStatsByGear()
|
||||||
|
.subscribe(data => {
|
||||||
|
this.dsNbJumpByGear = new MatTableDataSource(data);
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
case 5:
|
||||||
|
this.serviceApi.getStatsByJumpType()
|
||||||
|
.subscribe(data => {
|
||||||
|
this.dsNbJumpByType = new MatTableDataSource(data);
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
case 6:
|
||||||
|
this.serviceApi.getStatsByYear()
|
||||||
|
.subscribe(data => {
|
||||||
|
this.dsNbJumpByYear = new MatTableDataSource(data);
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
13
Front/skydivelogs-app/src/models/cache-api-key.enum.ts
Normal file
13
Front/skydivelogs-app/src/models/cache-api-key.enum.ts
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
export enum CacheApiKey {
|
||||||
|
JumpType,
|
||||||
|
Aircraft,
|
||||||
|
Gear,
|
||||||
|
Dropzone,
|
||||||
|
SimpleSummary,
|
||||||
|
StatsByDz,
|
||||||
|
StatsByAircraft,
|
||||||
|
StatsByJumpType,
|
||||||
|
StatsByGear,
|
||||||
|
StatsOfLastYear,
|
||||||
|
StatsOfLastMonth
|
||||||
|
}
|
||||||
@@ -1,6 +0,0 @@
|
|||||||
export enum RefData {
|
|
||||||
JumpType,
|
|
||||||
Aircraft,
|
|
||||||
Gear,
|
|
||||||
Dropzone
|
|
||||||
}
|
|
||||||
@@ -1,16 +1,6 @@
|
|||||||
import { Observable } from 'rxjs';
|
import { Observable } from 'rxjs';
|
||||||
import { JumpResp } from './jump';
|
import { JumpResp } from './jump';
|
||||||
|
|
||||||
export enum StatType {
|
|
||||||
ForLastMonth = 1,
|
|
||||||
ForLastYear = 2,
|
|
||||||
ByDz = 3,
|
|
||||||
ByAircraft = 4,
|
|
||||||
ByGear = 5,
|
|
||||||
ByJumpType = 6,
|
|
||||||
ByYear = 7,
|
|
||||||
}
|
|
||||||
|
|
||||||
export class StatsResp {
|
export class StatsResp {
|
||||||
public simpleSummary: Observable<SimpleSummary>;
|
public simpleSummary: Observable<SimpleSummary>;
|
||||||
|
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import { Observable } from 'rxjs';
|
|||||||
import { AircraftResp, AircraftReq } from '../models/aircraft';
|
import { AircraftResp, AircraftReq } from '../models/aircraft';
|
||||||
|
|
||||||
import { BaseService } from './base.service';
|
import { BaseService } from './base.service';
|
||||||
import { RefData } from '../models/ref-data.enum';
|
import { CacheApiKey } from '../models/cache-api-key.enum';
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class AircraftService extends BaseService {
|
export class AircraftService extends BaseService {
|
||||||
@@ -22,7 +22,7 @@ export class AircraftService extends BaseService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
let callToApi = this.http.get<Array<AircraftResp>>(url, { headers: this.headers });
|
let callToApi = this.http.get<Array<AircraftResp>>(url, { headers: this.headers });
|
||||||
return this.serviceRefData.get<Array<AircraftResp>>(RefData.Aircraft, callToApi);
|
return this.serviceCacheApi.get<Array<AircraftResp>>(CacheApiKey.Aircraft, callToApi);
|
||||||
}
|
}
|
||||||
|
|
||||||
public AddAircraft(aircraftName: string, dataImg: string) {
|
public AddAircraft(aircraftName: string, dataImg: string) {
|
||||||
|
|||||||
@@ -1,12 +1,12 @@
|
|||||||
import { HttpHeaders } from '@angular/common/http';
|
import { HttpHeaders } from '@angular/common/http';
|
||||||
|
|
||||||
import { ConfigurationHelper } from './configuration-helper';
|
import { ConfigurationHelper } from './configuration-helper';
|
||||||
import { ServiceRefData } from './service-ref-data.service';
|
import { ServiceCacheApi } from './service-cache-api.service';
|
||||||
|
|
||||||
export class BaseService {
|
export class BaseService {
|
||||||
protected headers: HttpHeaders;
|
protected headers: HttpHeaders;
|
||||||
protected apiUrl: string;
|
protected apiUrl: string;
|
||||||
protected serviceRefData : ServiceRefData;
|
protected serviceCacheApi : ServiceCacheApi;
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
ConfigurationHelper.settings.subscribe(settings =>
|
ConfigurationHelper.settings.subscribe(settings =>
|
||||||
@@ -21,6 +21,6 @@ export class BaseService {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
this.serviceRefData = new ServiceRefData();
|
this.serviceCacheApi = new ServiceCacheApi();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import { map } from "rxjs/operators";
|
|||||||
import { DropZoneResp, DropZoneReq } from "../models/dropzone";
|
import { DropZoneResp, DropZoneReq } from "../models/dropzone";
|
||||||
|
|
||||||
import { BaseService } from "./base.service";
|
import { BaseService } from "./base.service";
|
||||||
import { RefData } from "../models/ref-data.enum";
|
import { CacheApiKey } from "../models/cache-api-key.enum";
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class DropzoneService extends BaseService {
|
export class DropzoneService extends BaseService {
|
||||||
@@ -27,7 +27,7 @@ export class DropzoneService extends BaseService {
|
|||||||
const details = response.map(data => new DropZoneResp(data));
|
const details = response.map(data => new DropZoneResp(data));
|
||||||
return details;
|
return details;
|
||||||
}));
|
}));
|
||||||
return this.serviceRefData.get<Array<DropZoneResp>>(RefData.Dropzone, callToApi);
|
return this.serviceCacheApi.get<Array<DropZoneResp>>(CacheApiKey.Dropzone, callToApi);
|
||||||
}
|
}
|
||||||
|
|
||||||
public SetFavoriteDropZone(selectedDz: DropZoneResp) {
|
public SetFavoriteDropZone(selectedDz: DropZoneResp) {
|
||||||
@@ -37,7 +37,7 @@ export class DropzoneService extends BaseService {
|
|||||||
selectedDz,
|
selectedDz,
|
||||||
{ headers: this.headers })
|
{ headers: this.headers })
|
||||||
.subscribe(() => {
|
.subscribe(() => {
|
||||||
this.serviceRefData.delete(RefData.Dropzone);
|
this.serviceCacheApi.delete(CacheApiKey.Dropzone);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -48,7 +48,7 @@ export class DropzoneService extends BaseService {
|
|||||||
selectedDz,
|
selectedDz,
|
||||||
{ headers: this.headers })
|
{ headers: this.headers })
|
||||||
.subscribe(() => {
|
.subscribe(() => {
|
||||||
this.serviceRefData.delete(RefData.Dropzone);
|
this.serviceCacheApi.delete(CacheApiKey.Dropzone);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -72,7 +72,7 @@ export class DropzoneService extends BaseService {
|
|||||||
isFavorite: isFavorite
|
isFavorite: isFavorite
|
||||||
};
|
};
|
||||||
|
|
||||||
this.serviceRefData.delete(RefData.Dropzone);
|
this.serviceCacheApi.delete(CacheApiKey.Dropzone);
|
||||||
return this.http.post(`${this.apiUrl}/DropZone`,
|
return this.http.post(`${this.apiUrl}/DropZone`,
|
||||||
bodyNewDropZone,
|
bodyNewDropZone,
|
||||||
{ headers: this.headers });
|
{ headers: this.headers });
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import { Observable } from "rxjs";
|
|||||||
import { GearResp, GearReq } from "../models/gear";
|
import { GearResp, GearReq } from "../models/gear";
|
||||||
|
|
||||||
import { BaseService } from "./base.service";
|
import { BaseService } from "./base.service";
|
||||||
import { RefData } from "../models/ref-data.enum";
|
import { CacheApiKey } from "../models/cache-api-key.enum";
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class GearService extends BaseService {
|
export class GearService extends BaseService {
|
||||||
@@ -15,7 +15,7 @@ export class GearService extends BaseService {
|
|||||||
|
|
||||||
public getListOfGears(): Observable<Array<GearResp>> {
|
public getListOfGears(): Observable<Array<GearResp>> {
|
||||||
let callToApi = this.http.get<Array<GearResp>>(`${this.apiUrl}/Gear`, { headers: this.headers });
|
let callToApi = this.http.get<Array<GearResp>>(`${this.apiUrl}/Gear`, { headers: this.headers });
|
||||||
return this.serviceRefData.get<Array<GearResp>>(RefData.Gear, callToApi);
|
return this.serviceCacheApi.get<Array<GearResp>>(CacheApiKey.Gear, callToApi);
|
||||||
}
|
}
|
||||||
|
|
||||||
public AddGear(name: string,
|
public AddGear(name: string,
|
||||||
@@ -37,7 +37,7 @@ export class GearService extends BaseService {
|
|||||||
reserveCanopy: reserveCanopy
|
reserveCanopy: reserveCanopy
|
||||||
};
|
};
|
||||||
|
|
||||||
this.serviceRefData.delete(RefData.Gear);
|
this.serviceCacheApi.delete(CacheApiKey.Gear);
|
||||||
return this.http.post(`${this.apiUrl}/Gear`, bodyNewGear, { headers: this.headers});
|
return this.http.post(`${this.apiUrl}/Gear`, bodyNewGear, { headers: this.headers});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import { Observable } from "rxjs";
|
|||||||
import { JumpTypeResp, JumpTypeReq } from "../models/jumpType";
|
import { JumpTypeResp, JumpTypeReq } from "../models/jumpType";
|
||||||
|
|
||||||
import { BaseService } from "./base.service";
|
import { BaseService } from "./base.service";
|
||||||
import { RefData } from "../models/ref-data.enum";
|
import { CacheApiKey } from "../models/cache-api-key.enum";
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class JumpTypeService extends BaseService {
|
export class JumpTypeService extends BaseService {
|
||||||
@@ -15,7 +15,7 @@ export class JumpTypeService extends BaseService {
|
|||||||
|
|
||||||
public getListOfJumpTypes(): Observable<Array<JumpTypeResp>> {
|
public getListOfJumpTypes(): Observable<Array<JumpTypeResp>> {
|
||||||
let callToApi = this.http.get<Array<JumpTypeResp>>(`${this.apiUrl}/JumpType`, { headers: this.headers });
|
let callToApi = this.http.get<Array<JumpTypeResp>>(`${this.apiUrl}/JumpType`, { headers: this.headers });
|
||||||
return this.serviceRefData.get<Array<JumpTypeResp>>(RefData.JumpType, callToApi);
|
return this.serviceCacheApi.get<Array<JumpTypeResp>>(CacheApiKey.JumpType, callToApi);
|
||||||
}
|
}
|
||||||
|
|
||||||
public AddJumpType(jumptypetName: string) {
|
public AddJumpType(jumptypetName: string) {
|
||||||
|
|||||||
@@ -1,21 +1,20 @@
|
|||||||
import { Injectable } from '@angular/core';
|
import { Injectable } from '@angular/core';
|
||||||
import { Observable } from 'rxjs/Observable';
|
import { Observable } from 'rxjs/Observable';
|
||||||
import { tap } from 'rxjs/operators';
|
import { tap } from 'rxjs/operators';
|
||||||
import { RefData } from '../models/ref-data.enum';
|
import { CacheApiKey } from '../models/cache-api-key.enum';
|
||||||
import { of } from 'rxjs';
|
import { of } from 'rxjs';
|
||||||
//import 'rxjs/add/observable/of';
|
|
||||||
|
|
||||||
@Injectable({
|
@Injectable({
|
||||||
providedIn: 'root',
|
providedIn: 'root',
|
||||||
})
|
})
|
||||||
export class ServiceRefData {
|
export class ServiceCacheApi {
|
||||||
private cache: Map<RefData, Observable<any>>;
|
private cache: Map<CacheApiKey, Observable<any>>;
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
this.cache = new Map<RefData, Observable<any>>();
|
this.cache = new Map<CacheApiKey, Observable<any>>();
|
||||||
}
|
}
|
||||||
|
|
||||||
public get<T>(key: RefData, callToApi: Observable<T>, withResetCache: boolean = false) : Observable<T> {
|
public get<T>(key: CacheApiKey, callToApi: Observable<T>, withResetCache: boolean = false) : Observable<T> {
|
||||||
if (withResetCache === true) {
|
if (withResetCache === true) {
|
||||||
this.cache.delete(key);
|
this.cache.delete(key);
|
||||||
}
|
}
|
||||||
@@ -32,7 +31,7 @@ export class ServiceRefData {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public delete(key: RefData) {
|
public delete(key: CacheApiKey) {
|
||||||
this.cache.delete(key);
|
this.cache.delete(key);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,21 +1,14 @@
|
|||||||
import { Injectable, Injector } from '@angular/core';
|
import { Injectable } from '@angular/core';
|
||||||
import { HttpClient } from '@angular/common/http';
|
import { HttpClient } from '@angular/common/http';
|
||||||
import { Observable } from 'rxjs';
|
import { Observable } from 'rxjs';
|
||||||
import { map } from 'rxjs/operators';
|
import { map } from 'rxjs/operators';
|
||||||
|
|
||||||
import {
|
import { StatsByDzResp, StatsByAircraftResp, StatsByJumpTypeResp,
|
||||||
StatsResp,
|
StatsByGearResp, StatsByYearResp, StatsForLastMonthResp,
|
||||||
StatsByDzResp,
|
StatsForLastYearResp, SimpleSummary } from '../models/stats';
|
||||||
StatsByAircraftResp,
|
|
||||||
StatsByJumpTypeResp,
|
|
||||||
StatsByGearResp,
|
|
||||||
StatsByYearResp,
|
|
||||||
StatsForLastMonthResp,
|
|
||||||
StatsForLastYearResp,
|
|
||||||
SimpleSummary
|
|
||||||
} from '../models/stats';
|
|
||||||
|
|
||||||
import { BaseService } from './base.service';
|
import { BaseService } from './base.service';
|
||||||
|
import { CacheApiKey } from '../models/cache-api-key.enum';
|
||||||
|
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
@@ -24,136 +17,117 @@ export class StatsService extends BaseService {
|
|||||||
super();
|
super();
|
||||||
}
|
}
|
||||||
|
|
||||||
public getStatsOfJumps(): StatsResp {
|
public deleteAllCache() {
|
||||||
const resultats = new StatsResp();
|
this.serviceCacheApi.delete(CacheApiKey.SimpleSummary);
|
||||||
|
this.serviceCacheApi.delete(CacheApiKey.StatsByDz);
|
||||||
resultats.simpleSummary = this.getSimpleSummary();
|
this.serviceCacheApi.delete(CacheApiKey.StatsByAircraft);
|
||||||
|
this.serviceCacheApi.delete(CacheApiKey.StatsByJumpType);
|
||||||
resultats.statsByDz = this.getStatsByDz();
|
this.serviceCacheApi.delete(CacheApiKey.StatsByGear);
|
||||||
resultats.statsByAircraft = this.getStatsByAircraft();
|
this.serviceCacheApi.delete(CacheApiKey.StatsOfLastYear);
|
||||||
resultats.statsByJumpType = this.getStatsByJumpType();
|
this.serviceCacheApi.delete(CacheApiKey.StatsOfLastMonth);
|
||||||
resultats.statsByGear = this.getStatsByGear();
|
|
||||||
resultats.statsByYear = this.getStatsByYear();
|
|
||||||
|
|
||||||
resultats.statsForLastYear = this.getStatsOfLastYear();
|
|
||||||
resultats.statsForLastMonth = this.getStatsOfLastMonth();
|
|
||||||
|
|
||||||
return resultats;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private getSimpleSummary(): Observable<SimpleSummary> {
|
public getSimpleSummary(): Observable<SimpleSummary> {
|
||||||
return this.http
|
let callToApi = this.http.get<Array<SimpleSummary>>(`${this.apiUrl}/Stats/Simple`, { headers: this.headers })
|
||||||
.get<Array<SimpleSummary>>(`${this.apiUrl}/Stats/Simple`, {
|
.pipe(
|
||||||
headers: this.headers
|
map(response => {
|
||||||
})
|
const stats = new SimpleSummary(response);
|
||||||
.pipe(
|
return stats;
|
||||||
map(response => {
|
})
|
||||||
const stats = new SimpleSummary(response);
|
);
|
||||||
return stats;
|
|
||||||
})
|
return this.serviceCacheApi.get<SimpleSummary>(CacheApiKey.SimpleSummary, callToApi);
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private getStatsByDz(): Observable<Array<StatsByDzResp>> {
|
public getStatsByDz(): Observable<Array<StatsByDzResp>> {
|
||||||
return this.http
|
let callToApi = this.http.get<Array<StatsByDzResp>>(`${this.apiUrl}/Stats/ByDz`, { headers: this.headers })
|
||||||
.get<Array<StatsByDzResp>>(`${this.apiUrl}/Stats/ByDz`, {
|
.pipe(
|
||||||
headers: this.headers
|
map(response => {
|
||||||
})
|
const stats = response.map(data => new StatsByDzResp(data));
|
||||||
.pipe(
|
return stats;
|
||||||
map(response => {
|
})
|
||||||
const stats = response.map(data => new StatsByDzResp(data));
|
);
|
||||||
return stats;
|
|
||||||
})
|
return this.serviceCacheApi.get<Array<StatsByDzResp>>(CacheApiKey.StatsByDz, callToApi);
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private getStatsByAircraft(): Observable<Array<StatsByAircraftResp>> {
|
public getStatsByAircraft(): Observable<Array<StatsByAircraftResp>> {
|
||||||
return this.http
|
let callToApi = this.http.get<Array<StatsByAircraftResp>>(`${this.apiUrl}/Stats/ByAircraft`, { headers: this.headers })
|
||||||
.get<Array<StatsByAircraftResp>>(
|
.pipe(
|
||||||
`${this.apiUrl}/Stats/ByAircraft`,
|
map(response => {
|
||||||
{ headers: this.headers }
|
const stats = response.map(data => new StatsByAircraftResp(data));
|
||||||
)
|
return stats;
|
||||||
.pipe(
|
})
|
||||||
map(response => {
|
);
|
||||||
const stats = response.map(data => new StatsByAircraftResp(data));
|
|
||||||
return stats;
|
return this.serviceCacheApi.get<Array<StatsByAircraftResp>>(CacheApiKey.StatsByAircraft, callToApi);
|
||||||
})
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private getStatsByJumpType(): Observable<Array<StatsByJumpTypeResp>> {
|
public getStatsByJumpType(): Observable<Array<StatsByJumpTypeResp>> {
|
||||||
return this.http
|
let callToApi = this.http.get<Array<StatsByJumpTypeResp>>(`${this.apiUrl}/Stats/ByJumpType`,{ headers: this.headers })
|
||||||
.get<Array<StatsByJumpTypeResp>>(
|
.pipe(
|
||||||
`${this.apiUrl}/Stats/ByJumpType`,
|
map(response => {
|
||||||
{ headers: this.headers }
|
const stats = response.map(data => new StatsByJumpTypeResp(data));
|
||||||
)
|
return stats;
|
||||||
.pipe(
|
})
|
||||||
map(response => {
|
);
|
||||||
const stats = response.map(data => new StatsByJumpTypeResp(data));
|
|
||||||
return stats;
|
return this.serviceCacheApi.get<Array<StatsByJumpTypeResp>>(CacheApiKey.StatsByJumpType, callToApi);
|
||||||
})
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private getStatsByGear(): Observable<Array<StatsByGearResp>> {
|
public getStatsByGear(): Observable<Array<StatsByGearResp>> {
|
||||||
return this.http
|
let callToApi = this.http.get<Array<StatsByGearResp>>(`${this.apiUrl}/Stats/ByGear`, { headers: this.headers })
|
||||||
.get<Array<StatsByGearResp>>(`${this.apiUrl}/Stats/ByGear`, {
|
.pipe(
|
||||||
headers: this.headers
|
map(response => {
|
||||||
})
|
const stats = response.map(data => new StatsByGearResp(data));
|
||||||
.pipe(
|
return stats;
|
||||||
map(response => {
|
})
|
||||||
const stats = response.map(data => new StatsByGearResp(data));
|
);
|
||||||
return stats;
|
|
||||||
})
|
return this.serviceCacheApi.get<Array<StatsByGearResp>>(CacheApiKey.StatsByGear, callToApi);
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private getStatsByYear(): Observable<Array<StatsByYearResp>> {
|
public getStatsByYear(): Observable<Array<StatsByYearResp>> {
|
||||||
return this.http
|
let callToApi = this.http.get<Array<StatsByYearResp>>(`${this.apiUrl}/Stats/ByYear`, { headers: this.headers })
|
||||||
.get<Array<StatsByYearResp>>(`${this.apiUrl}/Stats/ByYear`, {
|
.pipe(
|
||||||
headers: this.headers
|
map(response => {
|
||||||
})
|
const stats = response.map(data => new StatsByYearResp(data));
|
||||||
.pipe(
|
return stats;
|
||||||
map(response => {
|
})
|
||||||
const stats = response.map(data => new StatsByYearResp(data));
|
);
|
||||||
return stats;
|
|
||||||
})
|
return this.serviceCacheApi.get<Array<StatsByYearResp>>(CacheApiKey.StatsByGear, callToApi);
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private getStatsOfLastYear(): Observable<StatsForLastYearResp> {
|
public getStatsOfLastYear(): Observable<StatsForLastYearResp> {
|
||||||
return this.http
|
let callToApi = this.http.get<StatsForLastYearResp>(`${this.apiUrl}/Stats/ForLastYear`, { headers: this.headers })
|
||||||
.get<StatsForLastYearResp>(
|
.pipe(
|
||||||
`${this.apiUrl}/Stats/ForLastYear`,
|
map(response => {
|
||||||
{ headers: this.headers }
|
const statsByDz = response.byDz.map(data => new StatsByDzResp(data));
|
||||||
)
|
const statsByJumpType = response.byJumpType.map(
|
||||||
.pipe(
|
data => new StatsByDzResp(data)
|
||||||
map(response => {
|
);
|
||||||
const statsByDz = response.byDz.map(data => new StatsByDzResp(data));
|
|
||||||
const statsByJumpType = response.byJumpType.map(
|
|
||||||
data => new StatsByDzResp(data)
|
|
||||||
);
|
|
||||||
|
|
||||||
return new StatsForLastYearResp(statsByDz, statsByJumpType);
|
return new StatsForLastYearResp(statsByDz, statsByJumpType);
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
|
||||||
|
return this.serviceCacheApi.get<StatsForLastYearResp>(CacheApiKey.StatsOfLastYear, callToApi);
|
||||||
}
|
}
|
||||||
|
|
||||||
private getStatsOfLastMonth(): Observable<StatsForLastMonthResp> {
|
public getStatsOfLastMonth(): Observable<StatsForLastMonthResp> {
|
||||||
return this.http
|
let callToApi = this.http.get<StatsForLastYearResp>(`${this.apiUrl}/Stats/ForLastMonth`, { headers: this.headers })
|
||||||
.get<StatsForLastYearResp>(
|
.pipe(
|
||||||
`${this.apiUrl}/Stats/ForLastMonth`,
|
map(response => {
|
||||||
{ headers: this.headers }
|
const statsByDz = response.byDz.map(data => new StatsByDzResp(data));
|
||||||
)
|
const statsByJumpType = response.byJumpType.map(
|
||||||
.pipe(
|
data => new StatsByDzResp(data)
|
||||||
map(response => {
|
);
|
||||||
const statsByDz = response.byDz.map(data => new StatsByDzResp(data));
|
|
||||||
const statsByJumpType = response.byJumpType.map(
|
|
||||||
data => new StatsByDzResp(data)
|
|
||||||
);
|
|
||||||
|
|
||||||
return new StatsForLastMonthResp(statsByDz, statsByJumpType);
|
return new StatsForLastMonthResp(statsByDz, statsByJumpType);
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
|
||||||
|
return this.serviceCacheApi.get<StatsForLastMonthResp>(CacheApiKey.StatsOfLastMonth, callToApi);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user