Browse Source

Add hardware information in instance config

Chocobozzz 3 months ago
parent
commit
be04c6fdab

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

@@ -73,11 +73,21 @@
73 73
       <div [innerHTML]="html.codeOfConduct"></div>
74 74
     </div>
75 75
 
76
-    <div class="block terms" id="terms-section">
76
+    <div class="block terms">
77 77
       <div i18n class="section-title">Terms</div>
78 78
 
79 79
       <div [innerHTML]="html.terms"></div>
80 80
     </div>
81
+
82
+    <div class="middle-title" *ngIf="html.hardwareInformation">
83
+      Other information
84
+    </div>
85
+
86
+    <div class="block hardware-information">
87
+      <div i18n class="section-title">Hardware information</div>
88
+
89
+      <div [innerHTML]="html.hardwareInformation"></div>
90
+    </div>
81 91
   </div>
82 92
 
83 93
   <div class="col-md-12 col-xl-6">

+ 2
- 1
client/src/app/+about/about-instance/about-instance.component.ts View File

@@ -22,7 +22,8 @@ export class AboutInstanceComponent implements OnInit {
22 22
     terms: '',
23 23
     codeOfConduct: '',
24 24
     moderationInformation: '',
25
-    administrator: ''
25
+    administrator: '',
26
+    hardwareInformation: ''
26 27
   }
27 28
 
28 29
   creationReason = ''

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

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

+ 2
- 0
client/src/app/+admin/config/edit-custom-config/edit-custom-config.component.ts View File

