diff options
Diffstat (limited to 'client')
21 files changed, 77 insertions, 48 deletions
diff --git a/client/src/app/+error-page/error-page.component.html b/client/src/app/+error-page/error-page.component.html index 070985d3c..b8b9296a3 100644 --- a/client/src/app/+error-page/error-page.component.html +++ b/client/src/app/+error-page/error-page.component.html | |||
@@ -31,10 +31,7 @@ | |||
31 | <ng-container *ngIf="type !== 'video'" i18n>You might need to login to see the resource.</ng-container> | 31 | <ng-container *ngIf="type !== 'video'" i18n>You might need to login to see the resource.</ng-container> |
32 | </div> | 32 | </div> |
33 | 33 | ||
34 | <a class="peertube-button-big-link orange-button mt-5" i18n routerLink="/login"> | 34 | <my-login-link className="peertube-button-big-link orange-button mt-5"></my-login-link> |
35 | Login | ||
36 | </a> | ||
37 | |||
38 | </div> | 35 | </div> |
39 | 36 | ||
40 | <div *ngIf="status === 403" class="box"> | 37 | <div *ngIf="status === 403" class="box"> |
diff --git a/client/src/app/+error-page/error-page.module.ts b/client/src/app/+error-page/error-page.module.ts index 807c6f5a9..34f026ea8 100644 --- a/client/src/app/+error-page/error-page.module.ts +++ b/client/src/app/+error-page/error-page.module.ts | |||
@@ -1,11 +1,13 @@ | |||
1 | import { CommonModule } from '@angular/common' | 1 | import { CommonModule } from '@angular/common' |
2 | import { NgModule } from '@angular/core' | 2 | import { NgModule } from '@angular/core' |
3 | import { SharedMainModule } from '@app/shared/shared-main' | ||
3 | import { ErrorPageRoutingModule } from './error-page-routing.module' | 4 | import { ErrorPageRoutingModule } from './error-page-routing.module' |
4 | import { ErrorPageComponent } from './error-page.component' | 5 | import { ErrorPageComponent } from './error-page.component' |
5 | 6 | ||
6 | @NgModule({ | 7 | @NgModule({ |
7 | imports: [ | 8 | imports: [ |
8 | CommonModule, | 9 | CommonModule, |
10 | SharedMainModule, | ||
9 | 11 | ||
10 | ErrorPageRoutingModule | 12 | ErrorPageRoutingModule |
11 | ], | 13 | ], |
diff --git a/client/src/app/+reset-password/reset-password.component.ts b/client/src/app/+reset-password/reset-password.component.ts index 44216f978..a6c05bbfb 100644 --- a/client/src/app/+reset-password/reset-password.component.ts +++ b/client/src/app/+reset-password/reset-password.component.ts | |||
@@ -45,6 +45,7 @@ export class ResetPasswordComponent extends FormReactive implements OnInit { | |||
45 | .subscribe({ | 45 | .subscribe({ |
46 | next: () => { | 46 | next: () => { |
47 | this.notifier.success($localize`Your password has been successfully reset!`) | 47 | this.notifier.success($localize`Your password has been successfully reset!`) |
48 | |||
48 | this.router.navigate([ '/login' ]) | 49 | this.router.navigate([ '/login' ]) |
49 | }, | 50 | }, |
50 | 51 | ||
diff --git a/client/src/app/+videos/+video-watch/shared/action-buttons/video-rate.component.ts b/client/src/app/+videos/+video-watch/shared/action-buttons/video-rate.component.ts index 0fef246b3..d0c138834 100644 --- a/client/src/app/+videos/+video-watch/shared/action-buttons/video-rate.component.ts +++ b/client/src/app/+videos/+video-watch/shared/action-buttons/video-rate.component.ts | |||
@@ -82,7 +82,7 @@ export class VideoRateComponent implements OnInit, OnChanges, OnDestroy { | |||
82 | getRatePopoverText () { | 82 | getRatePopoverText () { |
83 | if (this.isUserLoggedIn) return undefined | 83 | if (this.isUserLoggedIn) return undefined |
84 | 84 | ||
85 | return $localize`You need to be <a href="/login">logged in</a> to rate this video.` | 85 | return $localize`You need to be logged in to rate this video.` |
86 | } | 86 | } |
87 | 87 | ||
88 | private checkUserRating () { | 88 | private checkUserRating () { |
diff --git a/client/src/app/+videos/+video-watch/shared/comment/video-comment-add.component.html b/client/src/app/+videos/+video-watch/shared/comment/video-comment-add.component.html index 6bc201f32..203e9ce62 100644 --- a/client/src/app/+videos/+video-watch/shared/comment/video-comment-add.component.html +++ b/client/src/app/+videos/+video-watch/shared/comment/video-comment-add.component.html | |||
@@ -74,10 +74,7 @@ | |||
74 | (click)="hideModals()" (key.enter)="hideModals()" | 74 | (click)="hideModals()" (key.enter)="hideModals()" |
75 | > | 75 | > |
76 | 76 | ||
77 | <input | 77 | <my-login-link i18n-label label="Login to comment" className="peertube-button-link orange-button"></my-login-link> |
78 | type="submit" i18n-value value="Login to comment" class="peertube-button orange-button" | ||
79 | (click)="gotoLogin()" | ||
80 | > | ||
81 | </div> | 78 | </div> |
82 | </ng-template> | 79 | </ng-template> |
83 | 80 | ||
diff --git a/client/src/app/+videos/+video-watch/shared/comment/video-comment-add.component.ts b/client/src/app/+videos/+video-watch/shared/comment/video-comment-add.component.ts index 9a9bfe710..033097084 100644 --- a/client/src/app/+videos/+video-watch/shared/comment/video-comment-add.component.ts +++ b/client/src/app/+videos/+video-watch/shared/comment/video-comment-add.component.ts | |||
@@ -13,7 +13,6 @@ import { | |||
13 | SimpleChanges, | 13 | SimpleChanges, |
14 | ViewChild | 14 | ViewChild |
15 | } from '@angular/core' | 15 | } from '@angular/core' |
16 | import { Router } from '@angular/router' | ||
17 | import { Notifier, User } from '@app/core' | 16 | import { Notifier, User } from '@app/core' |
18 | import { VIDEO_COMMENT_TEXT_VALIDATOR } from '@app/shared/form-validators/video-comment-validators' | 17 | import { VIDEO_COMMENT_TEXT_VALIDATOR } from '@app/shared/form-validators/video-comment-validators' |
19 | import { FormReactive, FormReactiveService } from '@app/shared/shared-forms' | 18 | import { FormReactive, FormReactiveService } from '@app/shared/shared-forms' |
@@ -52,7 +51,6 @@ export class VideoCommentAddComponent extends FormReactive implements OnChanges, | |||
52 | private notifier: Notifier, | 51 | private notifier: Notifier, |
53 | private videoCommentService: VideoCommentService, | 52 | private videoCommentService: VideoCommentService, |
54 | private modalService: NgbModal, | 53 | private modalService: NgbModal, |
55 | private router: Router, | ||
56 | @Inject(LOCALE_ID) private localeId: string | 54 | @Inject(LOCALE_ID) private localeId: string |
57 | ) { | 55 | ) { |
58 | super() | 56 | super() |
@@ -161,11 +159,6 @@ export class VideoCommentAddComponent extends FormReactive implements OnChanges, | |||
161 | return window.location.href | 159 | return window.location.href |
162 | } | 160 | } |
163 | 161 | ||
164 | gotoLogin () { | ||
165 | this.hideModals() | ||
166 | this.router.navigate([ '/login' ]) | ||
167 | } | ||
168 | |||
169 | cancelCommentReply () { | 162 | cancelCommentReply () { |
170 | this.cancel.emit(null) | 163 | this.cancel.emit(null) |
171 | this.form.value['text'] = this.textareaElement.nativeElement.value = '' | 164 | this.form.value['text'] = this.textareaElement.nativeElement.value = '' |
diff --git a/client/src/app/core/auth/auth.service.ts b/client/src/app/core/auth/auth.service.ts index ed7eabb76..6fe601d8d 100644 --- a/client/src/app/core/auth/auth.service.ts +++ b/client/src/app/core/auth/auth.service.ts | |||
@@ -5,11 +5,11 @@ import { HttpClient, HttpErrorResponse, HttpHeaders, HttpParams } from '@angular | |||
5 | import { Injectable } from '@angular/core' | 5 | import { Injectable } from '@angular/core' |
6 | import { Router } from '@angular/router' | 6 | import { Router } from '@angular/router' |
7 | import { Notifier } from '@app/core/notification/notifier.service' | 7 | import { Notifier } from '@app/core/notification/notifier.service' |
8 | import { logger, OAuthUserTokens, objectToUrlEncoded, peertubeLocalStorage, PluginsManager } from '@root-helpers/index' | 8 | import { logger, OAuthUserTokens, objectToUrlEncoded, peertubeLocalStorage } from '@root-helpers/index' |
9 | import { HttpStatusCode, MyUser as UserServerModel, OAuthClientLocal, User, UserLogin, UserRefreshToken } from '@shared/models' | 9 | import { HttpStatusCode, MyUser as UserServerModel, OAuthClientLocal, User, UserLogin, UserRefreshToken } from '@shared/models' |
10 | import { environment } from '../../../environments/environment' | 10 | import { environment } from '../../../environments/environment' |
11 | import { RestExtractor } from '../rest/rest-extractor.service' | 11 | import { RestExtractor } from '../rest/rest-extractor.service' |
12 | import { ServerService } from '../server' | 12 | import { RedirectService } from '../routing' |
13 | import { AuthStatus } from './auth-status.model' | 13 | import { AuthStatus } from './auth-status.model' |
14 | import { AuthUser } from './auth-user.model' | 14 | import { AuthUser } from './auth-user.model' |
15 | 15 | ||
@@ -45,7 +45,7 @@ export class AuthService { | |||
45 | private refreshingTokenObservable: Observable<any> | 45 | private refreshingTokenObservable: Observable<any> |
46 | 46 | ||
47 | constructor ( | 47 | constructor ( |
48 | private serverService: ServerService, | 48 | private redirectService: RedirectService, |
49 | private http: HttpClient, | 49 | private http: HttpClient, |
50 | private notifier: Notifier, | 50 | private notifier: Notifier, |
51 | private hotkeysService: HotkeysService, | 51 | private hotkeysService: HotkeysService, |
@@ -227,9 +227,7 @@ Ensure you have correctly configured PeerTube (config/ directory), in particular | |||
227 | logger.info('Cannot refresh token -> logout...') | 227 | logger.info('Cannot refresh token -> logout...') |
228 | this.logout() | 228 | this.logout() |
229 | 229 | ||
230 | const externalLoginUrl = PluginsManager.getDefaultLoginHref(environment.apiUrl, this.serverService.getHTMLConfig()) | 230 | this.redirectService.redirectToLogin() |
231 | if (externalLoginUrl) window.location.href = externalLoginUrl | ||
232 | else this.router.navigate([ '/login' ]) | ||
233 | 231 | ||
234 | return observableThrowError(() => ({ | 232 | return observableThrowError(() => ({ |
235 | error: $localize`You need to reconnect.` | 233 | error: $localize`You need to reconnect.` |
diff --git a/client/src/app/core/routing/login-guard.service.ts b/client/src/app/core/routing/login-guard.service.ts index a949be14c..2f5a31e7f 100644 --- a/client/src/app/core/routing/login-guard.service.ts +++ b/client/src/app/core/routing/login-guard.service.ts | |||
@@ -1,19 +1,20 @@ | |||
1 | import { Injectable } from '@angular/core' | 1 | import { Injectable } from '@angular/core' |
2 | import { ActivatedRouteSnapshot, CanActivate, CanActivateChild, Router, RouterStateSnapshot } from '@angular/router' | 2 | import { ActivatedRouteSnapshot, CanActivate, CanActivateChild, RouterStateSnapshot } from '@angular/router' |
3 | import { AuthService } from '../auth/auth.service' | 3 | import { AuthService } from '../auth/auth.service' |
4 | import { RedirectService } from './redirect.service' | ||
4 | 5 | ||
5 | @Injectable() | 6 | @Injectable() |
6 | export class LoginGuard implements CanActivate, CanActivateChild { | 7 | export class LoginGuard implements CanActivate, CanActivateChild { |
7 | 8 | ||
8 | constructor ( | 9 | constructor ( |
9 | private router: Router, | 10 | private auth: AuthService, |
10 | private auth: AuthService | 11 | private redirectService: RedirectService |
11 | ) {} | 12 | ) {} |
12 | 13 | ||
13 | canActivate (route: ActivatedRouteSnapshot, state: RouterStateSnapshot) { | 14 | canActivate (route: ActivatedRouteSnapshot, state: RouterStateSnapshot) { |
14 | if (this.auth.isLoggedIn() === true) return true | 15 | if (this.auth.isLoggedIn() === true) return true |
15 | 16 | ||
16 | this.router.navigate([ '/login' ]) | 17 | this.redirectService.redirectToLogin() |
17 | return false | 18 | return false |
18 | } | 19 | } |
19 | 20 | ||
diff --git a/client/src/app/core/routing/redirect.service.ts b/client/src/app/core/routing/redirect.service.ts index 1344458d5..e239c6210 100644 --- a/client/src/app/core/routing/redirect.service.ts +++ b/client/src/app/core/routing/redirect.service.ts | |||
@@ -4,6 +4,8 @@ import { NavigationCancel, NavigationEnd, Router } from '@angular/router' | |||
4 | import { logger } from '@root-helpers/logger' | 4 | import { logger } from '@root-helpers/logger' |
5 | import { ServerService } from '../server' | 5 | import { ServerService } from '../server' |
6 | import { SessionStorageService } from '../wrappers/storage.service' | 6 | import { SessionStorageService } from '../wrappers/storage.service' |
7 | import { PluginsManager } from '@root-helpers/plugins-manager' | ||
8 | import { environment } from 'src/environments/environment' | ||
7 | 9 | ||
8 | const debugLogger = debug('peertube:router:RedirectService') | 10 | const debugLogger = debug('peertube:router:RedirectService') |
9 | 11 | ||
@@ -100,6 +102,13 @@ export class RedirectService { | |||
100 | 102 | ||
101 | } | 103 | } |
102 | 104 | ||
105 | redirectToLogin () { | ||
106 | const externalLoginUrl = PluginsManager.getDefaultLoginHref(environment.apiUrl, this.serverService.getHTMLConfig()) | ||
107 | |||
108 | if (externalLoginUrl) window.location.href = externalLoginUrl | ||
109 | else this.router.navigate([ '/login' ]) | ||
110 | } | ||
111 | |||
103 | private doRedirect (redirectUrl: string, fallbackRoute?: string) { | 112 | private doRedirect (redirectUrl: string, fallbackRoute?: string) { |
104 | debugLogger('Redirecting on %s', redirectUrl) | 113 | debugLogger('Redirecting on %s', redirectUrl) |
105 | 114 | ||
diff --git a/client/src/app/core/routing/user-right-guard.service.ts b/client/src/app/core/routing/user-right-guard.service.ts index a2ce772db..c6bd05bb6 100644 --- a/client/src/app/core/routing/user-right-guard.service.ts +++ b/client/src/app/core/routing/user-right-guard.service.ts | |||
@@ -1,12 +1,13 @@ | |||
1 | import { Injectable } from '@angular/core' | 1 | import { Injectable } from '@angular/core' |
2 | import { ActivatedRouteSnapshot, CanActivate, CanActivateChild, Router, RouterStateSnapshot } from '@angular/router' | 2 | import { ActivatedRouteSnapshot, CanActivate, CanActivateChild, RouterStateSnapshot } from '@angular/router' |
3 | import { AuthService } from '../auth/auth.service' | 3 | import { AuthService } from '../auth/auth.service' |
4 | import { RedirectService } from './redirect.service' | ||
4 | 5 | ||
5 | @Injectable() | 6 | @Injectable() |
6 | export class UserRightGuard implements CanActivate, CanActivateChild { | 7 | export class UserRightGuard implements CanActivate, CanActivateChild { |
7 | 8 | ||
8 | constructor ( | 9 | constructor ( |
9 | private router: Router, | 10 | private redirectService: RedirectService, |
10 | private auth: AuthService | 11 | private auth: AuthService |
11 | ) {} | 12 | ) {} |
12 | 13 | ||
@@ -18,7 +19,7 @@ export class UserRightGuard implements CanActivate, CanActivateChild { | |||
18 | if (user.hasRight(neededUserRight)) return true | 19 | if (user.hasRight(neededUserRight)) return true |
19 | } | 20 | } |
20 | 21 | ||
21 | this.router.navigate([ '/login' ]) | 22 | this.redirectService.redirectToLogin() |
22 | return false | 23 | return false |
23 | } | 24 | } |
24 | 25 | ||
diff --git a/client/src/app/menu/menu.component.html b/client/src/app/menu/menu.component.html index abfc151e7..0fb9897b9 100644 --- a/client/src/app/menu/menu.component.html +++ b/client/src/app/menu/menu.component.html | |||
@@ -100,8 +100,7 @@ | |||
100 | </div> | 100 | </div> |
101 | 101 | ||
102 | <div *ngIf="!isLoggedIn" class="login-buttons-block"> | 102 | <div *ngIf="!isLoggedIn" class="login-buttons-block"> |
103 | <a i18n *ngIf="!getExternalLoginHref()" routerLink="/login" class="peertube-button-link orange-button">Login</a> | 103 | <my-login-link className="peertube-button-link orange-button w-100"></my-login-link> |
104 | <a i18n *ngIf="getExternalLoginHref()" [href]="getExternalLoginHref()" class="peertube-button-link orange-button">Login</a> | ||
105 | 104 | ||
106 | <a *ngIf="isRegistrationAllowed()" routerLink="/signup" class="peertube-button-link create-account-button"> | 105 | <a *ngIf="isRegistrationAllowed()" routerLink="/signup" class="peertube-button-link create-account-button"> |
107 | <my-signup-label [requiresApproval]="requiresApproval"></my-signup-label> | 106 | <my-signup-label [requiresApproval]="requiresApproval"></my-signup-label> |
diff --git a/client/src/app/menu/menu.component.scss b/client/src/app/menu/menu.component.scss index cd57e134e..9d5ad57c2 100644 --- a/client/src/app/menu/menu.component.scss +++ b/client/src/app/menu/menu.component.scss | |||
@@ -251,7 +251,8 @@ my-actor-avatar { | |||
251 | .login-buttons-block { | 251 | .login-buttons-block { |
252 | margin: 30px 25px 35px; | 252 | margin: 30px 25px 35px; |
253 | 253 | ||
254 | > a { | 254 | > a, |
255 | > my-login-link { | ||
255 | display: block; | 256 | display: block; |
256 | width: 100%; | 257 | width: 100%; |
257 | 258 | ||
diff --git a/client/src/app/menu/menu.component.ts b/client/src/app/menu/menu.component.ts index fc6d74cff..21354e52d 100644 --- a/client/src/app/menu/menu.component.ts +++ b/client/src/app/menu/menu.component.ts | |||
@@ -1,7 +1,6 @@ | |||
1 | import { HotkeysService } from 'angular2-hotkeys' | 1 | import { HotkeysService } from 'angular2-hotkeys' |
2 | import * as debug from 'debug' | 2 | import * as debug from 'debug' |
3 | import { switchMap } from 'rxjs/operators' | 3 | import { switchMap } from 'rxjs/operators' |
4 | import { environment } from 'src/environments/environment' | ||
5 | import { ViewportScroller } from '@angular/common' | 4 | import { ViewportScroller } from '@angular/common' |
6 | import { Component, OnInit, ViewChild } from '@angular/core' | 5 | import { Component, OnInit, ViewChild } from '@angular/core' |
7 | import { Router } from '@angular/router' | 6 | import { Router } from '@angular/router' |
@@ -22,7 +21,6 @@ import { LanguageChooserComponent } from '@app/menu/language-chooser.component' | |||
22 | import { QuickSettingsModalComponent } from '@app/modal/quick-settings-modal.component' | 21 | import { QuickSettingsModalComponent } from '@app/modal/quick-settings-modal.component' |
23 | import { PeertubeModalService } from '@app/shared/shared-main/peertube-modal/peertube-modal.service' | 22 | import { PeertubeModalService } from '@app/shared/shared-main/peertube-modal/peertube-modal.service' |
24 | import { NgbDropdown } from '@ng-bootstrap/ng-bootstrap' | 23 | import { NgbDropdown } from '@ng-bootstrap/ng-bootstrap' |
25 | import { PluginsManager } from '@root-helpers/plugins-manager' | ||
26 | import { HTMLServerConfig, ServerConfig, UserRight, VideoConstant } from '@shared/models' | 24 | import { HTMLServerConfig, ServerConfig, UserRight, VideoConstant } from '@shared/models' |
27 | 25 | ||
28 | const debugLogger = debug('peertube:menu:MenuComponent') | 26 | const debugLogger = debug('peertube:menu:MenuComponent') |
@@ -135,10 +133,6 @@ export class MenuComponent implements OnInit { | |||
135 | .subscribe(() => this.openQuickSettings()) | 133 | .subscribe(() => this.openQuickSettings()) |
136 | } | 134 | } |
137 | 135 | ||
138 | getExternalLoginHref () { | ||
139 | return PluginsManager.getDefaultLoginHref(environment.apiUrl, this.serverConfig) | ||
140 | } | ||
141 | |||
142 | isRegistrationAllowed () { | 136 | isRegistrationAllowed () { |
143 | if (!this.serverConfig) return false | 137 | if (!this.serverConfig) return false |
144 | 138 | ||
diff --git a/client/src/app/shared/shared-main/angular/index.ts b/client/src/app/shared/shared-main/angular/index.ts index 4b87c2952..f72d60313 100644 --- a/client/src/app/shared/shared-main/angular/index.ts +++ b/client/src/app/shared/shared-main/angular/index.ts | |||
@@ -5,5 +5,6 @@ export * from './duration-formatter.pipe' | |||
5 | export * from './from-now.pipe' | 5 | export * from './from-now.pipe' |
6 | export * from './infinite-scroller.directive' | 6 | export * from './infinite-scroller.directive' |
7 | export * from './link.component' | 7 | export * from './link.component' |
8 | export * from './login-link.component' | ||
8 | export * from './number-formatter.pipe' | 9 | export * from './number-formatter.pipe' |
9 | export * from './peertube-template.directive' | 10 | export * from './peertube-template.directive' |
diff --git a/client/src/app/shared/shared-main/angular/link.component.html b/client/src/app/shared/shared-main/angular/link.component.html index e61a1e085..2ea2df2b5 100644 --- a/client/src/app/shared/shared-main/angular/link.component.html +++ b/client/src/app/shared/shared-main/angular/link.component.html | |||
@@ -2,10 +2,10 @@ | |||
2 | <ng-content></ng-content> | 2 | <ng-content></ng-content> |
3 | </ng-template> | 3 | </ng-template> |
4 | 4 | ||
5 | <a *ngIf="!href" [routerLink]="internalLink" [attr.title]="title" [tabindex]="tabindex"> | 5 | <a *ngIf="!href" [routerLink]="internalLink" [attr.title]="title" [tabindex]="tabindex" [ngClass]="builtClasses"> |
6 | <ng-template *ngTemplateOutlet="content"></ng-template> | 6 | <ng-template *ngTemplateOutlet="content"></ng-template> |
7 | </a> | 7 | </a> |
8 | 8 | ||
9 | <a *ngIf="href" [href]="href" [target]="target" [attr.title]="title" [tabindex]="tabindex"> | 9 | <a *ngIf="href" [href]="href" [target]="target" [attr.title]="title" [tabindex]="tabindex" [ngClass]="builtClasses"> |
10 | <ng-template *ngTemplateOutlet="content"></ng-template> | 10 | <ng-template *ngTemplateOutlet="content"></ng-template> |
11 | </a> | 11 | </a> |
diff --git a/client/src/app/shared/shared-main/angular/link.component.scss b/client/src/app/shared/shared-main/angular/link.component.scss index bb86d5488..f54240d31 100644 --- a/client/src/app/shared/shared-main/angular/link.component.scss +++ b/client/src/app/shared/shared-main/angular/link.component.scss | |||
@@ -1,4 +1,4 @@ | |||
1 | a { | 1 | .no-class { |
2 | color: inherit; | 2 | color: inherit; |
3 | text-decoration: inherit; | 3 | text-decoration: inherit; |
4 | position: inherit; | 4 | position: inherit; |
diff --git a/client/src/app/shared/shared-main/angular/link.component.ts b/client/src/app/shared/shared-main/angular/link.component.ts index ecbd9151c..1f5975589 100644 --- a/client/src/app/shared/shared-main/angular/link.component.ts +++ b/client/src/app/shared/shared-main/angular/link.component.ts | |||
@@ -1,17 +1,27 @@ | |||
1 | import { Component, Input } from '@angular/core' | 1 | import { Component, Input, OnInit } from '@angular/core' |
2 | 2 | ||
3 | @Component({ | 3 | @Component({ |
4 | selector: 'my-link', | 4 | selector: 'my-link', |
5 | styleUrls: [ './link.component.scss' ], | 5 | styleUrls: [ './link.component.scss' ], |
6 | templateUrl: './link.component.html' | 6 | templateUrl: './link.component.html' |
7 | }) | 7 | }) |
8 | export class LinkComponent { | 8 | export class LinkComponent implements OnInit { |
9 | @Input() internalLink?: string | any[] | 9 | @Input() internalLink?: string | any[] |
10 | 10 | ||
11 | @Input() href?: string | 11 | @Input() href?: string |
12 | @Input() target?: string | 12 | @Input() target = '_self' |
13 | 13 | ||
14 | @Input() title?: string | 14 | @Input() title?: string |
15 | 15 | ||
16 | @Input() className?: string | ||
17 | |||
16 | @Input() tabindex: string | number | 18 | @Input() tabindex: string | number |
19 | |||
20 | builtClasses: string | ||
21 | |||
22 | ngOnInit () { | ||
23 | this.builtClasses = this.className | ||
24 | ? this.className | ||
25 | : 'no-class' | ||
26 | } | ||
17 | } | 27 | } |
diff --git a/client/src/app/shared/shared-main/angular/login-link.component.html b/client/src/app/shared/shared-main/angular/login-link.component.html new file mode 100644 index 000000000..f90ffba68 --- /dev/null +++ b/client/src/app/shared/shared-main/angular/login-link.component.html | |||
@@ -0,0 +1 @@ | |||
<my-link i18n internalLink="/login" [href]="getExternalLoginHref()" [className]="className">{{ label }}</my-link> | |||
diff --git a/client/src/app/shared/shared-main/angular/login-link.component.ts b/client/src/app/shared/shared-main/angular/login-link.component.ts new file mode 100644 index 000000000..7e3a773c2 --- /dev/null +++ b/client/src/app/shared/shared-main/angular/login-link.component.ts | |||
@@ -0,0 +1,22 @@ | |||
1 | import { environment } from 'src/environments/environment' | ||
2 | import { Component, Input } from '@angular/core' | ||
3 | import { ServerService } from '@app/core' | ||
4 | import { PluginsManager } from '@root-helpers/plugins-manager' | ||
5 | |||
6 | @Component({ | ||
7 | selector: 'my-login-link', | ||
8 | templateUrl: './login-link.component.html' | ||
9 | }) | ||
10 | export class LoginLinkComponent { | ||
11 | @Input() label = $localize`Login` | ||
12 | |||
13 | @Input() className?: string | ||
14 | |||
15 | constructor (private server: ServerService) { | ||
16 | |||
17 | } | ||
18 | |||
19 | getExternalLoginHref () { | ||
20 | return PluginsManager.getDefaultLoginHref(environment.apiUrl, this.server.getHTMLConfig()) | ||
21 | } | ||
22 | } | ||
diff --git a/client/src/app/shared/shared-main/shared-main.module.ts b/client/src/app/shared/shared-main/shared-main.module.ts index eb1642d97..0bdf27263 100644 --- a/client/src/app/shared/shared-main/shared-main.module.ts +++ b/client/src/app/shared/shared-main/shared-main.module.ts | |||
@@ -25,6 +25,7 @@ import { | |||
25 | FromNowPipe, | 25 | FromNowPipe, |
26 | InfiniteScrollerDirective, | 26 | InfiniteScrollerDirective, |
27 | LinkComponent, | 27 | LinkComponent, |
28 | LoginLinkComponent, | ||
28 | NumberFormatterPipe, | 29 | NumberFormatterPipe, |
29 | PeerTubeTemplateDirective | 30 | PeerTubeTemplateDirective |
30 | } from './angular' | 31 | } from './angular' |
@@ -92,6 +93,7 @@ import { VideoChannelService } from './video-channel' | |||
92 | InfiniteScrollerDirective, | 93 | InfiniteScrollerDirective, |
93 | PeerTubeTemplateDirective, | 94 | PeerTubeTemplateDirective, |
94 | LinkComponent, | 95 | LinkComponent, |
96 | LoginLinkComponent, | ||
95 | 97 | ||
96 | ActionDropdownComponent, | 98 | ActionDropdownComponent, |
97 | ButtonComponent, | 99 | ButtonComponent, |
@@ -152,6 +154,7 @@ import { VideoChannelService } from './video-channel' | |||
152 | InfiniteScrollerDirective, | 154 | InfiniteScrollerDirective, |
153 | PeerTubeTemplateDirective, | 155 | PeerTubeTemplateDirective, |
154 | LinkComponent, | 156 | LinkComponent, |
157 | LoginLinkComponent, | ||
155 | 158 | ||
156 | ActionDropdownComponent, | 159 | ActionDropdownComponent, |
157 | ButtonComponent, | 160 | ButtonComponent, |
diff --git a/client/src/app/shared/shared-user-subscription/subscribe-button.component.ts b/client/src/app/shared/shared-user-subscription/subscribe-button.component.ts index 7a55a6ffb..a002bf4e7 100644 --- a/client/src/app/shared/shared-user-subscription/subscribe-button.component.ts +++ b/client/src/app/shared/shared-user-subscription/subscribe-button.component.ts | |||
@@ -1,7 +1,6 @@ | |||
1 | import { concat, forkJoin, merge } from 'rxjs' | 1 | import { concat, forkJoin, merge } from 'rxjs' |
2 | import { Component, Input, OnChanges, OnInit } from '@angular/core' | 2 | import { Component, Input, OnChanges, OnInit } from '@angular/core' |
3 | import { Router } from '@angular/router' | 3 | import { AuthService, Notifier, RedirectService } from '@app/core' |
4 | import { AuthService, Notifier } from '@app/core' | ||
5 | import { Account, VideoChannel, VideoService } from '@app/shared/shared-main' | 4 | import { Account, VideoChannel, VideoService } from '@app/shared/shared-main' |
6 | import { FeedFormat } from '@shared/models' | 5 | import { FeedFormat } from '@shared/models' |
7 | import { UserSubscriptionService } from './user-subscription.service' | 6 | import { UserSubscriptionService } from './user-subscription.service' |
@@ -27,7 +26,7 @@ export class SubscribeButtonComponent implements OnInit, OnChanges { | |||
27 | 26 | ||
28 | constructor ( | 27 | constructor ( |
29 | private authService: AuthService, | 28 | private authService: AuthService, |
30 | private router: Router, | 29 | private redirectService: RedirectService, |
31 | private notifier: Notifier, | 30 | private notifier: Notifier, |
32 | private userSubscriptionService: UserSubscriptionService, | 31 | private userSubscriptionService: UserSubscriptionService, |
33 | private videoService: VideoService | 32 | private videoService: VideoService |
@@ -152,7 +151,7 @@ export class SubscribeButtonComponent implements OnInit, OnChanges { | |||
152 | } | 151 | } |
153 | 152 | ||
154 | gotoLogin () { | 153 | gotoLogin () { |
155 | this.router.navigate([ '/login' ]) | 154 | this.redirectService.redirectToLogin() |
156 | } | 155 | } |
157 | 156 | ||
158 | subscribeStatus (subscribed: boolean) { | 157 | subscribeStatus (subscribed: boolean) { |