X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=client%2Fsrc%2Fapp%2Fmenu%2Fmenu.component.ts;h=371beb4a579620775cf8a152fc162349ceaa2d8a;hb=fc2ec87a8c4dcfbb91a1a62cf4c07a2a8e6a50fe;hp=8b8b714a807139a9619429eaef445d8d382023fb;hpb=fada8d75550dc7365f7e18ee1569b9406251d660;p=github%2FChocobozzz%2FPeerTube.git diff --git a/client/src/app/menu/menu.component.ts b/client/src/app/menu/menu.component.ts index 8b8b714a8..371beb4a5 100644 --- a/client/src/app/menu/menu.component.ts +++ b/client/src/app/menu/menu.component.ts @@ -1,8 +1,9 @@ -import { Component, OnInit } from '@angular/core' -import { Router } from '@angular/router' +import { Component, OnInit, ViewChild } from '@angular/core' import { UserRight } from '../../../../shared/models/users/user-right.enum' -import { AuthService, AuthStatus, ServerService } from '../core' +import { AuthService, AuthStatus, RedirectService, ServerService, ThemeService } from '../core' import { User } from '../shared/users/user.model' +import { LanguageChooserComponent } from '@app/menu/language-chooser.component' +import { HotkeysService } from 'angular2-hotkeys' @Component({ selector: 'my-menu', @@ -10,21 +11,28 @@ import { User } from '../shared/users/user.model' styleUrls: [ './menu.component.scss' ] }) export class MenuComponent implements OnInit { + @ViewChild('languageChooserModal') languageChooserModal: LanguageChooserComponent + user: User isLoggedIn: boolean userHasAdminAccess = false + helpVisible = false - private routesPerRight = { + private routesPerRight: { [ role in UserRight ]?: string } = { [UserRight.MANAGE_USERS]: '/admin/users', [UserRight.MANAGE_SERVER_FOLLOW]: '/admin/friends', - [UserRight.MANAGE_VIDEO_ABUSES]: '/admin/video-abuses', - [UserRight.MANAGE_VIDEO_BLACKLIST]: '/admin/video-blacklist' + [UserRight.MANAGE_VIDEO_ABUSES]: '/admin/moderation/video-abuses', + [UserRight.MANAGE_VIDEO_BLACKLIST]: '/admin/moderation/video-blacklist', + [UserRight.MANAGE_JOBS]: '/admin/jobs', + [UserRight.MANAGE_CONFIGURATION]: '/admin/config' } constructor ( private authService: AuthService, private serverService: ServerService, - private router: Router + private redirectService: RedirectService, + private themeService: ThemeService, + private hotkeysService: HotkeysService ) {} ngOnInit () { @@ -49,14 +57,15 @@ export class MenuComponent implements OnInit { } } ) - } - getUserAvatarPath () { - return this.user.getAvatarPath() + this.hotkeysService.cheatSheetToggle.subscribe(isOpen => { + this.helpVisible = isOpen + }) } isRegistrationAllowed () { - return this.serverService.getConfig().signup.allowed + return this.serverService.getConfig().signup.allowed && + this.serverService.getConfig().signup.allowedForCurrentIP } getFirstAdminRightAvailable () { @@ -67,7 +76,9 @@ export class MenuComponent implements OnInit { UserRight.MANAGE_USERS, UserRight.MANAGE_SERVER_FOLLOW, UserRight.MANAGE_VIDEO_ABUSES, - UserRight.MANAGE_VIDEO_BLACKLIST + UserRight.MANAGE_VIDEO_BLACKLIST, + UserRight.MANAGE_JOBS, + UserRight.MANAGE_CONFIGURATION ] for (const adminRight of adminRights) { @@ -90,7 +101,19 @@ export class MenuComponent implements OnInit { this.authService.logout() // Redirect to home page - this.router.navigate(['/videos/list']) + this.redirectService.redirectToHomepage() + } + + openLanguageChooser () { + this.languageChooserModal.show() + } + + openHotkeysCheatSheet () { + this.hotkeysService.cheatSheetToggle.next(!this.helpVisible) + } + + toggleDarkTheme () { + this.themeService.toggleDarkTheme() } private computeIsUserHasAdminAccess () {