Add hardware information in instance config
authorChocobozzz <me@florianbigard.com>
Thu, 5 Sep 2019 07:43:35 +0000 (09:43 +0200)
committerChocobozzz <chocobozzz@cpy.re>
Thu, 5 Sep 2019 08:17:02 +0000 (10:17 +0200)
14 files changed:
client/src/app/+about/about-instance/about-instance.component.html
client/src/app/+about/about-instance/about-instance.component.ts
client/src/app/+admin/config/edit-custom-config/edit-custom-config.component.html
client/src/app/+admin/config/edit-custom-config/edit-custom-config.component.ts
client/src/app/shared/instance/instance.service.ts
config/default.yaml
config/production.yaml.example
server/controllers/api/config.ts
server/initializers/config.ts
server/tests/api/check-params/config.ts
server/tests/api/server/config.ts
shared/extra-utils/server/config.ts
shared/models/server/about.model.ts
shared/models/server/custom-config.model.ts

index 8b21137af63c0f98d9f06fef3b13097a7d7f0ee9..9499bbe4e6703256dcccc018424965e2ff3ecb09 100644 (file)
       <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">
index b6cade4fe12e37a672f78bf57355db31da30d166..16ccae2e27c6a879905b3e44692863ff6e5abe4c 100644 (file)
@@ -22,7 +22,8 @@ export class AboutInstanceComponent implements OnInit {
     terms: '',
     codeOfConduct: '',
     moderationInformation: '',
-    administrator: ''
+    administrator: '',
+    hardwareInformation: ''
   }
 
   creationReason = ''
index ef24e5b24687d74034be7655d325a1250b63a080..54115055ad088a6f80d356e3bff5c650a0051ddc 100644 (file)
             <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>
index e6f56bc97448f32cfffa9f85242e1ce4c97edb8b..0a69f34819fc970f7132a83f40fb00cbc2096174 100644 (file)
@@ -107,6 +107,8 @@ export class EditCustomConfigComponent extends FormReactive implements OnInit {
         maintenanceLifetime: null,
         businessModel: null,
 
+        hardwareInformation: null,
+
         categories: null,
         languages: null,
 
index 7c76bc98b5f0dd729e9c4528d71375bd71f62a73..44b413fa4263f0980de3d9ecc52d609b254d3656 100644 (file)
@@ -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 ])
     }
 
index 7ed096dcd031cdb3cbd381c03dfa0318885e0a5c..5ebfdeddb6a00ccf619aec6bed0e380c095b98db 100644 (file)
@@ -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
index b86068bde0eb2f8cac5e2cf08fb25aa5e6f8e9d6..96d676a35c65f7778bf3594d3d89e9052bb23812 100644 (file)
@@ -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
index 909907ad60c72274560644d7fe7c0bfc6f683aeb..39a124fc5382dd7efa08406a00885f0c6afb10c7 100644 (file)
@@ -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,
index 8df411ca5e6f4f242856268335f9ca4c86220114..164d714d6b94ad7fd4edd10da4324334f087830f 100644 (file)
@@ -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') || [] },
index 9b902a1cd5a511e5ba370862041f3ed4ac06accf..9435bb1e88ed6f054269cceb3aaa6198af6915b9 100644 (file)
@@ -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 ],
index 85d0f970215198fb8ccab404f3988cf8de1e46fb..97cc99eeaf892494bc22a8d8ab22ef7b4d9a16aa 100644 (file)
@@ -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 () {
index 66e0a008ec656cc0b89343fecc0f1b7b7b41de0d..578dd35cf16c33a6fe14757d534d59694f1a8a82 100644 (file)
@@ -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 ],
index bde4e0b5033af15f516bb1f03aaff40f8a0be81b..6d4ba63c48aabf16be2883818e7afcf18baed2e6 100644 (file)
@@ -6,6 +6,7 @@ export interface About {
     terms: string
 
     codeOfConduct: string
+    hardwareInformation: string
 
     creationReason: string
     moderationInformation: string
index a7c2a3bab16a77ba7dd014747fe4a8ed7b4f7e72..c9957f8256a18efeb52b4d2675036738021d0c49 100644 (file)
@@ -13,6 +13,7 @@ export interface CustomConfig {
     administrator: string
     maintenanceLifetime: string
     businessModel: string
+    hardwareInformation: string
 
     languages: string[]
     categories: number[]