import { ViewportScroller } from '@angular/common'
import { Component, OnInit, ViewChild } from '@angular/core'
import { Router } from '@angular/router'
-import { AuthService, AuthStatus, AuthUser, MenuService, RedirectService, ScreenService, ServerService, UserService } from '@app/core'
+import {
+ AuthService,
+ AuthStatus,
+ AuthUser,
+ MenuLink,
+ MenuService,
+ RedirectService,
+ ScreenService,
+ ServerService,
+ UserService
+} from '@app/core'
import { scrollToTop } from '@app/helpers'
import { LanguageChooserComponent } from '@app/menu/language-chooser.component'
import { QuickSettingsModalComponent } from '@app/modal/quick-settings-modal.component'
import { PeertubeModalService } from '@app/shared/shared-main/peertube-modal/peertube-modal.service'
import { NgbDropdown } from '@ng-bootstrap/ng-bootstrap'
-import { ServerConfig, UserRight, VideoConstant } from '@shared/models'
+import { HTMLServerConfig, ServerConfig, UserRight, VideoConstant } from '@shared/models'
const logger = debug('peertube:menu:MenuComponent')
currentInterfaceLanguage: string
+ commonMenuLinks: MenuLink[] = []
+
private languages: VideoConstant<string>[] = []
+
+ private htmlServerConfig: HTMLServerConfig
private serverConfig: ServerConfig
+
private routesPerRight: { [role in UserRight]?: string } = {
[UserRight.MANAGE_USERS]: '/admin/users',
[UserRight.MANAGE_SERVER_FOLLOW]: '/admin/friends',
}
get instanceName () {
- return this.serverConfig.instance.name
+ return this.htmlServerConfig.instance.name
}
ngOnInit () {
- this.serverConfig = this.serverService.getTmpConfig()
- this.serverService.getConfig()
- .subscribe(config => this.serverConfig = config)
+ this.htmlServerConfig = this.serverService.getHTMLConfig()
+ this.buildMenuLinks()
this.isLoggedIn = this.authService.isLoggedIn()
if (this.isLoggedIn === true) {
}
isRegistrationAllowed () {
+ if (!this.serverConfig) return false
+
return this.serverConfig.signup.allowed &&
this.serverConfig.signup.allowedForCurrentIP
}
}
}
+ private buildMenuLinks () {
+ this.commonMenuLinks = this.menuService.buildCommonLinks(this.htmlServerConfig)
+ }
+
private buildUserLanguages () {
if (!this.user) {
this.videoLanguages = []