Display the num of minutes of flights
This commit is contained in:
@@ -12,6 +12,12 @@
|
|||||||
<mat-radio-button value="all">{{ 'ListTunnelFlight_AllFlights' | translate }}</mat-radio-button>
|
<mat-radio-button value="all">{{ 'ListTunnelFlight_AllFlights' | translate }}</mat-radio-button>
|
||||||
</mat-radio-group>
|
</mat-radio-group>
|
||||||
|
|
||||||
|
<mat-nav-list>
|
||||||
|
<mat-list-item matListItemLine *ngFor="let stat of stats">
|
||||||
|
<label>{{stat.id}} : {{stat.values}}</label>
|
||||||
|
</mat-list-item>
|
||||||
|
</mat-nav-list>
|
||||||
|
|
||||||
<div style="display: inline-block; position: relative; width: 100%;">
|
<div style="display: inline-block; position: relative; width: 100%;">
|
||||||
<canvas baseChart
|
<canvas baseChart
|
||||||
[data]="barChartData"
|
[data]="barChartData"
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import { formatDate } from '@angular/common';
|
|||||||
import { TranslateService } from '@ngx-translate/core';
|
import { TranslateService } from '@ngx-translate/core';
|
||||||
import { MatTableDataSource } from '@angular/material/table';
|
import { MatTableDataSource } from '@angular/material/table';
|
||||||
import { ChartConfiguration, ChartData, ChartType } from 'chart.js';
|
import { ChartConfiguration, ChartData, ChartType } from 'chart.js';
|
||||||
import { from, of, groupBy, mergeMap, reduce, map } from 'rxjs';
|
import { from, of, groupBy, mergeMap, reduce, map, Observable } from 'rxjs';
|
||||||
|
|
||||||
import { ServiceComm } from '../../services/service-comm.service';
|
import { ServiceComm } from '../../services/service-comm.service';
|
||||||
import { TunnelFlightService } from "../../services/tunnel-flight.service";
|
import { TunnelFlightService } from "../../services/tunnel-flight.service";
|
||||||
@@ -33,6 +33,7 @@ export class ListOfTunnelFlightsComponent implements OnInit {
|
|||||||
"flightDate",
|
"flightDate",
|
||||||
"actions"
|
"actions"
|
||||||
];
|
];
|
||||||
|
public stats: Array<{id: String|Number, values: String|Number}> = [];
|
||||||
|
|
||||||
constructor(private serviceComm: ServiceComm,
|
constructor(private serviceComm: ServiceComm,
|
||||||
private serviceTunnelFlight: TunnelFlightService,
|
private serviceTunnelFlight: TunnelFlightService,
|
||||||
@@ -138,14 +139,18 @@ export class ListOfTunnelFlightsComponent implements OnInit {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private computeTimeByType(stats: TunnelFlightByMonth[]) {
|
private computeTimeByType(stats: TunnelFlightByMonth[]) {
|
||||||
|
this.stats = [];
|
||||||
from(stats).pipe(
|
from(stats).pipe(
|
||||||
groupBy((type) => type.type, { element: (p) => p.nb }),
|
groupBy((type) => type.type, { element: (p) => p.nb }),
|
||||||
mergeMap((group$) =>
|
mergeMap((group$) =>
|
||||||
group$.pipe(reduce((acc, cur) => [...acc, cur], [`${group$.key}`]))
|
group$.pipe(reduce((acc, cur) => [...acc, cur], [`${group$.key}`]))
|
||||||
),
|
),
|
||||||
map((arr) => ({ id: arr[0], values: arr.slice(1) }))
|
map((arr) => ({ id: arr[0], values: arr.slice(1).reduce((a, b) => Number(a) + Number(b), 0) }))
|
||||||
)
|
)
|
||||||
.subscribe((p) => console.log(p));
|
.subscribe((p) => {
|
||||||
|
console.log(p);
|
||||||
|
this.stats.push(p);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private getMontsBetweenDates(beginDate: Date, endDate: Date): Array<string> {
|
private getMontsBetweenDates(beginDate: Date, endDate: Date): Array<string> {
|
||||||
|
|||||||
@@ -1,9 +1,10 @@
|
|||||||
import { Injectable } from '@angular/core';
|
import { Injectable } from '@angular/core';
|
||||||
import { HttpEvent, HttpRequest, HttpResponse, HttpInterceptor, HttpHandler } from '@angular/common/http';
|
import { HttpEvent, HttpRequest, HttpResponse, HttpInterceptor, HttpHandler } from '@angular/common/http';
|
||||||
|
|
||||||
import { Observable } from 'rxjs/Observable';
|
// import { Observable } from 'rxjs/Observable';
|
||||||
|
// import 'rxjs/add/observable/of';
|
||||||
import { tap } from 'rxjs/operators';
|
import { tap } from 'rxjs/operators';
|
||||||
import 'rxjs/add/observable/of';
|
import { Observable, of } from 'rxjs';
|
||||||
|
|
||||||
import { RequestCache } from '../services/request-cache.service';
|
import { RequestCache } from '../services/request-cache.service';
|
||||||
|
|
||||||
@@ -13,7 +14,7 @@ export class CachingInterceptor implements HttpInterceptor {
|
|||||||
|
|
||||||
intercept(req: HttpRequest<any>, next: HttpHandler) {
|
intercept(req: HttpRequest<any>, next: HttpHandler) {
|
||||||
const cachedResponse = this.cache.get(req);
|
const cachedResponse = this.cache.get(req);
|
||||||
return cachedResponse ? Observable.of(cachedResponse) : this.sendRequest(req, next);
|
return cachedResponse ? of(cachedResponse) : this.sendRequest(req, next);
|
||||||
}
|
}
|
||||||
|
|
||||||
sendRequest(req: HttpRequest<any>, next: HttpHandler): Observable<HttpEvent<any>> {
|
sendRequest(req: HttpRequest<any>, next: HttpHandler): Observable<HttpEvent<any>> {
|
||||||
|
|||||||
Reference in New Issue
Block a user