Fix sur la pagination et fix sur le tri par date

This commit is contained in:
Sébastien André
2019-11-28 14:53:35 +01:00
parent 5522a534b2
commit 54f5398af1
16 changed files with 113 additions and 72 deletions

View File

@@ -1,3 +1,9 @@
table { table {
width: 100%; width: 100%;
} }
.table-container {
position: relative;
height: 600px;
overflow: auto;
}

View File

@@ -1,4 +1,4 @@
<div *ngIf="dataSourceTable != null else loading"> <div *ngIf="dataSourceTable != null else loading" class="table-container">
<table mat-table [dataSource]="dataSourceTable"> <table mat-table [dataSource]="dataSourceTable">
<ng-container matColumnDef="id"> <ng-container matColumnDef="id">
<th mat-header-cell *matHeaderCellDef>ID</th> <th mat-header-cell *matHeaderCellDef>ID</th>
@@ -13,6 +13,6 @@
<tr mat-header-row *matHeaderRowDef="displayedColumns"></tr> <tr mat-header-row *matHeaderRowDef="displayedColumns"></tr>
<tr mat-row *matRowDef="let row; columns: displayedColumns;"></tr> <tr mat-row *matRowDef="let row; columns: displayedColumns;"></tr>
</table> </table>
<mat-paginator [length]="resultsLength" [pageSize]="20"></mat-paginator>
</div> </div>
<mat-paginator [length]="resultsLength" [pageSize]="5"></mat-paginator>
<ng-template #loading>Waiting...</ng-template> <ng-template #loading>Waiting...</ng-template>

View File

