external-page-header.component.ts 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. import { ExternalPageService } from './../../shared/external-page.service';
  2. import { AuthServiceService } from './../../shared/auth-service.service';
  3. import { Component, OnInit } from '@angular/core';
  4. import { Router } from '@angular/router';
  5. @Component({
  6. selector: 'app-external-page-header',
  7. templateUrl: './external-page-header.component.html',
  8. styleUrls: ['./external-page-header.component.css']
  9. })
  10. export class ExternalPageHeaderComponent implements OnInit {
  11. constructor(public authSer: AuthServiceService,
  12. private externalService: ExternalPageService,
  13. private router: Router) { }
  14. currentDate: any = Date.now()//ararbic date
  15. currentEnglishDate: any = Date.now(); //english date
  16. 372
  17. dataLoginUser:any;
  18. ngOnInit() {
  19. this.authSer.arabicTemplate = true;
  20. this.authSer.showDashboardHeader = false;
  21. this.authSer.setLocalLang(); //set languages icons
  22. console.log('current data ', this.currentDate);
  23. this.currentDate = this.authSer.writeHijri(new Date(this.currentDate), 'ar', 'header');
  24. if(!this.authSer.isAuthenticated()) {
  25. console.log('user data external header', this.authSer.returnUserData());
  26. this.dataLoginUser = this.authSer.returnUserData();
  27. }
  28. console.log(this.dataLoginUser);
  29. this.authSer.footerData = [];
  30. this.authSer.onGetFooterData('external').subscribe(
  31. (responce) => {
  32. this.authSer.footerData = responce['footer'];
  33. console.log('fooooooooooooooter dattaaa' , this.authSer.footerData);
  34. },
  35. (error) => {
  36. console.log(error);
  37. }
  38. );
  39. //get header data
  40. this.externalService.getHeader().subscribe(
  41. (responce) => {
  42. console.log(responce);
  43. this.externalService.headerMenus = responce['parents'];
  44. console.log('menu data' , this.externalService.headerMenus);
  45. },
  46. (error) => {
  47. console.log(error);
  48. }
  49. );
  50. }
  51. onDashBoard() {
  52. this.router.navigate(['services/' + this.dataLoginUser.id]);
  53. }
  54. goToHome() {
  55. this.router.navigate(['/ExternalPage']);
  56. }
  57. onLogin() {
  58. this.router.navigate(['auth/login']);
  59. }
  60. onGetProfile() {
  61. this.router.navigate(['auth/profile/' + this.dataLoginUser.id]);
  62. }
  63. //log out function
  64. onLogout() {
  65. localStorage.clear();
  66. this.router.navigate(['auth/login']);
  67. }
  68. }