user.service.ts 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  1. import { AuthServiceService } from './auth-service.service';
  2. import { HttpClient } from '@angular/common/http';
  3. import { Injectable } from '@angular/core';
  4. import { ToastrService } from 'ngx-toastr';
  5. import { NgxSpinnerService } from 'ngx-spinner';
  6. @Injectable({
  7. providedIn: 'root'
  8. })
  9. export class UserService {
  10. constructor(private http: HttpClient,
  11. private authService: AuthServiceService,
  12. private toastr: ToastrService,
  13. private spinner: NgxSpinnerService) { }
  14. //get profile data
  15. getUserDataProfile() {
  16. this.http.get(this.authService.pathApi + '/profile').subscribe(
  17. (responce) => {
  18. this.authService.setDataUser(responce);
  19. },
  20. (error) => {console.log(error)},
  21. );
  22. }
  23. //get services data user
  24. getServicesData(id) {
  25. return this.http.get(this.authService.pathApi + '/get_user_services/' + id);
  26. }
  27. //get services of user
  28. getPagesPermetiotns(userId, serviceId){
  29. return this.http.get(this.authService.pathApi + '/get_user_pages_permissions/' + userId + '/' + serviceId);
  30. }
  31. //get adminstration
  32. getAdministration(){
  33. return this.http.get(this.authService.pathApi + '/adminstrations_list');
  34. }
  35. //get month
  36. getMonth(){
  37. return this.http.get(this.authService.pathApi + '/months_list');
  38. }
  39. getDepartments(adminstrationId) {
  40. return this.http.get(this.authService.pathApi + '/admin_departments/' + adminstrationId);
  41. }
  42. //get nationality
  43. getNationality() {
  44. return this.http.get(this.authService.pathApi + '/countries_list');
  45. }
  46. //get list data of page
  47. getPageData(id:number, currentPage, dataPageNumber) {
  48. console.log(this.authService.pathApi + '/page_list/' + id + '/' + currentPage + '/' + dataPageNumber + '/all');
  49. return this.http.get(this.authService.pathApi + '/page_list/' + id + '/' + currentPage + '/' + dataPageNumber + '/all');
  50. }
  51. //get job titile
  52. getJobTitle() {
  53. return this.http.get(this.authService.pathApi + '/job_titles_list');
  54. }
  55. //get contract list
  56. getContract(){
  57. return this.http.get(this.authService.pathApi + '/contract_types_list');
  58. }
  59. //get staff list
  60. getStaff(){
  61. return this.http.get(this.authService.pathApi + '/staff_list');
  62. }
  63. //get specialization
  64. getSpecialization() {
  65. return this.http.get(this.authService.pathApi + '/specialization_list');
  66. }
  67. //add user
  68. addUser(userForm, typePage: string){
  69. if(typePage == 'user'){
  70. return this.http.post(this.authService.pathApi + '/add_user', userForm);
  71. } else if(typePage == 'joinUs') {
  72. return this.http.post(this.authService.pathApi + '/add_join_us_user', userForm);
  73. }
  74. }
  75. //get user data
  76. onGetUserData(idUser:number, typePage: string){
  77. if(typePage == 'editUs') {
  78. return this.http.get(this.authService.pathApi + '/get_user/' + idUser);
  79. } else if(typePage == 'editJo') {
  80. return this.http.get(this.authService.pathApi + '/get_join_us_user/' + idUser);
  81. }
  82. }
  83. //edit data of user
  84. onEditUser(editDataUser, typePage: string){
  85. console.log(editDataUser);
  86. if(typePage == 'user'){
  87. return this.http.post(this.authService.pathApi + '/edit_user', editDataUser);
  88. } else if(typePage == 'joinUs') {
  89. return this.http.post(this.authService.pathApi + '/edit_join_us_user', editDataUser);
  90. }
  91. }
  92. onEditProfile(dataProfile) {
  93. return this.http.post(this.authService.pathApi + '/edit_profile', dataProfile);
  94. }
  95. //get data of pagenation
  96. getUserListPagenation(pageNumber:number , pageId: number) {
  97. const page = pageNumber;
  98. const pageID = pageId;
  99. return this.http.get(this.authService.pathApi + '/page_list/' + pageID + '/' + page);
  100. }
  101. //get data user from searchBar
  102. getDataUSerSearchBar(data, pageId, pagenationNumber, dataPageNumber) {
  103. console.log('url', this.authService.pathApi + '/page_list' + '/' + pageId + '/' + pagenationNumber + '/' + dataPageNumber + '/all/' + data);
  104. return this.http.get(this.authService.pathApi + '/page_list' + '/' + pageId + '/' + pagenationNumber + '/' + dataPageNumber + '/all/' + data);
  105. }
  106. //delete user
  107. deleteUser(userIds, typePageId) {
  108. if(typePageId == 1){
  109. console.log(userIds);
  110. return this.http.post(this.authService.pathApi + '/delete_user' , {'users_id' : userIds});
  111. } else if(typePageId == 9) {
  112. console.log(userIds);
  113. return this.http.post(this.authService.pathApi + '/delete_join_us_users' , {'users_id' : userIds});
  114. }
  115. }
  116. //get permission list
  117. getPermissionList() {
  118. return this.http.get(this.authService.pathApi + '/permissions_list');
  119. }
  120. //get roles list
  121. getRolesList() {
  122. return this.http.get(this.authService.pathApi + '/roles_list');
  123. }
  124. //get report data
  125. onGetReportData(user_id:number) {
  126. return this.http.get(this.authService.pathApi + '/report_user_permissions/' + user_id);
  127. }
  128. //get indetities
  129. onGetIdentities() {
  130. return this.http.get(this.authService.pathApi + '/identities_list');
  131. }
  132. }