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 {
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">
<ng-container matColumnDef="id">
<th mat-header-cell *matHeaderCellDef>ID</th>
@@ -35,6 +35,6 @@
<tr mat-header-row *matHeaderRowDef="displayedColumns"></tr>
<tr mat-row *matRowDef="let row; columns: displayedColumns;"></tr>
</table>
<mat-paginator [length]="resultsLength" [pageSize]="10"></mat-paginator>
</div>
<mat-paginator [length]="resultsLength" [pageSize]="10"></mat-paginator>
<ng-template #loading>Waiting...</ng-template>

View File

@@ -1,24 +1,24 @@
import { Component, OnInit, ViewChild } from "@angular/core";
import { MatPaginator, MatTableDataSource } from "@angular/material";
import { Component, OnInit, ViewChild } from '@angular/core';
import { MatPaginator, MatTableDataSource } from '@angular/material';
import { ServiceApiGet } from "../../services/service-api-get.service";
import { ServiceComm } from "../../services/service-comm.service";
import { GearResp } from "../../models/gear";
import { ServiceApiGet } from '../../services/service-api-get.service';
import { ServiceComm } from '../../services/service-comm.service';
import { GearResp } from '../../models/gear';
@Component({
selector: "app-list-of-gears",
templateUrl: "./list-of-gears.component.html",
styleUrls: ["./list-of-gears.component.css"]
selector: 'app-list-of-gears',
templateUrl: './list-of-gears.component.html',
styleUrls: ['./list-of-gears.component.css']
})
export class ListOfGearsComponent implements OnInit {
public displayedColumns: Array<string> = [
"id",
"name",
"latitude",
"longitude",
"address",
"email",
"type"
'id',
'name',
'latitude',
'longitude',
'address',
'email',
'type'
];
public dataSourceTable;
public resultsLength = 0;
@@ -27,15 +27,16 @@ export class ListOfGearsComponent implements OnInit {
constructor(
private serviceApi: ServiceApiGet,
private serviceComm: ServiceComm
) {}
) { }
ngOnInit() {
this.serviceComm.updatedComponentTitle("List of gears");
this.serviceComm.updatedComponentTitle('List of gears');
this.getListOfGears();
}
getListOfGears() {
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.paginator = this.paginator;
this.resultsLength = data.length;