1
|
import {AfterViewInit, Component, Input, OnInit, ViewChild} from '@angular/core';
|
2
|
import { MatPaginator } from '@angular/material/paginator';
|
3
|
import { MatSort } from '@angular/material/sort';
|
4
|
import { MatTable } from '@angular/material/table';
|
5
|
import { SearchPaginatorDataSource } from './search-paginator-datasource';
|
6
|
import { TextRegion } from '../../../../model/parts/TextRegion';
|
7
|
import { SearchResponse } from '../../../../model/SearchResponse';
|
8
|
|
9
|
@Component({
|
10
|
selector: 'app-search-paginator',
|
11
|
templateUrl: './search-paginator.component.html',
|
12
|
styleUrls: ['./search-paginator.component.css']
|
13
|
})
|
14
|
export class SearchPaginatorComponent implements AfterViewInit, OnInit {
|
15
|
@ViewChild(MatPaginator) paginator: MatPaginator;
|
16
|
@ViewChild(MatSort) sort: MatSort;
|
17
|
@ViewChild(MatTable) table: MatTable<TextRegion>;
|
18
|
@Input() inputData: SearchResponse;
|
19
|
dataSource: SearchPaginatorDataSource;
|
20
|
|
21
|
/** Columns displayed in the table. Columns IDs can be added, removed, or reordered. */
|
22
|
displayedColumns = ['image'];
|
23
|
|
24
|
ngOnInit() {
|
25
|
this.dataSource = new SearchPaginatorDataSource();
|
26
|
this.dataSource.data = this.inputData.textRegions;
|
27
|
}
|
28
|
|
29
|
ngAfterViewInit() {
|
30
|
this.dataSource.sort = this.sort;
|
31
|
this.dataSource.paginator = this.paginator;
|
32
|
this.table.dataSource = this.dataSource;
|
33
|
}
|
34
|
}
|