]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/commitdiff
Use -1 for max live duration unlimited
authorChocobozzz <me@florianbigard.com>
Tue, 15 Dec 2020 08:23:28 +0000 (09:23 +0100)
committerChocobozzz <me@florianbigard.com>
Tue, 15 Dec 2020 08:26:37 +0000 (09:26 +0100)
14 files changed:
client/src/app/+admin/config/edit-custom-config/edit-custom-config.component.html
client/src/app/+admin/config/edit-custom-config/edit-custom-config.component.scss
client/src/app/+admin/config/edit-custom-config/edit-custom-config.component.ts
client/src/sass/include/_mixins.scss
config/default.yaml
config/production.yaml.example
server/lib/live-manager.ts
server/middlewares/validators/config.ts
server/tests/api/check-params/config.ts
server/tests/api/live/live-permanent.ts
server/tests/api/live/live-save-replay.ts
server/tests/api/live/live.ts
server/tests/api/server/config.ts
shared/extra-utils/server/config.ts

index bba7365f67b179c12d43d4ab479939958d6cd13a..af8a4e18dd73cd1c36518cf60af5ecdab9f24362 100644 (file)
     </ng-container>
 
     <ng-container ngbNavItem="transcoding">
-      <a ngbNavLink i18n>Transcoding</a>
+      <a ngbNavLink i18n>VOD Transcoding</a>
 
       <ng-template ngbNavContent>
 
 
                     <div class="form-group" [ngClass]="{ 'disabled-checkbox-extra': !isLiveEnabled() }">
                       <label i18n for="liveMaxDuration">Max live duration</label>
-                      <div>
-                        <ng-select
-                          labelForId="liveMaxDuration" [items]="liveMaxDurationOptions" formControlName="maxDuration"
-                          bindLabel="label" bindValue="value"
-                          [clearable]="false"
-                          [searchable]="false"
-                        ></ng-select>
-                      </div>
+
+                      <ng-select
+                        labelForId="liveMaxDuration" [items]="liveMaxDurationOptions" formControlName="maxDuration"
+                        bindLabel="label" bindValue="value" [clearable]="false" [searchable]="false"
+                      ></ng-select>
                     </div>
 
                   </ng-container>
index 3d570f571c281108adb8b10e77b231d5414f3d83..4c64bd2e0a29df8ea88e40478da6be7747a909e8 100644 (file)
@@ -18,7 +18,8 @@ input[type=text] {
 }
 
 input[type=number] {
-  @include peertube-input-text(315px);
+  @include peertube-input-text($form-base-input-width);
+
   display: block;
 }
 