@@ -107,6 +107,8 @@ export class EditCustomConfigComponent extends FormReactive implements OnInit {
107 107
         maintenanceLifetime: null,
108 108
         businessModel: null,
109 109
 
110
+        hardwareInformation: null,
111
+
110 112
         categories: null,
111 113
         languages: null,
112 114
 

+ 3
- 2
client/src/app/shared/instance/instance.service.ts View File

@@ -46,10 +46,11 @@ export class InstanceService {
46 46
       terms: '',
47 47
       codeOfConduct: '',
48 48
       moderationInformation: '',
49
-      administrator: ''
49
+      administrator: '',
50
+      hardwareInformation: ''
50 51
     }
51 52
 
52
-    for (const key of [ 'description', 'terms', 'codeOfConduct', 'moderationInformation', 'administrator' ]) {
53
+    for (const key of Object.keys(html)) {
53 54
       html[ key ] = await this.markdownService.textMarkdownToHTML(about.instance[ key ])
54 55
     }
55 56
 

+ 4
- 0
config/default.yaml View File

@@ -255,6 +255,10 @@ instance:
255 255
   # How will you pay the PeerTube instance server? With you own funds? With users donations? Advertising?
256 256
   business_model: ''
257 257
 
258
+  # If you want to explain on what type of hardware your PeerTube instance runs
259
+  # Example: "2 vCore, 2GB RAM..."
260
+  hardware_information: '' # Supports Markdown
261
+
258 262
   # What are the main languages of your instance? To interact with your users for example
259 263
   # Uncomment or add the languages you want
260 264
   # List of supported languages: https://peertube.cpy.re/api/v1/videos/languages

+ 4
- 0
config/production.yaml.example View File

@@ -270,6 +270,10 @@ instance:
270 270
   # How will you pay the PeerTube instance server? With you own funds? With users donations? Advertising?
271 271
   business_model: ''
272 272
 
273
+  # If you want to explain on what type of hardware your PeerTube instance runs
274
+  # Example: "2 vCore, 2GB RAM..."
275
+  hardware_information: '' # Supports Markdown
276
+
273 277
   # What are the main languages of your instance? To interact with your users for example
274 278
   # Uncomment or add the languages you want
275 279
   # List of supported languages: https://peertube.cpy.re/api/v1/videos/languages

+ 3
- 0
server/controllers/api/config.ts View File

@@ -161,6 +161,8 @@ function getAbout (req: express.Request, res: express.Response) {
161 161
       terms: CONFIG.INSTANCE.TERMS,
162 162
       codeOfConduct: CONFIG.INSTANCE.CODE_OF_CONDUCT,
163 163
 
164
+      hardwareInformation: CONFIG.INSTANCE.HARDWARE_INFORMATION,
165
+
164 166
       creationReason: CONFIG.INSTANCE.CREATION_REASON,
165 167
       moderationInformation: CONFIG.INSTANCE.MODERATION_INFORMATION,
166 168
       administrator: CONFIG.INSTANCE.ADMINISTRATOR,
@@ -238,6 +240,7 @@ function customConfig (): CustomConfig {
238 240
       administrator: CONFIG.INSTANCE.ADMINISTRATOR,
239 241
       maintenanceLifetime: CONFIG.INSTANCE.MAINTENANCE_LIFETIME,
240 242
       businessModel: CONFIG.INSTANCE.BUSINESS_MODEL,
243
+      hardwareInformation: CONFIG.INSTANCE.HARDWARE_INFORMATION,
241 244
 
242 245
       languages: CONFIG.INSTANCE.LANGUAGES,
243 246
       categories: CONFIG.INSTANCE.CATEGORIES,

+ 1
- 0
server/initializers/config.ts View File

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

+ 1
- 0
server/tests/api/check-params/config.ts View File

@@ -34,6 +34,7 @@ describe('Test config API validators', function () {
34 34
       administrator: 'Kuja',
35 35
       maintenanceLifetime: 'forever',
36 36
       businessModel: 'my super business model',
37
+      hardwareInformation: '2vCore 3GB RAM',
37 38
 
38 39
       languages: [ 'en', 'es' ],
39 40
       categories: [ 1, 2 ],

+ 14
- 0
server/tests/api/server/config.ts View File

@@ -36,6 +36,7 @@ function checkInitialConfig (server: ServerInfo, data: CustomConfig) {
36 36
   expect(data.instance.administrator).to.be.empty
37 37
   expect(data.instance.maintenanceLifetime).to.be.empty
38 38
   expect(data.instance.businessModel).to.be.empty
39
+  expect(data.instance.hardwareInformation).to.be.empty
39 40
 
40 41
   expect(data.instance.languages).to.have.lengthOf(0)
41 42
   expect(data.instance.categories).to.have.lengthOf(0)
@@ -97,6 +98,7 @@ function checkUpdatedConfig (data: CustomConfig) {
97 98
   expect(data.instance.administrator).to.equal('Kuja')
98 99
   expect(data.instance.maintenanceLifetime).to.equal('forever')
99 100
   expect(data.instance.businessModel).to.equal('my super business model')
101
+  expect(data.instance.hardwareInformation).to.equal('2vCore 3GB RAM')
100 102
 
101 103
   expect(data.instance.languages).to.deep.equal([ 'en', 'es' ])
102 104
   expect(data.instance.categories).to.deep.equal([ 1, 2 ])
@@ -219,6 +221,7 @@ describe('Test config', function () {
219 221
         administrator: 'Kuja',
220 222
         maintenanceLifetime: 'forever',
221 223
         businessModel: 'my super business model',
224
+        hardwareInformation: '2vCore 3GB RAM',
222 225
 
223 226
         languages: [ 'en', 'es' ],
224 227
         categories: [ 1, 2 ],
@@ -362,6 +365,17 @@ describe('Test config', function () {
362 365
     expect(data.instance.shortDescription).to.equal('my short description')
363 366
     expect(data.instance.description).to.equal('my super description')
364 367
     expect(data.instance.terms).to.equal('my super terms')
368
+    expect(data.instance.codeOfConduct).to.equal('my super coc')
369
+
370
+    expect(data.instance.creationReason).to.equal('my super creation reason')
371
+    expect(data.instance.moderationInformation).to.equal('my super moderation information')
372
+    expect(data.instance.administrator).to.equal('Kuja')
373
+    expect(data.instance.maintenanceLifetime).to.equal('forever')
374
+    expect(data.instance.businessModel).to.equal('my super business model')
375
+    expect(data.instance.hardwareInformation).to.equal('2vCore 3GB RAM')
376
+
377
+    expect(data.instance.languages).to.deep.equal([ 'en', 'es' ])
378
+    expect(data.instance.categories).to.deep.equal([ 1, 2 ])
365 379
   })
366 380
 
367 381
   it('Should remove the custom configuration', async function () {

+ 1
- 0
shared/extra-utils/server/config.ts View File

@@ -60,6 +60,7 @@ function updateCustomSubConfig (url: string, token: string, newConfig: DeepParti
60 60
       administrator: 'Kuja',
61 61
       maintenanceLifetime: 'forever',
62 62
       businessModel: 'my super business model',
63
+      hardwareInformation: '2vCore 3GB RAM',
63 64
 
64 65
       languages: [ 'en', 'es' ],
65 66
       categories: [ 1, 2 ],

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

@@ -6,6 +6,7 @@ export interface About {
6 6
     terms: string
7 7
 
8 8
     codeOfConduct: string
9
+    hardwareInformation: string
9 10
 
10 11
     creationReason: string
11 12
     moderationInformation: string

+ 1
- 0
shared/models/server/custom-config.model.ts View File

@@ -13,6 +13,7 @@ export interface CustomConfig {
13 13
     administrator: string
14 14
     maintenanceLifetime: string
15 15
     businessModel: string
16
+    hardwareInformation: string
16 17
 
17 18
     languages: string[]
18 19
     categories: number[]

Loading…
Cancel
Save