diff options
Diffstat (limited to 'client/src/app/core')
-rw-r--r-- | client/src/app/core/auth/auth.service.ts | 24 | ||||
-rw-r--r-- | client/src/app/core/hotkeys/hotkeys.component.ts | 12 | ||||
-rw-r--r-- | client/src/app/core/notification/notifier.service.ts | 14 | ||||
-rw-r--r-- | client/src/app/core/rest/rest-extractor.service.ts | 17 | ||||
-rw-r--r-- | client/src/app/core/routing/can-deactivate-guard.service.ts | 11 | ||||
-rw-r--r-- | client/src/app/core/users/user.service.ts | 12 |
6 files changed, 35 insertions, 55 deletions
diff --git a/client/src/app/core/auth/auth.service.ts b/client/src/app/core/auth/auth.service.ts index d3dc48267..10e2c2c58 100644 --- a/client/src/app/core/auth/auth.service.ts +++ b/client/src/app/core/auth/auth.service.ts | |||
@@ -6,7 +6,6 @@ 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 { objectToUrlEncoded, peertubeLocalStorage } from '@root-helpers/index' | 8 | import { objectToUrlEncoded, peertubeLocalStorage } from '@root-helpers/index' |
9 | import { I18n } from '@ngx-translate/i18n-polyfill' | ||
10 | import { MyUser as UserServerModel, OAuthClientLocal, User, UserLogin, UserRefreshToken } from '@shared/models' | 9 | import { MyUser as UserServerModel, OAuthClientLocal, User, UserLogin, UserRefreshToken } from '@shared/models' |
11 | import { environment } from '../../../environments/environment' | 10 | import { environment } from '../../../environments/environment' |
12 | import { RestExtractor } from '../rest/rest-extractor.service' | 11 | import { RestExtractor } from '../rest/rest-extractor.service' |
@@ -48,9 +47,8 @@ export class AuthService { | |||
48 | private notifier: Notifier, | 47 | private notifier: Notifier, |
49 | private hotkeysService: HotkeysService, | 48 | private hotkeysService: HotkeysService, |
50 | private restExtractor: RestExtractor, | 49 | private restExtractor: RestExtractor, |
51 | private router: Router, | 50 | private router: Router |
52 | private i18n: I18n | 51 | ) { |
53 | ) { | ||
54 | this.loginChanged = new Subject<AuthStatus>() | 52 | this.loginChanged = new Subject<AuthStatus>() |
55 | this.loginChangedSource = this.loginChanged.asObservable() | 53 | this.loginChangedSource = this.loginChanged.asObservable() |
56 | 54 | ||
@@ -62,19 +60,19 @@ export class AuthService { | |||
62 | new Hotkey('m s', (event: KeyboardEvent): boolean => { | 60 | new Hotkey('m s', (event: KeyboardEvent): boolean => { |
63 | this.router.navigate([ '/videos/subscriptions' ]) | 61 | this.router.navigate([ '/videos/subscriptions' ]) |
64 | return false | 62 | return false |
65 | }, undefined, this.i18n('Go to my subscriptions')), | 63 | }, undefined, $localize`Go to my subscriptions`), |
66 | new Hotkey('m v', (event: KeyboardEvent): boolean => { | 64 | new Hotkey('m v', (event: KeyboardEvent): boolean => { |
67 | this.router.navigate([ '/my-account/videos' ]) | 65 | this.router.navigate([ '/my-account/videos' ]) |
68 | return false | 66 | return false |
69 | }, undefined, this.i18n('Go to my videos')), | 67 | }, undefined, $localize`Go to my videos`), |
70 | new Hotkey('m i', (event: KeyboardEvent): boolean => { | 68 | new Hotkey('m i', (event: KeyboardEvent): boolean => { |
71 | this.router.navigate([ '/my-account/video-imports' ]) | 69 | this.router.navigate([ '/my-account/video-imports' ]) |
72 | return false | 70 | return false |
73 | }, undefined, this.i18n('Go to my imports')), | 71 | }, undefined, $localize`Go to my imports`), |
74 | new Hotkey('m c', (event: KeyboardEvent): boolean => { | 72 | new Hotkey('m c', (event: KeyboardEvent): boolean => { |
75 | this.router.navigate([ '/my-account/video-channels' ]) | 73 | this.router.navigate([ '/my-account/video-channels' ]) |
76 | return false | 74 | return false |
77 | }, undefined, this.i18n('Go to my channels')) | 75 | }, undefined, $localize`Go to my channels`) |
78 | ] | 76 | ] |
79 | } | 77 | } |
80 | 78 | ||
@@ -97,14 +95,12 @@ export class AuthService { | |||
97 | let errorMessage = error.message | 95 | let errorMessage = error.message |
98 | 96 | ||
99 | if (error.status === 403) { | 97 | if (error.status === 403) { |
100 | errorMessage = this.i18n('Cannot retrieve OAuth Client credentials: {{errorText}}.\n', { errorText: error.text }) | 98 | errorMessage = $localize`Cannot retrieve OAuth Client credentials: ${error.text}. |
101 | errorMessage += this.i18n( | 99 | Ensure you have correctly configured PeerTube (config/ directory), in particular the "webserver" section.` |
102 | 'Ensure you have correctly configured PeerTube (config/ directory), in particular the "webserver" section.' | ||
103 | ) | ||
104 | } | 100 | } |
105 | 101 | ||
106 | // We put a bigger timeout: this is an important message | 102 | // We put a bigger timeout: this is an important message |
107 | this.notifier.error(errorMessage, this.i18n('Error'), 7000) | 103 | this.notifier.error(errorMessage, $localize`Error`, 7000) |
108 | } | 104 | } |
109 | ) | 105 | ) |
110 | } | 106 | } |
@@ -216,7 +212,7 @@ export class AuthService { | |||
216 | this.router.navigate([ '/login' ]) | 212 | this.router.navigate([ '/login' ]) |
217 | 213 | ||
218 | return observableThrowError({ | 214 | return observableThrowError({ |
219 | error: this.i18n('You need to reconnect.') | 215 | error: $localize`You need to reconnect.` |
220 | }) | 216 | }) |
221 | }), | 217 | }), |
222 | share() | 218 | share() |
diff --git a/client/src/app/core/hotkeys/hotkeys.component.ts b/client/src/app/core/hotkeys/hotkeys.component.ts index 512a2399a..315e1a25e 100644 --- a/client/src/app/core/hotkeys/hotkeys.component.ts +++ b/client/src/app/core/hotkeys/hotkeys.component.ts | |||
@@ -1,7 +1,6 @@ | |||
1 | import { Component, OnInit, OnDestroy, Input } from '@angular/core' | 1 | import { Hotkey, HotkeysService } from 'angular2-hotkeys' |
2 | import { Subscription } from 'rxjs' | 2 | import { Subscription } from 'rxjs' |
3 | import { I18n } from '@ngx-translate/i18n-polyfill' | 3 | import { Component, Input, OnDestroy, OnInit } from '@angular/core' |
4 | import { HotkeysService, Hotkey } from 'angular2-hotkeys' | ||
5 | 4 | ||
6 | @Component({ | 5 | @Component({ |
7 | selector : 'my-hotkeys-cheatsheet', | 6 | selector : 'my-hotkeys-cheatsheet', |
@@ -9,16 +8,15 @@ import { HotkeysService, Hotkey } from 'angular2-hotkeys' | |||
9 | styleUrls: [ './hotkeys.component.scss' ] | 8 | styleUrls: [ './hotkeys.component.scss' ] |
10 | }) | 9 | }) |
11 | export class CheatSheetComponent implements OnInit, OnDestroy { | 10 | export class CheatSheetComponent implements OnInit, OnDestroy { |
12 | @Input() title = this.i18n('Keyboard Shortcuts:') | 11 | @Input() title = $localize`Keyboard Shortcuts:` |
13 | helpVisible = false | 12 | helpVisible = false |
14 | subscription: Subscription | 13 | subscription: Subscription |
15 | 14 | ||
16 | hotkeys: Hotkey[] | 15 | hotkeys: Hotkey[] |
17 | 16 | ||
18 | constructor ( | 17 | constructor ( |
19 | private hotkeysService: HotkeysService, | 18 | private hotkeysService: HotkeysService |
20 | private i18n: I18n | 19 | ) {} |
21 | ) {} | ||
22 | 20 | ||
23 | public ngOnInit (): void { | 21 | public ngOnInit (): void { |
24 | this.subscription = this.hotkeysService.cheatSheetToggle.subscribe((isOpen) => { | 22 | this.subscription = this.hotkeysService.cheatSheetToggle.subscribe((isOpen) => { |
diff --git a/client/src/app/core/notification/notifier.service.ts b/client/src/app/core/notification/notifier.service.ts index 9833c65a0..f736672bb 100644 --- a/client/src/app/core/notification/notifier.service.ts +++ b/client/src/app/core/notification/notifier.service.ts | |||
@@ -1,30 +1,26 @@ | |||
1 | import { Injectable } from '@angular/core' | ||
2 | import { MessageService } from 'primeng/api' | 1 | import { MessageService } from 'primeng/api' |
3 | import { I18n } from '@ngx-translate/i18n-polyfill' | 2 | import { Injectable } from '@angular/core' |
4 | 3 | ||
5 | @Injectable() | 4 | @Injectable() |
6 | export class Notifier { | 5 | export class Notifier { |
7 | readonly TIMEOUT = 5000 | 6 | readonly TIMEOUT = 5000 |
8 | 7 | ||
9 | constructor ( | 8 | constructor (private messageService: MessageService) { } |
10 | private i18n: I18n, | ||
11 | private messageService: MessageService) { | ||
12 | } | ||
13 | 9 | ||
14 | info (text: string, title?: string, timeout?: number) { | 10 | info (text: string, title?: string, timeout?: number) { |
15 | if (!title) title = this.i18n('Info') | 11 | if (!title) title = $localize`Info` |
16 | 12 | ||
17 | return this.notify('info', text, title, timeout) | 13 | return this.notify('info', text, title, timeout) |
18 | } | 14 | } |
19 | 15 | ||
20 | error (text: string, title?: string, timeout?: number) { | 16 | error (text: string, title?: string, timeout?: number) { |
21 | if (!title) title = this.i18n('Error') | 17 | if (!title) title = $localize`Error` |
22 | 18 | ||
23 | return this.notify('error', text, title, timeout) | 19 | return this.notify('error', text, title, timeout) |
24 | } | 20 | } |
25 | 21 | ||
26 | success (text: string, title?: string, timeout?: number) { | 22 | success (text: string, title?: string, timeout?: number) { |
27 | if (!title) title = this.i18n('Success') | 23 | if (!title) title = $localize`Success` |
28 | 24 | ||
29 | return this.notify('success', text, title, timeout) | 25 | return this.notify('success', text, title, timeout) |
30 | } | 26 | } |
diff --git a/client/src/app/core/rest/rest-extractor.service.ts b/client/src/app/core/rest/rest-extractor.service.ts index 9de964f79..36702b371 100644 --- a/client/src/app/core/rest/rest-extractor.service.ts +++ b/client/src/app/core/rest/rest-extractor.service.ts | |||
@@ -2,16 +2,12 @@ import { throwError as observableThrowError } from 'rxjs' | |||
2 | import { Injectable } from '@angular/core' | 2 | import { Injectable } from '@angular/core' |
3 | import { Router } from '@angular/router' | 3 | import { Router } from '@angular/router' |
4 | import { dateToHuman } from '@app/helpers' | 4 | import { dateToHuman } from '@app/helpers' |
5 | import { I18n } from '@ngx-translate/i18n-polyfill' | ||
6 | import { ResultList } from '@shared/models' | 5 | import { ResultList } from '@shared/models' |
7 | 6 | ||
8 | @Injectable() | 7 | @Injectable() |
9 | export class RestExtractor { | 8 | export class RestExtractor { |
10 | 9 | ||
11 | constructor ( | 10 | constructor (private router: Router) { } |
12 | private router: Router, | ||
13 | private i18n: I18n | ||
14 | ) { } | ||
15 | 11 | ||
16 | extractDataBool () { | 12 | extractDataBool () { |
17 | return true | 13 | return true |
@@ -62,19 +58,18 @@ export class RestExtractor { | |||
62 | } else if (err.error && err.error.error) { | 58 | } else if (err.error && err.error.error) { |
63 | errorMessage = err.error.error | 59 | errorMessage = err.error.error |
64 | } else if (err.status === 413) { | 60 | } else if (err.status === 413) { |
65 | errorMessage = this.i18n( | 61 | errorMessage = $localize`Request is too large for the server. |
66 | 'Request is too large for the server. Please contact you administrator if you want to increase the limit size.' | 62 | Please contact you administrator if you want to increase the limit size.` |
67 | ) | ||
68 | } else if (err.status === 429) { | 63 | } else if (err.status === 429) { |
69 | const secondsLeft = err.headers.get('retry-after') | 64 | const secondsLeft = err.headers.get('retry-after') |
70 | if (secondsLeft) { | 65 | if (secondsLeft) { |
71 | const minutesLeft = Math.floor(parseInt(secondsLeft, 10) / 60) | 66 | const minutesLeft = Math.floor(parseInt(secondsLeft, 10) / 60) |
72 | errorMessage = this.i18n('Too many attempts, please try again after {{minutesLeft}} minutes.', { minutesLeft }) | 67 | errorMessage = $localize`Too many attempts, please try again after ${minutesLeft} minutes.` |
73 | } else { | 68 | } else { |
74 | errorMessage = this.i18n('Too many attempts, please try again later.') | 69 | errorMessage = $localize`Too many attempts, please try again later.` |
75 | } | 70 | } |
76 | } else if (err.status === 500) { | 71 | } else if (err.status === 500) { |
77 | errorMessage = this.i18n('Server error. Please retry later.') | 72 | errorMessage = $localize`Server error. Please retry later.` |
78 | } | 73 | } |
79 | 74 | ||
80 | errorMessage = errorMessage ? errorMessage : 'Unknown error.' | 75 | errorMessage = errorMessage ? errorMessage : 'Unknown error.' |
diff --git a/client/src/app/core/routing/can-deactivate-guard.service.ts b/client/src/app/core/routing/can-deactivate-guard.service.ts index e0405293a..8fce495e9 100644 --- a/client/src/app/core/routing/can-deactivate-guard.service.ts +++ b/client/src/app/core/routing/can-deactivate-guard.service.ts | |||
@@ -2,7 +2,6 @@ import { Observable } from 'rxjs' | |||
2 | import { Injectable } from '@angular/core' | 2 | import { Injectable } from '@angular/core' |
3 | import { CanDeactivate } from '@angular/router' | 3 | import { CanDeactivate } from '@angular/router' |
4 | import { ConfirmService } from '@app/core/confirm' | 4 | import { ConfirmService } from '@app/core/confirm' |
5 | import { I18n } from '@ngx-translate/i18n-polyfill' | ||
6 | 5 | ||
7 | export type CanComponentDeactivateResult = { text?: string, canDeactivate: Observable<boolean> | boolean } | 6 | export type CanComponentDeactivateResult = { text?: string, canDeactivate: Observable<boolean> | boolean } |
8 | 7 | ||
@@ -12,18 +11,16 @@ export interface CanComponentDeactivate { | |||
12 | 11 | ||
13 | @Injectable() | 12 | @Injectable() |
14 | export class CanDeactivateGuard implements CanDeactivate<CanComponentDeactivate> { | 13 | export class CanDeactivateGuard implements CanDeactivate<CanComponentDeactivate> { |
15 | constructor ( | 14 | |
16 | private confirmService: ConfirmService, | 15 | constructor (private confirmService: ConfirmService) { } |
17 | private i18n: I18n | ||
18 | ) { } | ||
19 | 16 | ||
20 | canDeactivate (component: CanComponentDeactivate) { | 17 | canDeactivate (component: CanComponentDeactivate) { |
21 | const result = component.canDeactivate() | 18 | const result = component.canDeactivate() |
22 | const text = result.text || this.i18n('All unsaved data will be lost, are you sure you want to leave this page?') | 19 | const text = result.text || $localize`All unsaved data will be lost, are you sure you want to leave this page?` |
23 | 20 | ||
24 | return result.canDeactivate || this.confirmService.confirm( | 21 | return result.canDeactivate || this.confirmService.confirm( |
25 | text, | 22 | text, |
26 | this.i18n('Warning') | 23 | $localize`Warning` |
27 | ) | 24 | ) |
28 | } | 25 | } |
29 | 26 | ||
diff --git a/client/src/app/core/users/user.service.ts b/client/src/app/core/users/user.service.ts index 6e7a48519..01c9be5bf 100644 --- a/client/src/app/core/users/user.service.ts +++ b/client/src/app/core/users/user.service.ts | |||
@@ -5,7 +5,6 @@ import { HttpClient, HttpParams } from '@angular/common/http' | |||
5 | import { Injectable } from '@angular/core' | 5 | import { Injectable } from '@angular/core' |
6 | import { AuthService } from '@app/core/auth' | 6 | import { AuthService } from '@app/core/auth' |
7 | import { BytesPipe } from '@app/shared/shared-main' | 7 | import { BytesPipe } from '@app/shared/shared-main' |
8 | import { I18n } from '@ngx-translate/i18n-polyfill' | ||
9 | import { UserLocalStorageKeys } from '@root-helpers/users' | 8 | import { UserLocalStorageKeys } from '@root-helpers/users' |
10 | import { | 9 | import { |
11 | Avatar, | 10 | Avatar, |
@@ -38,9 +37,8 @@ export class UserService { | |||
38 | private restExtractor: RestExtractor, | 37 | private restExtractor: RestExtractor, |
39 | private restService: RestService, | 38 | private restService: RestService, |
40 | private localStorageService: LocalStorageService, | 39 | private localStorageService: LocalStorageService, |
41 | private sessionStorageService: SessionStorageService, | 40 | private sessionStorageService: SessionStorageService |
42 | private i18n: I18n | 41 | ) { } |
43 | ) { } | ||
44 | 42 | ||
45 | changePassword (currentPassword: string, newPassword: string) { | 43 | changePassword (currentPassword: string, newPassword: string) { |
46 | const url = UserService.BASE_USERS_URL + 'me' | 44 | const url = UserService.BASE_USERS_URL + 'me' |
@@ -383,9 +381,9 @@ export class UserService { | |||
383 | } | 381 | } |
384 | 382 | ||
385 | const roleLabels: { [ id in UserRole ]: string } = { | 383 | const roleLabels: { [ id in UserRole ]: string } = { |
386 | [UserRole.USER]: this.i18n('User'), | 384 | [UserRole.USER]: $localize`User`, |
387 | [UserRole.ADMINISTRATOR]: this.i18n('Administrator'), | 385 | [UserRole.ADMINISTRATOR]: $localize`Administrator`, |
388 | [UserRole.MODERATOR]: this.i18n('Moderator') | 386 | [UserRole.MODERATOR]: $localize`Moderator` |
389 | } | 387 | } |
390 | 388 | ||
391 | return Object.assign(user, { | 389 | return Object.assign(user, { |