dashboard.service.ts 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218
  1. import { HttpClient } from '@angular/common/http';
  2. import { Injectable } from '@angular/core';
  3. import { NgxSpinnerService } from 'ngx-spinner';
  4. import { ToastrService } from 'ngx-toastr';
  5. import { AuthServiceService } from './auth-service.service';
  6. @Injectable({
  7. providedIn: 'root'
  8. })
  9. export class DashboardService {
  10. constructor(private http: HttpClient,
  11. private toastr: ToastrService,
  12. private authService: AuthServiceService,
  13. private spinner: NgxSpinnerService) { }
  14. //get hospitals list
  15. getListData(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. //addEvent
  26. addItem(data, addType) {
  27. if(addType == 'advertisiment'){
  28. return this.http.post(this.authService.pathApi + '/add_main_ad' , data);
  29. } else if(addType == 'internalHospital') {
  30. return this.http.post(this.authService.pathApi + '/add_hospitals_centers' , data);
  31. } else if(addType == 'externalHospital') {
  32. return this.http.post(this.authService.pathApi + '/add_hospitals_centers_ex' , data);
  33. } else if(addType == 'internalManagement') {
  34. return this.http.post(this.authService.pathApi + '/add_management' , data);
  35. } else if(addType == 'externalManagement') {
  36. return this.http.post(this.authService.pathApi + '/add_management_ex' , data);
  37. } else if(addType == 'internalMainMenu') {
  38. return this.http.post(this.authService.pathApi + '/add_menu' , data);
  39. } else if(addType == 'externalMainMenu') {
  40. return this.http.post(this.authService.pathApi + '/add_external_menu' , data);
  41. } else if(addType == 'internalServiceExternalPage') {
  42. return this.http.post(this.authService.pathApi + '/add_external_service' , data);
  43. } else if(addType == 'externalServiceExternalPage') {
  44. return this.http.post(this.authService.pathApi + '/add_external_service_ex' , data);
  45. } else if(addType == 'internalNews') {
  46. return this.http.post(this.authService.pathApi + '/add_report' , data);
  47. } else if(addType == 'externalNews') {
  48. return this.http.post(this.authService.pathApi + '/add_report_ex' , data);
  49. } else if(addType == 'internalFooter') {
  50. return this.http.post(this.authService.pathApi + '/add_footer' , data);
  51. } else if(addType == 'externalFooter') {
  52. return this.http.post(this.authService.pathApi + '/add_footer_ex' , data);
  53. } else if(addType == 'barEvent') {
  54. return this.http.post(this.authService.pathApi + '/add_event_bar', data);
  55. } else if(addType == 'visitingTime') {
  56. return this.http.post(this.authService.pathApi + '/add_visiting_time', data);
  57. } else if(addType == 'eventCalendar') {
  58. return this.http.post(this.authService.pathApi + '/add_event_calendar', data);
  59. } else if(addType == 'externalAchievement') {
  60. return this.http.post(this.authService.pathApi + "/add_external_achievement", data);
  61. } else if(addType == 'statistic') {
  62. return this.http.post(this.authService.pathApi + "/add_statistic", data);
  63. } else if(addType == 'advertising') {
  64. return this.http.post(this.authService.pathApi + "/add_advertising_service", data);
  65. }
  66. }
  67. //edit event
  68. editItem(editId,dataEdit,editPageName){
  69. const editData = dataEdit;
  70. console.log(editId);
  71. console.log(editPageName);
  72. editData['id'] = editId;
  73. console.log(dataEdit);
  74. if(editPageName == 'advertisiment') {
  75. return this.http.post(this.authService.pathApi + '/edit_main_ad', editData);
  76. } else if(editPageName == 'internalHospital') {
  77. return this.http.post(this.authService.pathApi + '/edit_hospitals_centers', editData);
  78. } else if(editPageName == 'externalHospital') {
  79. return this.http.post(this.authService.pathApi + '/edit_hospitals_centers_ex', editData);
  80. } else if(editPageName == 'internalManagement') {
  81. return this.http.post(this.authService.pathApi + '/edit_management' , dataEdit);
  82. } else if(editPageName == 'externalManagement') {
  83. return this.http.post(this.authService.pathApi + '/edit_management_ex' , dataEdit);
  84. } else if(editPageName == 'internalMenu') {
  85. return this.http.post(this.authService.pathApi + '/edit_menu' , dataEdit);
  86. } else if(editPageName == 'externalMenu') {
  87. return this.http.post(this.authService.pathApi + '/edit_external_menu' , dataEdit);
  88. } else if(editPageName == 'internalServiceExternalPage') {
  89. return this.http.post(this.authService.pathApi + '/edit_external_service' , dataEdit);
  90. } else if(editPageName == 'externalServiceExternalPage') {
  91. return this.http.post(this.authService.pathApi + '/edit_external_service_ex' , dataEdit);
  92. } else if(editPageName == 'internalNew') {
  93. return this.http.post(this.authService.pathApi + '/edit_report' , dataEdit);
  94. } else if(editPageName == 'externalNew') {
  95. return this.http.post(this.authService.pathApi + '/edit_report_ex' , dataEdit);
  96. } else if(editPageName == 'internalFooter') {
  97. return this.http.post(this.authService.pathApi + '/edit_footer', dataEdit);
  98. } else if(editPageName == 'externalFooter') {
  99. return this.http.post(this.authService.pathApi + '/edit_footer_ex', dataEdit);
  100. }else if(editPageName == 'barEvent') {
  101. console.log(editData);
  102. return this.http.post(this.authService.pathApi + '/edit_event_bar', editData);
  103. } else if(editPageName == 'contactUs') {
  104. console.log(editData);
  105. return this.http.post(this.authService.pathApi + '/edit_contact_us', editData);
  106. } else if(editPageName == 'visitingTime') {
  107. console.log(editData);
  108. return this.http.post(this.authService.pathApi + '/edit_visiting_time', editData);
  109. } else if(editPageName == 'eventCalendar') {
  110. console.log(editData);
  111. return this.http.post(this.authService.pathApi + '/edit_event_calendar', editData);
  112. } else if(editPageName == 'externalAchievement') {
  113. console.log(editData);
  114. return this.http.post(this.authService.pathApi + '/edit_external_achievement', editData);
  115. } else if(editPageName == 'statistic') {
  116. console.log(editData);
  117. return this.http.post(this.authService.pathApi + '/edit_statistic', editData);
  118. } else if(editPageName == 'advertising') {
  119. console.log(editData);
  120. return this.http.post(this.authService.pathApi + '/edit_advertising_service', editData);
  121. }
  122. }
  123. //get event data
  124. getItemData(pageId: number, typeGetData:string) {
  125. console.log('wwwwwwwwwwwwwwwwwwwwwwwwwwww', pageId);
  126. if(typeGetData == 'advertisiment') {
  127. return this.http.get(this.authService.pathApi + '/get_main_ad/' + pageId);
  128. } else if(typeGetData == 'hospital') {
  129. return this.http.get(this.authService.pathApi + '/get_hospitals_centers/' + pageId);
  130. } else if(typeGetData == 'managament') {
  131. return this.http.get(this.authService.pathApi + '/get_management/' + pageId);
  132. } else if(typeGetData == 'mainMenu') {
  133. return this.http.get(this.authService.pathApi + '/get_menu/' + pageId);
  134. } else if(typeGetData == 'externalService') {
  135. return this.http.get(this.authService.pathApi + '/get_external_service/' + pageId);
  136. } else if(typeGetData == 'news') {
  137. return this.http.get(this.authService.pathApi + '/get_report/' + pageId);
  138. } else if(typeGetData == 'footer') {
  139. return this.http.get(this.authService.pathApi + '/get_footer/' + pageId);
  140. }else if(typeGetData == 'barEvent') {
  141. return this.http.get(this.authService.pathApi + '/get_event_bar/' + pageId);
  142. } else if(typeGetData == 'contactUs') {
  143. return this.http.get(this.authService.pathApi + '/get_contact_us/' + pageId);
  144. } else if(typeGetData == 'visitingTime') {
  145. return this.http.get(this.authService.pathApi + '/get_visiting_time/' + pageId);
  146. } else if(typeGetData == 'eventCalendar') {
  147. return this.http.get(this.authService.pathApi + '/get_event_calendar/' + pageId);
  148. } else if(typeGetData == 'externalAchievement') {
  149. return this.http.get(this.authService.pathApi + '/get_external_achievement/' + pageId);
  150. } else if(typeGetData == 'statistic') {
  151. return this.http.get(this.authService.pathApi + '/get_statistic/' + pageId);
  152. } else if(typeGetData == 'advertising') {
  153. return this.http.get(this.authService.pathApi + '/get_advertising_service/' + pageId);
  154. }
  155. }
  156. //delete event
  157. deleteItem(dataIds, pageId) {
  158. console.log(dataIds);
  159. console.log(pageId);
  160. if(pageId == 24) {
  161. return this.http.post(this.authService.pathApi + '/delete_main_ads' , {'ads_id' : dataIds});
  162. } else if(pageId == 10) {
  163. return this.http.post(this.authService.pathApi + '/delete_managements' , {'managements_id' : dataIds});
  164. } else if(pageId == 31) {
  165. return this.http.post(this.authService.pathApi + '/delete_managements_ex' , {'managements_id' : dataIds});
  166. } else if(pageId == 6) {
  167. return this.http.post(this.authService.pathApi + '/delete_hospitals_centers' , {'hospitals_centers_id' : dataIds});
  168. } else if(pageId == 30) {
  169. return this.http.post(this.authService.pathApi + '/delete_hospitals_centers_ex' , {'hospitals_centers_id' : dataIds});
  170. } else if(pageId == 17) {
  171. return this.http.post(this.authService.pathApi + '/delete_menus' , {'menus_id' : dataIds});
  172. } else if(pageId == 18) {
  173. return this.http.post(this.authService.pathApi + '/delete_external_menus' , {'menus_id' : dataIds});
  174. } else if(pageId == 19) {
  175. return this.http.post(this.authService.pathApi + '/delete_external_services_ex' , {'external_services_id' : dataIds});
  176. } else if(pageId == 7) {
  177. return this.http.post(this.authService.pathApi + '/delete_external_services' , {'external_services_id' : dataIds});
  178. } else if(pageId == 20) {
  179. return this.http.post(this.authService.pathApi + '/delete_reports_ex' , {'reports_id' : dataIds});
  180. } else if(pageId == 13) {
  181. return this.http.post(this.authService.pathApi + '/delete_reports' , {'reports_id' : dataIds});
  182. } else if(pageId == 16) {
  183. return this.http.post(this.authService.pathApi + '/delete_footers' , {'footers_id' : dataIds});
  184. } else if(pageId == 29) {
  185. return this.http.post(this.authService.pathApi + '/delete_footers_ex' , {'footers_id' : dataIds});
  186. } else if (pageId == 21){
  187. return this.http.post(this.authService.pathApi + '/delete_event_bars' , {'event_bars_id' : dataIds});
  188. } else if (pageId == 23){
  189. return this.http.post(this.authService.pathApi + '/delete_visiting_times' , {'visiting_times_id' : dataIds});
  190. } else if (pageId == 25){
  191. return this.http.post(this.authService.pathApi + '/delete_event_calendars' , {'event_calendars_id' : dataIds});
  192. } else if (pageId == 27){
  193. return this.http.post(this.authService.pathApi + '/delete_external_achievements' , {'external_achievements_id' : dataIds});
  194. } else if (pageId == 26){
  195. return this.http.post(this.authService.pathApi + '/delete_statistics' , {'statistics_id' : dataIds});
  196. } else if (pageId == 22){
  197. return this.http.post(this.authService.pathApi + '/delete_advertising_services' , {'advertising_services_id' : dataIds});
  198. }
  199. };
  200. }