From 000eb0e40d74e914f6691305511c44e89cd8bf07 Mon Sep 17 00:00:00 2001 From: Rigel Kent Date: Fri, 10 Jan 2020 14:01:13 +0100 Subject: Add informational message at login for visitors coming from upload button resolves #1880 --- client/src/app/header/header.component.html | 2 +- client/src/app/header/header.component.scss | 1 + client/src/app/header/header.component.ts | 36 +++++++++++++++++++++++++++-- 3 files changed, 36 insertions(+), 3 deletions(-) (limited to 'client/src/app/header') diff --git a/client/src/app/header/header.component.html b/client/src/app/header/header.component.html index 8ee41c4de..4b3d5e105 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 736035b72..2bbde74bc 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 c6e942e0e..192d6945b 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) -- cgit v1.2.3