external-page-header.component.ts 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  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. dataLoginUser:any;
  17. ngOnInit() {
  18. this.authSer.arabicTemplate = true;
  19. this.authSer.showDashboardHeader = false;
  20. this.authSer.setLocalLang(); //set languages icons
  21. this.currentDate = this.authSer.writeHijri(new Date(this.currentDate), 'ar', 'header');
  22. if(!this.authSer.isAuthenticated()) {
  23. console.log('user data external header', this.authSer.returnUserData());
  24. this.dataLoginUser = this.authSer.returnUserData();
  25. }
  26. console.log(this.dataLoginUser);
  27. this.authSer.footerData = [];
  28. this.authSer.onGetFooterData('external').subscribe(
  29. (responce) => {
  30. this.authSer.footerData = responce['footer'];
  31. console.log('fooooooooooooooter dattaaa' , this.authSer.footerData);
  32. },
  33. (error) => {
  34. console.log(error);
  35. }
  36. );
  37. //get header data
  38. this.externalService.getHeader().subscribe(
  39. (responce) => {
  40. console.log(responce);
  41. this.externalService.headerMenus = responce['parents'];
  42. console.log('menu data' , this.externalService.headerMenus);
  43. },
  44. (error) => {
  45. console.log(error);
  46. }
  47. );
  48. }
  49. onDashBoard() {
  50. this.router.navigate(['services/' + this.dataLoginUser.id]);
  51. }
  52. goToHome() {
  53. this.router.navigate(['/ExternalPage']);
  54. }
  55. onLogin() {
  56. this.router.navigate(['auth/login']);
  57. }
  58. onGetProfile() {
  59. this.router.navigate(['auth/profile/' + this.dataLoginUser.id]);
  60. }
  61. //log out function
  62. onLogout() {
  63. localStorage.clear();
  64. this.router.navigate(['auth/login']);
  65. }
  66. }