WIP: DataSets Module
This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
import { HttpClient } from '@angular/common/http';
|
||||
import { Component, OnInit, ViewChild } from '@angular/core';
|
||||
import { MatPaginator } from '@angular/material/paginator';
|
||||
import { MatSort } from '@angular/material/sort';
|
||||
import { MatTableDataSource } from '@angular/material/table';
|
||||
import { DataSet } from 'src/app/models/dataSet.model';
|
||||
|
||||
@Component({
|
||||
selector: 'app-data-sets-list',
|
||||
templateUrl: './data-sets-list.component.html',
|
||||
styleUrls: ['./data-sets-list.component.scss']
|
||||
})
|
||||
export class DataSetsListComponent implements OnInit {
|
||||
displayedColumns = ['number', 'name'];
|
||||
dataSource!: MatTableDataSource<DataSet>;
|
||||
|
||||
@ViewChild(MatPaginator) paginator!: MatPaginator;
|
||||
@ViewChild(MatSort) sort!: MatSort;
|
||||
|
||||
constructor(
|
||||
private _http: HttpClient
|
||||
) { }
|
||||
|
||||
async ngOnInit() {
|
||||
this.dataSource = new MatTableDataSource(await DataSet.getList(this._http));
|
||||
this.dataSource.paginator = this.paginator;
|
||||
this.dataSource.sort = this.sort;
|
||||
}
|
||||
|
||||
applyFilter(event: Event) {
|
||||
const filterValue = (event.target as HTMLInputElement).value;
|
||||
this.dataSource.filter = filterValue.trim().toLowerCase();
|
||||
}
|
||||
trackByUid(index : number, item : DataSet) {
|
||||
return item.id;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user