Fix setting max channel sync in config

Signed-off-by: Chocobozzz <me@florianbigard.com>
This commit is contained in:
Chocobozzz 2024-11-25 16:31:52 +01:00
parent d6eb99edb2
commit a253a8088a
No known key found for this signature in database
GPG Key ID: 583A612D890159BE
4 changed files with 29 additions and 6 deletions

View File

@ -321,6 +321,20 @@
</ng-container>
</my-peertube-checkbox>
</div>
<div class="form-group">
<label i18n for="videoChannelSynchronizationMaxPerUser">Max channel synchronization per user</label>
<div class="number-with-unit">
<input
type="number" min="1" id="videoChannelSynchronizationMaxPerUser" class="form-control"
formControlName="maxPerUser" [ngClass]="{ 'input-error': formErrors['import']['videoChannelSynchronization']['maxPerUser'] }"
>
<span i18n>{form.value['import']['videoChannelSynchronization']['maxPerUser'], plural, =1 {sync} other {syncs}}</span>
</div>
<div *ngIf="formErrors.import.videoChannelSynchronization.maxPerUser" class="form-error" role="alert">{{ formErrors.import.videoChannelSynchronization.maxPerUser }}</div>
</div>
</ng-container>
</ng-container>

View File

@ -16,6 +16,7 @@ import {
INSTANCE_SHORT_DESCRIPTION_VALIDATOR,
MAX_INSTANCE_LIVES_VALIDATOR,
MAX_LIVE_DURATION_VALIDATOR,
MAX_SYNC_PER_USER,
MAX_USER_LIVES_VALIDATOR,
MAX_VIDEO_CHANNELS_PER_USER_VALIDATOR,
SEARCH_INDEX_URL_VALIDATOR,
@ -182,7 +183,9 @@ export class EditCustomConfigComponent extends FormReactive implements OnInit {
}
},
videoChannelSynchronization: {
enabled: null
enabled: null,
maxPerUser: MAX_SYNC_PER_USER
},
users: {
enabled: null

View File

@ -77,6 +77,7 @@ export class RestExtractor {
}
private buildErrorMessage (err: any) {
console.log(err)
if (err.error instanceof Error) {
// A client-side or network error occurred. Handle it accordingly.
const errorMessage = err.error.detail || err.error.title
@ -115,10 +116,6 @@ export class RestExtractor {
.join('. ')
}
if (err.error?.error) {
return err.error.error
}
if (err.status === HttpStatusCode.PAYLOAD_TOO_LARGE_413) {
return $localize`Media is too large for the server. Please contact you administrator if you want to increase the limit size.`
}
@ -142,6 +139,6 @@ export class RestExtractor {
return $localize`Server is unavailable. Please retry later.`
}
return $localize`Unknown server error`
return err.error?.error || err.error?.detail || err.error?.title || $localize`Unknown server error`
}
}

View File

@ -106,6 +106,15 @@ export const MAX_VIDEO_CHANNELS_PER_USER_VALIDATOR: BuildFormValidator = {
}
}
export const MAX_SYNC_PER_USER: BuildFormValidator = {
VALIDATORS: [ Validators.required, Validators.min(1), Validators.pattern('[0-9]+') ],
MESSAGES: {
required: $localize`Max synchronizations per user is required.`,
min: $localize`Max synchronizations per user must be greater or equal to 1.`,
pattern: $localize`Max synchronizations per user must be a number.`
}
}
export const CONCURRENCY_VALIDATOR: BuildFormValidator = {
VALIDATORS: [ Validators.required, Validators.min(1) ],
MESSAGES: {