Frontend/src/app/app.component.ts

41 lines
1.1 KiB
TypeScript

import {Component, Inject, PLATFORM_ID} from '@angular/core'
import {isPlatformBrowser} from '@angular/common'
import {AppState} from './modules/shared/app-state'
import {SubscribingComponent} from './modules/shared/components/subscribing.component'
import {ActivatedRoute, Router} from '@angular/router'
import {ErrorService} from './modules/shared/service/error.service'
@Component({
selector: 'cre-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.sass']
})
export class AppComponent extends SubscribingComponent {
isOnline: boolean
isServerOnline = true
constructor(
@Inject(PLATFORM_ID) private platformId: object,
private appState: AppState,
errorService: ErrorService,
router: Router,
activatedRoute: ActivatedRoute
) {
super(errorService, activatedRoute, router)
}
ngOnInit() {
this.isOnline = isPlatformBrowser(this.platformId)
super.ngOnInit()
this.subscribe(
this.appState.serverOnline$,
online => this.isServerOnline = online
)
}
reload() {
window.location.reload()
}
}