From 4402b54dce0fe652ba71326f0dc74db287963260 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Tue, 27 Aug 2019 10:18:49 +0200 Subject: [PATCH] Add categories and languages to about page --- .../about-instance.component.html | 26 ++++++-- .../about-instance.component.scss | 1 + .../about-instance.component.ts | 60 ++++++++++++------- 3 files changed, 62 insertions(+), 25 deletions(-) diff --git a/client/src/app/+about/about-instance/about-instance.component.html b/client/src/app/+about/about-instance/about-instance.component.html index 0fd3626b7..c6247c4ae 100644 --- a/client/src/app/+about/about-instance/about-instance.component.html +++ b/client/src/app/+about/about-instance/about-instance.component.html @@ -8,9 +8,25 @@
-
{{ shortDescription }}
+
{{ shortDescription }}
-
This instance is dedicated to sensitive/NSFW content.
+
This instance is dedicated to sensitive/NSFW content.
+ +
+
Main instance languages
+ +
    +
  • {{ language }}
  • +
+
+ +
+
Main instance categories
+ +
    +
  • {{ category }}
  • +
+
@@ -18,19 +34,19 @@
-
Instance administrators
+
Who are we?
-
Maintenance lifetime
+
How long do we plan to maintain this instance?

{{ maintenanceLifetime }}

-
Business model
+
How will we pay this instance?

{{ businessModel }}

diff --git a/client/src/app/+about/about-instance/about-instance.component.scss b/client/src/app/+about/about-instance/about-instance.component.scss index 0585ad5f3..d71cfffc6 100644 --- a/client/src/app/+about/about-instance/about-instance.component.scss +++ b/client/src/app/+about/about-instance/about-instance.component.scss @@ -36,6 +36,7 @@ .block { margin-bottom: 30px; + font-size: 15px; } .short-description .dedicated-to-nsfw { diff --git a/client/src/app/+about/about-instance/about-instance.component.ts b/client/src/app/+about/about-instance/about-instance.component.ts index b85a6be94..0af1dca9c 100644 --- a/client/src/app/+about/about-instance/about-instance.component.ts +++ b/client/src/app/+about/about-instance/about-instance.component.ts @@ -4,6 +4,9 @@ import { I18n } from '@ngx-translate/i18n-polyfill' import { ContactAdminModalComponent } from '@app/+about/about-instance/contact-admin-modal.component' import { InstanceService } from '@app/shared/instance/instance.service' import { MarkdownService } from '@app/shared/renderer' +import { forkJoin } from 'rxjs' +import { first } from 'rxjs/operators' +import { peertubeTranslate } from '@shared/models' @Component({ selector: 'my-about-instance', @@ -27,7 +30,7 @@ export class AboutInstanceComponent implements OnInit { businessModel = '' languages: string[] = [] - categories: number[] = [] + categories: string[] = [] constructor ( private notifier: Notifier, @@ -50,28 +53,45 @@ export class AboutInstanceComponent implements OnInit { } ngOnInit () { - this.instanceService.getAbout() - .subscribe( - async res => { - this.shortDescription = res.instance.shortDescription - - this.maintenanceLifetime = res.instance.maintenanceLifetime - this.businessModel = res.instance.businessModel - - for (const key of [ 'description', 'terms', 'codeOfConduct', 'moderationInformation', 'administrator' ]) { - this.html[key] = await this.markdownService.textMarkdownToHTML(res.instance[key]) - } - - this.languages = res.instance.languages - this.categories = res.instance.categories - }, - - () => this.notifier.error(this.i18n('Cannot get about information from server')) - ) + forkJoin([ + this.instanceService.getAbout(), + this.serverService.localeObservable.pipe(first()), + this.serverService.videoLanguagesLoaded.pipe(first()), + this.serverService.videoCategoriesLoaded.pipe(first()) + ]).subscribe( + async ([ res, translations ]) => { + this.shortDescription = res.instance.shortDescription + + this.maintenanceLifetime = res.instance.maintenanceLifetime + this.businessModel = res.instance.businessModel + + for (const key of [ 'description', 'terms', 'codeOfConduct', 'moderationInformation', 'administrator' ]) { + this.html[ key ] = await this.markdownService.textMarkdownToHTML(res.instance[ key ]) + } + + const languagesArray = this.serverService.getVideoLanguages() + const categoriesArray = this.serverService.getVideoCategories() + + this.languages = res.instance.languages + .map(l => { + const languageObj = languagesArray.find(la => la.id === l) + + return peertubeTranslate(languageObj.label, translations) + }) + + this.categories = res.instance.categories + .map(c => { + const categoryObj = categoriesArray.find(ca => ca.id === c) + + return peertubeTranslate(categoryObj.label, translations) + }) + }, + + () => this.notifier.error(this.i18n('Cannot get about information from server')) + ) } openContactModal () { return this.contactAdminModal.show() } - } -- 2.25.1