aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src
diff options
context:
space:
mode:
Diffstat (limited to 'client/src')
-rw-r--r--client/src/app/app.component.ts2
-rw-r--r--client/src/app/app.module.ts3
-rw-r--r--client/src/app/core/routing/redirect.service.ts9
-rw-r--r--client/src/app/menu/menu.component.html6
-rw-r--r--client/src/app/menu/menu.component.ts65
-rw-r--r--client/src/app/shared/shared-main/date/date-toggle.component.html5
-rw-r--r--client/src/app/shared/shared-main/date/date-toggle.component.ts16
-rw-r--r--client/src/main.ts12
8 files changed, 69 insertions, 49 deletions
diff --git a/client/src/app/app.component.ts b/client/src/app/app.component.ts
index 75f4bdfe6..c5cb54ddd 100644
--- a/client/src/app/app.component.ts
+++ b/client/src/app/app.component.ts
@@ -1,6 +1,6 @@
1import { Hotkey, HotkeysService } from 'angular2-hotkeys' 1import { Hotkey, HotkeysService } from 'angular2-hotkeys'
2import { concat } from 'rxjs' 2import { concat } from 'rxjs'
3import { filter, first, map, pairwise } from 'rxjs/operators' 3import { filter, first, map, pairwise, tap } from 'rxjs/operators'
4import { DOCUMENT, PlatformLocation, ViewportScroller } from '@angular/common' 4import { DOCUMENT, PlatformLocation, ViewportScroller } from '@angular/common'
5import { AfterViewInit, Component, Inject, LOCALE_ID, OnInit, ViewChild } from '@angular/core' 5import { AfterViewInit, Component, Inject, LOCALE_ID, OnInit, ViewChild } from '@angular/core'
6import { DomSanitizer, SafeHtml } from '@angular/platform-browser' 6import { DomSanitizer, SafeHtml } from '@angular/platform-browser'
diff --git a/client/src/app/app.module.ts b/client/src/app/app.module.ts
index 5c4616153..3f874856d 100644
--- a/client/src/app/app.module.ts
+++ b/client/src/app/app.module.ts
@@ -1,11 +1,10 @@
1import 'focus-visible' 1import 'focus-visible'
2import { APP_BASE_HREF, registerLocaleData } from '@angular/common' 2import { APP_BASE_HREF, registerLocaleData } from '@angular/common'
3import { LOCALE_ID, NgModule, TRANSLATIONS, TRANSLATIONS_FORMAT } from '@angular/core' 3import { NgModule } from '@angular/core'
4import { BrowserModule } from '@angular/platform-browser' 4import { BrowserModule } from '@angular/platform-browser'
5import { ServerService } from '@app/core' 5import { ServerService } from '@app/core'
6import localeOc from '@app/helpers/locales/oc' 6import localeOc from '@app/helpers/locales/oc'
7import { MetaLoader, MetaModule, MetaStaticLoader, PageTitlePositioning } from '@ngx-meta/core' 7import { MetaLoader, MetaModule, MetaStaticLoader, PageTitlePositioning } from '@ngx-meta/core'
8import { buildFileLocale, getCompleteLocale, isDefaultLocale } from '@shared/core-utils/i18n'
9import { AppRoutingModule } from './app-routing.module' 8import { AppRoutingModule } from './app-routing.module'
10import { AppComponent } from './app.component' 9import { AppComponent } from './app.component'
11import { CoreModule } from './core' 10import { CoreModule } from './core'
diff --git a/client/src/app/core/routing/redirect.service.ts b/client/src/app/core/routing/redirect.service.ts
index 3982cf36f..4f4b346e2 100644
--- a/client/src/app/core/routing/redirect.service.ts
+++ b/client/src/app/core/routing/redirect.service.ts
@@ -11,6 +11,8 @@ export class RedirectService {
11 private previousUrl: string 11 private previousUrl: string
12 private currentUrl: string 12 private currentUrl: string
13 13
14 private redirectingToHomepage = false
15
14 constructor ( 16 constructor (
15 private router: Router, 17 private router: Router,
16 private serverService: ServerService 18 private serverService: ServerService
@@ -56,10 +58,17 @@ export class RedirectService {
56 } 58 }
57 59
58 redirectToHomepage (skipLocationChange = false) { 60 redirectToHomepage (skipLocationChange = false) {
61 if (this.redirectingToHomepage) return
62
63 this.redirectingToHomepage = true
64
59 console.log('Redirecting to %s...', RedirectService.DEFAULT_ROUTE) 65 console.log('Redirecting to %s...', RedirectService.DEFAULT_ROUTE)
60 66
61 this.router.navigate([ RedirectService.DEFAULT_ROUTE ], { skipLocationChange }) 67 this.router.navigate([ RedirectService.DEFAULT_ROUTE ], { skipLocationChange })
68 .then(() => this.redirectingToHomepage = false)
62 .catch(() => { 69 .catch(() => {
70 this.redirectingToHomepage = false
71
63 console.error( 72 console.error(
64 'Cannot navigate to %s, resetting default route to %s.', 73 'Cannot navigate to %s, resetting default route to %s.',
65 RedirectService.DEFAULT_ROUTE, 74 RedirectService.DEFAULT_ROUTE,
diff --git a/client/src/app/menu/menu.component.html b/client/src/app/menu/menu.component.html
index 810466a72..bba5fdadf 100644
--- a/client/src/app/menu/menu.component.html
+++ b/client/src/app/menu/menu.component.html
@@ -12,7 +12,7 @@
12 <div class="logged-in-username">@{{ user.username }}</div> 12 <div class="logged-in-username">@{{ user.username }}</div>
13 </div> 13 </div>
14 14
15 <div class="logged-in-more" ngbDropdown [placement]="placement" container="body" autoClose="outside"> 15 <div class="logged-in-more" ngbDropdown [placement]="loggedInMorePlacement" container="body" autoClose="outside">
16 <my-global-icon iconName="more-vertical" ngbDropdownToggle role="button"></my-global-icon> 16 <my-global-icon iconName="more-vertical" ngbDropdownToggle role="button"></my-global-icon>
17 17
18 <div ngbDropdownMenu> 18 <div ngbDropdownMenu>
@@ -32,7 +32,7 @@
32 <a ngbDropdownItem ngbDropdownToggle class="dropdown-item" (click)="openLanguageChooser()"> 32 <a ngbDropdownItem ngbDropdownToggle class="dropdown-item" (click)="openLanguageChooser()">
33 <my-global-icon iconName="language" aria-hidden="true"></my-global-icon> 33 <my-global-icon iconName="language" aria-hidden="true"></my-global-icon>
34 <span i18n>Interface:</span> 34 <span i18n>Interface:</span>
35 <span class="ml-auto text-muted">{{ language }}</span> 35 <span class="ml-auto text-muted">{{ currentInterfaceLanguage }}</span>
36 </a> 36 </a>
37 37
38 <a ngbDropdownItem ngbDropdownToggle class="dropdown-item" routerLink="/my-account/settings" fragment="video-languages-subtitles" 38 <a ngbDropdownItem ngbDropdownToggle class="dropdown-item" routerLink="/my-account/settings" fragment="video-languages-subtitles"
@@ -168,7 +168,7 @@
168 168
169 <div class="footer-links"> 169 <div class="footer-links">
170 <div *ngIf="isLoggedIn === false"> 170 <div *ngIf="isLoggedIn === false">
171 <span role="button" (click)="openLanguageChooser()" class="c-hand" i18n>Interface: {{ language }}</span> 171 <span role="button" (click)="openLanguageChooser()" class="c-hand" i18n>Interface: {{ currentInterfaceLanguage }}</span>
172 </div> 172 </div>
173 173
174 <div> 174 <div>
diff --git a/client/src/app/menu/menu.component.ts b/client/src/app/menu/menu.component.ts
index 97a3b6d24..bdc95127b 100644
--- a/client/src/app/menu/menu.component.ts
+++ b/client/src/app/menu/menu.component.ts
@@ -28,6 +28,11 @@ export class MenuComponent implements OnInit {
28 helpVisible = false 28 helpVisible = false
29 29
30 videoLanguages: string[] = [] 30 videoLanguages: string[] = []
31 nsfwPolicy: string
32
33 loggedInMorePlacement: string
34
35 currentInterfaceLanguage: string
31 36
32 private languages: VideoConstant<string>[] = [] 37 private languages: VideoConstant<string>[] = []
33 private serverConfig: ServerConfig 38 private serverConfig: ServerConfig
@@ -52,37 +57,6 @@ export class MenuComponent implements OnInit {
52 private router: Router 57 private router: Router
53 ) { } 58 ) { }
54 59
55 get isInMobileView () {
56 return this.screenService.isInMobileView()
57 }
58
59 get placement () {
60 if (this.isInMobileView) {
61 return 'left-top auto'
62 } else {
63 return 'right-top auto'
64 }
65 }
66
67 get language () {
68 return this.languageChooserModal.getCurrentLanguage()
69 }
70
71 get nsfwPolicy () {
72 if (!this.user) return
73
74 switch (this.user.nsfwPolicy) {
75 case 'do_not_list':
76 return $localize`hide`
77
78 case 'blur':
79 return $localize`blur`
80
81 case 'display':
82 return $localize`display`
83 }
84 }
85
86 get instanceName () { 60 get instanceName () {
87 return this.serverConfig.instance.name 61 return this.serverConfig.instance.name
88 } 62 }
@@ -95,11 +69,19 @@ export class MenuComponent implements OnInit {
95 this.isLoggedIn = this.authService.isLoggedIn() 69 this.isLoggedIn = this.authService.isLoggedIn()
96 if (this.isLoggedIn === true) { 70 if (this.isLoggedIn === true) {
97 this.user = this.authService.getUser() 71 this.user = this.authService.getUser()
72
73 this.computeNSFWPolicy()
98 this.computeVideosLink() 74 this.computeVideosLink()
99 } 75 }
100 76
101 this.computeAdminAccess() 77 this.computeAdminAccess()
102 78
79 this.loggedInMorePlacement = this.screenService.isInMobileView()
80 ? 'left-top auto'
81 : 'right-top auto'
82
83 this.currentInterfaceLanguage = this.languageChooserModal.getCurrentLanguage()
84
103 this.authService.loginChangedSource.subscribe( 85 this.authService.loginChangedSource.subscribe(
104 status => { 86 status => {
105 if (status === AuthStatus.LoggedIn) { 87 if (status === AuthStatus.LoggedIn) {
@@ -252,4 +234,25 @@ export class MenuComponent implements OnInit {
252 else logger('User cannot see videos link.') 234 else logger('User cannot see videos link.')
253 }) 235 })
254 } 236 }
237
238 private computeNSFWPolicy () {
239 if (!this.user) {
240 this.nsfwPolicy = null
241 return
242 }
243
244 switch (this.user.nsfwPolicy) {
245 case 'do_not_list':
246 this.nsfwPolicy = $localize`hide`
247 break
248
249 case 'blur':
250 this.nsfwPolicy = $localize`blur`
251 break
252
253 case 'display':
254 this.nsfwPolicy = $localize`display`
255 break
256 }
257 }
255} 258}
diff --git a/client/src/app/shared/shared-main/date/date-toggle.component.html b/client/src/app/shared/shared-main/date/date-toggle.component.html
index ebd4ce442..14b6e7d7a 100644
--- a/client/src/app/shared/shared-main/date/date-toggle.component.html
+++ b/client/src/app/shared/shared-main/date/date-toggle.component.html
@@ -1,6 +1,7 @@
1<span 1<span
2 class="date-toggle" 2 class="date-toggle"
3 [title]="getTitle()" 3 [title]="getTitle()"
4 [innerHtml]="getContent()"
5 (click)="toggle()" 4 (click)="toggle()"
6></span> 5>
6 {{ getContent() }}
7</span>
diff --git a/client/src/app/shared/shared-main/date/date-toggle.component.ts b/client/src/app/shared/shared-main/date/date-toggle.component.ts
index bedf0ba4e..53f25f0ad 100644
--- a/client/src/app/shared/shared-main/date/date-toggle.component.ts
+++ b/client/src/app/shared/shared-main/date/date-toggle.component.ts
@@ -7,7 +7,7 @@ import { FromNowPipe } from '../angular/from-now.pipe'
7 templateUrl: './date-toggle.component.html', 7 templateUrl: './date-toggle.component.html',
8 styleUrls: [ './date-toggle.component.scss' ] 8 styleUrls: [ './date-toggle.component.scss' ]
9}) 9})
10export class DateToggleComponent implements OnInit, OnChanges { 10export class DateToggleComponent implements OnChanges {
11 @Input() date: Date 11 @Input() date: Date
12 @Input() toggled = false 12 @Input() toggled = false
13 13
@@ -19,10 +19,6 @@ export class DateToggleComponent implements OnInit, OnChanges {
19 private fromNowPipe: FromNowPipe 19 private fromNowPipe: FromNowPipe
20 ) { } 20 ) { }
21 21
22 ngOnInit () {
23 this.updateDates()
24 }
25
26 ngOnChanges () { 22 ngOnChanges () {
27 this.updateDates() 23 this.updateDates()
28 } 24 }
@@ -32,15 +28,19 @@ export class DateToggleComponent implements OnInit, OnChanges {
32 } 28 }
33 29
34 getTitle () { 30 getTitle () {
35 return this.toggled ? this.dateRelative : this.dateAbsolute 31 return this.toggled
32 ? this.dateRelative
33 : this.dateAbsolute
36 } 34 }
37 35
38 getContent () { 36 getContent () {
39 return this.toggled ? this.dateAbsolute : this.dateRelative 37 return this.toggled
38 ? this.dateAbsolute
39 : this.dateRelative
40 } 40 }
41 41
42 private updateDates () { 42 private updateDates () {
43 this.dateRelative = this.fromNowPipe.transform(this.date) 43 this.dateRelative = this.fromNowPipe.transform(this.date)
44 this.dateAbsolute = this.datePipe.transform(this.date, 'long') 44 this.dateAbsolute = this.date.toLocaleDateString()
45 } 45 }
46} 46}
diff --git a/client/src/main.ts b/client/src/main.ts
index 2d1749c42..0fddf3aac 100644
--- a/client/src/main.ts
+++ b/client/src/main.ts
@@ -1,6 +1,6 @@
1import { enableProdMode } from '@angular/core' 1import { ApplicationRef, enableProdMode } from '@angular/core'
2import { enableDebugTools } from '@angular/platform-browser'
2import { platformBrowserDynamic } from '@angular/platform-browser-dynamic' 3import { platformBrowserDynamic } from '@angular/platform-browser-dynamic'
3
4import { AppModule } from './app/app.module' 4import { AppModule } from './app/app.module'
5import { environment } from './environments/environment' 5import { environment } from './environments/environment'
6 6
@@ -27,6 +27,14 @@ const bootstrap = () => platformBrowserDynamic()
27 }) 27 })
28 } 28 }
29 29
30 if (!environment.production) {
31 const applicationRef = bootstrapModule.injector.get(ApplicationRef)
32 const componentRef = applicationRef.components[0]
33
34 // allows to run `ng.profiler.timeChangeDetection();`
35 enableDebugTools(componentRef)
36 }
37
30 return bootstrapModule 38 return bootstrapModule
31 }) 39 })
32 .catch(err => { 40 .catch(err => {