Browse Source

Add hardware information in instance config

Chocobozzz 4 years ago
parent
commit
be04c6fdab

+ 11 - 1
client/src/app/+about/about-instance/about-instance.component.html

@@ -73,11 +73,21 @@
       <div [innerHTML]="html.codeOfConduct"></div>
     </div>
 
-    <div class="block terms" id="terms-section">
+    <div class="block terms">
       <div i18n class="section-title">Terms</div>
 
       <div [innerHTML]="html.terms"></div>
     </div>
+
+    <div class="middle-title" *ngIf="html.hardwareInformation">
+      Other information
+    </div>
+
+    <div class="block hardware-information">
+      <div i18n class="section-title">Hardware information</div>
+
+      <div [innerHTML]="html.hardwareInformation"></div>
+    </div>
   </div>
 
   <div class="col-md-12 col-xl-6">

+ 2 - 1
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 = ''

+ 14 - 0
client/src/app/+admin/config/edit-custom-config/edit-custom-config.component.html

@@ -174,6 +174,20 @@
             <div *ngIf="formErrors.instance.businessModel" class="form-error">{{ formErrors.instance.businessModel }}</div>
           </div>
 
+          <div i18n class="inner-form-title">Other information</div>
+
+          <div class="form-group">
+            <label i18n for="instanceHardwareInformation">On what server/hardware the instance runs?</label>
+            <div class="label-small-info">2vCore 2GB RAM/or directly the link to the server you rent etc</div>
+
+            <my-markdown-textarea
+              id="instanceHardwareInformation" formControlName="hardwareInformation" textareaWidth="500px" textareaHeight="75px" [previewColumn]="true"
+              [classes]="{ 'input-error': formErrors['instance.hardwareInformation'] }"
+            ></my-markdown-textarea>
+
+            <div *ngIf="formErrors.instance.hardwareInformation" class="form-error">{{ formErrors.instance.hardwareInformation }}</div>
+          </div>
+
         </ng-container>
       </ng-template>
     </ngb-tab>

+ 2 - 0
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,
 

+ 3 - 2
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 ])
     }
 

+ 4 - 0
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

+ 4 - 0
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

+ 3 - 0
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,

+ 1 - 0
server/initializers/config.ts

@@ -217,6 +217,7 @@ const CONFIG = {
     get ADMINISTRATOR () { return config.get<string>('instance.administrator') },
     get MAINTENANCE_LIFETIME () { return config.get<string>('instance.maintenance_lifetime') },
     get BUSINESS_MODEL () { return config.get<string>('instance.business_model') },
+    get HARDWARE_INFORMATION () { return config.get<string>('instance.hardware_information') },
 
     get LANGUAGES () { return config.get<string[]>('instance.languages') || [] },
     get CATEGORIES () { return config.get<number[]>('instance.categories') || [] },

+ 1 - 0
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 ],

+ 14 - 0
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 () {

+ 1 - 0
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 ],

+ 1 - 0
shared/models/server/about.model.ts

@@ -6,6 +6,7 @@ export interface About {
     terms: string
 
     codeOfConduct: string
+    hardwareInformation: string
 
     creationReason: string
     moderationInformation: string

+ 1 - 0
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[]