First step to display the number of hours of

tunnel flights by period
This commit is contained in:
Sébastien ANDRE
2023-12-28 19:16:51 +01:00
parent 644feaae54
commit 54f553279e
22 changed files with 15 additions and 522 deletions

View File

@@ -1,27 +0,0 @@
import { TestBed, waitForAsync } from '@angular/core/testing';
import { AppComponent } from './app.component';
describe('AppComponent', () => {
beforeEach(waitForAsync(() => {
TestBed.configureTestingModule({
declarations: [
AppComponent
],
}).compileComponents();
}));
it('should create the app', waitForAsync(() => {
const fixture = TestBed.createComponent(AppComponent);
const app = fixture.debugElement.componentInstance;
expect(app).toBeTruthy();
}));
it(`should have as title 'app'`, waitForAsync(() => {
const fixture = TestBed.createComponent(AppComponent);
const app = fixture.debugElement.componentInstance;
expect(app.title).toEqual('app');
}));
it('should render title in a h1 tag', waitForAsync(() => {
const fixture = TestBed.createComponent(AppComponent);
fixture.detectChanges();
const compiled = fixture.debugElement.nativeElement;
expect(compiled.querySelector('h1').textContent).toContain('Welcome to app!');
}));
});

View File

@@ -1,25 +0,0 @@
import { ComponentFixture, TestBed, waitForAsync } from '@angular/core/testing';
import { CreateUserComponent } from './create-user.component';
describe('CreateUserComponent', () => {
let component: CreateUserComponent;
let fixture: ComponentFixture<CreateUserComponent>;
beforeEach(waitForAsync(() => {
TestBed.configureTestingModule({
declarations: [ CreateUserComponent ]
})
.compileComponents();
}));
beforeEach(() => {
fixture = TestBed.createComponent(CreateUserComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});

View File

@@ -1,25 +0,0 @@
import { ComponentFixture, TestBed, waitForAsync } from '@angular/core/testing';
import { DefaultComponent } from './default.component';
describe('DefaultComponent', () => {
let component: DefaultComponent;
let fixture: ComponentFixture<DefaultComponent>;
beforeEach(waitForAsync(() => {
TestBed.configureTestingModule({
declarations: [ DefaultComponent ]
})
.compileComponents();
}));
beforeEach(() => {
fixture = TestBed.createComponent(DefaultComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});

View File

@@ -1,25 +0,0 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { JumpInfosComponent } from './jump-infos.component';
describe('JumpInfosComponent', () => {
let component: JumpInfosComponent;
let fixture: ComponentFixture<JumpInfosComponent>;
beforeEach(async () => {
await TestBed.configureTestingModule({
declarations: [ JumpInfosComponent ]
})
.compileComponents();
});
beforeEach(() => {
fixture = TestBed.createComponent(JumpInfosComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});

View File

@@ -1,25 +0,0 @@
import { ComponentFixture, TestBed, waitForAsync } from '@angular/core/testing';
import { ListOfAircraftsComponent } from './list-of-aircrafts.component';
describe('ListOfAircraftsComponent', () => {
let component: ListOfAircraftsComponent;
let fixture: ComponentFixture<ListOfAircraftsComponent>;
beforeEach(waitForAsync(() => {
TestBed.configureTestingModule({
declarations: [ ListOfAircraftsComponent ]
})
.compileComponents();
}));
beforeEach(() => {
fixture = TestBed.createComponent(ListOfAircraftsComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});

View File

@@ -1,25 +0,0 @@
import { ComponentFixture, TestBed, waitForAsync } from '@angular/core/testing';
import { ListOfDzsComponent } from './list-of-dzs.component';
describe('ListOfDzsComponent', () => {
let component: ListOfDzsComponent;
let fixture: ComponentFixture<ListOfDzsComponent>;
beforeEach(waitForAsync(() => {
TestBed.configureTestingModule({
declarations: [ ListOfDzsComponent ]
})
.compileComponents();
}));
beforeEach(() => {
fixture = TestBed.createComponent(ListOfDzsComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});

View File

@@ -1,25 +0,0 @@
import { ComponentFixture, TestBed, waitForAsync } from '@angular/core/testing';
import { ListOfGearsComponent } from './list-of-gears.component';
describe('ListOfGearsComponent', () => {
let component: ListOfGearsComponent;
let fixture: ComponentFixture<ListOfGearsComponent>;
beforeEach(waitForAsync(() => {
TestBed.configureTestingModule({
declarations: [ ListOfGearsComponent ]
})
.compileComponents();
}));
beforeEach(() => {
fixture = TestBed.createComponent(ListOfGearsComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});

View File

@@ -1,25 +0,0 @@
import { ComponentFixture, TestBed, waitForAsync } from '@angular/core/testing';
import { ListOfImagesComponent } from './list-of-images.component';
describe('ListOfImagesComponent', () => {
let component: ListOfImagesComponent;
let fixture: ComponentFixture<ListOfImagesComponent>;
beforeEach(waitForAsync(() => {
TestBed.configureTestingModule({
declarations: [ ListOfImagesComponent ]
})
.compileComponents();
}));
beforeEach(() => {
fixture = TestBed.createComponent(ListOfImagesComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});

View File

@@ -1,25 +0,0 @@
import { ComponentFixture, TestBed, waitForAsync } from '@angular/core/testing';
import { ListOfJumpTypesComponent } from './list-of-jump-types.component';
describe('ListOfJumpTypesComponent', () => {
let component: ListOfJumpTypesComponent;
let fixture: ComponentFixture<ListOfJumpTypesComponent>;
beforeEach(waitForAsync(() => {
TestBed.configureTestingModule({
declarations: [ ListOfJumpTypesComponent ]
})
.compileComponents();
}));
beforeEach(() => {
fixture = TestBed.createComponent(ListOfJumpTypesComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});

View File

@@ -1,25 +0,0 @@
import { ComponentFixture, TestBed, waitForAsync } from '@angular/core/testing';
import { ListOfJumpsComponent } from './list-of-jumps.component';
describe('ListOfJumpsComponent', () => {
let component: ListOfJumpsComponent;
let fixture: ComponentFixture<ListOfJumpsComponent>;
beforeEach(waitForAsync(() => {
TestBed.configureTestingModule({
declarations: [ ListOfJumpsComponent ]
})
.compileComponents();
}));
beforeEach(() => {
fixture = TestBed.createComponent(ListOfJumpsComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});

View File

@@ -1,21 +0,0 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { ListOfTunnelFlightsComponent } from './list-of-tunnel-flights.component';
describe('ListOfTunnelFlightsComponent', () => {
let component: ListOfTunnelFlightsComponent;
let fixture: ComponentFixture<ListOfTunnelFlightsComponent>;
beforeEach(() => {
TestBed.configureTestingModule({
declarations: [ListOfTunnelFlightsComponent]
});
fixture = TestBed.createComponent(ListOfTunnelFlightsComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});

View File

@@ -2,7 +2,8 @@ import { Component, OnInit } from '@angular/core';
import { formatDate } from '@angular/common';
import { TranslateService } from '@ngx-translate/core';
import { MatTableDataSource } from '@angular/material/table';
import { ChartConfiguration, ChartData } from 'chart.js';
import { ChartConfiguration, ChartData, ChartType } from 'chart.js';
import { from, of, groupBy, mergeMap, reduce, map } from 'rxjs';
import { ServiceComm } from '../../services/service-comm.service';
import { TunnelFlightService } from "../../services/tunnel-flight.service";
@@ -19,7 +20,7 @@ export class ListOfTunnelFlightsComponent implements OnInit {
public barChartPlugins = [];
public barChartData: ChartData<'bar'>;
public barChartOptions: ChartConfiguration['options'];
public barChartType: string;
public barChartType: ChartType;
public isLoading: boolean = false;
public selectedPeriod: string;
public dataSourceTable: MatTableDataSource<TunnelFlight> = new MatTableDataSource();
@@ -64,7 +65,6 @@ export class ListOfTunnelFlightsComponent implements OnInit {
private chartConfig() {
this.barChartType = "bar";
this.barChartOptions = {
responsive: true,
maintainAspectRatio: true,
@@ -127,6 +127,7 @@ export class ListOfTunnelFlightsComponent implements OnInit {
.subscribe((data) => {
const allMonths = this.getMontsBetweenDates(beginDate, endDate)
const cumulatedTime = this.getCumulatedTimeByTypeByMonth(data, allMonths);
this.computeTimeByType(data);
this.barChartData = {
labels: allMonths,
datasets: cumulatedTime
@@ -136,6 +137,17 @@ export class ListOfTunnelFlightsComponent implements OnInit {
});
}
private computeTimeByType(stats: TunnelFlightByMonth[]) {
from(stats).pipe(
groupBy((type) => type.type, { element: (p) => p.nb }),
mergeMap((group$) =>
group$.pipe(reduce((acc, cur) => [...acc, cur], [`${group$.key}`]))
),
map((arr) => ({ id: arr[0], values: arr.slice(1) }))
)
.subscribe((p) => console.log(p));
}
private getMontsBetweenDates(beginDate: Date, endDate: Date): Array<string> {
let results: Array<string> = [];
let tmpBeginDate = new Date(beginDate.getTime());

View File

@@ -1,25 +0,0 @@
import { ComponentFixture, TestBed, waitForAsync } from '@angular/core/testing';
import { LoginUserComponent } from './login-user.component';
describe('LoginUserComponent', () => {
let component: LoginUserComponent;
let fixture: ComponentFixture<LoginUserComponent>;
beforeEach(waitForAsync(() => {
TestBed.configureTestingModule({
declarations: [ LoginUserComponent ]
})
.compileComponents();
}));
beforeEach(() => {
fixture = TestBed.createComponent(LoginUserComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});

View File

@@ -1,25 +0,0 @@
import { ComponentFixture, TestBed, waitForAsync } from '@angular/core/testing';
import { LoginComponent } from './login.component';
describe('LoginComponent', () => {
let component: LoginComponent;
let fixture: ComponentFixture<LoginComponent>;
beforeEach(waitForAsync(() => {
TestBed.configureTestingModule({
declarations: [ LoginComponent ]
})
.compileComponents();
}));
beforeEach(() => {
fixture = TestBed.createComponent(LoginComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});

View File

@@ -1,25 +0,0 @@
import { ComponentFixture, TestBed, waitForAsync } from '@angular/core/testing';
import { NewAircraftComponent } from './new-aircraft.component';
describe('NewAircraftComponent', () => {
let component: NewAircraftComponent;
let fixture: ComponentFixture<NewAircraftComponent>;
beforeEach(waitForAsync(() => {
TestBed.configureTestingModule({
declarations: [ NewAircraftComponent ]
})
.compileComponents();
}));
beforeEach(() => {
fixture = TestBed.createComponent(NewAircraftComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});

View File

@@ -1,25 +0,0 @@
import { ComponentFixture, TestBed, waitForAsync } from '@angular/core/testing';
import { NewDropZoneComponent } from './new-drop-zone.component';
describe('NewDropZoneComponent', () => {
let component: NewDropZoneComponent;
let fixture: ComponentFixture<NewDropZoneComponent>;
beforeEach(waitForAsync(() => {
TestBed.configureTestingModule({
declarations: [ NewDropZoneComponent ]
})
.compileComponents();
}));
beforeEach(() => {
fixture = TestBed.createComponent(NewDropZoneComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});

View File

@@ -1,25 +0,0 @@
import { ComponentFixture, TestBed, waitForAsync } from '@angular/core/testing';
import { NewGearComponent } from './new-gear.component';
describe('NewGearComponent', () => {
let component: NewGearComponent;
let fixture: ComponentFixture<NewGearComponent>;
beforeEach(waitForAsync(() => {
TestBed.configureTestingModule({
declarations: [ NewGearComponent ]
})
.compileComponents();
}));
beforeEach(() => {
fixture = TestBed.createComponent(NewGearComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});

View File

@@ -1,25 +0,0 @@
import { ComponentFixture, TestBed, waitForAsync } from '@angular/core/testing';
import { NewJumpTypeComponent } from './new-jump-type.component';
describe('NewJumpTypeComponent', () => {
let component: NewJumpTypeComponent;
let fixture: ComponentFixture<NewJumpTypeComponent>;
beforeEach(waitForAsync(() => {
TestBed.configureTestingModule({
declarations: [ NewJumpTypeComponent ]
})
.compileComponents();
}));
beforeEach(() => {
fixture = TestBed.createComponent(NewJumpTypeComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});

View File

@@ -1,25 +0,0 @@
import { ComponentFixture, TestBed, waitForAsync } from '@angular/core/testing';
import { NewJumpComponent } from './new-jump.component';
describe('NewJumpComponent', () => {
let component: NewJumpComponent;
let fixture: ComponentFixture<NewJumpComponent>;
beforeEach(waitForAsync(() => {
TestBed.configureTestingModule({
declarations: [ NewJumpComponent ]
})
.compileComponents();
}));
beforeEach(() => {
fixture = TestBed.createComponent(NewJumpComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});

View File

@@ -1,21 +0,0 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { NewTunnelFlightComponent } from './new-tunnel-flight.component';
describe('NewTunnelFlightComponent', () => {
let component: NewTunnelFlightComponent;
let fixture: ComponentFixture<NewTunnelFlightComponent>;
beforeEach(() => {
TestBed.configureTestingModule({
declarations: [NewTunnelFlightComponent]
});
fixture = TestBed.createComponent(NewTunnelFlightComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});

View File

@@ -1,25 +0,0 @@
import { ComponentFixture, TestBed, waitForAsync } from '@angular/core/testing';
import { SummaryComponent } from './summary.component';
describe('SummaryComponent', () => {
let component: SummaryComponent;
let fixture: ComponentFixture<SummaryComponent>;
beforeEach(waitForAsync(() => {
TestBed.configureTestingModule({
declarations: [ SummaryComponent ]
})
.compileComponents();
}));
beforeEach(() => {
fixture = TestBed.createComponent(SummaryComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});

View File

@@ -1,25 +0,0 @@
import { ComponentFixture, TestBed, waitForAsync } from '@angular/core/testing';
import { UserProfileComponent } from './user-profile.component';
describe('UserProfileComponent', () => {
let component: UserProfileComponent;
let fixture: ComponentFixture<UserProfileComponent>;
beforeEach(waitForAsync(() => {
TestBed.configureTestingModule({
declarations: [ UserProfileComponent ]
})
.compileComponents();
}));
beforeEach(() => {
fixture = TestBed.createComponent(UserProfileComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});