diff options
author | Chocobozzz <me@florianbigard.com> | 2020-06-23 14:10:17 +0200 |
---|---|---|
committer | Chocobozzz <chocobozzz@cpy.re> | 2020-06-23 16:00:49 +0200 |
commit | 67ed6552b831df66713bac9e672738796128d33f (patch) | |
tree | 59c97d41e0b49d75a90aa3de987968ab9b1ff447 /client/src/app/shared/instance/instance-features-table.component.ts | |
parent | 0c4bacbff53bc732f5a2677d62a6ead7752e2405 (diff) | |
download | PeerTube-67ed6552b831df66713bac9e672738796128d33f.tar.gz PeerTube-67ed6552b831df66713bac9e672738796128d33f.tar.zst PeerTube-67ed6552b831df66713bac9e672738796128d33f.zip |
Reorganize client shared modules
Diffstat (limited to 'client/src/app/shared/instance/instance-features-table.component.ts')
-rw-r--r-- | client/src/app/shared/instance/instance-features-table.component.ts | 81 |
1 files changed, 0 insertions, 81 deletions
diff --git a/client/src/app/shared/instance/instance-features-table.component.ts b/client/src/app/shared/instance/instance-features-table.component.ts deleted file mode 100644 index 8fd15ebad..000000000 --- a/client/src/app/shared/instance/instance-features-table.component.ts +++ /dev/null | |||
@@ -1,81 +0,0 @@ | |||
1 | import { Component, OnInit } from '@angular/core' | ||
2 | import { ServerService } from '@app/core' | ||
3 | import { I18n } from '@ngx-translate/i18n-polyfill' | ||
4 | import { ServerConfig } from '@shared/models' | ||
5 | |||
6 | @Component({ | ||
7 | selector: 'my-instance-features-table', | ||
8 | templateUrl: './instance-features-table.component.html', | ||
9 | styleUrls: [ './instance-features-table.component.scss' ] | ||
10 | }) | ||
11 | export class InstanceFeaturesTableComponent implements OnInit { | ||
12 | quotaHelpIndication = '' | ||
13 | serverConfig: ServerConfig | ||
14 | |||
15 | constructor ( | ||
16 | private i18n: I18n, | ||
17 | private serverService: ServerService | ||
18 | ) { | ||
19 | } | ||
20 | |||
21 | get initialUserVideoQuota () { | ||
22 | return this.serverConfig.user.videoQuota | ||
23 | } | ||
24 | |||
25 | get dailyUserVideoQuota () { | ||
26 | return Math.min(this.initialUserVideoQuota, this.serverConfig.user.videoQuotaDaily) | ||
27 | } | ||
28 | |||
29 | ngOnInit () { | ||
30 | this.serverConfig = this.serverService.getTmpConfig() | ||
31 | this.serverService.getConfig() | ||
32 | .subscribe(config => { | ||
33 | this.serverConfig = config | ||
34 | this.buildQuotaHelpIndication() | ||
35 | }) | ||
36 | } | ||
37 | |||
38 | buildNSFWLabel () { | ||
39 | const policy = this.serverConfig.instance.defaultNSFWPolicy | ||
40 | |||
41 | if (policy === 'do_not_list') return this.i18n('Hidden') | ||
42 | if (policy === 'blur') return this.i18n('Blurred with confirmation request') | ||
43 | if (policy === 'display') return this.i18n('Displayed') | ||
44 | } | ||
45 | |||
46 | getServerVersionAndCommit () { | ||
47 | return this.serverService.getServerVersionAndCommit() | ||
48 | } | ||
49 | |||
50 | private getApproximateTime (seconds: number) { | ||
51 | const hours = Math.floor(seconds / 3600) | ||
52 | let pluralSuffix = '' | ||
53 | if (hours > 1) pluralSuffix = 's' | ||
54 | if (hours > 0) return `~ ${hours} hour${pluralSuffix}` | ||
55 | |||
56 | const minutes = Math.floor(seconds % 3600 / 60) | ||
57 | |||
58 | return this.i18n('~ {{minutes}} {minutes, plural, =1 {minute} other {minutes}}', { minutes }) | ||
59 | } | ||
60 | |||
61 | private buildQuotaHelpIndication () { | ||
62 | if (this.initialUserVideoQuota === -1) return | ||
63 | |||
64 | const initialUserVideoQuotaBit = this.initialUserVideoQuota * 8 | ||
65 | |||
66 | // 1080p: ~ 6Mbps | ||
67 | // 720p: ~ 4Mbps | ||
68 | // 360p: ~ 1.5Mbps | ||
69 | const fullHdSeconds = initialUserVideoQuotaBit / (6 * 1000 * 1000) | ||
70 | const hdSeconds = initialUserVideoQuotaBit / (4 * 1000 * 1000) | ||
71 | const normalSeconds = initialUserVideoQuotaBit / (1.5 * 1000 * 1000) | ||
72 | |||
73 | const lines = [ | ||
74 | this.i18n('{{seconds}} of full HD videos', { seconds: this.getApproximateTime(fullHdSeconds) }), | ||
75 | this.i18n('{{seconds}} of HD videos', { seconds: this.getApproximateTime(hdSeconds) }), | ||
76 | this.i18n('{{seconds}} of average quality videos', { seconds: this.getApproximateTime(normalSeconds) }) | ||
77 | ] | ||
78 | |||
79 | this.quotaHelpIndication = lines.join('<br />') | ||
80 | } | ||
81 | } | ||