|
|
@@ -5,7 +5,8 @@ import {MatTableDataSource, MatTableModule} from "@angular/material/table"; |
|
|
import {ActivatedRoute, RouterLink, RouterLinkActive} from "@angular/router"; |
|
|
import {ActivatedRoute, RouterLink, RouterLinkActive} from "@angular/router"; |
|
|
import {Subscription} from "rxjs"; |
|
|
import {Subscription} from "rxjs"; |
|
|
import {PartnerJsonld, PartnerService} from "@app/core/api/v1"; |
|
|
import {PartnerJsonld, PartnerService} from "@app/core/api/v1"; |
|
|
import {MatPaginator, MatPaginatorIntl, MatPaginatorModule} from "@angular/material/paginator"; |
|
|
|
|
|
|
|
|
import {MatPaginator, MatPaginatorIntl, MatPaginatorModule, PageEvent} from "@angular/material/paginator"; |
|
|
|
|
|
import {NumberInput} from "@angular/cdk/coercion"; |
|
|
|
|
|
|
|
|
@Component({ |
|
|
@Component({ |
|
|
selector: 'app-partners', |
|
|
selector: 'app-partners', |
|
|
@@ -19,11 +20,17 @@ export class PartnersComponent implements OnInit, AfterViewInit { |
|
|
@ViewChild(MatPaginator) paginator: MatPaginator; |
|
|
@ViewChild(MatPaginator) paginator: MatPaginator; |
|
|
|
|
|
|
|
|
protected partnersSub: Subscription; |
|
|
protected partnersSub: Subscription; |
|
|
protected partners: Array<PartnerJsonld> = []; |
|
|
|
|
|
|
|
|
protected partners: Array<PartnerJsonld>; |
|
|
|
|
|
protected length: number; |
|
|
|
|
|
protected pageEvent: PageEvent; |
|
|
|
|
|
protected pageSize: NumberInput; |
|
|
|
|
|
protected pageIndex: NumberInput; |
|
|
|
|
|
protected currentPageIndex: number; |
|
|
|
|
|
protected pageSizeOptions = [10]; |
|
|
|
|
|
|
|
|
dataType!: string; |
|
|
|
|
|
displayedColumns: string[] = ['pos', 'name', 'address', 'website']; |
|
|
|
|
|
dataSource = new MatTableDataSource(this.partners); |
|
|
|
|
|
|
|
|
protected dataType!: string; |
|
|
|
|
|
protected displayedColumns: string[]; |
|
|
|
|
|
protected dataSource; |
|
|
|
|
|
|
|
|
constructor( |
|
|
constructor( |
|
|
private _liveAnnouncer: LiveAnnouncer, |
|
|
private _liveAnnouncer: LiveAnnouncer, |
|
|
@@ -35,20 +42,21 @@ export class PartnersComponent implements OnInit, AfterViewInit { |
|
|
|
|
|
|
|
|
this.partnersSub = new Subscription(); |
|
|
this.partnersSub = new Subscription(); |
|
|
this.partners = []; |
|
|
this.partners = []; |
|
|
|
|
|
this.displayedColumns = ['pos', 'name', 'address', 'website']; |
|
|
|
|
|
|
|
|
|
|
|
this.dataSource = new MatTableDataSource(this.partners); |
|
|
|
|
|
this.pageEvent = new PageEvent(); |
|
|
|
|
|
this.length = 0; |
|
|
|
|
|
this.pageSize = 10; |
|
|
|
|
|
this.pageIndex = 0; |
|
|
|
|
|
this.currentPageIndex = 1; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
ngOnInit() { |
|
|
ngOnInit() { |
|
|
this.dataType = this.route.snapshot.data['dataType']; |
|
|
this.dataType = this.route.snapshot.data['dataType']; |
|
|
console.log('Data Type:', this.dataType); |
|
|
console.log('Data Type:', this.dataType); |
|
|
|
|
|
|
|
|
this.partnersSub = this.partnerService.partnersGetCollection(1, "asc", this.dataType).subscribe( |
|
|
|
|
|
data => { |
|
|
|
|
|
this.partners = data["hydra:member"]; |
|
|
|
|
|
|
|
|
|
|
|
this.dataSource.data = this.partners; |
|
|
|
|
|
console.log(this.partners); |
|
|
|
|
|
} |
|
|
|
|
|
); |
|
|
|
|
|
|
|
|
this.getData(); |
|
|
console.log(this.dataSource.data); |
|
|
console.log(this.dataSource.data); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
@@ -70,4 +78,38 @@ export class PartnersComponent implements OnInit, AfterViewInit { |
|
|
this._liveAnnouncer.announce('Sorting cleared'); |
|
|
this._liveAnnouncer.announce('Sorting cleared'); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
getData() |
|
|
|
|
|
{ |
|
|
|
|
|
this.partnersSub = this.partnerService.partnersGetCollection(this.currentPageIndex, "asc", this.dataType).subscribe( |
|
|
|
|
|
data => { |
|
|
|
|
|
this.partners = data["hydra:member"]; |
|
|
|
|
|
this.length = Number(data["hydra:totalItems"]); |
|
|
|
|
|
console.log('GET DATA:'); |
|
|
|
|
|
console.log('length:' + this.length); |
|
|
|
|
|
console.log('page index:' + this.pageIndex); |
|
|
|
|
|
console.log('page size:' + this.pageSize); |
|
|
|
|
|
this.dataSource.data = this.partners; |
|
|
|
|
|
console.log(this.partners); |
|
|
|
|
|
} |
|
|
|
|
|
); |
|
|
|
|
|
console.log(this.dataSource.data); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
handlePageEvent(e: PageEvent) { |
|
|
|
|
|
console.log(e); |
|
|
|
|
|
this.pageEvent = e; |
|
|
|
|
|
this.length = e.length; |
|
|
|
|
|
this.pageSize = e.pageSize; |
|
|
|
|
|
this.pageIndex = e.pageIndex; |
|
|
|
|
|
console.log('PAGE EVENT:'); |
|
|
|
|
|
console.log('length:' + this.length); |
|
|
|
|
|
console.log('page index:' + this.pageIndex); |
|
|
|
|
|
console.log('page size:' + this.pageSize); |
|
|
|
|
|
|
|
|
|
|
|
this.currentPageIndex = this.pageIndex.valueOf() + 1; |
|
|
|
|
|
this.getData(); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
} |
|
|
} |