aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app/+admin
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2019-12-18 15:31:54 +0100
committerChocobozzz <me@florianbigard.com>2019-12-18 15:40:59 +0100
commitba430d7516bc5b1324b60571ba7594460969b7fb (patch)
treedf5c6952c82f49a94c0a884bbc97d4a0cbd9f867 /client/src/app/+admin
parent5dfb7c1dec8222b0bbccac5b56ad46da1438747e (diff)
downloadPeerTube-ba430d7516bc5b1324b60571ba7594460969b7fb.tar.gz
PeerTube-ba430d7516bc5b1324b60571ba7594460969b7fb.tar.zst
PeerTube-ba430d7516bc5b1324b60571ba7594460969b7fb.zip
Lazy load static objects
Diffstat (limited to 'client/src/app/+admin')
-rw-r--r--client/src/app/+admin/config/edit-custom-config/edit-custom-config.component.ts23
-rw-r--r--client/src/app/+admin/moderation/moderation.component.ts14
-rw-r--r--client/src/app/+admin/moderation/video-blacklist-list/video-blacklist-list.component.ts19
-rw-r--r--client/src/app/+admin/users/user-edit/user-create.component.ts2
-rw-r--r--client/src/app/+admin/users/user-edit/user-edit.ts17
-rw-r--r--client/src/app/+admin/users/user-edit/user-update.component.ts2
-rw-r--r--client/src/app/+admin/users/user-list/user-list.component.ts10
7 files changed, 59 insertions, 28 deletions
diff --git a/client/src/app/+admin/config/edit-custom-config/edit-custom-config.component.ts b/client/src/app/+admin/config/edit-custom-config/edit-custom-config.component.ts
index 1f6751297..25e06d8a1 100644
--- a/client/src/app/+admin/config/edit-custom-config/edit-custom-config.component.ts
+++ b/client/src/app/+admin/config/edit-custom-config/edit-custom-config.component.ts
@@ -8,7 +8,7 @@ import { I18n } from '@ngx-translate/i18n-polyfill'
8import { FormValidatorService } from '@app/shared/forms/form-validators/form-validator.service' 8import { FormValidatorService } from '@app/shared/forms/form-validators/form-validator.service'
9import { SelectItem } from 'primeng/api' 9import { SelectItem } from 'primeng/api'
10import { forkJoin } from 'rxjs' 10import { forkJoin } from 'rxjs'
11import { first } from 'rxjs/operators' 11import { ServerConfig } from '@shared/models'
12 12
13@Component({ 13@Component({
14 selector: 'my-edit-custom-config', 14 selector: 'my-edit-custom-config',
@@ -24,6 +24,8 @@ export class EditCustomConfigComponent extends FormReactive implements OnInit {
24 languageItems: SelectItem[] = [] 24 languageItems: SelectItem[] = []
25 categoryItems: SelectItem[] = [] 25 categoryItems: SelectItem[] = []
26 26
27 private serverConfig: ServerConfig
28
27 constructor ( 29 constructor (
28 protected formValidatorService: FormValidatorService, 30 protected formValidatorService: FormValidatorService,
29 private customConfigValidatorsService: CustomConfigValidatorsService, 31 private customConfigValidatorsService: CustomConfigValidatorsService,
@@ -84,7 +86,7 @@ export class EditCustomConfigComponent extends FormReactive implements OnInit {
84 } 86 }
85 87
86 get availableThemes () { 88 get availableThemes () {
87 return this.serverService.getConfig().theme.registered 89 return this.serverConfig.theme.registered
88 .map(t => t.name) 90 .map(t => t.name)
89 } 91 }
90 92
@@ -93,6 +95,10 @@ export class EditCustomConfigComponent extends FormReactive implements OnInit {
93 } 95 }
94 96
95 ngOnInit () { 97 ngOnInit () {
98 this.serverConfig = this.serverService.getTmpConfig()
99 this.serverService.getConfig()
100 .subscribe(config => this.serverConfig = config)
101
96 const formGroupData: { [key in keyof CustomConfig ]: any } = { 102 const formGroupData: { [key in keyof CustomConfig ]: any } = {
97 instance: { 103 instance: {
98 name: this.customConfigValidatorsService.INSTANCE_NAME, 104 name: this.customConfigValidatorsService.INSTANCE_NAME,
@@ -218,16 +224,13 @@ export class EditCustomConfigComponent extends FormReactive implements OnInit {
218 224
219 forkJoin([ 225 forkJoin([
220 this.configService.getCustomConfig(), 226 this.configService.getCustomConfig(),
221 this.serverService.videoLanguagesLoaded.pipe(first()), // First so the observable completes 227 this.serverService.getVideoLanguages(),
222 this.serverService.videoCategoriesLoaded.pipe(first()) 228 this.serverService.getVideoCategories()
223 ]).subscribe( 229 ]).subscribe(
224 ([ config ]) => { 230 ([ config, languages, categories ]) => {
225 this.customConfig = config 231 this.customConfig = config
226 232
227 const languages = this.serverService.getVideoLanguages()
228 this.languageItems = languages.map(l => ({ label: l.label, value: l.id })) 233 this.languageItems = languages.map(l => ({ label: l.label, value: l.id }))
229
230 const categories = this.serverService.getVideoCategories()
231 this.categoryItems = categories.map(l => ({ label: l.label, value: l.id })) 234 this.categoryItems = categories.map(l => ({ label: l.label, value: l.id }))
232 235
233 this.updateForm() 236 this.updateForm()
@@ -249,12 +252,14 @@ export class EditCustomConfigComponent extends FormReactive implements OnInit {
249 252
250 async formValidated () { 253 async formValidated () {
251 this.configService.updateCustomConfig(this.form.value) 254 this.configService.updateCustomConfig(this.form.value)
255 .pipe(
256 )
252 .subscribe( 257 .subscribe(
253 res => { 258 res => {
254 this.customConfig = res 259 this.customConfig = res
255 260
256 // Reload general configuration 261 // Reload general configuration
257 this.serverService.loadConfig() 262 this.serverService.resetConfig()
258 263
259 this.updateForm() 264 this.updateForm()
260 265
diff --git a/client/src/app/+admin/moderation/moderation.component.ts b/client/src/app/+admin/moderation/moderation.component.ts
index 47154af3f..7744deb06 100644
--- a/client/src/app/+admin/moderation/moderation.component.ts
+++ b/client/src/app/+admin/moderation/moderation.component.ts
@@ -1,4 +1,4 @@
1import { Component } from '@angular/core' 1import { Component, OnInit } from '@angular/core'
2import { UserRight } from '../../../../../shared' 2import { UserRight } from '../../../../../shared'
3import { AuthService, ServerService } from '@app/core' 3import { AuthService, ServerService } from '@app/core'
4 4
@@ -6,14 +6,18 @@ import { AuthService, ServerService } from '@app/core'
6 templateUrl: './moderation.component.html', 6 templateUrl: './moderation.component.html',
7 styleUrls: [ './moderation.component.scss' ] 7 styleUrls: [ './moderation.component.scss' ]
8}) 8})
9export class ModerationComponent { 9export class ModerationComponent implements OnInit {
10 autoBlacklistVideosEnabled: boolean 10 autoBlacklistVideosEnabled = false
11 11
12 constructor ( 12 constructor (
13 private auth: AuthService, 13 private auth: AuthService,
14 private serverService: ServerService 14 private serverService: ServerService
15 ) { 15 ) { }
16 this.autoBlacklistVideosEnabled = this.serverService.getConfig().autoBlacklist.videos.ofUsers.enabled 16
17 ngOnInit (): void {
18 this.serverService.getConfig()
19 .subscribe(config => this.autoBlacklistVideosEnabled = config.autoBlacklist.videos.ofUsers.enabled)
20
17 } 21 }
18 22
19 hasVideoAbusesRight () { 23 hasVideoAbusesRight () {
diff --git a/client/src/app/+admin/moderation/video-blacklist-list/video-blacklist-list.component.ts b/client/src/app/+admin/moderation/video-blacklist-list/video-blacklist-list.component.ts
index f4bce7c48..5876f658b 100644
--- a/client/src/app/+admin/moderation/video-blacklist-list/video-blacklist-list.component.ts
+++ b/client/src/app/+admin/moderation/video-blacklist-list/video-blacklist-list.component.ts
@@ -33,11 +33,18 @@ export class VideoBlacklistListComponent extends RestTable implements OnInit {
33 private i18n: I18n 33 private i18n: I18n
34 ) { 34 ) {
35 super() 35 super()
36 }
36 37
37 // don't filter if auto-blacklist not enabled as this will be only list 38 ngOnInit () {
38 if (this.serverService.getConfig().autoBlacklist.videos.ofUsers.enabled) { 39 this.serverService.getConfig()
39 this.listBlacklistTypeFilter = VideoBlacklistType.MANUAL 40 .subscribe(config => {
40 } 41 // don't filter if auto-blacklist not enabled as this will be only list
42 if (config.autoBlacklist.videos.ofUsers.enabled) {
43 this.listBlacklistTypeFilter = VideoBlacklistType.MANUAL
44 }
45 })
46
47 this.initialize()
41 48
42 this.videoBlacklistActions = [ 49 this.videoBlacklistActions = [
43 { 50 {
@@ -47,10 +54,6 @@ export class VideoBlacklistListComponent extends RestTable implements OnInit {
47 ] 54 ]
48 } 55 }
49 56
50 ngOnInit () {
51 this.initialize()
52 }
53
54 getVideoUrl (videoBlacklist: VideoBlacklist) { 57 getVideoUrl (videoBlacklist: VideoBlacklist) {
55 return Video.buildClientUrl(videoBlacklist.video.uuid) 58 return Video.buildClientUrl(videoBlacklist.video.uuid)
56 } 59 }
diff --git a/client/src/app/+admin/users/user-edit/user-create.component.ts b/client/src/app/+admin/users/user-edit/user-create.component.ts
index 3b57a49c6..e726ec4d7 100644
--- a/client/src/app/+admin/users/user-edit/user-create.component.ts
+++ b/client/src/app/+admin/users/user-edit/user-create.component.ts
@@ -34,6 +34,8 @@ export class UserCreateComponent extends UserEdit implements OnInit {
34 } 34 }
35 35
36 ngOnInit () { 36 ngOnInit () {
37 super.ngOnInit()
38
37 const defaultValues = { 39 const defaultValues = {
38 role: UserRole.USER.toString(), 40 role: UserRole.USER.toString(),
39 videoQuota: '-1', 41 videoQuota: '-1',
diff --git a/client/src/app/+admin/users/user-edit/user-edit.ts b/client/src/app/+admin/users/user-edit/user-edit.ts
index 6625d65d6..02f1dcd42 100644
--- a/client/src/app/+admin/users/user-edit/user-edit.ts
+++ b/client/src/app/+admin/users/user-edit/user-edit.ts
@@ -1,21 +1,30 @@
1import { AuthService, ServerService } from '../../../core' 1import { AuthService, ServerService } from '../../../core'
2import { FormReactive } from '../../../shared' 2import { FormReactive } from '../../../shared'
3import { USER_ROLE_LABELS, UserRole, VideoResolution } from '../../../../../../shared' 3import { ServerConfig, USER_ROLE_LABELS, UserRole, VideoResolution } from '../../../../../../shared'
4import { ConfigService } from '@app/+admin/config/shared/config.service' 4import { ConfigService } from '@app/+admin/config/shared/config.service'
5import { UserAdminFlag } from '@shared/models/users/user-flag.model' 5import { UserAdminFlag } from '@shared/models/users/user-flag.model'
6import { OnInit } from '@angular/core'
6 7
7export abstract class UserEdit extends FormReactive { 8export abstract class UserEdit extends FormReactive implements OnInit {
8 videoQuotaOptions: { value: string, label: string }[] = [] 9 videoQuotaOptions: { value: string, label: string }[] = []
9 videoQuotaDailyOptions: { value: string, label: string }[] = [] 10 videoQuotaDailyOptions: { value: string, label: string }[] = []
10 username: string 11 username: string
11 userId: number 12 userId: number
12 13
14 protected serverConfig: ServerConfig
15
13 protected abstract serverService: ServerService 16 protected abstract serverService: ServerService
14 protected abstract configService: ConfigService 17 protected abstract configService: ConfigService
15 protected abstract auth: AuthService 18 protected abstract auth: AuthService
16 abstract isCreation (): boolean 19 abstract isCreation (): boolean
17 abstract getFormButtonTitle (): string 20 abstract getFormButtonTitle (): string
18 21
22 ngOnInit (): void {
23 this.serverConfig = this.serverService.getTmpConfig()
24 this.serverService.getConfig()
25 .subscribe(config => this.serverConfig = config)
26 }
27
19 getRoles () { 28 getRoles () {
20 const authUser = this.auth.getUser() 29 const authUser = this.auth.getUser()
21 30
@@ -32,12 +41,12 @@ export abstract class UserEdit extends FormReactive {
32 isTranscodingInformationDisplayed () { 41 isTranscodingInformationDisplayed () {
33 const formVideoQuota = parseInt(this.form.value['videoQuota'], 10) 42 const formVideoQuota = parseInt(this.form.value['videoQuota'], 10)
34 43
35 return this.serverService.getConfig().transcoding.enabledResolutions.length !== 0 && 44 return this.serverConfig.transcoding.enabledResolutions.length !== 0 &&
36 formVideoQuota > 0 45 formVideoQuota > 0
37 } 46 }
38 47
39 computeQuotaWithTranscoding () { 48 computeQuotaWithTranscoding () {
40 const transcodingConfig = this.serverService.getConfig().transcoding 49 const transcodingConfig = this.serverConfig.transcoding
41 50
42 const resolutions = transcodingConfig.enabledResolutions 51 const resolutions = transcodingConfig.enabledResolutions
43 const higherResolution = VideoResolution.H_4K 52 const higherResolution = VideoResolution.H_4K
diff --git a/client/src/app/+admin/users/user-edit/user-update.component.ts b/client/src/app/+admin/users/user-edit/user-update.component.ts
index c7052a925..d1682a99d 100644
--- a/client/src/app/+admin/users/user-edit/user-update.component.ts
+++ b/client/src/app/+admin/users/user-edit/user-update.component.ts
@@ -43,6 +43,8 @@ export class UserUpdateComponent extends UserEdit implements OnInit, OnDestroy {
43 } 43 }
44 44
45 ngOnInit () { 45 ngOnInit () {
46 super.ngOnInit()
47
46 const defaultValues = { videoQuota: '-1', videoQuotaDaily: '-1' } 48 const defaultValues = { videoQuota: '-1', videoQuotaDaily: '-1' }
47 this.buildForm({ 49 this.buildForm({
48 email: this.userValidatorsService.USER_EMAIL, 50 email: this.userValidatorsService.USER_EMAIL,
diff --git a/client/src/app/+admin/users/user-list/user-list.component.ts b/client/src/app/+admin/users/user-list/user-list.component.ts
index ab82713b2..1083ba291 100644
--- a/client/src/app/+admin/users/user-list/user-list.component.ts
+++ b/client/src/app/+admin/users/user-list/user-list.component.ts
@@ -4,7 +4,7 @@ import { SortMeta } from 'primeng/components/common/sortmeta'
4import { ConfirmService, ServerService } from '../../../core' 4import { ConfirmService, ServerService } from '../../../core'
5import { RestPagination, RestTable, UserService } from '../../../shared' 5import { RestPagination, RestTable, UserService } from '../../../shared'
6import { I18n } from '@ngx-translate/i18n-polyfill' 6import { I18n } from '@ngx-translate/i18n-polyfill'
7import { User } from '../../../../../../shared' 7import { ServerConfig, User } from '../../../../../../shared'
8import { UserBanModalComponent } from '@app/shared/moderation' 8import { UserBanModalComponent } from '@app/shared/moderation'
9import { DropdownAction } from '@app/shared/buttons/action-dropdown.component' 9import { DropdownAction } from '@app/shared/buttons/action-dropdown.component'
10 10
@@ -25,6 +25,8 @@ export class UserListComponent extends RestTable implements OnInit {
25 selectedUsers: User[] = [] 25 selectedUsers: User[] = []
26 bulkUserActions: DropdownAction<User[]>[] = [] 26 bulkUserActions: DropdownAction<User[]>[] = []
27 27
28 private serverConfig: ServerConfig
29
28 constructor ( 30 constructor (
29 private notifier: Notifier, 31 private notifier: Notifier,
30 private confirmService: ConfirmService, 32 private confirmService: ConfirmService,
@@ -41,10 +43,14 @@ export class UserListComponent extends RestTable implements OnInit {
41 } 43 }
42 44
43 get requiresEmailVerification () { 45 get requiresEmailVerification () {
44 return this.serverService.getConfig().signup.requiresEmailVerification 46 return this.serverConfig.signup.requiresEmailVerification
45 } 47 }
46 48
47 ngOnInit () { 49 ngOnInit () {
50 this.serverConfig = this.serverService.getTmpConfig()
51 this.serverService.getConfig()
52 .subscribe(config => this.serverConfig = config)
53
48 this.initialize() 54 this.initialize()
49 55
50 this.bulkUserActions = [ 56 this.bulkUserActions = [