aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app/menu
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2020-11-27 15:31:09 +0100
committerChocobozzz <me@florianbigard.com>2020-11-27 15:46:49 +0100
commit68f6c87a27bd3616644368154914a683001f8aa6 (patch)
treed1db9fb50f9973b697c43c5c06935a5c5a9ff819 /client/src/app/menu
parentacfa2e300defbf79994f49b2062ec6bece5ad1a9 (diff)
downloadPeerTube-68f6c87a27bd3616644368154914a683001f8aa6.tar.gz
PeerTube-68f6c87a27bd3616644368154914a683001f8aa6.tar.zst
PeerTube-68f6c87a27bd3616644368154914a683001f8aa6.zip
Various front optimizations
Diffstat (limited to 'client/src/app/menu')
-rw-r--r--client/src/app/menu/menu.component.html6
-rw-r--r--client/src/app/menu/menu.component.ts65
2 files changed, 37 insertions, 34 deletions
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}