internal-page-header.component.ts 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. import { Router, ActivatedRoute, Params } from '@angular/router';
  2. import { InternalPageService } from './../../shared/internal-page.service';
  3. import { UserService } from './../../shared/user.service';
  4. import { AuthServiceService } from './../../shared/auth-service.service';
  5. import { Component, OnInit } from '@angular/core';
  6. import 'hijri-date';
  7. import HijriDate,{toHijri} from 'hijri-date/lib/safe';
  8. import { NgxSpinnerService } from 'ngx-spinner';
  9. @Component({
  10. selector: 'app-internal-page-header',
  11. templateUrl: './internal-page-header.component.html',
  12. styleUrls: ['./internal-page-header.component.css']
  13. })
  14. export class InternalPageHeaderComponent implements OnInit {
  15. constructor(public authSer: AuthServiceService,
  16. private userservice: UserService,
  17. private internalService: InternalPageService,
  18. private route: ActivatedRoute,
  19. private spinner: NgxSpinnerService,
  20. private router: Router) {
  21. spinner.show();
  22. }
  23. dataLoginUser = {
  24. name: '',
  25. photo: '',
  26. }
  27. currentDate: any = Date.now();
  28. currentEnglishDate: any = Date.now();
  29. showActiveBackground: boolean = false;
  30. ngOnInit() {
  31. this.authSer.footerData = [];
  32. if(!this.authSer.isAuthenticated()) {
  33. this.dataLoginUser.name = this.authSer.returnUserData().name;
  34. this.dataLoginUser.photo = this.authSer.returnUserData().photo;
  35. }
  36. this.authSer.onGetFooterData('internal').subscribe(
  37. (responce) => {
  38. this.authSer.footerData = responce['footer'];
  39. console.log(this.authSer.footerData);
  40. },
  41. (error) => {
  42. console.log(error);
  43. }
  44. );
  45. this.authSer.setLocalLang();
  46. console.log('tooooken', this.authSer.isAuthenticated());
  47. this.internalService.getParentData().subscribe(
  48. (responce) => {
  49. this.authSer.parentsPage = responce['parents'];
  50. console.log('parents pageees', this.authSer.parentsPage);
  51. },
  52. (error) => {
  53. console.log(error);
  54. }
  55. );
  56. //this.spinner.show();
  57. this.authSer.showDashboardHeader = false;
  58. this.internalService.getParentData();
  59. //console.log(this.checkTokenExpire);
  60. //get profile data
  61. //this.userservice.getUserDataProfile();
  62. this.currentDate = this.authSer.writeHijri(new Date(this.currentDate), 'ar', 'header');
  63. }
  64. onLogin() {
  65. this.router.navigate(['auth/login']);
  66. }
  67. onGetProfile() {
  68. console.log('profile/' + this.authSer.dataLoginUser['id']);
  69. this.router.navigate(['auth/profile/' + this.authSer.dataLoginUser['id']]);
  70. }
  71. //log out function
  72. onLogout() {
  73. localStorage.clear();
  74. this.router.navigate(['auth/login']);
  75. }
  76. onDashBoard() {
  77. this.router.navigate(['services/' + this.authSer.dataLoginUser['id']]);
  78. }
  79. goToHome() {
  80. this.router.navigate(['/InternalPage']);
  81. }
  82. getData(parentData) {
  83. console.log(parentData);
  84. }
  85. }