X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=client%2Fsrc%2Fapp%2Fmenu%2Fmenu.component.ts;h=c767f19b27186f957905802063127e747fd36e80;hb=2989628b7913383b39ac34c7db8666a21f8e5037;hp=50ff0e2b30884fb342c9381499c8f935324f7930;hpb=51a83970061b4005343d2bfc4edb883318ef2ca6;p=github%2FChocobozzz%2FPeerTube.git diff --git a/client/src/app/menu/menu.component.ts b/client/src/app/menu/menu.component.ts index 50ff0e2b3..c767f19b2 100644 --- a/client/src/app/menu/menu.component.ts +++ b/client/src/app/menu/menu.component.ts @@ -1,15 +1,26 @@ -import { ViewportScroller } from '@angular/common' import { HotkeysService } from 'angular2-hotkeys' import * as debug from 'debug' import { switchMap } from 'rxjs/operators' +import { ViewportScroller } from '@angular/common' import { Component, OnInit, ViewChild } from '@angular/core' import { Router } from '@angular/router' +import { + AuthService, + AuthStatus, + AuthUser, + MenuLink, + MenuService, + RedirectService, + ScreenService, + ServerService, + UserService +} from '@app/core' import { scrollToTop } from '@app/helpers' -import { AuthService, AuthStatus, AuthUser, MenuService, RedirectService, ScreenService, ServerService, UserService } from '@app/core' import { LanguageChooserComponent } from '@app/menu/language-chooser.component' import { QuickSettingsModalComponent } from '@app/modal/quick-settings-modal.component' -import { ServerConfig, UserRight, VideoConstant } from '@shared/models' -import { NgbDropdown, NgbDropdownConfig } from '@ng-bootstrap/ng-bootstrap' +import { PeertubeModalService } from '@app/shared/shared-main/peertube-modal/peertube-modal.service' +import { NgbDropdown } from '@ng-bootstrap/ng-bootstrap' +import { HTMLServerConfig, ServerConfig, UserRight, VideoConstant } from '@shared/models' const logger = debug('peertube:menu:MenuComponent') @@ -34,8 +45,13 @@ export class MenuComponent implements OnInit { currentInterfaceLanguage: string + commonMenuLinks: MenuLink[] = [] + private languages: VideoConstant[] = [] + + private htmlServerConfig: HTMLServerConfig private serverConfig: ServerConfig + private routesPerRight: { [role in UserRight]?: string } = { [UserRight.MANAGE_USERS]: '/admin/users', [UserRight.MANAGE_SERVER_FOLLOW]: '/admin/friends', @@ -54,22 +70,18 @@ export class MenuComponent implements OnInit { private hotkeysService: HotkeysService, private screenService: ScreenService, private menuService: MenuService, - private dropdownConfig: NgbDropdownConfig, + private modalService: PeertubeModalService, private router: Router - ) { - this.dropdownConfig.container = 'body' - } + ) { } get isInMobileView () { return this.screenService.isInMobileView() } get dropdownContainer () { - if (this.isInMobileView) { - return null - } else { - return this.dropdownConfig.container - } + if (this.isInMobileView) return null + + return 'body' as 'body' } get language () { @@ -77,13 +89,12 @@ export class MenuComponent implements OnInit { } 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) { @@ -130,9 +141,14 @@ export class MenuComponent implements OnInit { this.authService.userInformationLoaded .subscribe(() => this.buildUserLanguages()) }) + + this.modalService.openQuickSettingsSubject + .subscribe(() => this.openQuickSettings()) } isRegistrationAllowed () { + if (!this.serverConfig) return false + return this.serverConfig.signup.allowed && this.serverConfig.signup.allowedForCurrentIP } @@ -228,7 +244,7 @@ export class MenuComponent implements OnInit { // Close dropdown when window scroll to avoid dropdown quick jump for re-position const onWindowScroll = () => { - this.dropdown.close() + this.dropdown?.close() window.removeEventListener('scroll', onWindowScroll) } @@ -241,6 +257,10 @@ export class MenuComponent implements OnInit { } } + private buildMenuLinks () { + this.commonMenuLinks = this.menuService.buildCommonLinks(this.htmlServerConfig) + } + private buildUserLanguages () { if (!this.user) { this.videoLanguages = []