hospital.service.ts 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. import { HttpClient } from '@angular/common/http';
  2. import { AuthServiceService } from './auth-service.service';
  3. import { Injectable } from '@angular/core';
  4. import { NgxSpinnerService } from 'ngx-spinner';
  5. import { ToastrService } from 'ngx-toastr';
  6. @Injectable({
  7. providedIn: 'root'
  8. })
  9. export class HospitalService {
  10. constructor(private authService: AuthServiceService,
  11. private http: HttpClient,
  12. private spinner: NgxSpinnerService,
  13. private toastr: ToastrService) { }
  14. //get hospitals list
  15. getHospitalsList(pageId: number, currentPage: number, dataTableNumber: number){
  16. this.spinner.show();
  17. console.log(this.authService.pathApi +'/page_list/' + pageId + '/' + currentPage + '/' + dataTableNumber + '/all');
  18. return this.http.get(this.authService.pathApi +'/page_list/' + pageId + '/' + currentPage + '/' + dataTableNumber + '/all');
  19. }
  20. //get data user from searchBar
  21. getDataUSerSearchBar(data, pageId, pagenationNumber, dataTableNumber) {
  22. console.log('url', this.authService.pathApi + '/page_list' + '/' + pageId + '/' + pagenationNumber + '/' + dataTableNumber + '/all/' + data);
  23. return this.http.get(this.authService.pathApi + '/page_list' + '/' + pageId + '/' + pagenationNumber + '/' + dataTableNumber + '/all/' + data);
  24. }
  25. //delete hospitals
  26. deleteDatas(datasIds, pageId) {
  27. if(pageId == 6){
  28. console.log(datasIds);
  29. return this.http.post(this.authService.pathApi + '/delete_hospitals_centers' , {'hospitals_centers_id' : datasIds});
  30. } else if(pageId == 10) {
  31. this.spinner.show();
  32. console.log(datasIds);
  33. return this.http.post(this.authService.pathApi + '/delete_managements' , {'managements_id' : datasIds});
  34. }
  35. }
  36. //add hospital
  37. addHospital(hospitalDataForm, pageName) {
  38. if(pageName == 'hospital'){
  39. return this.http.post(this.authService.pathApi + '/add_hospitals_centers', hospitalDataForm);
  40. } else if(pageName == 'management'){
  41. return this.http.post(this.authService.pathApi + '/add_management', hospitalDataForm);
  42. }
  43. }
  44. //get hospital data
  45. getHospitalData(typeId: number, typeEditPage: string) {
  46. if(typeEditPage == 'edithos') {
  47. return this.http.get(this.authService.pathApi + '/get_hospitals_centers/' + typeId);
  48. } else if(typeEditPage == 'editman') {
  49. return this.http.get(this.authService.pathApi + '/get_management/' + typeId);
  50. }
  51. }
  52. //edit hospital data
  53. editHospital(id: number, newData, typePage:string) {
  54. newData['id'] = id;
  55. console.log(newData);
  56. if(typePage == 'hospital') {
  57. return this.http.post(this.authService.pathApi + '/edit_hospitals_centers', newData);
  58. } else if (typePage == 'management') {
  59. return this.http.post(this.authService.pathApi + '/edit_management', newData);
  60. }
  61. }
  62. }