|
|
|
@@ -1,7 +1,8 @@ |
|
|
|
import {ChangeDetectorRef, Component, Input, OnInit, ViewChild} from '@angular/core'; |
|
|
|
import {MatPaginator, MatPaginatorIntl, PageEvent} from "@angular/material/paginator"; |
|
|
|
import {FormBuilder, FormGroup} from "@angular/forms"; |
|
|
|
import {debounceTime, distinctUntilChanged} from "rxjs"; |
|
|
|
import {debounceTime, distinctUntilChanged, Subscription} from "rxjs"; |
|
|
|
import {LoadingService} from "@app/_services/loading.service"; |
|
|
|
|
|
|
|
@Component({ |
|
|
|
selector: 'app-paging', |
|
|
|
@@ -25,17 +26,28 @@ export class PagingComponent implements OnInit { |
|
|
|
public pageEvent: PageEvent; |
|
|
|
protected pageIndex: number; |
|
|
|
public searchForm!: FormGroup; |
|
|
|
public loadingSub: Subscription; |
|
|
|
public loading: boolean; |
|
|
|
|
|
|
|
constructor( |
|
|
|
private fb: FormBuilder |
|
|
|
private fb: FormBuilder, |
|
|
|
private loadingService: LoadingService |
|
|
|
) { |
|
|
|
this.dataLength = 0; |
|
|
|
this.pageEvent = new PageEvent(); |
|
|
|
this.pageIndex = 0; |
|
|
|
this.searchable = false; |
|
|
|
this.loadingSub = new Subscription(); |
|
|
|
this.loading = false; |
|
|
|
} |
|
|
|
|
|
|
|
ngOnInit() { |
|
|
|
this.loadingSub = this.loadingService.getLoading().subscribe( |
|
|
|
loading => { |
|
|
|
this.loading = loading; |
|
|
|
console.log(this.loading); |
|
|
|
} |
|
|
|
); |
|
|
|
this.pageSize = this.pageSize !== undefined ? this.pageSize : this.defaultPageSize; |
|
|
|
this.pageSizeOptions = this.pageSizeOptions !== undefined ? this.pageSizeOptions : this.defaultPageSizeOptions; |
|
|
|
this.paginator = new MatPaginator(new MatPaginatorIntl(), ChangeDetectorRef.prototype); |
|
|
|
@@ -45,8 +57,8 @@ export class PagingComponent implements OnInit { |
|
|
|
inputText: [''] |
|
|
|
}); |
|
|
|
this.searchForm.get('inputText')?.valueChanges.pipe( |
|
|
|
debounceTime(1000), // Warte 2 Sekunden |
|
|
|
distinctUntilChanged() // Nur bei Änderungen auslösen |
|
|
|
debounceTime(1000), |
|
|
|
distinctUntilChanged() |
|
|
|
).subscribe(value => { |
|
|
|
this.getData() |
|
|
|
}); |
|
|
|
|