import { Component, OnInit, ViewChildren, QueryList, Input } from '@angular/core'; import { FeatureCollection, Feature } from '../../models/layer-type'; import { SortableHeaderDirective, SortEvent } from 'src/app/directives/sortable-header.directive'; import { Observable } from 'rxjs'; import { TableViewDataService } from 'src/app/services/table-view-data.service'; import { Structure } from 'src/app/models/structure'; @Component({ selector: 'app-table-view', templateUrl: './table-view.component.html', styleUrls: ['./table-view.component.css'], }) export class TableViewComponent implements OnInit { /** */ public structures$: Observable; /** */ public featureCollection: FeatureCollection; /** */ public uuid: string; /** Pour la pagination */ public features$: Observable; public total$: Observable; /** Pour le tri */ @ViewChildren(SortableHeaderDirective) headers: QueryList; /** */ constructor( public tableViewData: TableViewDataService, ) { this.features$ = this.tableViewData.getFeatures$(); this.structures$ = this.tableViewData.getStructures$(); this.total$ = this.tableViewData.getTotal$(); } /** */ ngOnInit(): void { this.tableViewData.searchFromUrlParam(); } onSort({column, direction}: SortEvent): void { // resetting other headers this.headers.forEach(header => { if (header.appSortable !== column) { header.direction = ''; } }); this.tableViewData.sortColumn = column; this.tableViewData.sortDirection = direction; } }