import { HotkeysService } from 'angular2-hotkeys'
import * as debug from 'debug'
import { switchMap } from 'rxjs/operators'
+import { environment } from 'src/environments/environment'
import { ViewportScroller } from '@angular/common'
import { Component, OnInit, ViewChild } from '@angular/core'
import { Router } from '@angular/router'
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 { PluginsManager } from '@root-helpers/plugins-manager'
import { HTMLServerConfig, ServerConfig, UserRight, VideoConstant } from '@shared/models'
-const logger = debug('peertube:menu:MenuComponent')
+const debugLogger = debug('peertube:menu:MenuComponent')
@Component({
selector: 'my-menu',
templateUrl: './menu.component.html',
- styleUrls: ['./menu.component.scss']
+ styleUrls: [ './menu.component.scss' ]
})
export class MenuComponent implements OnInit {
@ViewChild('languageChooserModal', { static: true }) languageChooserModal: LanguageChooserComponent
this.htmlServerConfig = this.serverService.getHTMLConfig()
this.currentInterfaceLanguage = this.languageChooserModal.getCurrentLanguage()
+ this.isLoggedIn = this.authService.isLoggedIn()
this.updateUserState()
this.buildMenuSections()
.subscribe(() => this.buildUserLanguages())
})
+ this.serverService.getConfig()
+ .subscribe(config => this.serverConfig = config)
+
this.modalService.openQuickSettingsSubject
.subscribe(() => this.openQuickSettings())
}
+ getExternalLoginHref () {
+ return PluginsManager.getDefaultLoginHref(environment.apiUrl, this.serverConfig)
+ }
+
isRegistrationAllowed () {
if (!this.serverConfig) return false
toggleUseP2P () {
if (!this.user) return
- this.user.webTorrentEnabled = !this.user.webTorrentEnabled
+ this.user.p2pEnabled = !this.user.p2pEnabled
- this.userService.updateMyProfile({ webTorrentEnabled: this.user.webTorrentEnabled })
+ this.userService.updateMyProfile({ p2pEnabled: this.user.p2pEnabled })
.subscribe(() => this.authService.refreshUserInformation())
}
.pipe(
switchMap(() => this.user.computeCanSeeVideosLink(this.userService.getMyVideoQuotaUsed()))
).subscribe(res => {
- if (res === true) logger('User can see videos link.')
- else logger('User cannot see videos link.')
+ if (res === true) debugLogger('User can see videos link.')
+ else debugLogger('User cannot see videos link.')
})
}