Add hardware information in instance config

This commit is contained in:
Chocobozzz 2019-09-05 09:43:35 +02:00 committed by Chocobozzz
parent 592c735c19
commit be04c6fdab
14 changed files with 62 additions and 4 deletions

View File

@ -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">

View File

@ -22,7 +22,8 @@ export class AboutInstanceComponent implements OnInit {
terms: '',
codeOfConduct: '',
moderationInformation: '',
administrator: ''
administrator: '',
hardwareInformation: ''
}
creationReason = ''

View File

@ -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>

View File

@ -107,6 +107,8 @@ export class EditCustomConfigComponent extends FormReactive implements OnInit {
maintenanceLifetime: null,
businessModel: null,
hardwareInformation: null,
categories: null,
languages: null,

View 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 ])
}

View 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

View 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

View 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,

View 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') || [] },

View 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 ],

View 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 () {

View 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 ],

View File

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

View File

@ -13,6 +13,7 @@ export interface CustomConfig {
administrator: string
maintenanceLifetime: string
businessModel: string
hardwareInformation: string
languages: string[]
categories: number[]