2 import { pairwise } from 'rxjs/operators'
3 import { Component, Input, OnInit } from '@angular/core'
4 import { FormGroup } from '@angular/forms'
5 import { ServerConfig } from '@shared/models'
6 import { ConfigService } from '../shared/config.service'
9 selector: 'my-edit-basic-configuration',
10 templateUrl: './edit-basic-configuration.component.html',
11 styleUrls: [ './edit-custom-config.component.scss' ]
13 export class EditBasicConfigurationComponent implements OnInit {
14 @Input() form: FormGroup
15 @Input() formErrors: any
17 @Input() serverConfig: ServerConfig
19 signupAlertMessage: string
22 private configService: ConfigService
26 this.checkSignupField()
29 getVideoQuotaOptions () {
30 return this.configService.videoQuotaOptions
33 getVideoQuotaDailyOptions () {
34 return this.configService.videoQuotaDailyOptions
37 getAvailableThemes () {
38 return this.serverConfig.theme.registered
42 doesTrendingVideosAlgorithmsEnabledInclude (algorithm: string) {
43 const enabled = this.form.value['trending']['videos']['algorithms']['enabled']
44 if (!Array.isArray(enabled)) return false
46 return !!enabled.find((e: string) => e === algorithm)
50 return this.form.value['signup']['enabled'] === true
53 isSearchIndexEnabled () {
54 return this.form.value['search']['searchIndex']['enabled'] === true
57 isAutoFollowIndexEnabled () {
58 return this.form.value['followings']['instance']['autoFollowIndex']['enabled'] === true
61 private checkSignupField () {
62 const signupControl = this.form.get('signup.enabled')
64 signupControl.valueChanges
66 .subscribe(([ oldValue, newValue ]) => {
67 if (oldValue !== true && newValue === true) {
68 // tslint:disable:max-line-length
69 this.signupAlertMessage = $localize`You enabled signup: we automatically enabled the "Block new videos automatically" checkbox of the "Videos" section just below.`
71 this.form.patchValue({