X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=client%2Fsrc%2Fapp%2Fapp.component.ts;h=84435b5dbddcfddc2ab03228bc3b3adcb859c7b9;hb=09700934b90e2ac7b1b9ed1694d9d4d52735e2e1;hp=3af33ba2b47c8d1922b36edf13e07ec07bef0a4c;hpb=07fa4c97ca50b83b0bee9230da97d02401b4e05f;p=github%2FChocobozzz%2FPeerTube.git diff --git a/client/src/app/app.component.ts b/client/src/app/app.component.ts index 3af33ba2b..84435b5db 100644 --- a/client/src/app/app.component.ts +++ b/client/src/app/app.component.ts @@ -1,6 +1,7 @@ import { Component, OnInit } from '@angular/core' +import { DomSanitizer, SafeHtml } from '@angular/platform-browser' import { GuardsCheckStart, Router } from '@angular/router' -import { AuthService, ServerService } from '@app/core' +import { AuthService, RedirectService, ServerService } from '@app/core' import { isInSmallView } from '@app/shared/misc/utils' @Component({ @@ -24,10 +25,14 @@ export class AppComponent implements OnInit { isMenuDisplayed = true + customCSS: SafeHtml + constructor ( private router: Router, private authService: AuthService, - private serverService: ServerService + private serverService: ServerService, + private domSanitizer: DomSanitizer, + private redirectService: RedirectService ) {} get serverVersion () { @@ -39,6 +44,13 @@ export class AppComponent implements OnInit { } ngOnInit () { + document.getElementById('incompatible-browser').className += ' browser-ok' + + const pathname = window.location.pathname + if (!pathname || pathname === '/') { + this.redirectService.redirectToHomepage() + } + this.authService.loadClientCredentials() if (this.authService.isLoggedIn()) { @@ -66,6 +78,26 @@ export class AppComponent implements OnInit { } } ) + + this.serverService.configLoaded + .subscribe(() => { + const config = this.serverService.getConfig() + + // We test customCSS in case or the admin removed the css + if (this.customCSS || config.instance.customizations.css) { + const styleTag = '' + this.customCSS = this.domSanitizer.bypassSecurityTrustHtml(styleTag) + } + + if (config.instance.customizations.javascript) { + try { + // tslint:disable:no-eval + eval(config.instance.customizations.javascript) + } catch (err) { + console.error('Cannot eval custom JavaScript.', err) + } + } + }) } toggleMenu () {