internal-page-header.component.ts 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  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(private 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. currentDate: any = Date.now();
  24. currentEnglishDate: any = Date.now();
  25. showActiveBackground: boolean = false;
  26. ngOnInit() {
  27. this.authSer.footerData = [];
  28. this.authSer.onGetFooterData('internal').subscribe(
  29. (responce) => {
  30. this.authSer.footerData = responce['footer'];
  31. console.log(this.authSer.footerData);
  32. },
  33. (error) => {
  34. console.log(error);
  35. }
  36. );
  37. this.authSer.setLocalLang();
  38. console.log('tooooken', this.authSer.isAuthenticated());
  39. this.internalService.getParentData().subscribe(
  40. (responce) => {
  41. this.authSer.parentsPage = responce['parents'];
  42. console.log('parents pageees', this.authSer.parentsPage);
  43. },
  44. (error) => {
  45. console.log(error);
  46. }
  47. );
  48. //this.spinner.show();
  49. this.authSer.showDashboardHeader = false;
  50. this.internalService.getParentData();
  51. //console.log(this.checkTokenExpire);
  52. //get profile data
  53. this.userservice.getUserDataProfile();
  54. this.currentDate = this.authSer.writeHijri(new Date(this.currentDate), 'ar', 'header');
  55. }
  56. onLogin() {
  57. this.router.navigate(['auth/login']);
  58. }
  59. onGetProfile() {
  60. console.log('profile/' + this.authSer.dataLoginUser['id']);
  61. this.router.navigate(['profile/' + this.authSer.dataLoginUser['id']]);
  62. }
  63. //log out function
  64. onLogout() {
  65. localStorage.clear();
  66. this.router.navigate(['auth/login']);
  67. }
  68. onDashBoard() {
  69. this.router.navigate(['services/' + this.authSer.dataLoginUser['id']]);
  70. }
  71. goToHome() {
  72. this.router.navigate(['/InternalPage']);
  73. }
  74. getData(parentData) {
  75. console.log(parentData);
  76. }
  77. }