index 7920600fc1b4e70119e9d2dcbaae204fad9faa69..c3a833843b83933d45dea101161e84673379d27f 100644 (file)
@@ -98,7 +98,7 @@ export class EditCustomConfigComponent extends FormReactive implements OnInit, A
     ]
 
     this.liveMaxDurationOptions = [
-      { value: null, label: $localize`No limit` },
+      { value: -1, label: $localize`No limit` },
       { value: 1000 * 3600, label: $localize`1 hour` },
       { value: 1000 * 3600 * 3, label: $localize`3 hours` },
       { value: 1000 * 3600 * 5, label: $localize`5 hours` },
@@ -359,10 +359,6 @@ export class EditCustomConfigComponent extends FormReactive implements OnInit, A
   async formValidated () {
     const value: CustomConfig = this.form.getRawValue()
 
-    // Transform "null" to null
-    const maxDuration = value.live.maxDuration as any
-    if (maxDuration === 'null') value.live.maxDuration = null
-
     this.configService.updateCustomConfig(value)
       .subscribe(
         res => {
index fecae9fbca55fdec6a06c0a2abf1adcedb71f882..19b4e204f5f4a67874f82edaa9828afb70a09e86 100644 (file)
 
 
 @mixin ng-select ($width) {
-  ::ng-deep ng-select {
+  ::ng-deep &.ng-select,
+  ::ng-deep .ng-select {
     width: $width;
 
     @media screen and (max-width: $width) {
index 88821fe3c925e43d23f51cf49b44930b3851bd1a..9d428f764fde075c2eedbd7c2b0a0bac06c7e8c8 100644 (file)
@@ -247,8 +247,8 @@ live:
   enabled: false
 
   # Limit lives duration
-  # Set null to disable duration limit
-  max_duration: null # For example: '5 hours'
+  # -1 == unlimited
+  max_duration: -1 # For example: '5 hours'
 
   # Limit max number of live videos created on your instance
   # -1 == unlimited
index b71a494f9b39089dae92967b025c8ec5bde7c5f0..bcf727d82541ee03489d4ba282956b6a8dea345a 100644 (file)
@@ -262,7 +262,7 @@ live:
 
   # Limit lives duration
   # Set null to disable duration limit
-  max_duration: null # For example: '5 hours'
+  max_duration: -1 # For example: '5 hours'
 
   # Limit max number of live videos created on your instance
   # -1 == unlimited
index 2fb4b774c1234868ebdb5fb51d47316e9781cb84..379f61bdf332de10b9491f2346b4631cb011bdf3 100644 (file)
@@ -505,7 +505,7 @@ class LiveManager {
   private isDurationConstraintValid (streamingStartTime: number) {
     const maxDuration = CONFIG.LIVE.MAX_DURATION
     // No limit
-    if (maxDuration === null) return true
+    if (maxDuration < 0) return true
 
     const now = new Date().getTime()
     const max = streamingStartTime + maxDuration
index 93de453a722caeee6fd2274de994fbb9381309ec..9c1cfa7e733288faaa925c00b4a2fd5a2d22e110 100644 (file)
@@ -2,13 +2,13 @@ import * as express from 'express'
 import { body } from 'express-validator'
 import { isIntOrNull } from '@server/helpers/custom-validators/misc'
 import { isEmailEnabled } from '@server/initializers/config'
+import { HttpStatusCode } from '../../../shared/core-utils/miscs/http-error-codes'
 import { CustomConfig } from '../../../shared/models/server/custom-config.model'
 import { isThemeNameValid } from '../../helpers/custom-validators/plugins'
 import { isUserNSFWPolicyValid, isUserVideoQuotaDailyValid, isUserVideoQuotaValid } from '../../helpers/custom-validators/users'
 import { logger } from '../../helpers/logger'
 import { isThemeRegistered } from '../../lib/plugins/theme-utils'
 import { areValidationErrors } from './utils'
-import { HttpStatusCode } from '../../../shared/core-utils/miscs/http-error-codes'
 
 const customConfigUpdateValidator = [
   body('instance.name').exists().withMessage('Should have a valid instance name'),
@@ -65,7 +65,7 @@ const customConfigUpdateValidator = [
 
   body('live.enabled').isBoolean().withMessage('Should have a valid live enabled boolean'),
   body('live.allowReplay').isBoolean().withMessage('Should have a valid live allow replay boolean'),
-  body('live.maxDuration').custom(isIntOrNull).withMessage('Should have a valid live max duration'),
+  body('live.maxDuration').isInt().withMessage('Should have a valid live max duration'),
   body('live.maxInstanceLives').custom(isIntOrNull).withMessage('Should have a valid max instance lives'),
   body('live.maxUserLives').custom(isIntOrNull).withMessage('Should have a valid max user lives'),
   body('live.transcoding.enabled').isBoolean().withMessage('Should have a valid live transcoding enabled boolean'),
index 08576c3ae664c167a71513cf24782548181863c0..fab440fc529e28c2238f62700628f69ceb32adf5 100644 (file)
@@ -105,7 +105,7 @@ describe('Test config API validators', function () {
       enabled: true,
 
       allowReplay: false,
-      maxDuration: null,
+      maxDuration: 30,
       maxInstanceLives: -1,
       maxUserLives: 50,
 
index 9e6c6cf70fe0ff9baa49c1f17dc68001eca1cb71..1128e993cae2f1574e271a39873b77c09b0e0e74 100644 (file)
@@ -66,7 +66,7 @@ describe('Permenant live', function () {
       live: {
         enabled: true,
         allowReplay: true,
-        maxDuration: null,
+        maxDuration: -1,
         transcoding: {
           enabled: true,
           resolutions: {
@@ -155,7 +155,7 @@ describe('Permenant live', function () {
       live: {
         enabled: true,
         allowReplay: true,
-        maxDuration: null,
+        maxDuration: -1,
         transcoding: {
           enabled: true,
           resolutions: {
index 6cd8cc23f27b25b46ed133eff516dc2aed776a91..35fe4e7bdf51b54c804e611dbda1a1afb9f4df5d 100644 (file)
@@ -90,7 +90,7 @@ describe('Save replay setting', function () {
       live: {
         enabled: true,
         allowReplay: true,
-        maxDuration: null,
+        maxDuration: -1,
         transcoding: {
           enabled: false,
           resolutions: {
index 91879208178b9914d01a4bab5b4796ed29bf58e2..939285ae85e5b0c7a2e45b95652ff0b17f92f613 100644 (file)
@@ -348,7 +348,7 @@ describe('Test live', function () {
         live: {
           enabled: true,
           allowReplay: true,
-          maxDuration: null,
+          maxDuration: -1,
           transcoding: {
             enabled: true,
             resolutions: {
index a505b8eded6dff00a963d153f5962b4f47c81690..bfaad36884a537155590409bbdd7a29333a990f2 100644 (file)
@@ -81,7 +81,7 @@ function checkInitialConfig (server: ServerInfo, data: CustomConfig) {
 
   expect(data.live.enabled).to.be.false
   expect(data.live.allowReplay).to.be.false
-  expect(data.live.maxDuration).to.be.null
+  expect(data.live.maxDuration).to.equal(-1)
   expect(data.live.maxInstanceLives).to.equal(20)
   expect(data.live.maxUserLives).to.equal(3)
   expect(data.live.transcoding.enabled).to.be.false
index 3b6afe9ffcf8b49cc5cedd93d7d569f603fcf3fd..8702659c493d195b61109683e223dfeddf4e1162 100644 (file)
@@ -129,7 +129,7 @@ function updateCustomSubConfig (url: string, token: string, newConfig: DeepParti
     live: {
       enabled: true,
       allowReplay: false,
-      maxDuration: null,
+      maxDuration: -1,
       maxInstanceLives: -1,
       maxUserLives: 50,
       transcoding: {