diff --git a/client/src/app/header/header.component.html b/client/src/app/header/header.component.html index 8ee41c4de3f..4b3d5e10515 100644 --- a/client/src/app/header/header.component.html +++ b/client/src/app/header/header.component.html @@ -4,7 +4,7 @@ > - + Upload diff --git a/client/src/app/header/header.component.scss b/client/src/app/header/header.component.scss index 736035b72ba..2bbde74bc7d 100644 --- a/client/src/app/header/header.component.scss +++ b/client/src/app/header/header.component.scss @@ -53,6 +53,7 @@ @include orange-button; @include button-with-icon(22px, 3px, -1px); + color: var(--mainBackgroundColor) !important; margin-right: 25px; @media screen and (max-width: 800px) { diff --git a/client/src/app/header/header.component.ts b/client/src/app/header/header.component.ts index c6e942e0e5c..192d6945b3f 100644 --- a/client/src/app/header/header.component.ts +++ b/client/src/app/header/header.component.ts @@ -2,8 +2,9 @@ import { filter, first, map, tap } from 'rxjs/operators' import { Component, OnInit } from '@angular/core' import { ActivatedRoute, NavigationEnd, Params, Router } from '@angular/router' import { getParameterByName } from '../shared/misc/utils' -import { AuthService } from '@app/core' +import { AuthService, ServerService, Notifier } from '@app/core' import { of } from 'rxjs' +import { ServerConfig } from '@shared/models' @Component({ selector: 'my-header', @@ -14,10 +15,15 @@ import { of } from 'rxjs' export class HeaderComponent implements OnInit { searchValue = '' + private serverConfig: ServerConfig + constructor ( private router: Router, private route: ActivatedRoute, - private auth: AuthService + private auth: AuthService, + private serverService: ServerService, + private authService: AuthService, + private notifier: Notifier ) {} ngOnInit () { @@ -27,6 +33,13 @@ export class HeaderComponent implements OnInit { map(() => getParameterByName('search', window.location.href)) ) .subscribe(searchQuery => this.searchValue = searchQuery || '') + + this.serverConfig = this.serverService.getTmpConfig() + this.serverService.getConfig().subscribe( + config => this.serverConfig = config, + + err => this.notifier.error(err.message) + ) } doSearch () { @@ -45,6 +58,25 @@ export class HeaderComponent implements OnInit { o.subscribe(() => this.router.navigate([ '/search' ], { queryParams })) } + isUserLoggedIn () { + return this.authService.isLoggedIn() + } + + isRegistrationAllowed () { + return this.serverConfig.signup.allowed && + this.serverConfig.signup.allowedForCurrentIP + } + + goToUpload () { + if (this.isUserLoggedIn()) { + this.router.navigate([ '/videos/upload' ]) + } else if (this.isRegistrationAllowed()) { + this.router.navigate([ '/signup' ]) + } else { + this.router.navigate([ '/login', { fromUpload: true } ]) + } + } + private loadUserLanguagesIfNeeded (queryParams: any) { if (queryParams && queryParams.languageOneOf) return of(queryParams) diff --git a/client/src/app/login/login.component.html b/client/src/app/login/login.component.html index 9bbeab3be3a..162f44ded8a 100644 --- a/client/src/app/login/login.component.html +++ b/client/src/app/login/login.component.html @@ -3,6 +3,18 @@ Login + +
{{ error }} Request new verification email.
diff --git a/client/src/app/login/login.component.scss b/client/src/app/login/login.component.scss index 8541a268137..8ac231475ec 100644 --- a/client/src/app/login/login.component.scss +++ b/client/src/app/login/login.component.scss @@ -20,8 +20,10 @@ input[type=submit] { .create-an-account, .forgot-password-button { color: var(--mainForegroundColor); cursor: pointer; + transition: opacity cubic-bezier(0.39, 0.575, 0.565, 1); &:hover { - text-decoration: underline !important; + text-decoration: none !important; + opacity: .7 !important; } } diff --git a/client/src/app/login/login.component.ts b/client/src/app/login/login.component.ts index ffadc9aa46e..1394d6b5856 100644 --- a/client/src/app/login/login.component.ts +++ b/client/src/app/login/login.component.ts @@ -1,5 +1,5 @@ import { Component, ElementRef, OnInit, ViewChild } from '@angular/core' -import { Notifier, RedirectService, ServerService } from '@app/core' +import { Notifier, RedirectService } from '@app/core' import { UserService } from '@app/shared' import { AuthService } from '../core' import { FormReactive } from '../shared' @@ -7,8 +7,8 @@ import { I18n } from '@ngx-translate/i18n-polyfill' import { FormValidatorService } from '@app/shared/forms/form-validators/form-validator.service' import { LoginValidatorsService } from '@app/shared/forms/form-validators/login-validators.service' import { NgbModal, NgbModalRef } from '@ng-bootstrap/ng-bootstrap' -import { ActivatedRoute, Router } from '@angular/router' -import { ServerConfig } from '@shared/models' +import { ActivatedRoute } from '@angular/router' +import { ServerConfig } from '@shared/models/server/server-config.model' @Component({ selector: 'my-login', @@ -22,6 +22,9 @@ export class LoginComponent extends FormReactive implements OnInit { error: string = null forgotPasswordEmail = '' + from = { + upload: false + } private openedForgotPasswordModal: NgbModalRef private serverConfig: ServerConfig @@ -44,12 +47,17 @@ export class LoginComponent extends FormReactive implements OnInit { return this.serverConfig.signup.allowed === true } + get instancesIndexUrl () { + return this.serverConfig.followings.instance.autoFollowIndex.indexUrl || 'https://instances.joinpeertube.org' + } + isEmailDisabled () { return this.serverConfig.email.enabled === false } ngOnInit () { this.serverConfig = this.route.snapshot.data.serverConfig + this.from.upload = Boolean(this.route.snapshot.paramMap.get('fromUpload')) this.buildForm({ username: this.loginValidatorsService.LOGIN_USERNAME, diff --git a/client/src/app/menu/menu.component.ts b/client/src/app/menu/menu.component.ts index 2d522b5217d..1d7651e78f4 100644 --- a/client/src/app/menu/menu.component.ts +++ b/client/src/app/menu/menu.component.ts @@ -33,7 +33,6 @@ export class MenuComponent implements OnInit { private authService: AuthService, private serverService: ServerService, private redirectService: RedirectService, - private themeService: ThemeService, private hotkeysService: HotkeysService ) {} diff --git a/client/src/sass/bootstrap.scss b/client/src/sass/bootstrap.scss index a3261a8a668..dc0d075c9a0 100644 --- a/client/src/sass/bootstrap.scss +++ b/client/src/sass/bootstrap.scss @@ -165,4 +165,8 @@ ngb-tabset.bootstrap { .dropdown-divider { margin: 0.3rem 0; -} \ No newline at end of file +} + +ngb-modal-backdrop { + z-index: 10000 !important; +} diff --git a/server/controllers/api/config.ts b/server/controllers/api/config.ts index 6fad82408b4..06ee1ee857a 100644 --- a/server/controllers/api/config.ts +++ b/server/controllers/api/config.ts @@ -155,6 +155,14 @@ async function getConfig (req: express.Request, res: express.Response) { }, tracker: { enabled: CONFIG.TRACKER.ENABLED + }, + + followings: { + instance: { + autoFollowIndex: { + indexUrl: CONFIG.FOLLOWINGS.INSTANCE.AUTO_FOLLOW_INDEX.INDEX_URL + } + } } } diff --git a/shared/models/server/server-config.model.ts b/shared/models/server/server-config.model.ts index 6d10723333f..f1bb2153cd3 100644 --- a/shared/models/server/server-config.model.ts +++ b/shared/models/server/server-config.model.ts @@ -126,4 +126,12 @@ export interface ServerConfig { tracker: { enabled: boolean } + + followings: { + instance: { + autoFollowIndex: { + indexUrl: string + } + } + } }