import { Component, OnInit } from '@angular/core'
import { DomSanitizer, SafeHtml } from '@angular/platform-browser'
-import { GuardsCheckStart, Router } from '@angular/router'
+import { GuardsCheckStart, NavigationEnd, Router } from '@angular/router'
import { AuthService, RedirectService, ServerService } from '@app/core'
import { isInSmallView } from '@app/shared/misc/utils'
+import { is18nPath } from '../../../shared/models/i18n'
@Component({
selector: 'my-app',
private serverService: ServerService,
private domSanitizer: DomSanitizer,
private redirectService: RedirectService
- ) {}
+ ) { }
get serverVersion () {
return this.serverService.getConfig().serverVersion
ngOnInit () {
document.getElementById('incompatible-browser').className += ' browser-ok'
- const pathname = window.location.pathname
- if (!pathname || pathname === '/') {
- this.redirectService.redirectToHomepage()
- }
+ this.router.events.subscribe(e => {
+ if (e instanceof NavigationEnd) {
+ const pathname = window.location.pathname
+ if (!pathname || pathname === '/' || is18nPath(pathname)) {
+ this.redirectService.redirectToHomepage()
+ }
+ }
+ })
this.authService.loadClientCredentials()
window.scrollTo(0, 0)
this.isMenuDisplayed = !this.isMenuDisplayed
}
-
- getMainColClasses () {
- // Take all width is the menu is not displayed
- if (this.isMenuDisplayed === false) return [ 'expanded' ]
-
- return []
- }
}