-
import { pairwise } from 'rxjs/operators'
-import { Component, Input, OnInit } from '@angular/core'
+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 { ConfigService } from '../shared/config.service'
templateUrl: './edit-basic-configuration.component.html',
styleUrls: [ './edit-custom-config.component.scss' ]
})
-export class EditBasicConfigurationComponent implements OnInit {
+export class EditBasicConfigurationComponent implements OnInit, OnChanges {
@Input() form: FormGroup
@Input() formErrors: any
@Input() serverConfig: ServerConfig
signupAlertMessage: string
+ defaultLandingPageOptions: SelectOptionsItem[] = []
constructor (
- private configService: ConfigService
+ private configService: ConfigService,
+ private menuService: MenuService
) { }
ngOnInit () {
+ this.buildLandingPageOptions()
this.checkSignupField()
}
+ ngOnChanges (changes: SimpleChanges) {
+ if (changes['serverConfig']) {
+ this.buildLandingPageOptions()
+ }
+ }
+
getVideoQuotaOptions () {
return this.configService.videoQuotaOptions
}
return this.form.value['signup']['enabled'] === true
}
+ getDisabledSignupClass () {
+ return { 'disabled-checkbox-extra': !this.isSignupEnabled() }
+ }
+
+ hasUnlimitedSignup () {
+ return this.form.value['signup']['limit'] === -1
+ }
+
isSearchIndexEnabled () {
return this.form.value['search']['searchIndex']['enabled'] === true
}
+ getDisabledSearchIndexClass () {
+ return { 'disabled-checkbox-extra': !this.isSearchIndexEnabled() }
+ }
+
isAutoFollowIndexEnabled () {
return this.form.value['followings']['instance']['autoFollowIndex']['enabled'] === true
}
+ buildLandingPageOptions () {
+ this.defaultLandingPageOptions = this.menuService.buildCommonLinks(this.serverConfig)
+ .map(o => ({
+ id: o.path,
+ label: o.label,
+ description: o.path
+ }))
+ }
+
private checkSignupField () {
const signupControl = this.form.get('signup.enabled')