internal-page-content.component.ts 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266
  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. this.spinner.show();
  28. }
  29. joinUs = [];
  30. reportsData = [];
  31. externalServices = [];
  32. congratulations = [];
  33. condolences = [];
  34. internalServices = [];
  35. tabsData = [];
  36. achievements = [];
  37. tabCongaData= {
  38. employee_name: '',
  39. employee_name_en: '',
  40. created_at: '',
  41. name: '',
  42. name_en: '',
  43. };
  44. tabSadData = {
  45. employee_name: '',
  46. employee_name_en: '',
  47. created_at: '',
  48. name: '',
  49. name_en: ''
  50. };
  51. joinTabData = {
  52. name: '',
  53. name_en: '',
  54. adminstration_name: '',
  55. adminstration_name_en: '',
  56. date_of_employment_hij: '',
  57. photo: '',
  58. };
  59. advertisiment = {
  60. photo : '',
  61. description: '',
  62. description_en: '',
  63. };
  64. checkShowData: boolean;
  65. tabtype:number = 0;
  66. expandedIndex:number;
  67. selectedItem: any = 0 //check تعاميم active class
  68. live_event = [];
  69. next_lecture = [];
  70. myInnerHeight = window.innerHeight;
  71. flag: boolean = false;
  72. catchEvent(event) {
  73. this.flag = true
  74. console.log(event)
  75. }
  76. hide(event) {
  77. this.flag = false;
  78. }
  79. ngOnInit() {
  80. //console.log(this.checkTokenExpire);
  81. //get profile data
  82. //this.userservice.getUserDataProfile();
  83. this.internalService.getInternalPageData().subscribe(
  84. (responce) => {
  85. console.log(responce);
  86. this.externalServices = responce['data'].external_services;
  87. console.log('external services ', this.externalServices);
  88. this.reportsData = responce['data'].reports;
  89. console.log('report data', this.reportsData);
  90. for(let i = 0; i< this.reportsData.length; i++) {
  91. if(this.reportsData[i].description.length > 60) {
  92. this.reportsData[i].description = this.reportsData[i].description.substr(0,100) + '.......';
  93. this.reportsData[i].description_en = this.reportsData[i].description_en.substr(0,100) + 'Read More';
  94. }
  95. }
  96. this.live_event = responce['data'].live_lecture;
  97. this.next_lecture = responce['data'].next_lecture;
  98. this.joinUs = responce['data'].users;
  99. this.showJoinData(this.joinUs[0]);
  100. this.condolences = responce['data'].condolences_events;
  101. this.showTabData(this.condolences[0], 'sad');
  102. this.congratulations = responce['data'].congratulations_events;
  103. this.showTabData(this.congratulations[0], 'wedding');
  104. this.internalService = responce['data'].internal_services;
  105. console.log('internalService', this.internalService);
  106. this.tabsData = responce['data'].tabs;
  107. if(this.tabsData.length > 0) {
  108. this.checkShowData = false;
  109. } else {
  110. this.checkShowData = true;
  111. }
  112. this.achievements = responce['data'].achievements;
  113. this.advertisiment = {
  114. photo: responce['data']['main_ad'].photo,
  115. description: responce['data']['main_ad'].description,
  116. description_en: responce['data']['main_ad'].description_en,
  117. }
  118. this.spinner.hide();
  119. },
  120. (error) => {
  121. console.log(error);
  122. }
  123. )
  124. }
  125. onGetData(numberTab) {
  126. this.selectedItem = numberTab;
  127. this.spinner.show();
  128. this.tabsData = [];
  129. this.tabtype = numberTab;
  130. this.http.get(this.authSer.pathApi + '/forth_tabs_list/' + this.tabtype).subscribe(
  131. (responce) => {
  132. console.log(responce);
  133. this.tabsData = responce['tabs'];
  134. this.spinner.hide();
  135. },
  136. (error) => {
  137. console.log(error);
  138. }
  139. );
  140. }
  141. onExtraPage(reportId) {
  142. this.router.navigate(['InternalPage/news/' + reportId]);
  143. }
  144. open(data,i) {
  145. console.log(data);
  146. this.expandedIndex = i;
  147. }
  148. closeCollapse(i) {
  149. this.expandedIndex = -1;
  150. }
  151. goToHome() {
  152. this.router.navigate(['InternalPage']);
  153. }
  154. onPageCir() {
  155. this.router.navigate(['InternalPage/circulars']);
  156. }
  157. onLectureTable() {
  158. this.router.navigate(['InternalPage/events']);
  159. }
  160. showTabData(tab, typeTab) {
  161. console.log(tab);
  162. if(typeTab == 'wedding') {
  163. this.tabCongaData = {
  164. employee_name : tab.employee_name,
  165. employee_name_en: tab.employee_name_en,
  166. created_at: tab.created_at,
  167. name: tab.name,
  168. name_en: tab.name_en,
  169. };
  170. for(let i = 0 ; i < this.congratulations.length; i++) {
  171. if(this.congratulations[i].id == tab.id) {
  172. this.congratulations[i].active = 1;
  173. } else {
  174. this.congratulations[i].active = 0;
  175. }
  176. }
  177. } else if(typeTab == 'sad') {
  178. this.tabSadData = {
  179. employee_name : tab.employee_name,
  180. employee_name_en: tab.employee_name_en,
  181. created_at: tab.created_at,
  182. name: tab.name,
  183. name_en: tab.name_en
  184. };
  185. for(let i = 0 ; i < this.condolences.length; i++) {
  186. if(this.condolences[i].id == tab.id) {
  187. this.condolences[i].active = 1;
  188. } else {
  189. this.condolences[i].active = 0;
  190. }
  191. }
  192. }
  193. }
  194. showJoinData(join){
  195. this.joinTabData = {
  196. name : join.name,
  197. name_en: join.name_en,
  198. adminstration_name: join.adminstration_name,
  199. adminstration_name_en: join.adminstration_name,
  200. date_of_employment_hij: join.date_of_employment_hij,
  201. photo: join.photo,
  202. };
  203. for(let i = 0 ; i < this.joinUs.length; i++) {
  204. if(this.joinUs[i].id == join.id) {
  205. this.joinUs[i].active = 1;
  206. } else {
  207. this.joinUs[i].active = 0;
  208. }
  209. }
  210. }
  211. getAllNews() {
  212. this.router.navigate(['InternalPage/newpages/']);
  213. }
  214. }