internal-page-content.component.ts 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288
  1. import { HttpClient } from '@angular/common/http';
  2. import { UserService } from './../../shared/user.service';
  3. import { Router, ActivatedRoute } from '@angular/router';
  4. import { AuthServiceService } from './../../shared/auth-service.service';
  5. import { Component, OnInit, AfterViewInit, ViewChild, EventEmitter } from '@angular/core';
  6. import { InternalPageService } from '../../shared/internal-page.service';
  7. import { NgxSpinnerService } from 'ngx-spinner';
  8. import {NgbCarousel,NgbCarouselConfig} from '@ng-bootstrap/ng-bootstrap';
  9. import * as $ from 'jquery';
  10. declare var jQuery: any;
  11. @Component({
  12. selector: 'app-internal-page-content',
  13. templateUrl: './internal-page-content.component.html',
  14. styleUrls: ['./internal-page-content.component.css'],
  15. providers: [NgbCarouselConfig],
  16. })
  17. export class InternalPageContentComponent implements OnInit {
  18. @ViewChild('myCarousel') myCarousel: NgbCarousel;
  19. constructor(private authSer: AuthServiceService,
  20. private router:Router,
  21. private userservice: UserService,
  22. private internalService: InternalPageService,
  23. private route: ActivatedRoute,
  24. private config: NgbCarouselConfig,
  25. private http: HttpClient,
  26. private spinner: NgxSpinnerService) {
  27. }
  28. joinUs = [];
  29. reportsData = [];
  30. externalServices = [];
  31. congratulations = [];
  32. condolences = [];
  33. internalServices = [];
  34. tabsData = [];
  35. achievements = [];
  36. tabCongaData= {
  37. employee_name: '',
  38. employee_name_en: '',
  39. created_at: '',
  40. name: '',
  41. name_en: '',
  42. };
  43. tabSadData = {
  44. employee_name: '',
  45. employee_name_en: '',
  46. created_at: '',
  47. name: '',
  48. name_en: ''
  49. };
  50. joinTabData = {
  51. name: '',
  52. name_en: '',
  53. adminstration_name: '',
  54. adminstration_name_en: '',
  55. date_of_employment_hij: '',
  56. photo: '',
  57. };
  58. advertisiment = {
  59. photo : '',
  60. description: '',
  61. description_en: '',
  62. };
  63. checkShowData: boolean;
  64. tabtype:number = 0;
  65. expandedIndex:number;
  66. selectedItem: any = 0 //check تعاميم active class
  67. live_event = [];
  68. next_lecture = [];
  69. myInnerHeight = window.innerHeight;
  70. flag: boolean = false;
  71. catchEvent(event) {
  72. this.flag = true
  73. console.log(event)
  74. }
  75. hide(event) {
  76. this.flag = false;
  77. }
  78. ngOnInit() {
  79. this.spinner.show();
  80. // this.myCarousel.activeId = '2';
  81. //this.spinner.show();
  82. //console.log(this.checkTokenExpire);
  83. //get profile data
  84. this.userservice.getUserDataProfile();
  85. this.internalService.getInternalPageData().subscribe(
  86. (responce) => {
  87. console.log(responce);
  88. this.externalServices = responce['data'].external_services;
  89. console.log('external services ', this.externalServices);
  90. this.reportsData = responce['data'].reports;
  91. console.log('report data', this.reportsData);
  92. for(let i = 0; i< this.reportsData.length; i++) {
  93. if(this.reportsData[i].description.length > 60) {
  94. this.reportsData[i].description = this.reportsData[i].description.substr(0,100) + '.......';
  95. this.reportsData[i].description_en = this.reportsData[i].description_en.substr(0,100) + 'Read More';
  96. }
  97. }
  98. this.live_event = responce['data'].live_lecture;
  99. this.next_lecture = responce['data'].next_lecture;
  100. this.joinUs = responce['data'].users;
  101. this.showJoinData(this.joinUs[0]);
  102. this.condolences = responce['data'].condolences_events;
  103. this.showTabData(this.condolences[0], 'sad');
  104. this.congratulations = responce['data'].congratulations_events;
  105. this.showTabData(this.congratulations[0], 'wedding');
  106. this.internalService = responce['data'].internal_services;
  107. console.log('internalService', this.internalService);
  108. this.tabsData = responce['data'].tabs;
  109. if(this.tabsData.length > 0) {
  110. this.checkShowData = false;
  111. } else {
  112. this.checkShowData = true;
  113. }
  114. this.achievements = responce['data'].achievements;
  115. this.advertisiment = {
  116. photo: responce['data']['main_ad'].photo,
  117. description: responce['data']['main_ad'].description,
  118. description_en: responce['data']['main_ad'].description_en,
  119. }
  120. this.spinner.hide();
  121. },
  122. (error) => {
  123. console.log(error);
  124. }
  125. )
  126. }
  127. onGetData(numberTab) {
  128. this.selectedItem = numberTab;
  129. this.spinner.show();
  130. this.tabsData = [];
  131. this.tabtype = numberTab;
  132. this.http.get(this.authSer.pathApi + '/forth_tabs_list/' + this.tabtype).subscribe(
  133. (responce) => {
  134. console.log(responce);
  135. this.tabsData = responce['tabs'];
  136. this.spinner.hide();
  137. },
  138. (error) => {
  139. console.log(error);
  140. }
  141. );
  142. }
  143. onExtraPage(reportId) {
  144. this.router.navigate(['InternalPage/news/' + reportId]);
  145. }
  146. open(data,i) {
  147. console.log(data);
  148. this.expandedIndex = i;
  149. }
  150. closeCollapse(i) {
  151. this.expandedIndex = -1;
  152. }
  153. goToHome() {
  154. this.router.navigate(['InternalPage']);
  155. }
  156. onPageCir() {
  157. this.router.navigate(['InternalPage/circulars']);
  158. }
  159. onLectureTable() {
  160. this.router.navigate(['InternalPage/events']);
  161. }
  162. showTabData(tab, typeTab) {
  163. console.log(tab);
  164. if(typeTab == 'wedding') {
  165. this.tabCongaData = {
  166. employee_name : tab.employee_name,
  167. employee_name_en: tab.employee_name_en,
  168. created_at: tab.created_at,
  169. name: tab.name,
  170. name_en: tab.name_en,
  171. };
  172. for(let i = 0 ; i < this.congratulations.length; i++) {
  173. if(this.congratulations[i].id == tab.id) {
  174. this.congratulations[i].active = 1;
  175. } else {
  176. this.congratulations[i].active = 0;
  177. }
  178. }
  179. } else if(typeTab == 'sad') {
  180. this.tabSadData = {
  181. employee_name : tab.employee_name,
  182. employee_name_en: tab.employee_name_en,
  183. created_at: tab.created_at,
  184. name: tab.name,
  185. name_en: tab.name_en
  186. };
  187. for(let i = 0 ; i < this.condolences.length; i++) {
  188. if(this.condolences[i].id == tab.id) {
  189. this.condolences[i].active = 1;
  190. } else {
  191. this.condolences[i].active = 0;
  192. }
  193. }
  194. }
  195. }
  196. showJoinData(join){
  197. this.joinTabData = {
  198. name : join.name,
  199. name_en: join.name_en,
  200. adminstration_name: join.adminstration_name,
  201. adminstration_name_en: join.adminstration_name,
  202. date_of_employment_hij: join.date_of_employment_hij,
  203. photo: join.photo,
  204. };
  205. for(let i = 0 ; i < this.joinUs.length; i++) {
  206. if(this.joinUs[i].id == join.id) {
  207. this.joinUs[i].active = 1;
  208. } else {
  209. this.joinUs[i].active = 0;
  210. }
  211. }
  212. }
  213. getAllNews() {
  214. this.router.navigate(['InternalPage/newpages/']);
  215. }
  216. }