Verified Commit 2989628b authored by Chocobozzz's avatar Chocobozzz
Browse files

Use HTML config when possible

parent 8e08d415
...@@ -2,10 +2,10 @@ import { ViewportScroller } from '@angular/common' ...@@ -2,10 +2,10 @@ import { ViewportScroller } from '@angular/common'
import { AfterViewChecked, Component, ElementRef, OnInit, ViewChild } from '@angular/core' import { AfterViewChecked, Component, ElementRef, OnInit, ViewChild } from '@angular/core'
import { ActivatedRoute } from '@angular/router' import { ActivatedRoute } from '@angular/router'
import { ContactAdminModalComponent } from '@app/+about/about-instance/contact-admin-modal.component' import { ContactAdminModalComponent } from '@app/+about/about-instance/contact-admin-modal.component'
import { Notifier } from '@app/core' import { Notifier, ServerService } from '@app/core'
import { CustomMarkupService } from '@app/shared/shared-custom-markup' import { CustomMarkupService } from '@app/shared/shared-custom-markup'
import { InstanceService } from '@app/shared/shared-instance' import { InstanceService } from '@app/shared/shared-instance'
import { About, ServerConfig } from '@shared/models' import { About, HTMLServerConfig, ServerConfig } from '@shared/models'
import { copyToClipboard } from '../../../root-helpers/utils' import { copyToClipboard } from '../../../root-helpers/utils'
import { ResolverData } from './about-instance.resolver' import { ResolverData } from './about-instance.resolver'
...@@ -35,16 +35,17 @@ export class AboutInstanceComponent implements OnInit, AfterViewChecked { ...@@ -35,16 +35,17 @@ export class AboutInstanceComponent implements OnInit, AfterViewChecked {
languages: string[] = [] languages: string[] = []
categories: string[] = [] categories: string[] = []
serverConfig: ServerConfig
initialized = false initialized = false
private serverConfig: HTMLServerConfig
private lastScrollHash: string private lastScrollHash: string
constructor ( constructor (
private viewportScroller: ViewportScroller, private viewportScroller: ViewportScroller,
private route: ActivatedRoute, private route: ActivatedRoute,
private notifier: Notifier, private notifier: Notifier,
private serverService: ServerService,
private instanceService: InstanceService private instanceService: InstanceService
) {} ) {}
...@@ -61,9 +62,9 @@ export class AboutInstanceComponent implements OnInit, AfterViewChecked { ...@@ -61,9 +62,9 @@ export class AboutInstanceComponent implements OnInit, AfterViewChecked {
} }
async ngOnInit () { async ngOnInit () {
const { about, languages, categories, serverConfig }: ResolverData = this.route.snapshot.data.instanceData const { about, languages, categories }: ResolverData = this.route.snapshot.data.instanceData
this.serverConfig = serverConfig this.serverConfig = this.serverService.getHTMLConfig()
this.languages = languages this.languages = languages
this.categories = categories this.categories = categories
......
import { forkJoin } from 'rxjs' import { forkJoin } from 'rxjs'
import { map, switchMap } from 'rxjs/operators' import { map, switchMap } from 'rxjs/operators'
import { Injectable } from '@angular/core' import { Injectable } from '@angular/core'
import { ActivatedRouteSnapshot, Resolve } from '@angular/router' import { Resolve } from '@angular/router'
import { ServerService } from '@app/core'
import { InstanceService } from '@app/shared/shared-instance' import { InstanceService } from '@app/shared/shared-instance'
import { About, ServerConfig } from '@shared/models/server' import { About } from '@shared/models/server'
export type ResolverData = { about: About, languages: string[], categories: string[], serverConfig: ServerConfig } export type ResolverData = { about: About, languages: string[], categories: string[] }
@Injectable() @Injectable()
export class AboutInstanceResolver implements Resolve<any> { export class AboutInstanceResolver implements Resolve<any> {
constructor ( constructor (
private instanceService: InstanceService, private instanceService: InstanceService
private serverService: ServerService
) {} ) {}
resolve (route: ActivatedRouteSnapshot) { resolve () {
return this.instanceService.getAbout() return this.instanceService.getAbout()
.pipe( .pipe(
switchMap(about => { switchMap(about => {
return forkJoin([ return forkJoin([
this.instanceService.buildTranslatedLanguages(about), this.instanceService.buildTranslatedLanguages(about),
this.instanceService.buildTranslatedCategories(about), this.instanceService.buildTranslatedCategories(about)
this.serverService.getConfig() ]).pipe(map(([ languages, categories ]) => ({ about, languages, categories }) as ResolverData))
]).pipe(map(([ languages, categories, serverConfig ]) => ({ about, languages, categories, serverConfig })))
}) })
) )
} }
......
...@@ -11,7 +11,7 @@ import { InstanceService } from '@app/shared/shared-instance' ...@@ -11,7 +11,7 @@ import { InstanceService } from '@app/shared/shared-instance'
import { NgbModal } from '@ng-bootstrap/ng-bootstrap' import { NgbModal } from '@ng-bootstrap/ng-bootstrap'
import { NgbModalRef } from '@ng-bootstrap/ng-bootstrap/modal/modal-ref' import { NgbModalRef } from '@ng-bootstrap/ng-bootstrap/modal/modal-ref'
import { HttpStatusCode } from '@shared/core-utils/miscs/http-error-codes' import { HttpStatusCode } from '@shared/core-utils/miscs/http-error-codes'
import { ServerConfig } from '@shared/models' import { HTMLServerConfig } from '@shared/models'
@Component({ @Component({
selector: 'my-contact-admin-modal', selector: 'my-contact-admin-modal',
...@@ -24,7 +24,7 @@ export class ContactAdminModalComponent extends FormReactive implements OnInit { ...@@ -24,7 +24,7 @@ export class ContactAdminModalComponent extends FormReactive implements OnInit {
error: string error: string
private openedModal: NgbModalRef private openedModal: NgbModalRef
private serverConfig: ServerConfig private serverConfig: HTMLServerConfig
constructor ( constructor (
protected formValidatorService: FormValidatorService, protected formValidatorService: FormValidatorService,
...@@ -41,9 +41,7 @@ export class ContactAdminModalComponent extends FormReactive implements OnInit { ...@@ -41,9 +41,7 @@ export class ContactAdminModalComponent extends FormReactive implements OnInit {
} }
ngOnInit () { ngOnInit () {
this.serverConfig = this.serverService.getTmpConfig() this.serverConfig = this.serverService.getHTMLConfig()
this.serverService.getConfig()
.subscribe(config => this.serverConfig = config)
this.buildForm({ this.buildForm({
fromName: FROM_NAME_VALIDATOR, fromName: FROM_NAME_VALIDATOR,
......
import { SelectOptionsItem } from 'src/types/select-options-item.model'
import { Component, Input } from '@angular/core' import { Component, Input } from '@angular/core'
import { FormGroup } from '@angular/forms' import { FormGroup } from '@angular/forms'
......
...@@ -3,7 +3,7 @@ import { SelectOptionsItem } from 'src/types/select-options-item.model' ...@@ -3,7 +3,7 @@ import { SelectOptionsItem } from 'src/types/select-options-item.model'
import { Component, Input, OnChanges, OnInit, SimpleChanges } from '@angular/core' import { Component, Input, OnChanges, OnInit, SimpleChanges } from '@angular/core'
import { FormGroup } from '@angular/forms' import { FormGroup } from '@angular/forms'
import { MenuService } from '@app/core' import { MenuService } from '@app/core'
import { ServerConfig } from '@shared/models' import { HTMLServerConfig } from '@shared/models'
import { ConfigService } from '../shared/config.service' import { ConfigService } from '../shared/config.service'
@Component({ @Component({
...@@ -15,7 +15,7 @@ export class EditBasicConfigurationComponent implements OnInit, OnChanges { ...@@ -15,7 +15,7 @@ export class EditBasicConfigurationComponent implements OnInit, OnChanges {
@Input() form: FormGroup @Input() form: FormGroup
@Input() formErrors: any @Input() formErrors: any
@Input() serverConfig: ServerConfig @Input() serverConfig: HTMLServerConfig
signupAlertMessage: string signupAlertMessage: string
defaultLandingPageOptions: SelectOptionsItem[] = [] defaultLandingPageOptions: SelectOptionsItem[] = []
......
...@@ -27,7 +27,7 @@ import { ...@@ -27,7 +27,7 @@ import {
import { USER_VIDEO_QUOTA_DAILY_VALIDATOR, USER_VIDEO_QUOTA_VALIDATOR } from '@app/shared/form-validators/user-validators' import { USER_VIDEO_QUOTA_DAILY_VALIDATOR, USER_VIDEO_QUOTA_VALIDATOR } from '@app/shared/form-validators/user-validators'
import { FormReactive, FormValidatorService } from '@app/shared/shared-forms' import { FormReactive, FormValidatorService } from '@app/shared/shared-forms'
import { CustomPageService } from '@app/shared/shared-main/custom-page' import { CustomPageService } from '@app/shared/shared-main/custom-page'
import { CustomConfig, CustomPage, ServerConfig } from '@shared/models' import { CustomConfig, CustomPage, HTMLServerConfig } from '@shared/models'
import { EditConfigurationService } from './edit-configuration.service' import { EditConfigurationService } from './edit-configuration.service'
type ComponentCustomConfig = CustomConfig & { type ComponentCustomConfig = CustomConfig & {
...@@ -43,7 +43,7 @@ export class EditCustomConfigComponent extends FormReactive implements OnInit { ...@@ -43,7 +43,7 @@ export class EditCustomConfigComponent extends FormReactive implements OnInit {
activeNav: string activeNav: string
customConfig: ComponentCustomConfig customConfig: ComponentCustomConfig
serverConfig: ServerConfig serverConfig: HTMLServerConfig
homepage: CustomPage homepage: CustomPage
...@@ -64,9 +64,7 @@ export class EditCustomConfigComponent extends FormReactive implements OnInit { ...@@ -64,9 +64,7 @@ export class EditCustomConfigComponent extends FormReactive implements OnInit {
} }
ngOnInit () { ngOnInit () {
this.serverConfig = this.serverService.getTmpConfig() this.serverConfig = this.serverService.getHTMLConfig()
this.serverService.getConfig()
.subscribe(config => this.serverConfig = config)
const formGroupData: { [key in keyof ComponentCustomConfig ]: any } = { const formGroupData: { [key in keyof ComponentCustomConfig ]: any } = {
instance: { instance: {
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
import { SelectOptionsItem } from 'src/types/select-options-item.model' import { SelectOptionsItem } from 'src/types/select-options-item.model'
import { Component, Input, OnChanges, OnInit, SimpleChanges } from '@angular/core' import { Component, Input, OnChanges, OnInit, SimpleChanges } from '@angular/core'
import { FormGroup } from '@angular/forms' import { FormGroup } from '@angular/forms'
import { ServerConfig } from '@shared/models' import { HTMLServerConfig } from '@shared/models'
import { ConfigService } from '../shared/config.service' import { ConfigService } from '../shared/config.service'
import { EditConfigurationService, ResolutionOption } from './edit-configuration.service' import { EditConfigurationService, ResolutionOption } from './edit-configuration.service'
...@@ -14,7 +14,7 @@ import { EditConfigurationService, ResolutionOption } from './edit-configuration ...@@ -14,7 +14,7 @@ import { EditConfigurationService, ResolutionOption } from './edit-configuration
export class EditLiveConfigurationComponent implements OnInit, OnChanges { export class EditLiveConfigurationComponent implements OnInit, OnChanges {
@Input() form: FormGroup @Input() form: FormGroup
@Input() formErrors: any @Input() formErrors: any
@Input() serverConfig: ServerConfig @Input() serverConfig: HTMLServerConfig
transcodingThreadOptions: SelectOptionsItem[] = [] transcodingThreadOptions: SelectOptionsItem[] = []
transcodingProfiles: SelectOptionsItem[] = [] transcodingProfiles: SelectOptionsItem[] = []
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
import { SelectOptionsItem } from 'src/types/select-options-item.model' import { SelectOptionsItem } from 'src/types/select-options-item.model'
import { Component, Input, OnChanges, OnInit, SimpleChanges } from '@angular/core' import { Component, Input, OnChanges, OnInit, SimpleChanges } from '@angular/core'
import { FormGroup } from '@angular/forms' import { FormGroup } from '@angular/forms'
import { ServerConfig } from '@shared/models' import { HTMLServerConfig } from '@shared/models'
import { ConfigService } from '../shared/config.service' import { ConfigService } from '../shared/config.service'
import { EditConfigurationService, ResolutionOption } from './edit-configuration.service' import { EditConfigurationService, ResolutionOption } from './edit-configuration.service'
...@@ -14,7 +14,7 @@ import { EditConfigurationService, ResolutionOption } from './edit-configuration ...@@ -14,7 +14,7 @@ import { EditConfigurationService, ResolutionOption } from './edit-configuration
export class EditVODTranscodingComponent implements OnInit, OnChanges { export class EditVODTranscodingComponent implements OnInit, OnChanges {
@Input() form: FormGroup @Input() form: FormGroup
@Input() formErrors: any @Input() formErrors: any
@Input() serverConfig: ServerConfig @Input() serverConfig: HTMLServerConfig
transcodingThreadOptions: SelectOptionsItem[] = [] transcodingThreadOptions: SelectOptionsItem[] = []
transcodingProfiles: SelectOptionsItem[] = [] transcodingProfiles: SelectOptionsItem[] = []
......
...@@ -13,7 +13,8 @@ export class ModerationComponent implements OnInit { ...@@ -13,7 +13,8 @@ export class ModerationComponent implements OnInit {
) { } ) { }
ngOnInit (): void { ngOnInit (): void {
this.serverService.getConfig() const serverConfig = this.serverService.getHTMLConfig()
.subscribe(config => this.autoBlockVideosEnabled = config.autoBlacklist.videos.ofUsers.enabled)
this.autoBlockVideosEnabled = serverConfig.autoBlacklist.videos.ofUsers.enabled
} }
} }
...@@ -107,13 +107,12 @@ export class VideoBlockListComponent extends RestTable implements OnInit { ...@@ -107,13 +107,12 @@ export class VideoBlockListComponent extends RestTable implements OnInit {
} }
ngOnInit () { ngOnInit () {
this.serverService.getConfig() const serverConfig = this.serverService.getHTMLConfig()
.subscribe(config => {
// don't filter if auto-blacklist is not enabled as this will be the only list // Don't filter if auto-blacklist is not enabled as this will be the only list
if (config.autoBlacklist.videos.ofUsers.enabled) { if (serverConfig.autoBlacklist.videos.ofUsers.enabled) {
this.blocklistTypeFilter = VideoBlacklistType.MANUAL this.blocklistTypeFilter = VideoBlacklistType.MANUAL
} }
})
this.initialize() this.initialize()
} }
......
...@@ -3,7 +3,7 @@ import { ConfigService } from '@app/+admin/config/shared/config.service' ...@@ -3,7 +3,7 @@ import { ConfigService } from '@app/+admin/config/shared/config.service'
import { AuthService, ScreenService, ServerService, User } from '@app/core' import { AuthService, ScreenService, ServerService, User } from '@app/core'
import { FormReactive } from '@app/shared/shared-forms' import { FormReactive } from '@app/shared/shared-forms'
import { USER_ROLE_LABELS } from '@shared/core-utils/users' import { USER_ROLE_LABELS } from '@shared/core-utils/users'
import { ServerConfig, UserAdminFlag, UserRole, VideoResolution } from '@shared/models' import { HTMLServerConfig, UserAdminFlag, UserRole, VideoResolution } from '@shared/models'
import { SelectOptionsItem } from '../../../../types/select-options-item.model' import { SelectOptionsItem } from '../../../../types/select-options-item.model'
@Directive() @Directive()
...@@ -16,7 +16,7 @@ export abstract class UserEdit extends FormReactive implements OnInit { ...@@ -16,7 +16,7 @@ export abstract class UserEdit extends FormReactive implements OnInit {
roles: { value: string, label: string }[] = [] roles: { value: string, label: string }[] = []
protected serverConfig: ServerConfig protected serverConfig: HTMLServerConfig
protected abstract serverService: ServerService protected abstract serverService: ServerService
protected abstract configService: ConfigService protected abstract configService: ConfigService
...@@ -26,9 +26,7 @@ export abstract class UserEdit extends FormReactive implements OnInit { ...@@ -26,9 +26,7 @@ export abstract class UserEdit extends FormReactive implements OnInit {
abstract getFormButtonTitle (): string abstract getFormButtonTitle (): string
ngOnInit (): void { ngOnInit (): void {
this.serverConfig = this.serverService.getTmpConfig() this.serverConfig = this.serverService.getHTMLConfig()
this.serverService.getConfig()
.subscribe(config => this.serverConfig = config)
this.buildRoles() this.buildRoles()
} }
......
...@@ -5,7 +5,7 @@ import { AuthService, ConfirmService, Notifier, RestPagination, RestTable, Serve ...@@ -5,7 +5,7 @@ import { AuthService, ConfirmService, Notifier, RestPagination, RestTable, Serve
import { AdvancedInputFilter } from '@app/shared/shared-forms' import { AdvancedInputFilter } from '@app/shared/shared-forms'
import { DropdownAction } from '@app/shared/shared-main' import { DropdownAction } from '@app/shared/shared-main'
import { UserBanModalComponent } from '@app/shared/shared-moderation' import { UserBanModalComponent } from '@app/shared/shared-moderation'
import { ServerConfig, User, UserRole } from '@shared/models' import { User, UserRole } from '@shared/models'
type UserForList = User & { type UserForList = User & {
rawVideoQuota: number rawVideoQuota: number
...@@ -41,8 +41,9 @@ export class UserListComponent extends RestTable implements OnInit { ...@@ -41,8 +41,9 @@ export class UserListComponent extends RestTable implements OnInit {
} }
] ]
requiresEmailVerification = false
private _selectedColumns: string[] private _selectedColumns: string[]
private serverConfig: ServerConfig
constructor ( constructor (
protected route: ActivatedRoute, protected route: ActivatedRoute,
...@@ -60,10 +61,6 @@ export class UserListComponent extends RestTable implements OnInit { ...@@ -60,10 +61,6 @@ export class UserListComponent extends RestTable implements OnInit {
return this.auth.getUser() return this.auth.getUser()
} }
get requiresEmailVerification () {
return this.serverConfig.signup.requiresEmailVerification
}
get selectedColumns () { get selectedColumns () {
return this._selectedColumns return this._selectedColumns
} }
...@@ -73,9 +70,8 @@ export class UserListComponent extends RestTable implements OnInit { ...@@ -73,9 +70,8 @@ export class UserListComponent extends RestTable implements OnInit {
} }
ngOnInit () { ngOnInit () {
this.serverConfig = this.serverService.getTmpConfig()
this.serverService.getConfig() this.serverService.getConfig()
.subscribe(config => this.serverConfig = config) .subscribe(config => this.requiresEmailVerification = config.signup.requiresEmailVerification)
this.initialize() this.initialize()
......
import { Routes } from '@angular/router' import { Routes } from '@angular/router'
import { ServerConfigResolver, UserRightGuard } from '@app/core' import { UserRightGuard } from '@app/core'
import { UserRight } from '@shared/models' import { UserRight } from '@shared/models'
import { UserCreateComponent, UserUpdateComponent } from './user-edit' import { UserCreateComponent, UserUpdateComponent } from './user-edit'
import { UserListComponent } from './user-list' import { UserListComponent } from './user-list'
...@@ -35,9 +35,6 @@ export const UsersRoutes: Routes = [ ...@@ -35,9 +35,6 @@ export const UsersRoutes: Routes = [
meta: { meta: {
title: $localize`Create a user` title: $localize`Create a user`
} }
},
resolve: {
serverConfig: ServerConfigResolver
} }
}, },
{ {
......
...@@ -60,10 +60,8 @@ export class MyAccountNotificationPreferencesComponent implements OnInit { ...@@ -60,10 +60,8 @@ export class MyAccountNotificationPreferencesComponent implements OnInit {
} }
ngOnInit () { ngOnInit () {
this.serverService.getConfig() const serverConfig = this.serverService.getHTMLConfig()
.subscribe(config => { this.emailEnabled = serverConfig.email.enabled
this.emailEnabled = config.email.enabled
})
this.userInformationLoaded.subscribe(() => this.loadNotificationSettings()) this.userInformationLoaded.subscribe(() => this.loadNotificationSettings())
} }
......
...@@ -11,7 +11,7 @@ import { ...@@ -11,7 +11,7 @@ import {
} from '@app/shared/form-validators/video-channel-validators' } from '@app/shared/form-validators/video-channel-validators'
import { FormValidatorService } from '@app/shared/shared-forms' import { FormValidatorService } from '@app/shared/shared-forms'
import { VideoChannel, VideoChannelService } from '@app/shared/shared-main' import { VideoChannel, VideoChannelService } from '@app/shared/shared-main'
import { ServerConfig, VideoChannelUpdate } from '@shared/models' import { HTMLServerConfig, VideoChannelUpdate } from '@shared/models'
import { MyVideoChannelEdit } from './my-video-channel-edit' import { MyVideoChannelEdit } from './my-video-channel-edit'
@Component({ @Component({
...@@ -25,7 +25,7 @@ export class MyVideoChannelUpdateComponent extends MyVideoChannelEdit implements ...@@ -25,7 +25,7 @@ export class MyVideoChannelUpdateComponent extends MyVideoChannelEdit implements
private paramsSub: Subscription private paramsSub: Subscription
private oldSupportField: string private oldSupportField: string
private serverConfig: ServerConfig private serverConfig: HTMLServerConfig
constructor ( constructor (
protected formValidatorService: FormValidatorService, protected formValidatorService: FormValidatorService,
...@@ -40,9 +40,7 @@ export class MyVideoChannelUpdateComponent extends MyVideoChannelEdit implements ...@@ -40,9 +40,7 @@ export class MyVideoChannelUpdateComponent extends MyVideoChannelEdit implements
} }
ngOnInit () { ngOnInit () {
this.serverConfig = this.serverService.getTmpConfig() this.serverConfig = this.serverService.getHTMLConfig()
this.serverService.getConfig()
.subscribe(config => this.serverConfig = config)
this.buildForm({ this.buildForm({
'display-name': VIDEO_CHANNEL_DISPLAY_NAME_VALIDATOR, 'display-name': VIDEO_CHANNEL_DISPLAY_NAME_VALIDATOR,
......
import { Component, OnInit } from '@angular/core' import { Component, OnInit } from '@angular/core'
import { AuthService, AuthUser, ScreenService, ServerService } from '@app/core' import { AuthService, AuthUser, ScreenService, ServerService } from '@app/core'
import { ServerConfig } from '@shared/models' import { HTMLServerConfig } from '@shared/models'
import { TopMenuDropdownParam } from '../shared/shared-main/misc/top-menu-dropdown.component' import { TopMenuDropdownParam } from '../shared/shared-main/misc/top-menu-dropdown.component'
@Component({ @Component({
...@@ -11,7 +11,8 @@ export class MyLibraryComponent implements OnInit { ...@@ -11,7 +11,8 @@ export class MyLibraryComponent implements OnInit {
menuEntries: TopMenuDropdownParam[] = [] menuEntries: TopMenuDropdownParam[] = []
user: AuthUser user: AuthUser
private serverConfig: ServerConfig
private serverConfig: HTMLServerConfig
constructor ( constructor (
private serverService: ServerService, private serverService: ServerService,
...@@ -24,9 +25,7 @@ export class MyLibraryComponent implements OnInit { ...@@ -24,9 +25,7 @@ export class MyLibraryComponent implements OnInit {
} }
ngOnInit (): void { ngOnInit (): void {
this.serverConfig = this.serverService.getTmpConfig() this.serverConfig = this.serverService.getHTMLConfig()