]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/commitdiff
Fix custom server configuration numbers
authorChocobozzz <me@florianbigard.com>
Tue, 27 Mar 2018 13:46:36 +0000 (15:46 +0200)
committerChocobozzz <me@florianbigard.com>
Tue, 27 Mar 2018 13:46:36 +0000 (15:46 +0200)
client/src/app/about/about.component.html
client/src/app/about/about.component.scss
client/src/app/about/about.component.ts
server/controllers/api/config.ts

index bcb4ed2becfb90652744a11d3596f91d06c02f43..bad90d1612f67c6e5ce9498c11c1cb84deb1cc4c 100644 (file)
     <div class="section-title">Terms</div>
 
     <div [innerHTML]="termsHTML"></div>
+  </div>
+
+  <div class="signup">
+    <div class="section-title">Signup</div>
+
+    <div *ngIf="isSignupAllowed">
+      User registration is allowed and
+
+      <ng-template [ngIf]="userVideoQuota !== -1">
+        this instance provides a baseline quota of {{ userVideoQuota | bytes }} space for the videos of its users.
+      </ng-template>
+
+      <ng-template [ngIf]="userVideoQuota === -1">
+        this instance provides unlimited space for the videos of its users.
+      </ng-template>
+    </div>
 
-    <div *ngIf="userVideoQuota !== -1;else noQuota">
-      This instance provides a baseline quota of {{ userVideoQuota | bytes: 0 }} space for the videos of its users.
+    <div *ngIf="isSignupAllowed === false">
+      User registration is currently not allowed.
     </div>
-    
-    <ng-template #noQuota>
-      This instance provides unlimited space for the videos of its users.
-    </ng-template>
   </div>
 
   <div id="p2p-privacy">
index 09e9c68cbf134bee378f7b17462f4eeed66f7a03..2a22b9528cc187af2b7d71fe8b5e2a4ded73e696 100644 (file)
@@ -7,6 +7,6 @@
   margin-bottom: 5px;
 }
 
-.description, .terms {
+.description, .terms, .signup {
   margin-bottom: 30px;
 }
index 7edc013e1277c97865bebd272987fc83ceb66af8..2fd48f0d305c068b2275799f14e4ecb8a6be8916 100644 (file)
@@ -27,6 +27,10 @@ export class AboutComponent implements OnInit {
     return this.serverService.getConfig().user.videoQuota
   }
 
+  get isSignupAllowed () {
+    return this.serverService.getConfig().signup.allowed
+  }
+
   ngOnInit () {
     this.serverService.getAbout()
       .subscribe(
index 8d7fc8cf11a26d375187b715e6acfb1038cf3b18..88f047adc8a1472b07a10155deddf4c6544e43c7 100644 (file)
@@ -117,14 +117,17 @@ async function deleteCustomConfig (req: express.Request, res: express.Response,
 async function updateCustomConfig (req: express.Request, res: express.Response, next: express.NextFunction) {
   const toUpdate: CustomConfig = req.body
 
-  // Need to change the videoQuota key a little bit
-  const toUpdateJSON = omit(toUpdate, 'videoQuota')
+  // Force number conversion
+  toUpdate.cache.previews.size = parseInt('' + toUpdate.cache.previews.size, 10)
+  toUpdate.signup.limit = parseInt('' + toUpdate.signup.limit, 10)
+  toUpdate.user.videoQuota = parseInt('' + toUpdate.user.videoQuota, 10)
+  toUpdate.transcoding.threads = parseInt('' + toUpdate.transcoding.threads, 10)
+
+  // camelCase to snake_case key
+  const toUpdateJSON = omit(toUpdate, 'user.videoQuota', 'instance.defaultClientRoute', 'instance.shortDescription')
   toUpdateJSON.user['video_quota'] = toUpdate.user.videoQuota
   toUpdateJSON.instance['default_client_route'] = toUpdate.instance.defaultClientRoute
   toUpdateJSON.instance['short_description'] = toUpdate.instance.shortDescription
-  delete toUpdate.user.videoQuota
-  delete toUpdate.instance.defaultClientRoute
-  delete toUpdate.instance.shortDescription
 
   await writeFilePromise(CONFIG.CUSTOM_FILE, JSON.stringify(toUpdateJSON, undefined, 2))