diff options
author | Chocobozzz <me@florianbigard.com> | 2021-02-10 12:06:26 +0100 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2021-02-10 12:06:26 +0100 |
commit | 45ba09fef3b970fb916ffb1b0ac7509db7bbdde6 (patch) | |
tree | dc0875d5c30dc895b9576eeec9711dc9a6c10774 | |
parent | 4e55c132a007aa5466e1ac95a998df3ca88f3fb7 (diff) | |
download | PeerTube-45ba09fef3b970fb916ffb1b0ac7509db7bbdde6.tar.gz PeerTube-45ba09fef3b970fb916ffb1b0ac7509db7bbdde6.tar.zst PeerTube-45ba09fef3b970fb916ffb1b0ac7509db7bbdde6.zip |
Improve edit config submit error
3 files changed, 34 insertions, 4 deletions
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 4596a130e..b6365614d 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 | |||
@@ -54,11 +54,16 @@ | |||
54 | <div class="form-row mt-4"> <!-- submit placement block --> | 54 | <div class="form-row mt-4"> <!-- submit placement block --> |
55 | <div class="col-md-7 col-xl-5"></div> | 55 | <div class="col-md-7 col-xl-5"></div> |
56 | <div class="col-md-5 col-xl-5"> | 56 | <div class="col-md-5 col-xl-5"> |
57 | <span class="form-error submit-error" i18n *ngIf="!form.valid"> | ||
58 | It seems like the configuration is invalid. Please search for potential errors in the different tabs. | ||
59 | 57 | ||
60 | {{ formErrors }} | 58 | <div class="form-error submit-error" i18n *ngIf="!form.valid"> |
61 | </span> | 59 | There are errors in the form: |
60 | |||
61 | <ul> | ||
62 | <li *ngFor="let error of grabAllErrors()"> | ||
63 | {{ error }} | ||
64 | </li> | ||
65 | </ul> | ||
66 | </div> | ||
62 | 67 | ||
63 | <span class="form-error submit-error" i18n *ngIf="!hasLiveAllowReplayConsistentOptions()"> | 68 | <span class="form-error submit-error" i18n *ngIf="!hasLiveAllowReplayConsistentOptions()"> |
64 | You cannot allow live replay if you don't enable transcoding. | 69 | You cannot allow live replay if you don't enable transcoding. |
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 bbdf1bfbe..2c7a10937 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 | |||
@@ -290,6 +290,25 @@ export class EditCustomConfigComponent extends FormReactive implements OnInit { | |||
290 | this.router.navigate([], { fragment: this.activeNav }) | 290 | this.router.navigate([], { fragment: this.activeNav }) |
291 | } | 291 | } |
292 | 292 | ||
293 | grabAllErrors (errorObjectArg?: any) { | ||
294 | const errorObject = errorObjectArg || this.formErrors | ||
295 | |||
296 | let acc: string[] = [] | ||
297 | |||
298 | for (const key of Object.keys(errorObject)) { | ||
299 | const value = errorObject[key] | ||
300 | if (!value) continue | ||
301 | |||
302 | if (typeof value === 'string') { | ||
303 | acc.push(value) | ||
304 | } else { | ||
305 | acc = acc.concat(this.grabAllErrors(value)) | ||
306 | } | ||
307 | } | ||
308 | |||
309 | return acc | ||
310 | } | ||
311 | |||
293 | private updateForm () { | 312 | private updateForm () { |
294 | this.form.patchValue(this.customConfig) | 313 | this.form.patchValue(this.customConfig) |
295 | } | 314 | } |
diff --git a/client/src/app/+admin/config/edit-custom-config/edit-live-configuration.component.html b/client/src/app/+admin/config/edit-custom-config/edit-live-configuration.component.html index 65fc31412..5d826fbe9 100644 --- a/client/src/app/+admin/config/edit-custom-config/edit-live-configuration.component.html +++ b/client/src/app/+admin/config/edit-custom-config/edit-live-configuration.component.html | |||
@@ -45,6 +45,8 @@ | |||
45 | <input type="number" name="liveMaxInstanceLives" formControlName="maxInstanceLives" /> | 45 | <input type="number" name="liveMaxInstanceLives" formControlName="maxInstanceLives" /> |
46 | <span i18n>{form.value['live']['maxInstanceLives'], plural, =1 {live} other {lives}}</span> | 46 | <span i18n>{form.value['live']['maxInstanceLives'], plural, =1 {live} other {lives}}</span> |
47 | </div> | 47 | </div> |
48 | |||
49 | <div *ngIf="formErrors.live.maxInstanceLives" class="form-error">{{ formErrors.live.maxInstanceLives }}</div> | ||
48 | </div> | 50 | </div> |
49 | 51 | ||
50 | <div class="form-group" [ngClass]="getDisabledLiveClass()"> | 52 | <div class="form-group" [ngClass]="getDisabledLiveClass()"> |
@@ -56,6 +58,8 @@ | |||
56 | <input type="number" name="liveMaxUserLives" formControlName="maxUserLives" /> | 58 | <input type="number" name="liveMaxUserLives" formControlName="maxUserLives" /> |
57 | <span i18n>{form.value['live']['maxUserLives'], plural, =1 {live} other {lives}}</span> | 59 | <span i18n>{form.value['live']['maxUserLives'], plural, =1 {live} other {lives}}</span> |
58 | </div> | 60 | </div> |
61 | |||
62 | <div *ngIf="formErrors.live.maxUserLives" class="form-error">{{ formErrors.live.maxUserLives }}</div> | ||
59 | </div> | 63 | </div> |
60 | 64 | ||
61 | <div class="form-group" [ngClass]="getDisabledLiveClass()"> | 65 | <div class="form-group" [ngClass]="getDisabledLiveClass()"> |
@@ -65,6 +69,8 @@ | |||
65 | labelForId="liveMaxDuration" [items]="liveMaxDurationOptions" formControlName="maxDuration" | 69 | labelForId="liveMaxDuration" [items]="liveMaxDurationOptions" formControlName="maxDuration" |
66 | bindLabel="label" bindValue="value" [clearable]="false" [searchable]="true" | 70 | bindLabel="label" bindValue="value" [clearable]="false" [searchable]="true" |
67 | ></my-select-options> | 71 | ></my-select-options> |
72 | |||
73 | <div *ngIf="formErrors.live.maxDuration" class="form-error">{{ formErrors.live.maxDuration }}</div> | ||
68 | </div> | 74 | </div> |
69 | 75 | ||
70 | </ng-container> | 76 | </ng-container> |