Broker System for Supercredit
Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

74 linhas
2.1KB

  1. import {Component, OnInit, ViewEncapsulation} from '@angular/core';
  2. import {PeopleModel} from '../models/people.model';
  3. import {PeopleService} from '../service/people.service';
  4. import {AuthService} from '../service/auth.service';
  5. import {ClonerService} from '../service/clone.service';
  6. import {PageChangeEvent} from '@progress/kendo-angular-pager';
  7. @Component({
  8. selector: 'app-list-all-people',
  9. templateUrl: './list-all-people.component.html',
  10. styleUrls: ['./list-all-people.component.scss'],
  11. })
  12. export class ListAllPeopleComponent implements OnInit {
  13. private AllPeople: PeopleModel[] = [];
  14. public filteredPeople: PeopleModel[] = [];
  15. public displayedPeople: PeopleModel[] = [];
  16. public skip = 0;
  17. public pageSize = 12;
  18. public total = 0;
  19. constructor(private ps: PeopleService, private auth: AuthService) { }
  20. ngOnInit(): void {
  21. this.ps.getPeopleList('').subscribe(
  22. resp => {
  23. this.AllPeople = resp.List;
  24. this.onFilterPeople('');
  25. }
  26. );
  27. }
  28. public onFilterPeople(hint: string): void {
  29. if ( hint === undefined || hint.length === 0 ) {
  30. this.filteredPeople = this.AllPeople.slice(0);
  31. }else {
  32. this.filteredPeople = this.AllPeople.filter(
  33. v => v.Display.toLowerCase().includes(hint.toLowerCase())
  34. );
  35. }
  36. this.skip = 0 ;
  37. this.total = this.filteredPeople.length;
  38. this.loadDisplayedPeople();
  39. }
  40. public onPeopleSelected(people: PeopleModel): void {
  41. if ( people !== undefined ) {
  42. this.filteredPeople = [];
  43. this.filteredPeople.push(people);
  44. }else{
  45. this.filteredPeople = this.AllPeople.slice(0);
  46. }
  47. this.loadDisplayedPeople();
  48. }
  49. public getContactImageUrl(contactId: string): string {
  50. return this.auth.getUrl('avatar/' + contactId);
  51. }
  52. public onPageChange(e: PageChangeEvent): void {
  53. this.skip = e.skip;
  54. this.pageSize = e.take;
  55. this.loadDisplayedPeople();
  56. }
  57. private loadDisplayedPeople(): void {
  58. this.displayedPeople = this.filteredPeople.slice(this.skip, this.skip + this.pageSize);
  59. this.total = this.filteredPeople.length;
  60. }
  61. }