add observable for filter

pull/22/head
Florian Hartwich 2017-12-27 12:21:41 +01:00
parent 7239995ce3
commit 2daefe0e6c
2 changed files with 9 additions and 1 deletions

View File

@ -3,7 +3,7 @@
<div class="input-group search-field"> <div class="input-group search-field">
<input id="search-tasks" <input id="search-tasks"
placeholder="Spielername" placeholder="Spielername (mehrere mit '&' trennen)"
type="text" #query class="form-control" type="text" #query class="form-control"
(keyup.enter)="filterPlayers()" (keyup.enter)="filterPlayers()"
[formControl]="searchTerm"> [formControl]="searchTerm">
@ -58,6 +58,7 @@
</ngx-datatable-column> </ngx-datatable-column>
<ngx-datatable-column [width]="valueColWidth" name="Tode" prop="death"></ngx-datatable-column> <ngx-datatable-column [width]="valueColWidth" name="Tode" prop="death"></ngx-datatable-column>
</ngx-datatable> </ngx-datatable>
<ngx-datatable <ngx-datatable
[rows]="players.respawn" [rows]="players.respawn"
[reorderable]="reorderable" [reorderable]="reorderable"

View File

@ -4,6 +4,7 @@ import {PlayerService} from "../../services/logs/player.service";
import {CampaignService} from "../../services/logs/campaign.service"; import {CampaignService} from "../../services/logs/campaign.service";
import {Fraction} from "../../utils/fraction.enum"; import {Fraction} from "../../utils/fraction.enum";
import {FormControl} from "@angular/forms"; import {FormControl} from "@angular/forms";
import {Observable} from "rxjs/Observable";
@Component({ @Component({
@ -61,6 +62,12 @@ export class StatisticHighScoreComponent {
}) })
} }
}); });
const searchTermStream = this.searchTerm.valueChanges.debounceTime(400);
Observable.merge(searchTermStream)
.distinctUntilChanged().map(query => this.filterPlayers())
.subscribe();
} }
initData() { initData() {