aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app/+admin/config/edit-custom-config/edit-basic-configuration.component.ts
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2021-02-10 11:06:32 +0100
committerChocobozzz <me@florianbigard.com>2021-02-10 11:36:40 +0100
commit5f46d28ccac4a20fcbb12c96a047a84a08e485ae (patch)
tree6529920195176736d187b93bcac8f3ad6920853d /client/src/app/+admin/config/edit-custom-config/edit-basic-configuration.component.ts
parent53e4e201797aa1b581209ffd775bf05197efa78f (diff)
downloadPeerTube-5f46d28ccac4a20fcbb12c96a047a84a08e485ae.tar.gz
PeerTube-5f46d28ccac4a20fcbb12c96a047a84a08e485ae.tar.zst
PeerTube-5f46d28ccac4a20fcbb12c96a047a84a08e485ae.zip
Split admin conf page
Diffstat (limited to 'client/src/app/+admin/config/edit-custom-config/edit-basic-configuration.component.ts')
-rw-r--r--client/src/app/+admin/config/edit-custom-config/edit-basic-configuration.component.ts83
1 files changed, 83 insertions, 0 deletions
diff --git a/client/src/app/+admin/config/edit-custom-config/edit-basic-configuration.component.ts b/client/src/app/+admin/config/edit-custom-config/edit-basic-configuration.component.ts
new file mode 100644
index 000000000..9a19c2913
--- /dev/null
+++ b/client/src/app/+admin/config/edit-custom-config/edit-basic-configuration.component.ts
@@ -0,0 +1,83 @@
1
2import { pairwise } from 'rxjs/operators'
3import { Component, Input, OnInit } from '@angular/core'
4import { FormGroup } from '@angular/forms'
5import { ServerConfig } from '@shared/models'
6import { ConfigService } from '../shared/config.service'
7
8@Component({
9 selector: 'my-edit-basic-configuration',
10 templateUrl: './edit-basic-configuration.component.html',
11 styleUrls: [ './edit-custom-config.component.scss' ]
12})
13export class EditBasicConfigurationComponent implements OnInit {
14 @Input() form: FormGroup
15 @Input() formErrors: any
16
17 @Input() serverConfig: ServerConfig
18
19 signupAlertMessage: string
20
21 constructor (
22 private configService: ConfigService
23 ) { }
24
25 ngOnInit () {
26 this.checkSignupField()
27 }
28
29 getVideoQuotaOptions () {
30 return this.configService.videoQuotaOptions
31 }
32
33 getVideoQuotaDailyOptions () {
34 return this.configService.videoQuotaDailyOptions
35 }
36
37 getAvailableThemes () {
38 return this.serverConfig.theme.registered
39 .map(t => t.name)
40 }
41
42 doesTrendingVideosAlgorithmsEnabledInclude (algorithm: string) {
43 const enabled = this.form.value['trending']['videos']['algorithms']['enabled']
44 if (!Array.isArray(enabled)) return false
45
46 return !!enabled.find((e: string) => e === algorithm)
47 }
48
49 isSignupEnabled () {
50 return this.form.value['signup']['enabled'] === true
51 }
52
53 isSearchIndexEnabled () {
54 return this.form.value['search']['searchIndex']['enabled'] === true
55 }
56
57 isAutoFollowIndexEnabled () {
58 return this.form.value['followings']['instance']['autoFollowIndex']['enabled'] === true
59 }
60
61 private checkSignupField () {
62 const signupControl = this.form.get('signup.enabled')
63
64 signupControl.valueChanges
65 .pipe(pairwise())
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.`
70
71 this.form.patchValue({
72 autoBlacklist: {
73 videos: {
74 ofUsers: {
75 enabled: true
76 }
77 }
78 }
79 })
80 }
81 })
82 }
83}