circulars-page.component.ts 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. import { InternalPageService } from './../../shared/internal-page.service';
  2. import { AuthServiceService } from './../../shared/auth-service.service';
  3. import { Component, OnInit } from '@angular/core';
  4. import { NgxSpinnerService } from 'ngx-spinner';
  5. @Component({
  6. selector: 'app-circulars-page',
  7. templateUrl: './circulars-page.component.html',
  8. styleUrls: ['./circulars-page.component.css']
  9. })
  10. export class CircularsPageComponent implements OnInit {
  11. constructor(private authSer: AuthServiceService,
  12. private spinner: NgxSpinnerService,
  13. private internalService: InternalPageService) { }
  14. count: number;
  15. perPagePagenation: number = 10;
  16. dataTableNumber:number = 5;
  17. data = [];
  18. //p: number[] = [];
  19. currentPage:number = 1;
  20. typeCircu:number = 0;
  21. ngOnInit() {
  22. this.spinner.show();
  23. this.internalService.getCircularsData(this.currentPage, this.perPagePagenation, 0).subscribe(
  24. (responce) => {
  25. console.log(responce);
  26. this.data = responce['tabs'];
  27. this.count = responce['count'];
  28. this.perPagePagenation = responce['per_page'];
  29. this.spinner.hide();
  30. },
  31. (error) => {
  32. console.log(error);
  33. }
  34. )
  35. };
  36. // /change page
  37. onPageChange(pagenationNumber) {
  38. this.spinner.show();
  39. this.currentPage = pagenationNumber;
  40. this.data = [];
  41. //console.log(pagenationNumber);
  42. //console.log(this.pageId);
  43. this.internalService.getCircularsData(this.currentPage, this.perPagePagenation, this.typeCircu).subscribe(
  44. (responce) => {
  45. console.log(responce);
  46. this.data = responce['tabs'];
  47. this.count = responce['count'];
  48. this.perPagePagenation = responce['per_page'];
  49. //console.log(this.tabsList);
  50. this.spinner.hide();
  51. },
  52. (error) => {
  53. console.log(error);
  54. this.spinner.hide();
  55. }
  56. );
  57. };
  58. onGetData(id) {
  59. this.spinner.show();
  60. this.typeCircu = id;
  61. this.internalService.getCircularsData(this.currentPage, this.perPagePagenation, id).subscribe(
  62. (responce) => {
  63. console.log(responce);
  64. this.data = responce['tabs'];
  65. this.count = responce['count'];
  66. this.perPagePagenation = responce['per_page'];
  67. this.spinner.hide();
  68. },
  69. (error) => {
  70. console.log(error);
  71. this.spinner.hide();
  72. }
  73. );
  74. }
  75. //determine the list count from select element
  76. onGetValue(event) {
  77. this.spinner.show();
  78. this.data = [];
  79. this.dataTableNumber = event.target.value;
  80. this.internalService.getCircularsData(this.currentPage, this.perPagePagenation, this.typeCircu).subscribe(
  81. (responce) => {
  82. console.log(responce);
  83. this.data = responce['tabs'];
  84. this.count = responce['count'];
  85. this.perPagePagenation = responce['per_page'];
  86. this.spinner.hide();
  87. },
  88. (error) => {
  89. console.log(error);
  90. this.spinner.hide();
  91. }
  92. );
  93. }
  94. }