diff options
author | Chocobozzz <me@florianbigard.com> | 2022-06-16 14:36:51 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2022-06-16 14:44:14 +0200 |
commit | 5e93a6d142b1151d1ebc16123206f87998839108 (patch) | |
tree | 71dff17c1a79bb87e753216a83e317ad6efebf47 /client/src/app/shared/shared-user-settings | |
parent | 3256771725430ab6fc716e937b88ca2b2b85263b (diff) | |
download | PeerTube-5e93a6d142b1151d1ebc16123206f87998839108.tar.gz PeerTube-5e93a6d142b1151d1ebc16123206f87998839108.tar.zst PeerTube-5e93a6d142b1151d1ebc16123206f87998839108.zip |
Improve theme label
Diffstat (limited to 'client/src/app/shared/shared-user-settings')
-rw-r--r-- | client/src/app/shared/shared-user-settings/user-interface-settings.component.html | 6 | ||||
-rw-r--r-- | client/src/app/shared/shared-user-settings/user-interface-settings.component.ts | 27 |
2 files changed, 18 insertions, 15 deletions
diff --git a/client/src/app/shared/shared-user-settings/user-interface-settings.component.html b/client/src/app/shared/shared-user-settings/user-interface-settings.component.html index b739e881b..1a24641a2 100644 --- a/client/src/app/shared/shared-user-settings/user-interface-settings.component.html +++ b/client/src/app/shared/shared-user-settings/user-interface-settings.component.html | |||
@@ -5,10 +5,10 @@ | |||
5 | 5 | ||
6 | <div class="peertube-select-container"> | 6 | <div class="peertube-select-container"> |
7 | <select formControlName="theme" id="theme" class="form-control"> | 7 | <select formControlName="theme" id="theme" class="form-control"> |
8 | <option i18n value="instance-default">Instance default theme ({{ getDefaultThemeLabel() }})</option> | 8 | <option i18n value="instance-default">{{ instanceName }} default theme ({{ getDefaultInstanceThemeLabel() }})</option> |
9 | <option i18n value="default">{{ defaultThemeLabel }}</option> | 9 | <option i18n value="default">{{ getDefaultThemeLabel() }}</option> |
10 | 10 | ||
11 | <option *ngFor="let theme of availableThemes" [value]="theme">{{ capitalizeFirstLetter(theme) }}</option> | 11 | <option *ngFor="let theme of getAvailableThemes()" [value]="theme">{{ theme }}</option> |
12 | </select> | 12 | </select> |
13 | </div> | 13 | </div> |
14 | </div> | 14 | </div> |
diff --git a/client/src/app/shared/shared-user-settings/user-interface-settings.component.ts b/client/src/app/shared/shared-user-settings/user-interface-settings.component.ts index 932db498a..24ad54b1d 100644 --- a/client/src/app/shared/shared-user-settings/user-interface-settings.component.ts +++ b/client/src/app/shared/shared-user-settings/user-interface-settings.component.ts | |||
@@ -1,8 +1,7 @@ | |||
1 | import { Subject, Subscription } from 'rxjs' | 1 | import { Subject, Subscription } from 'rxjs' |
2 | import { Component, Input, OnDestroy, OnInit } from '@angular/core' | 2 | import { Component, Input, OnDestroy, OnInit } from '@angular/core' |
3 | import { AuthService, Notifier, ServerService, UserService } from '@app/core' | 3 | import { AuthService, Notifier, ServerService, ThemeService, UserService } from '@app/core' |
4 | import { FormReactive, FormValidatorService } from '@app/shared/shared-forms' | 4 | import { FormReactive, FormValidatorService } from '@app/shared/shared-forms' |
5 | import { capitalizeFirstLetter } from '@root-helpers/string' | ||
6 | import { HTMLServerConfig, User, UserUpdateMe } from '@shared/models' | 5 | import { HTMLServerConfig, User, UserUpdateMe } from '@shared/models' |
7 | 6 | ||
8 | @Component({ | 7 | @Component({ |
@@ -18,8 +17,6 @@ export class UserInterfaceSettingsComponent extends FormReactive implements OnIn | |||
18 | 17 | ||
19 | formValuesWatcher: Subscription | 18 | formValuesWatcher: Subscription |
20 | 19 | ||
21 | defaultThemeLabel = $localize`Light/Orange` | ||
22 | |||
23 | private serverConfig: HTMLServerConfig | 20 | private serverConfig: HTMLServerConfig |
24 | 21 | ||
25 | constructor ( | 22 | constructor ( |
@@ -27,14 +24,14 @@ export class UserInterfaceSettingsComponent extends FormReactive implements OnIn | |||
27 | private authService: AuthService, | 24 | private authService: AuthService, |
28 | private notifier: Notifier, | 25 | private notifier: Notifier, |
29 | private userService: UserService, | 26 | private userService: UserService, |
27 | private themeService: ThemeService, | ||
30 | private serverService: ServerService | 28 | private serverService: ServerService |
31 | ) { | 29 | ) { |
32 | super() | 30 | super() |
33 | } | 31 | } |
34 | 32 | ||
35 | get availableThemes () { | 33 | get instanceName () { |
36 | return this.serverConfig.theme.registered | 34 | return this.serverConfig.instance.name |
37 | .map(t => t.name) | ||
38 | } | 35 | } |
39 | 36 | ||
40 | ngOnInit () { | 37 | ngOnInit () { |
@@ -61,17 +58,23 @@ export class UserInterfaceSettingsComponent extends FormReactive implements OnIn | |||
61 | } | 58 | } |
62 | 59 | ||
63 | getDefaultThemeLabel () { | 60 | getDefaultThemeLabel () { |
61 | return this.themeService.getDefaultThemeLabel() | ||
62 | } | ||
63 | |||
64 | getAvailableThemes () { | ||
65 | return this.themeService.getAvailableThemeLabels() | ||
66 | } | ||
67 | |||
68 | getDefaultInstanceThemeLabel () { | ||
64 | const theme = this.serverConfig.theme.default | 69 | const theme = this.serverConfig.theme.default |
65 | 70 | ||
66 | if (theme === 'default') return this.defaultThemeLabel | 71 | if (theme === 'default') { |
72 | return this.getDefaultThemeLabel() | ||
73 | } | ||
67 | 74 | ||
68 | return theme | 75 | return theme |
69 | } | 76 | } |
70 | 77 | ||
71 | capitalizeFirstLetter (str: string) { | ||
72 | return capitalizeFirstLetter(str) | ||
73 | } | ||
74 | |||
75 | updateInterfaceSettings () { | 78 | updateInterfaceSettings () { |
76 | const theme = this.form.value['theme'] | 79 | const theme = this.form.value['theme'] |
77 | 80 | ||