1 import { Component, OnInit } from '@angular/core'
2 import { ServerService } from '@app/core'
3 import { I18n } from '@ngx-translate/i18n-polyfill'
6 selector: 'my-instance-features-table',
7 templateUrl: './instance-features-table.component.html',
8 styleUrls: [ './instance-features-table.component.scss' ]
10 export class InstanceFeaturesTableComponent implements OnInit {
11 features: { label: string, value?: boolean }[] = []
12 quotaHelpIndication = ''
16 private serverService: ServerService
20 get initialUserVideoQuota () {
21 return this.serverService.getConfig().user.videoQuota
25 this.serverService.configLoaded
28 this.buildQuotaHelpIndication()
32 private buildFeatures () {
33 const config = this.serverService.getConfig()
37 label: this.i18n('Transcode your videos in multiple resolutions'),
38 value: config.transcoding.enabledResolutions.length !== 0
41 label: this.i18n('HTTP import (YouTube, Vimeo, direct URL...)'),
42 value: config.import.videos.http.enabled
45 label: this.i18n('Torrent import'),
46 value: config.import.videos.torrent.enabled
52 private getApproximateTime (seconds: number) {
53 const hours = Math.floor(seconds / 3600)
55 if (hours > 1) pluralSuffix = 's'
56 if (hours > 0) return `~ ${hours} hour${pluralSuffix}`
58 const minutes = Math.floor(seconds % 3600 / 60)
60 return this.i18n('~ {{minutes}} {minutes, plural, =1 {minute} other {minutes}}', { minutes })
63 private buildQuotaHelpIndication () {
64 if (this.initialUserVideoQuota === -1) return
66 const initialUserVideoQuotaBit = this.initialUserVideoQuota * 8
71 const fullHdSeconds = initialUserVideoQuotaBit / (6 * 1000 * 1000)
72 const hdSeconds = initialUserVideoQuotaBit / (4 * 1000 * 1000)
73 const normalSeconds = initialUserVideoQuotaBit / (1.5 * 1000 * 1000)
76 this.i18n('{{seconds}} of full HD videos', { seconds: this.getApproximateTime(fullHdSeconds) }),
77 this.i18n('{{seconds}} of HD videos', { seconds: this.getApproximateTime(hdSeconds) }),
78 this.i18n('{{seconds}} of average quality videos', { seconds: this.getApproximateTime(normalSeconds) })
81 this.quotaHelpIndication = lines.join('<br />')