]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - client/src/app/shared/shared-instance/instance-features-table.component.ts
Merge branch 'release/4.2.0' into develop
[github/Chocobozzz/PeerTube.git] / client / src / app / shared / shared-instance / instance-features-table.component.ts
index 76b595c20e3bf2c95433e5bd6b8cc49dd7aed06c..e405c579082e896df107705ef9eabcd4f5d2451f 100644 (file)
@@ -1,6 +1,8 @@
 import { Component, OnInit } from '@angular/core'
 import { ServerService } from '@app/core'
+import { prepareIcu } from '@app/helpers'
 import { ServerConfig } from '@shared/models'
+import { PeertubeModalService } from '../shared-main/peertube-modal/peertube-modal.service'
 
 @Component({
   selector: 'my-instance-features-table',
@@ -11,7 +13,10 @@ export class InstanceFeaturesTableComponent implements OnInit {
   quotaHelpIndication = ''
   serverConfig: ServerConfig
 
-  constructor (private serverService: ServerService) { }
+  constructor (
+    private serverService: ServerService,
+    private modalService: PeertubeModalService
+  ) { }
 
   get initialUserVideoQuota () {
     return this.serverConfig.user.videoQuota
@@ -21,8 +26,21 @@ 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()
         .subscribe(config => {
           this.serverConfig = config
@@ -42,17 +60,26 @@ export class InstanceFeaturesTableComponent implements OnInit {
     return this.serverService.getServerVersionAndCommit()
   }
 
+  openQuickSettingsHighlight () {
+    this.modalService.openQuickSettingsSubject.next()
+  }
+
   private getApproximateTime (seconds: number) {
     const hours = Math.floor(seconds / 3600)
-    let pluralSuffix = ''
-    if (hours > 1) pluralSuffix = 's'
-    if (hours > 0) return `~ ${hours} hour${pluralSuffix}`
 
-    const minutes = Math.floor(seconds % 3600 / 60)
+    if (hours !== 0) {
+      return prepareIcu($localize`~ {hours, plural, =1 {1 hour} other {{hours} hours}}`)(
+        { hours },
+        $localize`~ ${hours} hours`
+      )
+    }
 
-    if (minutes === 1) return $localize`~ 1 minute`
+    const minutes = Math.floor(seconds % 3600 / 60)
 
-    return $localize`~ ${minutes} minutes`
+    return prepareIcu($localize`~ {minutes, plural, =1 {1 minute} other {{minutes} minutes}}`)(
+      { minutes },
+      $localize`~ ${minutes} minutes`
+    )
   }
 
   private buildQuotaHelpIndication () {