Fix setting theme in client

pull/5098/head
Chocobozzz 2022-06-27 09:59:10 +02:00
parent b713976afb
commit 00fe5d6136
No known key found for this signature in database
GPG Key ID: 583A612D890159BE
5 changed files with 11 additions and 12 deletions

View File

@ -17,7 +17,7 @@
<select formControlName="default" id="themeDefault" class="form-control"> <select formControlName="default" id="themeDefault" class="form-control">
<option i18n value="default">{{ getDefaultThemeLabel() }}</option> <option i18n value="default">{{ getDefaultThemeLabel() }}</option>
<option *ngFor="let theme of getAvailableThemes()" [value]="theme">{{ theme }}</option> <option *ngFor="let theme of availableThemes" [value]="theme.id">{{ theme.label }}</option>
</select> </select>
</div> </div>
</div> </div>

View File

@ -19,6 +19,7 @@ export class EditBasicConfigurationComponent implements OnInit, OnChanges {
signupAlertMessage: string signupAlertMessage: string
defaultLandingPageOptions: SelectOptionsItem[] = [] defaultLandingPageOptions: SelectOptionsItem[] = []
availableThemes: SelectOptionsItem[]
constructor ( constructor (
private configService: ConfigService, private configService: ConfigService,
@ -29,6 +30,8 @@ export class EditBasicConfigurationComponent implements OnInit, OnChanges {
ngOnInit () { ngOnInit () {
this.buildLandingPageOptions() this.buildLandingPageOptions()
this.checkSignupField() this.checkSignupField()
this.availableThemes = this.themeService.buildAvailableThemes()
} }
ngOnChanges (changes: SimpleChanges) { ngOnChanges (changes: SimpleChanges) {
@ -49,10 +52,6 @@ export class EditBasicConfigurationComponent implements OnInit, OnChanges {
return this.configService.videoQuotaDailyOptions return this.configService.videoQuotaDailyOptions
} }
getAvailableThemes () {
return this.themeService.getAvailableThemeLabels()
}
doesTrendingVideosAlgorithmsEnabledInclude (algorithm: string) { doesTrendingVideosAlgorithmsEnabledInclude (algorithm: string) {
const enabled = this.form.value['trending']['videos']['algorithms']['enabled'] const enabled = this.form.value['trending']['videos']['algorithms']['enabled']
if (!Array.isArray(enabled)) return false if (!Array.isArray(enabled)) return false

View File

@ -49,9 +49,9 @@ export class ThemeService {
return $localize`Light/Orange` return $localize`Light/Orange`
} }
getAvailableThemeLabels () { buildAvailableThemes () {
return this.serverConfig.theme.registered return this.serverConfig.theme.registered
.map(t => capitalizeFirstLetter(t.name)) .map(t => ({ id: t.name, label: capitalizeFirstLetter(t.name) }))
} }
private injectThemes (themes: ServerConfigTheme[], fromLocalStorage = false) { private injectThemes (themes: ServerConfigTheme[], fromLocalStorage = false) {

View File

@ -8,7 +8,7 @@
<option i18n value="instance-default">{{ instanceName }} default theme ({{ getDefaultInstanceThemeLabel() }})</option> <option i18n value="instance-default">{{ instanceName }} default theme ({{ getDefaultInstanceThemeLabel() }})</option>
<option i18n value="default">{{ getDefaultThemeLabel() }}</option> <option i18n value="default">{{ getDefaultThemeLabel() }}</option>
<option *ngFor="let theme of getAvailableThemes()" [value]="theme">{{ theme }}</option> <option *ngFor="let theme of availableThemes" [value]="theme.id">{{ theme.label }}</option>
</select> </select>
</div> </div>
</div> </div>

View File

@ -3,6 +3,7 @@ import { Component, Input, OnDestroy, OnInit } from '@angular/core'
import { AuthService, Notifier, ServerService, ThemeService, UserService } from '@app/core' import { AuthService, Notifier, ServerService, ThemeService, UserService } from '@app/core'
import { FormReactive, FormValidatorService } from '@app/shared/shared-forms' import { FormReactive, FormValidatorService } from '@app/shared/shared-forms'
import { HTMLServerConfig, User, UserUpdateMe } from '@shared/models' import { HTMLServerConfig, User, UserUpdateMe } from '@shared/models'
import { SelectOptionsItem } from 'src/types'
@Component({ @Component({
selector: 'my-user-interface-settings', selector: 'my-user-interface-settings',
@ -15,6 +16,7 @@ export class UserInterfaceSettingsComponent extends FormReactive implements OnIn
@Input() notifyOnUpdate = true @Input() notifyOnUpdate = true
@Input() userInformationLoaded: Subject<any> @Input() userInformationLoaded: Subject<any>
availableThemes: SelectOptionsItem[]
formValuesWatcher: Subscription formValuesWatcher: Subscription
private serverConfig: HTMLServerConfig private serverConfig: HTMLServerConfig
@ -37,6 +39,8 @@ export class UserInterfaceSettingsComponent extends FormReactive implements OnIn
ngOnInit () { ngOnInit () {
this.serverConfig = this.serverService.getHTMLConfig() this.serverConfig = this.serverService.getHTMLConfig()
this.availableThemes = this.themeService.buildAvailableThemes()
this.buildForm({ this.buildForm({
theme: null theme: null
}) })
@ -61,10 +65,6 @@ export class UserInterfaceSettingsComponent extends FormReactive implements OnIn
return this.themeService.getDefaultThemeLabel() return this.themeService.getDefaultThemeLabel()
} }
getAvailableThemes () {
return this.themeService.getAvailableThemeLabels()
}
getDefaultInstanceThemeLabel () { getDefaultInstanceThemeLabel () {
const theme = this.serverConfig.theme.default const theme = this.serverConfig.theme.default