import { Component, OnInit } from '@angular/core'; import { AuthService } from '../shared/services/auth.service'; import { ActivatedRoute, Router } from '@angular/router'; import { EventPage } from './resources/event.page'; import { AttendeesService } from '../shared/services/attendees.service'; import { DomSanitizer } from '@angular/platform-browser'; import * as WebFont from 'webfontloader'; import { Font } from 'ngx-font-picker'; @Component({ selector: 'app-public-app', templateUrl: './public-app.component.html', styleUrls: ['./public-app.component.css'], providers: [ AttendeesService ] }) export class PublicAppComponent implements OnInit { isWorking: boolean = false; Page: EventPage; constructor(private _auth: AuthService, private _route: ActivatedRoute, private _router: Router, private _tournament: AttendeesService, public sanitizer: DomSanitizer) { } ngOnInit() { this._route.params.subscribe(params => { this.isWorking = true; this._tournament.get_from_url(params['url']) .then((result) => { if (!result.result) { this._router.navigate(['/404']); } else { this.Page = new EventPage(result.result); WebFont.load({ google: { families: [this.Page.branding.global_font.family, this.Page.branding.banner_font.family] } }); this.isWorking = false; } }) .catch((err) => { console.log(err); this._router.navigate(['/404']); }); }); } DisplayGDPRPrompt() { if (this._auth.loggedIn()) { return this._auth.User.gdpr_date_expired; } return false; } get_global_font_styles() { if (this.Page) { return new Font(this.Page.branding.global_font).getStyles(); } } get_banner_font_styles() { if (this.Page) { return new Font(this.Page.branding.banner_font).getStyles(); } } }