aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app/menu
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2020-03-11 16:41:38 +0100
committerChocobozzz <me@florianbigard.com>2020-03-11 16:45:09 +0100
commit111fdc267b36201cf1be1fdf91017005102b4a5e (patch)
tree5ea98f766cc74de3434a855e998e763324e9da72 /client/src/app/menu
parent764a965778ac89e027fd05dd35697c6763e0dc18 (diff)
downloadPeerTube-111fdc267b36201cf1be1fdf91017005102b4a5e.tar.gz
PeerTube-111fdc267b36201cf1be1fdf91017005102b4a5e.tar.zst
PeerTube-111fdc267b36201cf1be1fdf91017005102b4a5e.zip
Handle overview pagination in client
Diffstat (limited to 'client/src/app/menu')
-rw-r--r--client/src/app/menu/language-chooser.component.ts1
-rw-r--r--client/src/app/menu/menu.component.ts50
2 files changed, 36 insertions, 15 deletions
diff --git a/client/src/app/menu/language-chooser.component.ts b/client/src/app/menu/language-chooser.component.ts
index fb74cdf19..9bc934ad4 100644
--- a/client/src/app/menu/language-chooser.component.ts
+++ b/client/src/app/menu/language-chooser.component.ts
@@ -36,6 +36,7 @@ export class LanguageChooserComponent {
36 getCurrentLanguage () { 36 getCurrentLanguage () {
37 const english = 'English' 37 const english = 'English'
38 const locale = isOnDevLocale() ? getDevLocale() : getCompleteLocale(this.localeId) 38 const locale = isOnDevLocale() ? getDevLocale() : getCompleteLocale(this.localeId)
39
39 if (locale) return I18N_LOCALES[locale] || english 40 if (locale) return I18N_LOCALES[locale] || english
40 return english 41 return english
41 } 42 }
diff --git a/client/src/app/menu/menu.component.ts b/client/src/app/menu/menu.component.ts
index ce209457c..37702e975 100644
--- a/client/src/app/menu/menu.component.ts
+++ b/client/src/app/menu/menu.component.ts
@@ -23,8 +23,10 @@ export class MenuComponent implements OnInit {
23 23
24 userHasAdminAccess = false 24 userHasAdminAccess = false
25 helpVisible = false 25 helpVisible = false
26 languages: VideoConstant<string>[] = []
27 26
27 videoLanguages: string[] = []
28
29 private languages: VideoConstant<string>[] = []
28 private serverConfig: ServerConfig 30 private serverConfig: ServerConfig
29 private routesPerRight: { [ role in UserRight ]?: string } = { 31 private routesPerRight: { [ role in UserRight ]?: string } = {
30 [UserRight.MANAGE_USERS]: '/admin/users', 32 [UserRight.MANAGE_USERS]: '/admin/users',
@@ -71,30 +73,32 @@ export class MenuComponent implements OnInit {
71 } 73 }
72 ) 74 )
73 75
74 this.hotkeysService.cheatSheetToggle.subscribe(isOpen => this.helpVisible = isOpen) 76 this.hotkeysService.cheatSheetToggle
77 .subscribe(isOpen => this.helpVisible = isOpen)
78
79 this.serverService.getVideoLanguages()
80 .subscribe(languages => {
81 this.languages = languages
75 82
76 this.serverService.getVideoLanguages().subscribe(languages => this.languages = languages) 83 this.authService.userInformationLoaded
84 .subscribe(() => this.buildUserLanguages())
85 })
77 } 86 }
78 87
79 get language () { 88 get language () {
80 return this.languageChooserModal.getCurrentLanguage() 89 return this.languageChooserModal.getCurrentLanguage()
81 } 90 }
82 91
83 get videoLanguages (): string[] {
84 if (!this.user) return
85 if (!this.user.videoLanguages) return [this.i18n('any language')]
86 return this.user.videoLanguages
87 .map(locale => this.langForLocale(locale))
88 .map(value => value === undefined ? '?' : value)
89 }
90
91 get nsfwPolicy () { 92 get nsfwPolicy () {
92 if (!this.user) return 93 if (!this.user) return
94
93 switch (this.user.nsfwPolicy) { 95 switch (this.user.nsfwPolicy) {
94 case 'do_not_list': 96 case 'do_not_list':
95 return this.i18n('hide') 97 return this.i18n('hide')
98
96 case 'blur': 99 case 'blur':
97 return this.i18n('blur') 100 return this.i18n('blur')
101
98 case 'display': 102 case 'display':
99 return this.i18n('display') 103 return this.i18n('display')
100 } 104 }
@@ -156,13 +160,29 @@ export class MenuComponent implements OnInit {
156 toggleUseP2P () { 160 toggleUseP2P () {
157 if (!this.user) return 161 if (!this.user) return
158 this.user.webTorrentEnabled = !this.user.webTorrentEnabled 162 this.user.webTorrentEnabled = !this.user.webTorrentEnabled
159 this.userService.updateMyProfile({ 163
160 webTorrentEnabled: this.user.webTorrentEnabled 164 this.userService.updateMyProfile({ webTorrentEnabled: this.user.webTorrentEnabled })
161 }).subscribe(() => this.authService.refreshUserInformation()) 165 .subscribe(() => this.authService.refreshUserInformation())
162 } 166 }
163 167
164 langForLocale (localeId: string) { 168 langForLocale (localeId: string) {
165 return this.languages.find(lang => lang.id = localeId).label 169 return this.languages.find(lang => lang.id === localeId).label
170 }
171
172 private buildUserLanguages () {
173 if (!this.user) {
174 this.videoLanguages = []
175 return
176 }
177
178 if (!this.user.videoLanguages) {
179 this.videoLanguages = [ this.i18n('any language') ]
180 return
181 }
182
183 this.videoLanguages = this.user.videoLanguages
184 .map(locale => this.langForLocale(locale))
185 .map(value => value === undefined ? '?' : value)
166 } 186 }
167 187
168 private computeIsUserHasAdminAccess () { 188 private computeIsUserHasAdminAccess () {