Update names part 2
This commit is contained in:
@@ -0,0 +1,45 @@
|
||||
<div class="list-container mat-elevation-z8">
|
||||
<div class="list-header">
|
||||
<mat-grid-list cols="10" rowHeight="60">
|
||||
<mat-grid-tile>
|
||||
<!--
|
||||
<button mat-button routerLink="Edit/new">
|
||||
Dodaj
|
||||
</button>
|
||||
-->
|
||||
</mat-grid-tile>
|
||||
<mat-grid-tile [colspan]="8">
|
||||
<mat-form-field class="searchListInput">
|
||||
<mat-label>Filtruj</mat-label>
|
||||
<input matInput (keyup)="applyFilter($event)">
|
||||
</mat-form-field>
|
||||
</mat-grid-tile>
|
||||
</mat-grid-list>
|
||||
</div>
|
||||
|
||||
<mat-table #table [dataSource]="dataSource" [trackBy]="trackByUid" matSort class="animate">
|
||||
|
||||
<ng-container matColumnDef="number">
|
||||
<mat-header-cell *matHeaderCellDef mat-sort-header>Numer</mat-header-cell>
|
||||
<mat-cell *matCellDef="let item">{{item.number}}</mat-cell>
|
||||
</ng-container>
|
||||
|
||||
<ng-container matColumnDef="name">
|
||||
<mat-header-cell *matHeaderCellDef mat-sort-header>Nazwa</mat-header-cell>
|
||||
<mat-cell *matCellDef="let item">{{item.name}}</mat-cell>
|
||||
</ng-container>
|
||||
|
||||
<ng-container matColumnDef="source">
|
||||
<mat-header-cell *matHeaderCellDef mat-sort-header>Źródło</mat-header-cell>
|
||||
<mat-cell *matCellDef="let item">{{item.source}}</mat-cell>
|
||||
</ng-container>
|
||||
|
||||
<mat-header-row *matHeaderRowDef="displayedColumns"></mat-header-row>
|
||||
<mat-row *matRowDef="let item; columns: displayedColumns;" [routerLink]="['Detail/', item.id]"></mat-row>
|
||||
</mat-table>
|
||||
<mat-paginator #paginator
|
||||
[pageSize]="10"
|
||||
[pageSizeOptions]="[5, 10, 20]">
|
||||
</mat-paginator>
|
||||
</div>
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
@import "../../../main-view/main-view.component.scss";
|
||||
@@ -0,0 +1,38 @@
|
||||
import { HttpClient } from '@angular/common/http';
|
||||
import { Component, OnInit, ViewChild } from '@angular/core';
|
||||
import { MatPaginator } from '@angular/material/paginator';
|
||||
import { MatSort, MatSortable } from '@angular/material/sort';
|
||||
import { MatTableDataSource } from '@angular/material/table';
|
||||
import { Layer } from 'src/app/models/layer.model';
|
||||
|
||||
@Component({
|
||||
selector: 'diunaBI-layers-list',
|
||||
templateUrl: './layers-list.component.html',
|
||||
styleUrls: ['./layers-list.component.scss']
|
||||
})
|
||||
export class LayersListComponent implements OnInit {
|
||||
displayedColumns = ['number', 'name', 'source'];
|
||||
dataSource!: MatTableDataSource<Layer>;
|
||||
|
||||
@ViewChild(MatPaginator) paginator!: MatPaginator;
|
||||
@ViewChild(MatSort) sort!: MatSort;
|
||||
|
||||
constructor(
|
||||
private _http: HttpClient
|
||||
) { }
|
||||
|
||||
async ngOnInit() {
|
||||
this.dataSource = new MatTableDataSource(await Layer.getList(this._http));
|
||||
this.dataSource.paginator = this.paginator;
|
||||
this.dataSource.sort = this.sort;
|
||||
this.dataSource.sort.sort({ id: 'number', start: 'desc' } as MatSortable);
|
||||
}
|
||||
|
||||
applyFilter(event: Event) {
|
||||
const filterValue = (event.target as HTMLInputElement).value;
|
||||
this.dataSource.filter = filterValue.trim().toLowerCase();
|
||||
}
|
||||
trackByUid(index : number, item : Layer) {
|
||||
return item.id;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user