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