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'
import { AfterViewChecked, Component, ElementRef, OnInit, ViewChild } from '@angular/core'
import { ActivatedRoute } from '@angular/router'
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 { 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 { ResolverData } from './about-instance.resolver'
......@@ -35,16 +35,17 @@ export class AboutInstanceComponent implements OnInit, AfterViewChecked {
languages: string[] = []
categories: string[] = []
serverConfig: ServerConfig
initialized = false
private serverConfig: HTMLServerConfig
private lastScrollHash: string
constructor (
private viewportScroller: ViewportScroller,
private route: ActivatedRoute,
private notifier: Notifier,
private serverService: ServerService,
private instanceService: InstanceService
) {}
......@@ -61,9 +62,9 @@ export class AboutInstanceComponent implements OnInit, AfterViewChecked {
}
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.categories = categories
......
import { forkJoin } from 'rxjs'
import { map, switchMap } from 'rxjs/operators'
import { Injectable } from '@angular/core'
import { ActivatedRouteSnapshot, Resolve } from '@angular/router'
import { ServerService } from '@app/core'
import { Resolve } from '@angular/router'
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()
export class AboutInstanceResolver implements Resolve<any> {
constructor (
private instanceService: InstanceService,
private serverService: ServerService
private instanceService: InstanceService
) {}
resolve (route: ActivatedRouteSnapshot) {
resolve () {
return this.instanceService.getAbout()
.pipe(
switchMap(about => {
return forkJoin([
this.instanceService.buildTranslatedLanguages(about),
this.instanceService.buildTranslatedCategories(about),
this.serverService.getConfig()
]).pipe(map(([ languages, categories, serverConfig ]) => ({ about, languages, categories, serverConfig })))
this.instanceService.buildTranslatedCategories(about)
]).pipe(map(([ languages, categories ]) => ({ about, languages, categories }) as ResolverData))
})
)
}
......
......@@ -11,7 +11,7 @@ import { InstanceService } from '@app/shared/shared-instance'
import { NgbModal } from '@ng-bootstrap/ng-bootstrap'
import { NgbModalRef } from '@ng-bootstrap/ng-bootstrap/modal/modal-ref'
import { HttpStatusCode } from '@shared/core-utils/miscs/http-error-codes'
import { ServerConfig } from '@shared/models'
import { HTMLServerConfig } from '@shared/models'
@Component({
selector: 'my-contact-admin-modal',
......@@ -24,7 +24,7 @@ export class ContactAdminModalComponent extends FormReactive implements OnInit {
error: string
private openedModal: NgbModalRef
private serverConfig: ServerConfig
private serverConfig: HTMLServerConfig
constructor (
protected formValidatorService: FormValidatorService,
......@@ -41,9 +41,7 @@ export class ContactAdminModalComponent extends FormReactive implements OnInit {
}
ngOnInit () {
this.serverConfig = this.serverService.getTmpConfig()
this.serverService.getConfig()
.subscribe(config => this.serverConfig = config)
this.serverConfig = this.serverService.getHTMLConfig()
this.buildForm({
fromName: FROM_NAME_VALIDATOR,
......
import { SelectOptionsItem } from 'src/types/select-options-item.model'
import { Component, Input } from '@angular/core'
import { FormGroup } from '@angular/forms'
......
......@@ -3,7 +3,7 @@ import { SelectOptionsItem } from 'src/types/select-options-item.model'
import { Component, Input, OnChanges, OnInit, SimpleChanges } from '@angular/core'
import { FormGroup } from '@angular/forms'
import { MenuService } from '@app/core'
import { ServerConfig } from '@shared/models'
import { HTMLServerConfig } from '@shared/models'
import { ConfigService } from '../shared/config.service'
@Component({
......@@ -15,7 +15,7 @@ export class EditBasicConfigurationComponent implements OnInit, OnChanges {
@Input() form: FormGroup
@Input() formErrors: any
@Input() serverConfig: ServerConfig
@Input() serverConfig: HTMLServerConfig
signupAlertMessage: string
defaultLandingPageOptions: SelectOptionsItem[] = []
......
......@@ -27,7 +27,7 @@ import {
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 { 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'
type ComponentCustomConfig = CustomConfig & {
......@@ -43,7 +43,7 @@ export class EditCustomConfigComponent extends FormReactive implements OnInit {
activeNav: string
customConfig: ComponentCustomConfig
serverConfig: ServerConfig
serverConfig: HTMLServerConfig
homepage: CustomPage
......@@ -64,9 +64,7 @@ export class EditCustomConfigComponent extends FormReactive implements OnInit {
}
ngOnInit () {
this.serverConfig = this.serverService.getTmpConfig()
this.serverService.getConfig()
.subscribe(config => this.serverConfig = config)
this.serverConfig = this.serverService.getHTMLConfig()
const formGroupData: { [key in keyof ComponentCustomConfig ]: any } = {
instance: {
......
......@@ -2,7 +2,7 @@
import { SelectOptionsItem } from 'src/types/select-options-item.model'
import { Component, Input, OnChanges, OnInit, SimpleChanges } from '@angular/core'
import { FormGroup } from '@angular/forms'
import { ServerConfig } from '@shared/models'
import { HTMLServerConfig } from '@shared/models'
import { ConfigService } from '../shared/config.service'
import { EditConfigurationService, ResolutionOption } from './edit-configuration.service'
......@@ -14,7 +14,7 @@ import { EditConfigurationService, ResolutionOption } from './edit-configuration
export class EditLiveConfigurationComponent implements OnInit, OnChanges {
@Input() form: FormGroup
@Input() formErrors: any
@Input() serverConfig: ServerConfig
@Input() serverConfig: HTMLServerConfig
transcodingThreadOptions: SelectOptionsItem[] = []
transcodingProfiles: SelectOptionsItem[] = []
......
......@@ -2,7 +2,7 @@
import { SelectOptionsItem } from 'src/types/select-options-item.model'
import { Component, Input, OnChanges, OnInit, SimpleChanges } from '@angular/core'
import { FormGroup } from '@angular/forms'
import { ServerConfig } from '@shared/models'
import { HTMLServerConfig } from '@shared/models'
import { ConfigService } from '../shared/config.service'
import { EditConfigurationService, ResolutionOption } from './edit-configuration.service'
......@@ -14,7 +14,7 @@ import { EditConfigurationService, ResolutionOption } from './edit-configuration
export class EditVODTranscodingComponent implements OnInit, OnChanges {
@Input() form: FormGroup
@Input() formErrors: any
@Input() serverConfig: ServerConfig
@Input() serverConfig: HTMLServerConfig
transcodingThreadOptions: SelectOptionsItem[] = []
transcodingProfiles: SelectOptionsItem[] = []
......
......@@ -13,7 +13,8 @@ export class ModerationComponent implements OnInit {
) { }
ngOnInit (): void {
this.serverService.getConfig()
.subscribe(config => this.autoBlockVideosEnabled = config.autoBlacklist.videos.ofUsers.enabled)
const serverConfig = this.serverService.getHTMLConfig()
this.autoBlockVideosEnabled = serverConfig.autoBlacklist.videos.ofUsers.enabled
}
}
......@@ -107,13 +107,12 @@ export class VideoBlockListComponent extends RestTable implements OnInit {
}
ngOnInit () {
this.serverService.getConfig()
.subscribe(config => {
// don't filter if auto-blacklist is not enabled as this will be the only list
if (config.autoBlacklist.videos.ofUsers.enabled) {
this.blocklistTypeFilter = VideoBlacklistType.MANUAL
}
})
const serverConfig = this.serverService.getHTMLConfig()
// Don't filter if auto-blacklist is not enabled as this will be the only list
if (serverConfig.autoBlacklist.videos.ofUsers.enabled) {
this.blocklistTypeFilter = VideoBlacklistType.MANUAL
}
this.initialize()
}
......
......@@ -3,7 +3,7 @@ import { ConfigService } from '@app/+admin/config/shared/config.service'
import { AuthService, ScreenService, ServerService, User } from '@app/core'
import { FormReactive } from '@app/shared/shared-forms'
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'
@Directive()
......@@ -16,7 +16,7 @@ export abstract class UserEdit extends FormReactive implements OnInit {
roles: { value: string, label: string }[] = []
protected serverConfig: ServerConfig
protected serverConfig: HTMLServerConfig
protected abstract serverService: ServerService
protected abstract configService: ConfigService
......@@ -26,9 +26,7 @@ export abstract class UserEdit extends FormReactive implements OnInit {
abstract getFormButtonTitle (): string
ngOnInit (): void {
this.serverConfig = this.serverService.getTmpConfig()
this.serverService.getConfig()
.subscribe(config => this.serverConfig = config)
this.serverConfig = this.serverService.getHTMLConfig()
this.buildRoles()
}
......
......@@ -5,7 +5,7 @@ import { AuthService, ConfirmService, Notifier, RestPagination, RestTable, Serve
import { AdvancedInputFilter } from '@app/shared/shared-forms'
import { DropdownAction } from '@app/shared/shared-main'
import { UserBanModalComponent } from '@app/shared/shared-moderation'
import { ServerConfig, User, UserRole } from '@shared/models'
import { User, UserRole } from '@shared/models'
type UserForList = User & {
rawVideoQuota: number
......@@ -41,8 +41,9 @@ export class UserListComponent extends RestTable implements OnInit {
}
]
requiresEmailVerification = false
private _selectedColumns: string[]
private serverConfig: ServerConfig
constructor (
protected route: ActivatedRoute,
......@@ -60,10 +61,6 @@ export class UserListComponent extends RestTable implements OnInit {
return this.auth.getUser()
}
get requiresEmailVerification () {
return this.serverConfig.signup.requiresEmailVerification
}
get selectedColumns () {
return this._selectedColumns
}
......@@ -73,9 +70,8 @@ export class UserListComponent extends RestTable implements OnInit {
}
ngOnInit () {
this.serverConfig = this.serverService.getTmpConfig()
this.serverService.getConfig()
.subscribe(config => this.serverConfig = config)
.subscribe(config => this.requiresEmailVerification = config.signup.requiresEmailVerification)
this.initialize()
......
import { Routes } from '@angular/router'
import { ServerConfigResolver, UserRightGuard } from '@app/core'
import { UserRightGuard } from '@app/core'
import { UserRight } from '@shared/models'
import { UserCreateComponent, UserUpdateComponent } from './user-edit'
import { UserListComponent } from './user-list'
......@@ -35,9 +35,6 @@ export const UsersRoutes: Routes = [
meta: {
title: $localize`Create a user`
}
},
resolve: {
serverConfig: ServerConfigResolver
}
},
{
......
......@@ -60,10 +60,8 @@ export class MyAccountNotificationPreferencesComponent implements OnInit {
}
ngOnInit () {
this.serverService.getConfig()
.subscribe(config => {
this.emailEnabled = config.email.enabled
})
const serverConfig = this.serverService.getHTMLConfig()
this.emailEnabled = serverConfig.email.enabled
this.userInformationLoaded.subscribe(() => this.loadNotificationSettings())
}
......
......@@ -11,7 +11,7 @@ import {
} from '@app/shared/form-validators/video-channel-validators'
import { FormValidatorService } from '@app/shared/shared-forms'
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'
@Component({
......@@ -25,7 +25,7 @@ export class MyVideoChannelUpdateComponent extends MyVideoChannelEdit implements
private paramsSub: Subscription
private oldSupportField: string
private serverConfig: ServerConfig
private serverConfig: HTMLServerConfig
constructor (
protected formValidatorService: FormValidatorService,
......@@ -40,9 +40,7 @@ export class MyVideoChannelUpdateComponent extends MyVideoChannelEdit implements
}
ngOnInit () {
this.serverConfig = this.serverService.getTmpConfig()
this.serverService.getConfig()
.subscribe(config => this.serverConfig = config)
this.serverConfig = this.serverService.getHTMLConfig()
this.buildForm({
'display-name': VIDEO_CHANNEL_DISPLAY_NAME_VALIDATOR,
......
import { Component, OnInit } from '@angular/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'
@Component({
......@@ -11,7 +11,8 @@ export class MyLibraryComponent implements OnInit {
menuEntries: TopMenuDropdownParam[] = []
user: AuthUser
private serverConfig: ServerConfig
private serverConfig: HTMLServerConfig
constructor (
private serverService: ServerService,
......@@ -24,9 +25,7 @@ export class MyLibraryComponent implements OnInit {
}
ngOnInit (): void {
this.serverConfig = this.serverService.getTmpConfig()
this.serverService.getConfig()
.subscribe(config => this.serverConfig = config)
this.serverConfig = this.serverService.getHTMLConfig()
this.user = this.authService.getUser()
......
import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core'
import { ServerService } from '@app/core'
import { AdvancedSearch } from '@app/shared/shared-search'
import { ServerConfig, VideoConstant } from '@shared/models'
import { HTMLServerConfig, VideoConstant } from '@shared/models'
type FormOption = { id: string, label: string }
......@@ -30,7 +30,7 @@ export class SearchFiltersComponent implements OnInit {
originallyPublishedStartYear: string
originallyPublishedEndYear: string
private serverConfig: ServerConfig
private serverConfig: HTMLServerConfig
constructor (
private serverService: ServerService
......@@ -97,9 +97,8 @@ export class SearchFiltersComponent implements OnInit {
}
ngOnInit () {
this.serverConfig = this.serverService.getTmpConfig()
this.serverService.getConfig()
.subscribe(config => this.serverConfig = config)
this.serverConfig = this.serverService.getHTMLConfig()
this.serverService.getVideoCategories().subscribe(categories => this.videoCategories = categories)
this.serverService.getVideoLicences().subscribe(licences => this.videoLicences = licences)
......
......@@ -6,7 +6,7 @@ import { immutableAssign } from '@app/helpers'
import { Video, VideoChannel } from '@app/shared/shared-main'
import { AdvancedSearch, SearchService } from '@app/shared/shared-search'
import { MiniatureDisplayOptions, VideoLinkType } from '@app/shared/shared-video-miniature'
import { SearchTargetType, ServerConfig } from '@shared/models'
import { HTMLServerConfig, SearchTargetType } from '@shared/models'
@Component({
selector: 'my-search',
......@@ -37,7 +37,6 @@ export class SearchComponent implements OnInit, OnDestroy {
}
errorMessage: string
serverConfig: ServerConfig
userMiniature: User
......@@ -49,6 +48,8 @@ export class SearchComponent implements OnInit, OnDestroy {
private lastSearchTarget: SearchTargetType
private serverConfig: HTMLServerConfig
constructor (
private route: ActivatedRoute,
private router: Router,
......@@ -62,8 +63,7 @@ export class SearchComponent implements OnInit, OnDestroy {
) { }
ngOnInit () {
this.serverService.getConfig()
.subscribe(config => this.serverConfig = config)
this.serverConfig = this.serverService.getHTMLConfig()
this.subActivatedRoute = this.route.queryParams.subscribe(
async queryParams => {
......@@ -81,7 +81,7 @@ export class SearchComponent implements OnInit, OnDestroy {
this.advancedSearch = new AdvancedSearch(queryParams)
if (!this.advancedSearch.searchTarget) {
this.advancedSearch.searchTarget = await this.serverService.getDefaultSearchTarget()
this.advancedSearch.searchTarget = this.getDefaultSearchTarget()
}
// Don't hide filters if we have some of them AND the user just came on the webpage
......@@ -286,4 +286,14 @@ export class SearchComponent implements OnInit, OnDestroy {
'filter:api.search.video-channels.list.result'
)
}
private getDefaultSearchTarget(): SearchTargetType {
const searchIndexConfig = this.serverConfig.search.searchIndex
if (searchIndexConfig.enabled && (searchIndexConfig.isDefaultSearch || searchIndexConfig.disableLocalSearch)) {
return 'search-index'
}
return 'local'
}
}
......@@ -2,7 +2,6 @@ import { Component, OnInit } from '@angular/core'
import { Notifier, RedirectService, ServerService, UserService } from '@app/core'
import { USER_EMAIL_VALIDATOR } from '@app/shared/form-validators/user-validators'
import { FormReactive, FormValidatorService } from '@app/shared/shared-forms'
import { ServerConfig } from '@shared/models'
@Component({
selector: 'my-verify-account-ask-send-email',
......@@ -11,7 +10,7 @@ import { ServerConfig } from '@shared/models'
})
export class VerifyAccountAskSendEmailComponent extends FormReactive implements OnInit {
private serverConfig: ServerConfig
requiresEmailVerification = false
constructor (
protected formValidatorService: FormValidatorService,
......@@ -19,18 +18,13 @@ export class VerifyAccountAskSendEmailComponent extends FormReactive implements
private serverService: ServerService,
private notifier: Notifier,
private redirectService: RedirectService
) {
) {
super()
}
get requiresEmailVerification () {
return this.serverConfig.signup.requiresEmailVerification
}
ngOnInit () {
this.serverConfig = this.serverService.getTmpConfig()
this.serverService.getConfig()
.subscribe(config => this.serverConfig = config)
.subscribe(config => this.requiresEmailVerification = config.signup.requiresEmailVerification)
this.buildForm({
'verify-email-email': USER_EMAIL_VALIDATOR
......
......@@ -4,7 +4,7 @@ import { VIDEO_CAPTION_FILE_VALIDATOR, VIDEO_CAPTION_LANGUAGE_VALIDATOR } from '
import { FormReactive, FormValidatorService } from '@app/shared/shared-forms'
import { VideoCaptionEdit } from '@app/shared/shared-main'
import { NgbModal, NgbModalRef } from '@ng-bootstrap/ng-bootstrap'
import { ServerConfig, VideoConstant } from '@shared/models'
import { HTMLServerConfig, VideoConstant } from '@shared/models'
@Component({
selector: 'my-video-caption-add-modal',
......@@ -14,7 +14,7 @@ import { ServerConfig, VideoConstant } from '@shared/models'
export class VideoCaptionAddModalComponent extends FormReactive implements OnInit {
@Input() existingCaptions: string[]
@Input() serverConfig: ServerConfig
@Input() serverConfig: HTMLServerConfig
@Output() captionAdded = new EventEmitter<VideoCaptionEdit>()
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment