From: Chocobozzz Date: Thu, 5 Sep 2019 07:43:35 +0000 (+0200) Subject: Add hardware information in instance config X-Git-Tag: v2.0.0-rc.1~78 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=be04c6fdab5d91a7a57fa3ff36cde22a549c29da;p=oweals%2Fpeertube.git Add hardware information in instance config --- 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 8b21137af..9499bbe4e 100644 --- a/client/src/app/+about/about-instance/about-instance.component.html +++ b/client/src/app/+about/about-instance/about-instance.component.html @@ -73,11 +73,21 @@
-
+
Terms
+ +
+ Other information +
+ +
+
Hardware information
+ +
+
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 b6cade4fe..16ccae2e2 100644 --- a/client/src/app/+about/about-instance/about-instance.component.ts +++ b/client/src/app/+about/about-instance/about-instance.component.ts @@ -22,7 +22,8 @@ export class AboutInstanceComponent implements OnInit { terms: '', codeOfConduct: '', moderationInformation: '', - administrator: '' + administrator: '', + hardwareInformation: '' } creationReason = '' diff --git a/client/src/app/+admin/config/edit-custom-config/edit-custom-config.component.html b/client/src/app/+admin/config/edit-custom-config/edit-custom-config.component.html index ef24e5b24..54115055a 100644 --- a/client/src/app/+admin/config/edit-custom-config/edit-custom-config.component.html +++ b/client/src/app/+admin/config/edit-custom-config/edit-custom-config.component.html @@ -174,6 +174,20 @@
{{ formErrors.instance.businessModel }}
+
Other information
+ +
+ +
2vCore 2GB RAM/or directly the link to the server you rent etc
+ + + +
{{ formErrors.instance.hardwareInformation }}
+
+ diff --git a/client/src/app/+admin/config/edit-custom-config/edit-custom-config.component.ts b/client/src/app/+admin/config/edit-custom-config/edit-custom-config.component.ts index e6f56bc97..0a69f3481 100644 --- a/client/src/app/+admin/config/edit-custom-config/edit-custom-config.component.ts +++ b/client/src/app/+admin/config/edit-custom-config/edit-custom-config.component.ts @@ -107,6 +107,8 @@ export class EditCustomConfigComponent extends FormReactive implements OnInit { maintenanceLifetime: null, businessModel: null, + hardwareInformation: null, + categories: null, languages: null, diff --git a/client/src/app/shared/instance/instance.service.ts b/client/src/app/shared/instance/instance.service.ts index 7c76bc98b..44b413fa4 100644 --- a/client/src/app/shared/instance/instance.service.ts +++ b/client/src/app/shared/instance/instance.service.ts @@ -46,10 +46,11 @@ export class InstanceService { terms: '', codeOfConduct: '', moderationInformation: '', - administrator: '' + administrator: '', + hardwareInformation: '' } - for (const key of [ 'description', 'terms', 'codeOfConduct', 'moderationInformation', 'administrator' ]) { + for (const key of Object.keys(html)) { html[ key ] = await this.markdownService.textMarkdownToHTML(about.instance[ key ]) } diff --git a/config/default.yaml b/config/default.yaml index 7ed096dcd..5ebfdeddb 100644 --- a/config/default.yaml +++ b/config/default.yaml @@ -255,6 +255,10 @@ instance: # How will you pay the PeerTube instance server? With you own funds? With users donations? Advertising? business_model: '' + # If you want to explain on what type of hardware your PeerTube instance runs + # Example: "2 vCore, 2GB RAM..." + hardware_information: '' # Supports Markdown + # What are the main languages of your instance? To interact with your users for example # Uncomment or add the languages you want # List of supported languages: https://peertube.cpy.re/api/v1/videos/languages diff --git a/config/production.yaml.example b/config/production.yaml.example index b86068bde..96d676a35 100644 --- a/config/production.yaml.example +++ b/config/production.yaml.example @@ -270,6 +270,10 @@ instance: # How will you pay the PeerTube instance server? With you own funds? With users donations? Advertising? business_model: '' + # If you want to explain on what type of hardware your PeerTube instance runs + # Example: "2 vCore, 2GB RAM..." + hardware_information: '' # Supports Markdown + # What are the main languages of your instance? To interact with your users for example # Uncomment or add the languages you want # List of supported languages: https://peertube.cpy.re/api/v1/videos/languages diff --git a/server/controllers/api/config.ts b/server/controllers/api/config.ts index 909907ad6..39a124fc5 100644 --- a/server/controllers/api/config.ts +++ b/server/controllers/api/config.ts @@ -161,6 +161,8 @@ function getAbout (req: express.Request, res: express.Response) { terms: CONFIG.INSTANCE.TERMS, codeOfConduct: CONFIG.INSTANCE.CODE_OF_CONDUCT, + hardwareInformation: CONFIG.INSTANCE.HARDWARE_INFORMATION, + creationReason: CONFIG.INSTANCE.CREATION_REASON, moderationInformation: CONFIG.INSTANCE.MODERATION_INFORMATION, administrator: CONFIG.INSTANCE.ADMINISTRATOR, @@ -238,6 +240,7 @@ function customConfig (): CustomConfig { administrator: CONFIG.INSTANCE.ADMINISTRATOR, maintenanceLifetime: CONFIG.INSTANCE.MAINTENANCE_LIFETIME, businessModel: CONFIG.INSTANCE.BUSINESS_MODEL, + hardwareInformation: CONFIG.INSTANCE.HARDWARE_INFORMATION, languages: CONFIG.INSTANCE.LANGUAGES, categories: CONFIG.INSTANCE.CATEGORIES, diff --git a/server/initializers/config.ts b/server/initializers/config.ts index 8df411ca5..164d714d6 100644 --- a/server/initializers/config.ts +++ b/server/initializers/config.ts @@ -217,6 +217,7 @@ const CONFIG = { get ADMINISTRATOR () { return config.get('instance.administrator') }, get MAINTENANCE_LIFETIME () { return config.get('instance.maintenance_lifetime') }, get BUSINESS_MODEL () { return config.get('instance.business_model') }, + get HARDWARE_INFORMATION () { return config.get('instance.hardware_information') }, get LANGUAGES () { return config.get('instance.languages') || [] }, get CATEGORIES () { return config.get('instance.categories') || [] }, diff --git a/server/tests/api/check-params/config.ts b/server/tests/api/check-params/config.ts index 9b902a1cd..9435bb1e8 100644 --- a/server/tests/api/check-params/config.ts +++ b/server/tests/api/check-params/config.ts @@ -34,6 +34,7 @@ describe('Test config API validators', function () { administrator: 'Kuja', maintenanceLifetime: 'forever', businessModel: 'my super business model', + hardwareInformation: '2vCore 3GB RAM', languages: [ 'en', 'es' ], categories: [ 1, 2 ], diff --git a/server/tests/api/server/config.ts b/server/tests/api/server/config.ts index 85d0f9702..97cc99eea 100644 --- a/server/tests/api/server/config.ts +++ b/server/tests/api/server/config.ts @@ -36,6 +36,7 @@ function checkInitialConfig (server: ServerInfo, data: CustomConfig) { expect(data.instance.administrator).to.be.empty expect(data.instance.maintenanceLifetime).to.be.empty expect(data.instance.businessModel).to.be.empty + expect(data.instance.hardwareInformation).to.be.empty expect(data.instance.languages).to.have.lengthOf(0) expect(data.instance.categories).to.have.lengthOf(0) @@ -97,6 +98,7 @@ function checkUpdatedConfig (data: CustomConfig) { expect(data.instance.administrator).to.equal('Kuja') expect(data.instance.maintenanceLifetime).to.equal('forever') expect(data.instance.businessModel).to.equal('my super business model') + expect(data.instance.hardwareInformation).to.equal('2vCore 3GB RAM') expect(data.instance.languages).to.deep.equal([ 'en', 'es' ]) expect(data.instance.categories).to.deep.equal([ 1, 2 ]) @@ -219,6 +221,7 @@ describe('Test config', function () { administrator: 'Kuja', maintenanceLifetime: 'forever', businessModel: 'my super business model', + hardwareInformation: '2vCore 3GB RAM', languages: [ 'en', 'es' ], categories: [ 1, 2 ], @@ -362,6 +365,17 @@ describe('Test config', function () { expect(data.instance.shortDescription).to.equal('my short description') expect(data.instance.description).to.equal('my super description') expect(data.instance.terms).to.equal('my super terms') + expect(data.instance.codeOfConduct).to.equal('my super coc') + + expect(data.instance.creationReason).to.equal('my super creation reason') + expect(data.instance.moderationInformation).to.equal('my super moderation information') + expect(data.instance.administrator).to.equal('Kuja') + expect(data.instance.maintenanceLifetime).to.equal('forever') + expect(data.instance.businessModel).to.equal('my super business model') + expect(data.instance.hardwareInformation).to.equal('2vCore 3GB RAM') + + expect(data.instance.languages).to.deep.equal([ 'en', 'es' ]) + expect(data.instance.categories).to.deep.equal([ 1, 2 ]) }) it('Should remove the custom configuration', async function () { diff --git a/shared/extra-utils/server/config.ts b/shared/extra-utils/server/config.ts index 66e0a008e..578dd35cf 100644 --- a/shared/extra-utils/server/config.ts +++ b/shared/extra-utils/server/config.ts @@ -60,6 +60,7 @@ function updateCustomSubConfig (url: string, token: string, newConfig: DeepParti administrator: 'Kuja', maintenanceLifetime: 'forever', businessModel: 'my super business model', + hardwareInformation: '2vCore 3GB RAM', languages: [ 'en', 'es' ], categories: [ 1, 2 ], diff --git a/shared/models/server/about.model.ts b/shared/models/server/about.model.ts index bde4e0b50..6d4ba63c4 100644 --- a/shared/models/server/about.model.ts +++ b/shared/models/server/about.model.ts @@ -6,6 +6,7 @@ export interface About { terms: string codeOfConduct: string + hardwareInformation: string creationReason: string moderationInformation: string diff --git a/shared/models/server/custom-config.model.ts b/shared/models/server/custom-config.model.ts index a7c2a3bab..c9957f825 100644 --- a/shared/models/server/custom-config.model.ts +++ b/shared/models/server/custom-config.model.ts @@ -13,6 +13,7 @@ export interface CustomConfig { administrator: string maintenanceLifetime: string businessModel: string + hardwareInformation: string languages: string[] categories: number[]