internal-page-header.component.ts 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  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. @Component({
  9. selector: 'app-internal-page-header',
  10. templateUrl: './internal-page-header.component.html',
  11. styleUrls: ['./internal-page-header.component.css']
  12. })
  13. export class InternalPageHeaderComponent implements OnInit {
  14. constructor(private authSer: AuthServiceService,
  15. private userservice: UserService,
  16. private internalService: InternalPageService,
  17. private route: ActivatedRoute,
  18. private router: Router) { }
  19. currentDate: any = Date.now();
  20. currentEnglishDate: any = Date.now();
  21. showActiveBackground: boolean = false;
  22. ngOnInit() {
  23. this.authSer.setLocalLang();
  24. console.log('tooooken', this.authSer.isAuthenticated());
  25. this.internalService.getParentData().subscribe(
  26. (responce) => {
  27. this.authSer.parentsPage = responce['parents'];
  28. console.log('parents pageees', this.authSer.parentsPage);
  29. },
  30. (error) => {
  31. console.log(error);
  32. }
  33. );
  34. //this.spinner.show();
  35. this.authSer.showDashboardHeader = false;
  36. this.internalService.getParentData();
  37. //console.log(this.checkTokenExpire);
  38. //get profile data
  39. this.userservice.getUserDataProfile();
  40. this.currentDate = this.authSer.writeHijri(new Date(this.currentDate), 'ar', 'header');
  41. }
  42. onLogin() {
  43. this.router.navigate(['/login']);
  44. }
  45. onGetProfile() {
  46. console.log('profile/' + this.authSer.dataLoginUser['id']);
  47. this.router.navigate(['profile/' + this.authSer.dataLoginUser['id']]);
  48. }
  49. //log out function
  50. onLogout() {
  51. localStorage.clear();
  52. this.router.navigate(['login']);
  53. }
  54. onDashBoard() {
  55. this.router.navigate(['services/' + this.authSer.dataLoginUser['id']]);
  56. }
  57. goToHome() {
  58. this.router.navigate(['InternalPage/home']);
  59. }
  60. }