File size: 1,194 Bytes
6dc3ffe
e4ab6d0
6dc3ffe
 
 
e4ab6d0
 
 
 
 
 
6dc3ffe
 
 
 
 
 
 
e4ab6d0
 
 
6dc3ffe
 
 
 
 
 
 
 
 
 
 
e4ab6d0
 
6dc3ffe
e4ab6d0
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
import { Component, Inject, OnInit } from '@angular/core';
import { AuthService } from './auth/auth.service';
import { BrandService } from './shared/brand.service';
import { Title } from '@angular/platform-browser';
import { DOCUMENT } from '@angular/common';

@Component({
  selector: 'app-root',
  templateUrl: './app.component.html',
  styleUrl: './app.component.css'
})
export class AppComponent implements OnInit {
  constructor(
    private authService: AuthService,
    public brandService: BrandService,
    private titleService: Title,
    @Inject(DOCUMENT) private document: Document
  ) { }
  title = 'Py-Learn';

  ngOnInit(): void {
    // Set dynamic title
    this.titleService.setTitle(this.brandService.name);

    // Set dynamic favicon
    const favicon: HTMLLinkElement | null = this.document.querySelector("link[rel*='icon']");
    if (favicon) {
      favicon.href = this.brandService.name === 'Py-Learn'
        ? 'assets/favicon.png'
        : 'assets/majema-favicon.png'; // Make sure this file exists for MJ-Learn
    }

    this.authService.checkSession().subscribe((status) => {
      if (status) {
        this.authService.startAutoRefresh();
      }
    });
  }
}