Broker System for Supercredit
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

59 lines
1.5KB

  1. import { Component, OnInit } from '@angular/core';
  2. import {AuthService} from '../service/auth.service';
  3. import {HttpClient} from '@angular/common/http';
  4. import {RewardByUserModel} from '../models/reward-by-user.model';
  5. import {DataStateChangeEvent, GridDataResult,} from '@progress/kendo-angular-grid';
  6. import {State, process} from '@progress/kendo-data-query';
  7. @Component({
  8. selector: 'app-list-all-rewards',
  9. templateUrl: './list-all-rewards.component.html',
  10. styleUrls: ['./list-all-rewards.component.scss']
  11. })
  12. export class ListAllRewardsComponent implements OnInit {
  13. public gridData: RewardByUserModel[] = [] ;
  14. public gridView: GridDataResult;
  15. public state: State = {
  16. skip: 0,
  17. take: 20
  18. };
  19. public loading = true;
  20. constructor(private auth: AuthService, private http: HttpClient) { }
  21. ngOnInit(): void {
  22. this.loadInitRewardGrid();
  23. }
  24. public loadInitRewardGrid(): void {
  25. this.loading = true;
  26. this.gridData = [];
  27. this.http.get<RewardByUserModel[]>(this.auth.getUrl('user-reward/')).subscribe(
  28. rsp => {
  29. this.loading = false;
  30. rsp.forEach(v => {
  31. this.gridData.push(new RewardByUserModel(v));
  32. });
  33. this.loadRewards();
  34. }
  35. );
  36. }
  37. private loadRewards(): void {
  38. this.gridView = process(this.gridData, this.state);
  39. }
  40. public dataStateChange(state: DataStateChangeEvent): void {
  41. this.state = state;
  42. this.loadRewards();
  43. }
  44. private photoURL(peopleId: any): string {
  45. const url = this.auth.getUrl('avatar/') + peopleId;
  46. return 'url("' + url + '")';
  47. }
  48. }