diff options
Diffstat (limited to 'client/src/app/shared/instance')
3 files changed, 48 insertions, 36 deletions
diff --git a/client/src/app/shared/instance/instance-features-table.component.html b/client/src/app/shared/instance/instance-features-table.component.html index f880a886f..fd8b3354f 100644 --- a/client/src/app/shared/instance/instance-features-table.component.html +++ b/client/src/app/shared/instance/instance-features-table.component.html | |||
@@ -1,6 +1,6 @@ | |||
1 | <div class="feature-table"> | 1 | <div class="feature-table"> |
2 | 2 | ||
3 | <table class="table" *ngIf="config"> | 3 | <table class="table" *ngIf="serverConfig"> |
4 | <tr> | 4 | <tr> |
5 | <td i18n class="label">PeerTube version</td> | 5 | <td i18n class="label">PeerTube version</td> |
6 | 6 | ||
@@ -19,7 +19,7 @@ | |||
19 | <tr> | 19 | <tr> |
20 | <td i18n class="label">User registration allowed</td> | 20 | <td i18n class="label">User registration allowed</td> |
21 | <td> | 21 | <td> |
22 | <my-feature-boolean [value]="config.signup.allowed"></my-feature-boolean> | 22 | <my-feature-boolean [value]="serverConfig.signup.allowed"></my-feature-boolean> |
23 | </td> | 23 | </td> |
24 | </tr> | 24 | </tr> |
25 | 25 | ||
@@ -30,15 +30,15 @@ | |||
30 | <tr> | 30 | <tr> |
31 | <td i18n class="sub-label">Transcoding in multiple resolutions</td> | 31 | <td i18n class="sub-label">Transcoding in multiple resolutions</td> |
32 | <td> | 32 | <td> |
33 | <my-feature-boolean [value]="config.transcoding.enabledResolutions.length !== 0"></my-feature-boolean> | 33 | <my-feature-boolean [value]="serverConfig.transcoding.enabledResolutions.length !== 0"></my-feature-boolean> |
34 | </td> | 34 | </td> |
35 | </tr> | 35 | </tr> |
36 | 36 | ||
37 | <tr> | 37 | <tr> |
38 | <td i18n class="sub-label">Video uploads</td> | 38 | <td i18n class="sub-label">Video uploads</td> |
39 | <td> | 39 | <td> |
40 | <span *ngIf="config.autoBlacklist.videos.ofUsers.enabled">Requires manual validation by moderators</span> | 40 | <span *ngIf="serverConfig.autoBlacklist.videos.ofUsers.enabled">Requires manual validation by moderators</span> |
41 | <span *ngIf="!config.autoBlacklist.videos.ofUsers.enabled">Automatically published</span> | 41 | <span *ngIf="!serverConfig.autoBlacklist.videos.ofUsers.enabled">Automatically published</span> |
42 | </td> | 42 | </td> |
43 | </tr> | 43 | </tr> |
44 | 44 | ||
@@ -69,14 +69,14 @@ | |||
69 | <tr> | 69 | <tr> |
70 | <td i18n class="sub-label">HTTP import (YouTube, Vimeo, direct URL...)</td> | 70 | <td i18n class="sub-label">HTTP import (YouTube, Vimeo, direct URL...)</td> |
71 | <td> | 71 | <td> |
72 | <my-feature-boolean [value]="config.import.videos.http.enabled"></my-feature-boolean> | 72 | <my-feature-boolean [value]="serverConfig.import.videos.http.enabled"></my-feature-boolean> |
73 | </td> | 73 | </td> |
74 | </tr> | 74 | </tr> |
75 | 75 | ||
76 | <tr> | 76 | <tr> |
77 | <td i18n class="sub-label">Torrent import</td> | 77 | <td i18n class="sub-label">Torrent import</td> |
78 | <td> | 78 | <td> |
79 | <my-feature-boolean [value]="config.import.videos.torrent.enabled"></my-feature-boolean> | 79 | <my-feature-boolean [value]="serverConfig.import.videos.torrent.enabled"></my-feature-boolean> |
80 | </td> | 80 | </td> |
81 | </tr> | 81 | </tr> |
82 | 82 | ||
@@ -88,7 +88,7 @@ | |||
88 | <tr> | 88 | <tr> |
89 | <td i18n class="sub-label">P2P enabled</td> | 89 | <td i18n class="sub-label">P2P enabled</td> |
90 | <td> | 90 | <td> |
91 | <my-feature-boolean [value]="config.tracker.enabled"></my-feature-boolean> | 91 | <my-feature-boolean [value]="serverConfig.tracker.enabled"></my-feature-boolean> |
92 | </td> | 92 | </td> |
93 | </tr> | 93 | </tr> |
94 | </table> | 94 | </table> |
diff --git a/client/src/app/shared/instance/instance-features-table.component.ts b/client/src/app/shared/instance/instance-features-table.component.ts index 1661f1efe..8fd15ebad 100644 --- a/client/src/app/shared/instance/instance-features-table.component.ts +++ b/client/src/app/shared/instance/instance-features-table.component.ts | |||
@@ -10,7 +10,7 @@ import { ServerConfig } from '@shared/models' | |||
10 | }) | 10 | }) |
11 | export class InstanceFeaturesTableComponent implements OnInit { | 11 | export class InstanceFeaturesTableComponent implements OnInit { |
12 | quotaHelpIndication = '' | 12 | quotaHelpIndication = '' |
13 | config: ServerConfig | 13 | serverConfig: ServerConfig |
14 | 14 | ||
15 | constructor ( | 15 | constructor ( |
16 | private i18n: I18n, | 16 | private i18n: I18n, |
@@ -19,29 +19,34 @@ export class InstanceFeaturesTableComponent implements OnInit { | |||
19 | } | 19 | } |
20 | 20 | ||
21 | get initialUserVideoQuota () { | 21 | get initialUserVideoQuota () { |
22 | return this.serverService.getConfig().user.videoQuota | 22 | return this.serverConfig.user.videoQuota |
23 | } | 23 | } |
24 | 24 | ||
25 | get dailyUserVideoQuota () { | 25 | get dailyUserVideoQuota () { |
26 | return Math.min(this.initialUserVideoQuota, this.serverService.getConfig().user.videoQuotaDaily) | 26 | return Math.min(this.initialUserVideoQuota, this.serverConfig.user.videoQuotaDaily) |
27 | } | 27 | } |
28 | 28 | ||
29 | ngOnInit () { | 29 | ngOnInit () { |
30 | this.serverService.configLoaded | 30 | this.serverConfig = this.serverService.getTmpConfig() |
31 | .subscribe(() => { | 31 | this.serverService.getConfig() |
32 | this.config = this.serverService.getConfig() | 32 | .subscribe(config => { |
33 | this.serverConfig = config | ||
33 | this.buildQuotaHelpIndication() | 34 | this.buildQuotaHelpIndication() |
34 | }) | 35 | }) |
35 | } | 36 | } |
36 | 37 | ||
37 | buildNSFWLabel () { | 38 | buildNSFWLabel () { |
38 | const policy = this.serverService.getConfig().instance.defaultNSFWPolicy | 39 | const policy = this.serverConfig.instance.defaultNSFWPolicy |
39 | 40 | ||
40 | if (policy === 'do_not_list') return this.i18n('Hidden') | 41 | if (policy === 'do_not_list') return this.i18n('Hidden') |
41 | if (policy === 'blur') return this.i18n('Blurred with confirmation request') | 42 | if (policy === 'blur') return this.i18n('Blurred with confirmation request') |
42 | if (policy === 'display') return this.i18n('Displayed') | 43 | if (policy === 'display') return this.i18n('Displayed') |
43 | } | 44 | } |
44 | 45 | ||
46 | getServerVersionAndCommit () { | ||
47 | return this.serverService.getServerVersionAndCommit() | ||
48 | } | ||
49 | |||
45 | private getApproximateTime (seconds: number) { | 50 | private getApproximateTime (seconds: number) { |
46 | const hours = Math.floor(seconds / 3600) | 51 | const hours = Math.floor(seconds / 3600) |
47 | let pluralSuffix = '' | 52 | let pluralSuffix = '' |
@@ -53,10 +58,6 @@ export class InstanceFeaturesTableComponent implements OnInit { | |||
53 | return this.i18n('~ {{minutes}} {minutes, plural, =1 {minute} other {minutes}}', { minutes }) | 58 | return this.i18n('~ {{minutes}} {minutes, plural, =1 {minute} other {minutes}}', { minutes }) |
54 | } | 59 | } |
55 | 60 | ||
56 | getServerVersionAndCommit () { | ||
57 | return this.serverService.getServerVersionAndCommit() | ||
58 | } | ||
59 | |||
60 | private buildQuotaHelpIndication () { | 61 | private buildQuotaHelpIndication () { |
61 | if (this.initialUserVideoQuota === -1) return | 62 | if (this.initialUserVideoQuota === -1) return |
62 | 63 | ||
diff --git a/client/src/app/shared/instance/instance.service.ts b/client/src/app/shared/instance/instance.service.ts index 44b413fa4..8b26063fb 100644 --- a/client/src/app/shared/instance/instance.service.ts +++ b/client/src/app/shared/instance/instance.service.ts | |||
@@ -1,4 +1,4 @@ | |||
1 | import { catchError } from 'rxjs/operators' | 1 | import { catchError, map } from 'rxjs/operators' |
2 | import { HttpClient } from '@angular/common/http' | 2 | import { HttpClient } from '@angular/common/http' |
3 | import { Injectable } from '@angular/core' | 3 | import { Injectable } from '@angular/core' |
4 | import { environment } from '../../../environments/environment' | 4 | import { environment } from '../../../environments/environment' |
@@ -7,6 +7,7 @@ import { About } from '../../../../../shared/models/server' | |||
7 | import { MarkdownService } from '@app/shared/renderer' | 7 | import { MarkdownService } from '@app/shared/renderer' |
8 | import { peertubeTranslate } from '@shared/models' | 8 | import { peertubeTranslate } from '@shared/models' |
9 | import { ServerService } from '@app/core' | 9 | import { ServerService } from '@app/core' |
10 | import { forkJoin } from 'rxjs' | ||
10 | 11 | ||
11 | @Injectable() | 12 | @Injectable() |
12 | export class InstanceService { | 13 | export class InstanceService { |
@@ -57,25 +58,35 @@ export class InstanceService { | |||
57 | return html | 58 | return html |
58 | } | 59 | } |
59 | 60 | ||
60 | buildTranslatedLanguages (about: About, translations: any) { | 61 | buildTranslatedLanguages (about: About) { |
61 | const languagesArray = this.serverService.getVideoLanguages() | 62 | return forkJoin([ |
63 | this.serverService.getVideoLanguages(), | ||
64 | this.serverService.getServerLocale() | ||
65 | ]).pipe( | ||
66 | map(([ languagesArray, translations ]) => { | ||
67 | return about.instance.languages | ||
68 | .map(l => { | ||
69 | const languageObj = languagesArray.find(la => la.id === l) | ||
62 | 70 | ||
63 | return about.instance.languages | 71 | return peertubeTranslate(languageObj.label, translations) |
64 | .map(l => { | 72 | }) |
65 | const languageObj = languagesArray.find(la => la.id === l) | 73 | }) |
66 | 74 | ) | |
67 | return peertubeTranslate(languageObj.label, translations) | ||
68 | }) | ||
69 | } | 75 | } |
70 | 76 | ||
71 | buildTranslatedCategories (about: About, translations: any) { | 77 | buildTranslatedCategories (about: About) { |
72 | const categoriesArray = this.serverService.getVideoCategories() | 78 | return forkJoin([ |
73 | 79 | this.serverService.getVideoCategories(), | |
74 | return about.instance.categories | 80 | this.serverService.getServerLocale() |
75 | .map(c => { | 81 | ]).pipe( |
76 | const categoryObj = categoriesArray.find(ca => ca.id === c) | 82 | map(([ categoriesArray, translations ]) => { |
83 | return about.instance.categories | ||
84 | .map(c => { | ||
85 | const categoryObj = categoriesArray.find(ca => ca.id === c) | ||
77 | 86 | ||
78 | return peertubeTranslate(categoryObj.label, translations) | 87 | return peertubeTranslate(categoryObj.label, translations) |
79 | }) | 88 | }) |
89 | }) | ||
90 | ) | ||
80 | } | 91 | } |
81 | } | 92 | } |