@@ -1,18 +1,18 @@
import { Component, OnInit, ViewChild } from "@angular/core"; import { Component, OnInit, ViewChild } from '@angular/core';
import { MatPaginator } from "@angular/material/paginator"; import { MatPaginator } from '@angular/material/paginator';
import { MatTableDataSource } from "@angular/material/table"; import { MatTableDataSource } from '@angular/material/table';
import { AircraftResp } from "../../models/aircraft"; import { AircraftResp } from '../../models/aircraft';
import { ServiceApiGet } from "../../services/service-api-get.service"; import { ServiceApiGet } from '../../services/service-api-get.service';
import { ServiceComm } from "../../services/service-comm.service"; import { ServiceComm } from '../../services/service-comm.service';
@Component({ @Component({
selector: "app-list-of-aircrafts", selector: 'app-list-of-aircrafts',
templateUrl: "./list-of-aircrafts.component.html", templateUrl: './list-of-aircrafts.component.html',
styleUrls: ["./list-of-aircrafts.component.css"] styleUrls: ['./list-of-aircrafts.component.css']
}) })
export class ListOfAircraftsComponent implements OnInit { export class ListOfAircraftsComponent implements OnInit {
public displayedColumns: Array<string> = ["id", "name"]; public displayedColumns: Array<string> = ['id', 'name'];
public dataSourceTable; public dataSourceTable;
public resultsLength = 0; public resultsLength = 0;
@ViewChild(MatPaginator, { static: true }) paginator: MatPaginator; @ViewChild(MatPaginator, { static: true }) paginator: MatPaginator;
@@ -23,12 +23,13 @@ export class ListOfAircraftsComponent implements OnInit {
) { } ) { }
ngOnInit() { ngOnInit() {
this.serviceComm.updatedComponentTitle("List of aircrafts"); this.serviceComm.updatedComponentTitle('List of aircrafts');
this.getListOfAircrafts(); this.getListOfAircrafts();
} }
getListOfAircrafts() { getListOfAircrafts() {
this.serviceApi.getListOfAircrafts().subscribe(data => { this.serviceApi.getListOfAircrafts().subscribe(data => {
data.sort((a, b) => (b.name < a.name) ? 1 : -1);
this.dataSourceTable = new MatTableDataSource<AircraftResp>(data); this.dataSourceTable = new MatTableDataSource<AircraftResp>(data);
this.dataSourceTable.paginator = this.paginator; this.dataSourceTable.paginator = this.paginator;
this.resultsLength = data.length; this.resultsLength = data.length;

View File

@@ -1,3 +1,9 @@
table { table {
width: 100%; width: 100%;
} }
.table-container {
position: relative;
height: 600px;
overflow: auto;
}

View File

@@ -1,4 +1,4 @@
<div *ngIf="dataSourceTable != null else loading"> <div *ngIf="dataSourceTable != null else loading" class="table-container">
<table mat-table [dataSource]="dataSourceTable"> <table mat-table [dataSource]="dataSourceTable">
<ng-container matColumnDef="isfavorite"> <ng-container matColumnDef="isfavorite">
<th mat-header-cell *matHeaderCellDef></th> <th mat-header-cell *matHeaderCellDef></th>
@@ -45,6 +45,6 @@
<tr mat-header-row *matHeaderRowDef="displayedColumns"></tr> <tr mat-header-row *matHeaderRowDef="displayedColumns"></tr>
<tr mat-row *matRowDef="let row; columns: displayedColumns;"></tr> <tr mat-row *matRowDef="let row; columns: displayedColumns;"></tr>
</table> </table>
<mat-paginator [length]="resultsLength" [pageSize]="20"></mat-paginator>
</div> </div>
<mat-paginator [length]="resultsLength" [pageSize]="20"></mat-paginator>
<ng-template #loading>Waiting...</ng-template> <ng-template #loading>Waiting...</ng-template>

View File

@@ -1,3 +1,9 @@
table { table {
width: 100%; width: 100%;
} }
.table-container {
position: relative;
height: 600px;
overflow: auto;
}

View File

@@ -1,4 +1,4 @@
<div *ngIf="dataSourceTable != null else loading"> <div *ngIf="dataSourceTable != null else loading" class="table-container">
<table mat-table [dataSource]="dataSourceTable"> <table mat-table [dataSource]="dataSourceTable">
<ng-container matColumnDef="id"> <ng-container matColumnDef="id">
<th mat-header-cell *matHeaderCellDef>ID</th> <th mat-header-cell *matHeaderCellDef>ID</th>
@@ -35,6 +35,6 @@
<tr mat-header-row *matHeaderRowDef="displayedColumns"></tr> <tr mat-header-row *matHeaderRowDef="displayedColumns"></tr>
<tr mat-row *matRowDef="let row; columns: displayedColumns;"></tr> <tr mat-row *matRowDef="let row; columns: displayedColumns;"></tr>
</table> </table>
<mat-paginator [length]="resultsLength" [pageSize]="10"></mat-paginator>
</div> </div>
<mat-paginator [length]="resultsLength" [pageSize]="10"></mat-paginator>
<ng-template #loading>Waiting...</ng-template> <ng-template #loading>Waiting...</ng-template>

View File

@@ -1,24 +1,24 @@
import { Component, OnInit, ViewChild } from "@angular/core"; import { Component, OnInit, ViewChild } from '@angular/core';
import { MatPaginator, MatTableDataSource } from "@angular/material"; import { MatPaginator, MatTableDataSource } from '@angular/material';
import { ServiceApiGet } from "../../services/service-api-get.service"; import { ServiceApiGet } from '../../services/service-api-get.service';
import { ServiceComm } from "../../services/service-comm.service"; import { ServiceComm } from '../../services/service-comm.service';
import { GearResp } from "../../models/gear"; import { GearResp } from '../../models/gear';
@Component({ @Component({
selector: "app-list-of-gears", selector: 'app-list-of-gears',
templateUrl: "./list-of-gears.component.html", templateUrl: './list-of-gears.component.html',
styleUrls: ["./list-of-gears.component.css"] styleUrls: ['./list-of-gears.component.css']
}) })
export class ListOfGearsComponent implements OnInit { export class ListOfGearsComponent implements OnInit {
public displayedColumns: Array<string> = [ public displayedColumns: Array<string> = [
"id", 'id',
"name", 'name',
"latitude", 'latitude',
"longitude", 'longitude',
"address", 'address',
"email", 'email',
"type" 'type'
]; ];
public dataSourceTable; public dataSourceTable;
public resultsLength = 0; public resultsLength = 0;
@@ -30,12 +30,13 @@ export class ListOfGearsComponent implements OnInit {
) { } ) { }
ngOnInit() { ngOnInit() {
this.serviceComm.updatedComponentTitle("List of gears"); this.serviceComm.updatedComponentTitle('List of gears');
this.getListOfGears(); this.getListOfGears();
} }
getListOfGears() { getListOfGears() {
this.serviceApi.getListOfGears().subscribe(data => { this.serviceApi.getListOfGears().subscribe(data => {
//data.sort((a, b) => (b.isFavorite ? 1 : 0) - (a.isFavorite ? 1 : 0));
this.dataSourceTable = new MatTableDataSource<GearResp>(data); this.dataSourceTable = new MatTableDataSource<GearResp>(data);
this.dataSourceTable.paginator = this.paginator; this.dataSourceTable.paginator = this.paginator;
this.resultsLength = data.length; this.resultsLength = data.length;

View File

@@ -1,3 +1,9 @@
table { table {
width: 100%; width: 100%;
} }
.table-container {
position: relative;
height: 600px;
overflow: auto;
}

View File

@@ -1,4 +1,4 @@
<div *ngIf="dataSourceTable != null else loading"> <div *ngIf="dataSourceTable != null else loading" class="table-container">
<table mat-table [dataSource]="dataSourceTable"> <table mat-table [dataSource]="dataSourceTable">
<ng-container matColumnDef="id"> <ng-container matColumnDef="id">
<th mat-header-cell *matHeaderCellDef>ID</th> <th mat-header-cell *matHeaderCellDef>ID</th>
@@ -13,6 +13,6 @@
<tr mat-header-row *matHeaderRowDef="displayedColumns"></tr> <tr mat-header-row *matHeaderRowDef="displayedColumns"></tr>
<tr mat-row *matRowDef="let row; columns: displayedColumns;"></tr> <tr mat-row *matRowDef="let row; columns: displayedColumns;"></tr>
</table> </table>
<mat-paginator [length]="resultsLength" [pageSize]="20"></mat-paginator>
</div> </div>
<mat-paginator [length]="resultsLength" [pageSize]="20"></mat-paginator>
<ng-template #loading>Waiting...</ng-template> <ng-template #loading>Waiting...</ng-template>

View File

@@ -1,18 +1,18 @@
import { Component, OnInit, ViewChild } from "@angular/core"; import { Component, OnInit, ViewChild } from '@angular/core';
import { MatPaginator } from "@angular/material/paginator"; import { MatPaginator } from '@angular/material/paginator';
import { MatTableDataSource } from "@angular/material/table"; import { MatTableDataSource } from '@angular/material/table';
import { JumpTypeResp } from "../../models/jumpType"; import { JumpTypeResp } from '../../models/jumpType';
import { ServiceApiGet } from "../../services/service-api-get.service"; import { ServiceApiGet } from '../../services/service-api-get.service';
import { ServiceComm } from "../../services/service-comm.service"; import { ServiceComm } from '../../services/service-comm.service';
@Component({ @Component({
selector: "app-list-of-jump-types", selector: 'app-list-of-jump-types',
templateUrl: "./list-of-jump-types.component.html", templateUrl: './list-of-jump-types.component.html',
styleUrls: ["./list-of-jump-types.component.css"] styleUrls: ['./list-of-jump-types.component.css']
}) })
export class ListOfJumpTypesComponent implements OnInit { export class ListOfJumpTypesComponent implements OnInit {
public displayedColumns: Array<string> = ["id", "name"]; public displayedColumns: Array<string> = ['id', 'name'];
public dataSourceTable; public dataSourceTable;
public resultsLength = 0; public resultsLength = 0;
@ViewChild(MatPaginator, { static: true }) paginator: MatPaginator; @ViewChild(MatPaginator, { static: true }) paginator: MatPaginator;
@@ -23,12 +23,13 @@ export class ListOfJumpTypesComponent implements OnInit {
) { } ) { }
ngOnInit() { ngOnInit() {
this.serviceComm.updatedComponentTitle("List of jump types"); this.serviceComm.updatedComponentTitle('List of jump types');
this.getListOfJumpTypes(); this.getListOfJumpTypes();
} }
getListOfJumpTypes() { getListOfJumpTypes() {
this.serviceApi.getListOfJumpTypes().subscribe(data => { this.serviceApi.getListOfJumpTypes().subscribe(data => {
data.sort((a, b) => (b.name < a.name) ? 1 : -1);
this.dataSourceTable = new MatTableDataSource<JumpTypeResp>(data); this.dataSourceTable = new MatTableDataSource<JumpTypeResp>(data);
this.dataSourceTable.paginator = this.paginator; this.dataSourceTable.paginator = this.paginator;
this.resultsLength = data.length; this.resultsLength = data.length;

View File

@@ -1,3 +1,9 @@
table { table {
width: 100%; width: 100%;
} }
.table-container {
position: relative;
height: 600px;
overflow: auto;
}

View File

@@ -1,4 +1,4 @@
<div *ngIf="dataSourceTable != null else loading"> <div *ngIf="dataSourceTable != null else loading" class="table-container">
<table mat-table [dataSource]="dataSourceTable"> <table mat-table [dataSource]="dataSourceTable">
<ng-container matColumnDef="id"> <ng-container matColumnDef="id">
<th mat-header-cell *matHeaderCellDef>ID</th> <th mat-header-cell *matHeaderCellDef>ID</th>
@@ -30,6 +30,6 @@
<tr mat-header-row *matHeaderRowDef="displayedColumns"></tr> <tr mat-header-row *matHeaderRowDef="displayedColumns"></tr>
<tr mat-row *matRowDef="let row; columns: displayedColumns;"></tr> <tr mat-row *matRowDef="let row; columns: displayedColumns;"></tr>
</table> </table>
<mat-paginator [length]="resultsLength" [pageSize]="10"></mat-paginator>
</div> </div>
<mat-paginator [length]="resultsLength" [pageSize]="10"></mat-paginator>
<ng-template #loading>Waiting...</ng-template> <ng-template #loading>Waiting...</ng-template>

View File

@@ -1,26 +1,26 @@
import { Component, OnInit, ViewChild } from "@angular/core"; import { Component, OnInit, ViewChild } from '@angular/core';
import { MatPaginator } from "@angular/material/paginator"; import { MatPaginator } from '@angular/material/paginator';
import { MatTableDataSource } from "@angular/material/table"; import { MatTableDataSource } from '@angular/material/table';
import { Observable } from "rxjs"; import { Observable } from 'rxjs';
import { JumpResp } from "../../models/jump"; import { JumpResp } from '../../models/jump';
import { ServiceApiGet } from "../../services/service-api-get.service"; import { ServiceApiGet } from '../../services/service-api-get.service';
import { ServiceComm } from "../../services/service-comm.service"; import { ServiceComm } from '../../services/service-comm.service';
@Component({ @Component({
selector: "app-list-of-jumps", selector: 'app-list-of-jumps',
templateUrl: "./list-of-jumps.component.html", templateUrl: './list-of-jumps.component.html',
styleUrls: ["./list-of-jumps.component.css"] styleUrls: ['./list-of-jumps.component.css']
}) })
export class ListOfJumpsComponent implements OnInit { export class ListOfJumpsComponent implements OnInit {
public listOfJumps: Observable<Array<JumpResp>>; public listOfJumps: Observable<Array<JumpResp>>;
public displayedColumns: Array<string> = [ public displayedColumns: Array<string> = [
"id", 'id',
"jumpDate", 'jumpDate',
"jumpType", 'jumpType',
"aircraft", 'aircraft',
"dropZone", 'dropZone',
"gear" 'gear'
]; ];
public dataSourceTable; public dataSourceTable;
public resultsLength = 0; public resultsLength = 0;
@@ -32,13 +32,14 @@ export class ListOfJumpsComponent implements OnInit {
) { } ) { }
ngOnInit() { ngOnInit() {
this.serviceComm.updatedComponentTitle("List of jumps"); this.serviceComm.updatedComponentTitle('List of jumps');
this.getListOfJumps(); this.getListOfJumps();
} }
getListOfJumps() { getListOfJumps() {
this.listOfJumps = this.serviceApi.getListOfJumps(); this.listOfJumps = this.serviceApi.getListOfJumps();
this.listOfJumps.subscribe(data => { this.listOfJumps.subscribe(data => {
data.sort((a, b) => b.jumpDate.getTime() - a.jumpDate.getTime());
this.dataSourceTable = new MatTableDataSource<JumpResp>(data); this.dataSourceTable = new MatTableDataSource<JumpResp>(data);
this.dataSourceTable.paginator = this.paginator; this.dataSourceTable.paginator = this.paginator;
this.resultsLength = data.length; this.resultsLength = data.length;

View File

@@ -1,7 +1,7 @@
import { GearResp } from "./gear"; import { GearResp } from './gear';
import { DropZoneResp } from "./dropzone"; import { DropZoneResp } from './dropzone';
import { AircraftResp } from "./aircraft"; import { AircraftResp } from './aircraft';
import { JumpTypeResp } from "./jumpType"; import { JumpTypeResp } from './jumpType';
export class JumpReq { export class JumpReq {
constructor(data: any) { constructor(data: any) {
@@ -23,6 +23,7 @@ export class JumpReq {
export class JumpResp { export class JumpResp {
constructor(data: any) { constructor(data: any) {
Object.assign(this, data); Object.assign(this, data);
this.jumpDate = new Date(data.jumpDate);
} }
public id: number; public id: number;

View File

@@ -42,7 +42,13 @@ export class ServiceApiGet {
public getListOfJumps(): Observable<Array<JumpResp>> { public getListOfJumps(): Observable<Array<JumpResp>> {
return this.http.get<Array<JumpResp>>(`${environment.urlApi}/api/Jump`, { return this.http.get<Array<JumpResp>>(`${environment.urlApi}/api/Jump`, {
headers: this.headers headers: this.headers
}); })
.pipe(
map(response => {
const details = response.map(data => new JumpResp(data));
return details;
})
);
} }
public getListOfAircrafts(): Observable<Array<AircraftResp>> { public getListOfAircrafts(): Observable<Array<AircraftResp>> {