From a056ca4813c82f490dcd31ac97a64d6bf76d3dcc Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Wed, 28 Oct 2020 15:24:40 +0100 Subject: Add max lives limit --- .../edit-custom-config/edit-custom-config.component.html | 10 ++++++++++ .../edit-custom-config/edit-custom-config.component.ts | 2 ++ .../video-add-components/video-go-live.component.ts | 13 +++++++++++-- client/src/app/core/server/server.service.ts | 2 ++ .../shared-instance/instance-features-table.component.html | 7 +++++++ .../shared-instance/instance-features-table.component.ts | 14 ++++++++++++++ 6 files changed, 46 insertions(+), 2 deletions(-) (limited to 'client') diff --git a/client/src/app/+admin/config/edit-custom-config/edit-custom-config.component.html b/client/src/app/+admin/config/edit-custom-config/edit-custom-config.component.html index 2f3202e06..686f3601b 100644 --- a/client/src/app/+admin/config/edit-custom-config/edit-custom-config.component.html +++ b/client/src/app/+admin/config/edit-custom-config/edit-custom-config.component.html @@ -739,6 +739,16 @@ +
+ + +
+ +
+ + +
+
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 745238647..de1cf46b1 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 @@ -216,6 +216,8 @@ export class EditCustomConfigComponent extends FormReactive implements OnInit, A enabled: null, maxDuration: null, + maxInstanceLives: null, + maxUserLives: null, allowReplay: null, transcoding: { diff --git a/client/src/app/+videos/+video-edit/video-add-components/video-go-live.component.ts b/client/src/app/+videos/+video-edit/video-add-components/video-go-live.component.ts index 9868c37d2..870a70d3d 100644 --- a/client/src/app/+videos/+video-edit/video-add-components/video-go-live.component.ts +++ b/client/src/app/+videos/+video-edit/video-add-components/video-go-live.component.ts @@ -7,7 +7,7 @@ import { scrollToTop } from '@app/helpers' import { FormValidatorService } from '@app/shared/shared-forms' import { LiveVideoService, VideoCaptionService, VideoEdit, VideoService } from '@app/shared/shared-main' import { LoadingBarService } from '@ngx-loading-bar/core' -import { LiveVideo, LiveVideoCreate, LiveVideoUpdate, VideoPrivacy } from '@shared/models' +import { LiveVideo, LiveVideoCreate, LiveVideoUpdate, ServerErrorCode, VideoPrivacy } from '@shared/models' import { VideoSend } from './video-send' @Component({ @@ -81,7 +81,16 @@ export class VideoGoLiveComponent extends VideoSend implements OnInit, CanCompon err => { this.firstStepError.emit() - this.notifier.error(err.message) + + let message = err.message + + if (err.body?.code === ServerErrorCode.MAX_INSTANCE_LIVES_LIMIT_REACHED) { + message = $localize`Cannot create live because this instance have too many created lives` + } else if (err.body?.code) { + message = $localize`Cannot create live because you created too many lives` + } + + this.notifier.error(message) } ) } diff --git a/client/src/app/core/server/server.service.ts b/client/src/app/core/server/server.service.ts index c19c3c12e..1abf87118 100644 --- a/client/src/app/core/server/server.service.ts +++ b/client/src/app/core/server/server.service.ts @@ -78,6 +78,8 @@ export class ServerService { enabled: false, allowReplay: true, maxDuration: null, + maxInstanceLives: -1, + maxUserLives: -1, transcoding: { enabled: false, enabledResolutions: [] diff --git a/client/src/app/shared/shared-instance/instance-features-table.component.html b/client/src/app/shared/shared-instance/instance-features-table.component.html index 002695238..ce2557147 100644 --- a/client/src/app/shared/shared-instance/instance-features-table.component.html +++ b/client/src/app/shared/shared-instance/instance-features-table.component.html @@ -81,6 +81,13 @@ + + Max parallel lives + + {{ maxUserLives }} per user / {{ maxInstanceLives }} per instance + + + Import diff --git a/client/src/app/shared/shared-instance/instance-features-table.component.ts b/client/src/app/shared/shared-instance/instance-features-table.component.ts index 76b595c20..0166157f9 100644 --- a/client/src/app/shared/shared-instance/instance-features-table.component.ts +++ b/client/src/app/shared/shared-instance/instance-features-table.component.ts @@ -21,6 +21,20 @@ export class InstanceFeaturesTableComponent implements OnInit { return Math.min(this.initialUserVideoQuota, this.serverConfig.user.videoQuotaDaily) } + get maxInstanceLives () { + const value = this.serverConfig.live.maxInstanceLives + if (value === -1) return $localize`Unlimited` + + return value + } + + get maxUserLives () { + const value = this.serverConfig.live.maxUserLives + if (value === -1) return $localize`Unlimited` + + return value + } + ngOnInit () { this.serverConfig = this.serverService.getTmpConfig() this.serverService.getConfig() -- cgit v1.2.3