diff options
author | Chocobozzz <me@florianbigard.com> | 2020-10-28 15:24:40 +0100 |
---|---|---|
committer | Chocobozzz <chocobozzz@cpy.re> | 2020-11-09 15:33:04 +0100 |
commit | a056ca4813c82f490dcd31ac97a64d6bf76d3dcc (patch) | |
tree | 11a0638cb92eee94f404e294f54632212836a4a6 /client/src | |
parent | d846d99c6c81028bb7bd3cb20abd433cbf396a22 (diff) | |
download | PeerTube-a056ca4813c82f490dcd31ac97a64d6bf76d3dcc.tar.gz PeerTube-a056ca4813c82f490dcd31ac97a64d6bf76d3dcc.tar.zst PeerTube-a056ca4813c82f490dcd31ac97a64d6bf76d3dcc.zip |
Add max lives limit
Diffstat (limited to 'client/src')
6 files changed, 46 insertions, 2 deletions
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 | |||
@@ -740,6 +740,16 @@ | |||
740 | </div> | 740 | </div> |
741 | 741 | ||
742 | <div class="form-group" [ngClass]="{ 'disabled-checkbox-extra': !isLiveEnabled() }"> | 742 | <div class="form-group" [ngClass]="{ 'disabled-checkbox-extra': !isLiveEnabled() }"> |
743 | <label i18n for="liveMaxInstanceLives">Max lives created on your instance (-1 for "unlimited")</label> | ||
744 | <input type="number" name="liveMaxInstanceLives" formControlName="maxInstanceLives" /> | ||
745 | </div> | ||
746 | |||
747 | <div class="form-group" [ngClass]="{ 'disabled-checkbox-extra': !isLiveEnabled() }"> | ||
748 | <label i18n for="liveMaxUserLives">Max lives created per user (-1 for "unlimited")</label> | ||
749 | <input type="number" name="liveMaxUserLives" formControlName="maxUserLives" /> | ||
750 | </div> | ||
751 | |||
752 | <div class="form-group" [ngClass]="{ 'disabled-checkbox-extra': !isLiveEnabled() }"> | ||
743 | <label i18n for="liveMaxDuration">Max live duration</label> | 753 | <label i18n for="liveMaxDuration">Max live duration</label> |
744 | <div class="peertube-select-container"> | 754 | <div class="peertube-select-container"> |
745 | <select id="liveMaxDuration" formControlName="maxDuration" class="form-control"> | 755 | <select id="liveMaxDuration" formControlName="maxDuration" class="form-control"> |
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 | |||
216 | enabled: null, | 216 | enabled: null, |
217 | 217 | ||
218 | maxDuration: null, | 218 | maxDuration: null, |
219 | maxInstanceLives: null, | ||
220 | maxUserLives: null, | ||
219 | allowReplay: null, | 221 | allowReplay: null, |
220 | 222 | ||
221 | transcoding: { | 223 | 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' | |||
7 | import { FormValidatorService } from '@app/shared/shared-forms' | 7 | import { FormValidatorService } from '@app/shared/shared-forms' |
8 | import { LiveVideoService, VideoCaptionService, VideoEdit, VideoService } from '@app/shared/shared-main' | 8 | import { LiveVideoService, VideoCaptionService, VideoEdit, VideoService } from '@app/shared/shared-main' |
9 | import { LoadingBarService } from '@ngx-loading-bar/core' | 9 | import { LoadingBarService } from '@ngx-loading-bar/core' |
10 | import { LiveVideo, LiveVideoCreate, LiveVideoUpdate, VideoPrivacy } from '@shared/models' | 10 | import { LiveVideo, LiveVideoCreate, LiveVideoUpdate, ServerErrorCode, VideoPrivacy } from '@shared/models' |
11 | import { VideoSend } from './video-send' | 11 | import { VideoSend } from './video-send' |
12 | 12 | ||
13 | @Component({ | 13 | @Component({ |
@@ -81,7 +81,16 @@ export class VideoGoLiveComponent extends VideoSend implements OnInit, CanCompon | |||
81 | 81 | ||
82 | err => { | 82 | err => { |
83 | this.firstStepError.emit() | 83 | this.firstStepError.emit() |
84 | this.notifier.error(err.message) | 84 | |
85 | let message = err.message | ||
86 | |||
87 | if (err.body?.code === ServerErrorCode.MAX_INSTANCE_LIVES_LIMIT_REACHED) { | ||
88 | message = $localize`Cannot create live because this instance have too many created lives` | ||
89 | } else if (err.body?.code) { | ||
90 | message = $localize`Cannot create live because you created too many lives` | ||
91 | } | ||
92 | |||
93 | this.notifier.error(message) | ||
85 | } | 94 | } |
86 | ) | 95 | ) |
87 | } | 96 | } |
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 { | |||
78 | enabled: false, | 78 | enabled: false, |
79 | allowReplay: true, | 79 | allowReplay: true, |
80 | maxDuration: null, | 80 | maxDuration: null, |
81 | maxInstanceLives: -1, | ||
82 | maxUserLives: -1, | ||
81 | transcoding: { | 83 | transcoding: { |
82 | enabled: false, | 84 | enabled: false, |
83 | enabledResolutions: [] | 85 | 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 | |||
@@ -82,6 +82,13 @@ | |||
82 | </tr> | 82 | </tr> |
83 | 83 | ||
84 | <tr> | 84 | <tr> |
85 | <th i18n class="sub-label" scope="row">Max parallel lives</th> | ||
86 | <td i18n> | ||
87 | {{ maxUserLives }} per user / {{ maxInstanceLives }} per instance | ||
88 | </td> | ||
89 | </tr> | ||
90 | |||
91 | <tr> | ||
85 | <th i18n class="label" colspan="2">Import</th> | 92 | <th i18n class="label" colspan="2">Import</th> |
86 | </tr> | 93 | </tr> |
87 | 94 | ||
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 { | |||
21 | return Math.min(this.initialUserVideoQuota, this.serverConfig.user.videoQuotaDaily) | 21 | return Math.min(this.initialUserVideoQuota, this.serverConfig.user.videoQuotaDaily) |
22 | } | 22 | } |
23 | 23 | ||
24 | get maxInstanceLives () { | ||
25 | const value = this.serverConfig.live.maxInstanceLives | ||
26 | if (value === -1) return $localize`Unlimited` | ||
27 | |||
28 | return value | ||
29 | } | ||
30 | |||
31 | get maxUserLives () { | ||
32 | const value = this.serverConfig.live.maxUserLives | ||
33 | if (value === -1) return $localize`Unlimited` | ||
34 | |||
35 | return value | ||
36 | } | ||
37 | |||
24 | ngOnInit () { | 38 | ngOnInit () { |
25 | this.serverConfig = this.serverService.getTmpConfig() | 39 | this.serverConfig = this.serverService.getTmpConfig() |
26 | this.serverService.getConfig() | 40 | this.serverService.getConfig() |