]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - client/src/app/shared/shared-instance/instance-features-table.component.ts
Fix select in share modal
[github/Chocobozzz/PeerTube.git] / client / src / app / shared / shared-instance / instance-features-table.component.ts
index 8fd15ebadad2bed015c4727630cee165bd75f3eb..6335de450144f801204212f6e3ce8d48110e6994 100644 (file)
@@ -1,7 +1,7 @@
 import { Component, OnInit } from '@angular/core'
 import { ServerService } from '@app/core'
-import { I18n } from '@ngx-translate/i18n-polyfill'
 import { ServerConfig } from '@shared/models'
+import { PeertubeModalService } from '../shared-main/peertube-modal/peertube-modal.service'
 
 @Component({
   selector: 'my-instance-features-table',
@@ -13,10 +13,9 @@ export class InstanceFeaturesTableComponent implements OnInit {
   serverConfig: ServerConfig
 
   constructor (
-    private i18n: I18n,
-    private serverService: ServerService
-  ) {
-  }
+    private serverService: ServerService,
+    private modalService: PeertubeModalService
+  ) { }
 
   get initialUserVideoQuota () {
     return this.serverConfig.user.videoQuota
@@ -26,8 +25,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
@@ -38,15 +50,19 @@ export class InstanceFeaturesTableComponent implements OnInit {
   buildNSFWLabel () {
     const policy = this.serverConfig.instance.defaultNSFWPolicy
 
-    if (policy === 'do_not_list') return this.i18n('Hidden')
-    if (policy === 'blur') return this.i18n('Blurred with confirmation request')
-    if (policy === 'display') return this.i18n('Displayed')
+    if (policy === 'do_not_list') return $localize`Hidden`
+    if (policy === 'blur') return $localize`Blurred with confirmation request`
+    if (policy === 'display') return $localize`Displayed`
   }
 
   getServerVersionAndCommit () {
     return this.serverService.getServerVersionAndCommit()
   }
 
+  openQuickSettingsHighlight () {
+    this.modalService.openQuickSettingsSubject.next()
+  }
+
   private getApproximateTime (seconds: number) {
     const hours = Math.floor(seconds / 3600)
     let pluralSuffix = ''
@@ -55,7 +71,9 @@ export class InstanceFeaturesTableComponent implements OnInit {
 
     const minutes = Math.floor(seconds % 3600 / 60)
 
-    return this.i18n('~ {{minutes}} {minutes, plural, =1 {minute} other {minutes}}', { minutes })
+    if (minutes === 1) return $localize`~ 1 minute`
+
+    return $localize`~ ${minutes} minutes`
   }
 
   private buildQuotaHelpIndication () {
@@ -71,9 +89,9 @@ export class InstanceFeaturesTableComponent implements OnInit {
     const normalSeconds = initialUserVideoQuotaBit / (1.5 * 1000 * 1000)
 
     const lines = [
-      this.i18n('{{seconds}} of full HD videos', { seconds: this.getApproximateTime(fullHdSeconds) }),
-      this.i18n('{{seconds}} of HD videos', { seconds: this.getApproximateTime(hdSeconds) }),
-      this.i18n('{{seconds}} of average quality videos', { seconds: this.getApproximateTime(normalSeconds) })
+      $localize`${this.getApproximateTime(fullHdSeconds)} of full HD videos`,
+      $localize`${this.getApproximateTime(hdSeconds)} of HD videos`,
+      $localize`${this.getApproximateTime(normalSeconds)} of average quality videos`
     ]
 
     this.quotaHelpIndication = lines.join('<br />')