registration-trainee-movement-list.component.ts 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197
  1. import { DashboardService } from './../../../shared/dashboard.service';
  2. import { HttpClient } from '@angular/common/http';
  3. import { UserService } from './../../../shared/user.service';
  4. import { ActivatedRoute, Router, Params } from '@angular/router';
  5. import { NgxSpinnerService } from 'ngx-spinner';
  6. import { AuthServiceService } from './../../../shared/auth-service.service';
  7. import { Component, OnInit } from '@angular/core';
  8. import { ToastrService } from 'ngx-toastr';
  9. import { Modal } from 'ngx-modialog/plugins/bootstrap';
  10. @Component({
  11. selector: 'app-registration-trainee-movement-list',
  12. templateUrl: './registration-trainee-movement-list.component.html',
  13. styleUrls: ['./registration-trainee-movement-list.component.css']
  14. })
  15. export class RegistrationTraineeMovementListComponent implements OnInit {
  16. constructor(private route: ActivatedRoute,
  17. private router: Router,
  18. private userSer: UserService,
  19. private http: HttpClient,
  20. private toastr: ToastrService,
  21. private modal: Modal,
  22. private dashBoardService: DashboardService,
  23. private spinner: NgxSpinnerService,
  24. private authSer: AuthServiceService) { }
  25. pageId: number;
  26. dataList = [];
  27. dataListIds = [];
  28. count: number;
  29. perPagePagenation: number;
  30. currentPage:number = 1;
  31. filtterStatus = '';
  32. selectedAll: any;
  33. userLoginId:number;
  34. serviceId:number;
  35. dataTableNumber: number = 5;
  36. serviceName: string = '';
  37. pages = [];
  38. ngOnInit() {
  39. this.spinner.show();
  40. //init the values of permision boolean
  41. this.route.params.subscribe(
  42. (params: Params) => {
  43. this.pageId = params['registrationListId'];
  44. }
  45. );
  46. //init the values of permision boolean
  47. this.authSer.showAddBtn = false;
  48. this.authSer.showDeleteBtn = false;
  49. this.authSer.showEditBtn = false;
  50. //show / hide notification search in header
  51. this.authSer.notificationLogin = true;
  52. this.authSer.showSearchHeader = false;
  53. this.authSer.showHeaderLogin = false;
  54. this.authSer.showHeaderDashBoard = true;
  55. this.authSer.showDashboardHeader = true;
  56. this.authSer.internalHeader = false;
  57. //to show / hide permissions
  58. this.route.parent.params.subscribe(
  59. (params:Params) => {
  60. this.userLoginId = params['userID'];
  61. this.serviceId = params['serviceID'];
  62. this.route.parent.params.subscribe(
  63. (params:Params) => {
  64. this.userLoginId = params['userID'];
  65. this.serviceId = params['serviceID'];
  66. this.userSer.getPagesPermetiotns(this.userLoginId, this.serviceId).subscribe(
  67. (responce) => {
  68. console.log(responce);
  69. this.pages = responce['pages'];
  70. for(let i = 0; i< this.pages.length; i++) {
  71. if(this.pages[i].id == 38) {
  72. this.authSer.showAddBtn = true;
  73. this.authSer.showEditBtn = true;
  74. this.authSer.showDeleteBtn = true;
  75. } else {
  76. console.log('no events');
  77. }
  78. }
  79. this.spinner.hide();
  80. },
  81. (error) => {console.log(error)}
  82. );
  83. }
  84. );
  85. //get list data
  86. this.dashBoardService.getListData(this.pageId, this.currentPage ,this.dataTableNumber).subscribe(
  87. (responce) => {
  88. console.log('rescponce dataaaa', responce);
  89. this.dataList = responce['requests'];
  90. if(this.dataList.length == 0) {
  91. this.toastr.warning('القائمه فارغه من الطلبات ');
  92. }
  93. this.count = responce['count'];
  94. this.perPagePagenation = responce['per_page'];
  95. console.log('evennnnts', this.dataList);
  96. this.spinner.hide();
  97. },
  98. (error) => {
  99. console.log(error);
  100. this.spinner.hide();
  101. }
  102. );
  103. }
  104. );
  105. }
  106. //filtter function
  107. filtterFunc(data) {
  108. this.dataList = [];
  109. console.log(data.target.value);
  110. const dataSearch = data.target.value;
  111. this.currentPage = 1;
  112. this.dashBoardService.getDataUSerSearchBar(dataSearch, this.pageId, this.currentPage, this.dataTableNumber).subscribe(
  113. (responce) => {
  114. console.log(responce);
  115. this.dataList = responce['requests'];
  116. this.count = responce['count'];
  117. this.perPagePagenation = responce['per_page'];
  118. console.log('filtter count', this.count);
  119. console.log('filtter perPagePAgenation', this.perPagePagenation);
  120. },
  121. (error) => {
  122. console.log(error)
  123. }
  124. );
  125. };
  126. //change page
  127. onPageChange(pagenationNumber) {
  128. this.spinner.show();
  129. this.currentPage = pagenationNumber;
  130. this.dataList = [];
  131. //console.log(pagenationNumber);
  132. //console.log(this.pageId);
  133. this.dashBoardService.getListData(this.pageId, pagenationNumber, this.dataTableNumber).subscribe(
  134. (responce) => {
  135. console.log(responce);
  136. this.dataList = responce['requests'];
  137. this.count = responce['count'];
  138. this.perPagePagenation = responce['per_page'];
  139. console.log(this.dataList);
  140. this.spinner.hide();
  141. },
  142. (error) => {
  143. console.log(error);
  144. this.spinner.hide();
  145. }
  146. );
  147. }
  148. //determine the list count from select element
  149. onGetValue(event) {
  150. this.spinner.show();
  151. this.dataList = [];
  152. this.dataTableNumber = event.target.value;
  153. this.dashBoardService.getListData(this.pageId, this.currentPage, this.dataTableNumber).subscribe(
  154. (responce) => {
  155. console.log(responce);
  156. this.dataList = responce['requests'];
  157. this.count = responce['count'];
  158. this.perPagePagenation = responce['per_page'];
  159. this.spinner.hide();
  160. },
  161. (error) => {
  162. console.log(error);
  163. this.spinner.hide();
  164. }
  165. );
  166. };
  167. //edit function
  168. onEdit(editPageID) {
  169. this.router.navigate(['service/' + this.userLoginId + '/' + this.serviceId + '/' + 'registrationTraineeList/edit/' + editPageID]);
  170. }
  171. }