Add informational message at login for visitors coming from upload button
resolves #1880
This commit is contained in:
parent
ab4d4db44a
commit
000eb0e40d
10 changed files with 83 additions and 9 deletions
|
@ -4,7 +4,7 @@
|
||||||
>
|
>
|
||||||
<span (click)="doSearch()" class="icon icon-search"></span>
|
<span (click)="doSearch()" class="icon icon-search"></span>
|
||||||
|
|
||||||
<a class="upload-button" routerLink="/videos/upload">
|
<a class="upload-button" (click)="goToUpload()">
|
||||||
<my-global-icon iconName="upload"></my-global-icon>
|
<my-global-icon iconName="upload"></my-global-icon>
|
||||||
<span i18n class="upload-button-label">Upload</span>
|
<span i18n class="upload-button-label">Upload</span>
|
||||||
</a>
|
</a>
|
||||||
|
|
|
@ -53,6 +53,7 @@
|
||||||
@include orange-button;
|
@include orange-button;
|
||||||
@include button-with-icon(22px, 3px, -1px);
|
@include button-with-icon(22px, 3px, -1px);
|
||||||
|
|
||||||
|
color: var(--mainBackgroundColor) !important;
|
||||||
margin-right: 25px;
|
margin-right: 25px;
|
||||||
|
|
||||||
@media screen and (max-width: 800px) {
|
@media screen and (max-width: 800px) {
|
||||||
|
|
|
@ -2,8 +2,9 @@ import { filter, first, map, tap } from 'rxjs/operators'
|
||||||
import { Component, OnInit } from '@angular/core'
|
import { Component, OnInit } from '@angular/core'
|
||||||
import { ActivatedRoute, NavigationEnd, Params, Router } from '@angular/router'
|
import { ActivatedRoute, NavigationEnd, Params, Router } from '@angular/router'
|
||||||
import { getParameterByName } from '../shared/misc/utils'
|
import { getParameterByName } from '../shared/misc/utils'
|
||||||
import { AuthService } from '@app/core'
|
import { AuthService, ServerService, Notifier } from '@app/core'
|
||||||
import { of } from 'rxjs'
|
import { of } from 'rxjs'
|
||||||
|
import { ServerConfig } from '@shared/models'
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'my-header',
|
selector: 'my-header',
|
||||||
|
@ -14,10 +15,15 @@ import { of } from 'rxjs'
|
||||||
export class HeaderComponent implements OnInit {
|
export class HeaderComponent implements OnInit {
|
||||||
searchValue = ''
|
searchValue = ''
|
||||||
|
|
||||||
|
private serverConfig: ServerConfig
|
||||||
|
|
||||||
constructor (
|
constructor (
|
||||||
private router: Router,
|
private router: Router,
|
||||||
private route: ActivatedRoute,
|
private route: ActivatedRoute,
|
||||||
private auth: AuthService
|
private auth: AuthService,
|
||||||
|
private serverService: ServerService,
|
||||||
|
private authService: AuthService,
|
||||||
|
private notifier: Notifier
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
ngOnInit () {
|
ngOnInit () {
|
||||||
|
@ -27,6 +33,13 @@ export class HeaderComponent implements OnInit {
|
||||||
map(() => getParameterByName('search', window.location.href))
|
map(() => getParameterByName('search', window.location.href))
|
||||||
)
|
)
|
||||||
.subscribe(searchQuery => this.searchValue = searchQuery || '')
|
.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 () {
|
doSearch () {
|
||||||
|
@ -45,6 +58,25 @@ export class HeaderComponent implements OnInit {
|
||||||
o.subscribe(() => this.router.navigate([ '/search' ], { queryParams }))
|
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) {
|
private loadUserLanguagesIfNeeded (queryParams: any) {
|
||||||
if (queryParams && queryParams.languageOneOf) return of(queryParams)
|
if (queryParams && queryParams.languageOneOf) return of(queryParams)
|
||||||
|
|
||||||
|
|
|
@ -3,6 +3,18 @@
|
||||||
Login
|
Login
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div class="alert alert-warning" *ngIf="from.upload" role="alert">
|
||||||
|
<h6 class="alert-heading" i18n>
|
||||||
|
If you are looking for an account…
|
||||||
|
</h6>
|
||||||
|
<div i18n>
|
||||||
|
Currently this instance doesn't allow for user registration, but you can find an instance
|
||||||
|
that gives you the possibility to sign up for an account and upload your videos there.
|
||||||
|
Find yours among multiple instances at <a class="alert-link" [href]="instancesIndexUrl" target="_blank" rel="noopener noreferrer">{{ instancesIndexUrl }}</a>
|
||||||
|
, a directory of instances recommended by this instance.
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div *ngIf="error" class="alert alert-danger">{{ error }}
|
<div *ngIf="error" class="alert alert-danger">{{ error }}
|
||||||
<span *ngIf="error === 'User email is not verified.'"> <a i18n routerLink="/verify-account/ask-send-email">Request new verification email.</a></span>
|
<span *ngIf="error === 'User email is not verified.'"> <a i18n routerLink="/verify-account/ask-send-email">Request new verification email.</a></span>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -20,8 +20,10 @@ input[type=submit] {
|
||||||
.create-an-account, .forgot-password-button {
|
.create-an-account, .forgot-password-button {
|
||||||
color: var(--mainForegroundColor);
|
color: var(--mainForegroundColor);
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
|
transition: opacity cubic-bezier(0.39, 0.575, 0.565, 1);
|
||||||
|
|
||||||
&:hover {
|
&:hover {
|
||||||
text-decoration: underline !important;
|
text-decoration: none !important;
|
||||||
|
opacity: .7 !important;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import { Component, ElementRef, OnInit, ViewChild } from '@angular/core'
|
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 { UserService } from '@app/shared'
|
||||||
import { AuthService } from '../core'
|
import { AuthService } from '../core'
|
||||||
import { FormReactive } from '../shared'
|
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 { FormValidatorService } from '@app/shared/forms/form-validators/form-validator.service'
|
||||||
import { LoginValidatorsService } from '@app/shared/forms/form-validators/login-validators.service'
|
import { LoginValidatorsService } from '@app/shared/forms/form-validators/login-validators.service'
|
||||||
import { NgbModal, NgbModalRef } from '@ng-bootstrap/ng-bootstrap'
|
import { NgbModal, NgbModalRef } from '@ng-bootstrap/ng-bootstrap'
|
||||||
import { ActivatedRoute, Router } from '@angular/router'
|
import { ActivatedRoute } from '@angular/router'
|
||||||
import { ServerConfig } from '@shared/models'
|
import { ServerConfig } from '@shared/models/server/server-config.model'
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'my-login',
|
selector: 'my-login',
|
||||||
|
@ -22,6 +22,9 @@ export class LoginComponent extends FormReactive implements OnInit {
|
||||||
|
|
||||||
error: string = null
|
error: string = null
|
||||||
forgotPasswordEmail = ''
|
forgotPasswordEmail = ''
|
||||||
|
from = {
|
||||||
|
upload: false
|
||||||
|
}
|
||||||
|
|
||||||
private openedForgotPasswordModal: NgbModalRef
|
private openedForgotPasswordModal: NgbModalRef
|
||||||
private serverConfig: ServerConfig
|
private serverConfig: ServerConfig
|
||||||
|
@ -44,12 +47,17 @@ export class LoginComponent extends FormReactive implements OnInit {
|
||||||
return this.serverConfig.signup.allowed === true
|
return this.serverConfig.signup.allowed === true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get instancesIndexUrl () {
|
||||||
|
return this.serverConfig.followings.instance.autoFollowIndex.indexUrl || 'https://instances.joinpeertube.org'
|
||||||
|
}
|
||||||
|
|
||||||
isEmailDisabled () {
|
isEmailDisabled () {
|
||||||
return this.serverConfig.email.enabled === false
|
return this.serverConfig.email.enabled === false
|
||||||
}
|
}
|
||||||
|
|
||||||
ngOnInit () {
|
ngOnInit () {
|
||||||
this.serverConfig = this.route.snapshot.data.serverConfig
|
this.serverConfig = this.route.snapshot.data.serverConfig
|
||||||
|
this.from.upload = Boolean(this.route.snapshot.paramMap.get('fromUpload'))
|
||||||
|
|
||||||
this.buildForm({
|
this.buildForm({
|
||||||
username: this.loginValidatorsService.LOGIN_USERNAME,
|
username: this.loginValidatorsService.LOGIN_USERNAME,
|
||||||
|
|
|
@ -33,7 +33,6 @@ export class MenuComponent implements OnInit {
|
||||||
private authService: AuthService,
|
private authService: AuthService,
|
||||||
private serverService: ServerService,
|
private serverService: ServerService,
|
||||||
private redirectService: RedirectService,
|
private redirectService: RedirectService,
|
||||||
private themeService: ThemeService,
|
|
||||||
private hotkeysService: HotkeysService
|
private hotkeysService: HotkeysService
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
|
|
4
client/src/sass/bootstrap.scss
vendored
4
client/src/sass/bootstrap.scss
vendored
|
@ -166,3 +166,7 @@ ngb-tabset.bootstrap {
|
||||||
.dropdown-divider {
|
.dropdown-divider {
|
||||||
margin: 0.3rem 0;
|
margin: 0.3rem 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ngb-modal-backdrop {
|
||||||
|
z-index: 10000 !important;
|
||||||
|
}
|
||||||
|
|
|
@ -155,6 +155,14 @@ async function getConfig (req: express.Request, res: express.Response) {
|
||||||
},
|
},
|
||||||
tracker: {
|
tracker: {
|
||||||
enabled: CONFIG.TRACKER.ENABLED
|
enabled: CONFIG.TRACKER.ENABLED
|
||||||
|
},
|
||||||
|
|
||||||
|
followings: {
|
||||||
|
instance: {
|
||||||
|
autoFollowIndex: {
|
||||||
|
indexUrl: CONFIG.FOLLOWINGS.INSTANCE.AUTO_FOLLOW_INDEX.INDEX_URL
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -126,4 +126,12 @@ export interface ServerConfig {
|
||||||
tracker: {
|
tracker: {
|
||||||
enabled: boolean
|
enabled: boolean
|
||||||
}
|
}
|
||||||
|
|
||||||
|
followings: {
|
||||||
|
instance: {
|
||||||
|
autoFollowIndex: {
|
||||||
|
indexUrl: string
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue