From 754b6f5f41bdc40aaaeefdb3c351666c305abe20 Mon Sep 17 00:00:00 2001 From: Florian CUNY Date: Tue, 26 Oct 2021 16:42:10 +0200 Subject: Made the video channels limit (per user) server-wide configurable (#4491) * Made the video channels limit (per user) server-wide configurable Implements https://github.com/Chocobozzz/PeerTube/issues/3092 Also added a "quota bar" in the account's settings page * Fixed lint errors * Another pass at fixing lint errors * Applied code suggestions * Removed 'video channels quota' --- .../edit-basic-configuration.component.html | 22 ++++++++++++++++++++++ .../edit-custom-config.component.ts | 6 +++++- .../form-validators/custom-config-validators.ts | 9 +++++++++ .../app/shared/shared-main/shared-main.module.ts | 7 ++++++- 4 files changed, 42 insertions(+), 2 deletions(-) (limited to 'client/src') diff --git a/client/src/app/+admin/config/edit-custom-config/edit-basic-configuration.component.html b/client/src/app/+admin/config/edit-custom-config/edit-basic-configuration.component.html index 537e06d4d..318c8e2c2 100644 --- a/client/src/app/+admin/config/edit-custom-config/edit-basic-configuration.component.html +++ b/client/src/app/+admin/config/edit-custom-config/edit-basic-configuration.component.html @@ -272,6 +272,28 @@ +
+
+
VIDEO CHANNELS
+
+ +
+
+ + +
+ + {form.value['videoChannels']['maxPerUser'], plural, =1 {channel} other {channels}} +
+ +
{{ formErrors.videoChannels.maxPerUser }}
+
+
+
+
SEARCH
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 96c67fac7..fdb0a7532 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 @@ -22,7 +22,8 @@ import { SERVICES_TWITTER_USERNAME_VALIDATOR, SIGNUP_LIMIT_VALIDATOR, SIGNUP_MINIMUM_AGE_VALIDATOR, - TRANSCODING_THREADS_VALIDATOR + TRANSCODING_THREADS_VALIDATOR, + MAX_VIDEO_CHANNELS_PER_USER_VALIDATOR } from '@app/shared/form-validators/custom-config-validators' 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' @@ -151,6 +152,9 @@ export class EditCustomConfigComponent extends FormReactive implements OnInit { videoQuota: USER_VIDEO_QUOTA_VALIDATOR, videoQuotaDaily: USER_VIDEO_QUOTA_DAILY_VALIDATOR }, + videoChannels: { + maxPerUser: MAX_VIDEO_CHANNELS_PER_USER_VALIDATOR + }, transcoding: { enabled: null, threads: TRANSCODING_THREADS_VALIDATOR, diff --git a/client/src/app/shared/form-validators/custom-config-validators.ts b/client/src/app/shared/form-validators/custom-config-validators.ts index fbf423d08..ba8512e95 100644 --- a/client/src/app/shared/form-validators/custom-config-validators.ts +++ b/client/src/app/shared/form-validators/custom-config-validators.ts @@ -98,6 +98,15 @@ export const MAX_USER_LIVES_VALIDATOR: BuildFormValidator = { } } +export const MAX_VIDEO_CHANNELS_PER_USER_VALIDATOR: BuildFormValidator = { + VALIDATORS: [ Validators.required, Validators.min(1), Validators.pattern('[0-9]+') ], + MESSAGES: { + required: $localize`Max video channels per user is required.`, + min: $localize`Max video channels per user must be greater or equal to 1.`, + pattern: $localize`Max video channels per user must be a number.` + } +} + export const CONCURRENCY_VALIDATOR: BuildFormValidator = { VALIDATORS: [ Validators.required, Validators.min(1) ], MESSAGES: { diff --git a/client/src/app/shared/shared-main/shared-main.module.ts b/client/src/app/shared/shared-main/shared-main.module.ts index 80d0a84f3..93989780d 100644 --- a/client/src/app/shared/shared-main/shared-main.module.ts +++ b/client/src/app/shared/shared-main/shared-main.module.ts @@ -43,7 +43,12 @@ import { } from './misc' import { PluginPlaceholderComponent } from './plugins' import { ActorRedirectGuard } from './router' -import { UserHistoryService, UserNotificationsComponent, UserNotificationService, UserQuotaComponent } from './users' +import { + UserHistoryService, + UserNotificationsComponent, + UserNotificationService, + UserQuotaComponent +} from './users' import { RedundancyService, VideoImportService, VideoOwnershipService, VideoService } from './video' import { VideoCaptionService } from './video-caption' import { VideoChannelService } from './video-channel' -- cgit v1.2.3