From a253a8088ac47517159c50b5eeeffd3681118e97 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Mon, 25 Nov 2024 16:31:52 +0100 Subject: [PATCH] Fix setting max channel sync in config Signed-off-by: Chocobozzz --- .../edit-basic-configuration.component.html | 14 ++++++++++++++ .../edit-custom-config.component.ts | 5 ++++- client/src/app/core/rest/rest-extractor.service.ts | 7 ++----- .../form-validators/custom-config-validators.ts | 9 +++++++++ 4 files changed, 29 insertions(+), 6 deletions(-) diff --git a/client/src/app/+admin/config/edit-custom-config/edit-basic-configuration.component.html b/client/src/app/+admin/config/edit-custom-config/edit-basic-configuration.component.html index b5f31e5d9..cfd188f08 100644 --- a/client/src/app/+admin/config/edit-custom-config/edit-basic-configuration.component.html +++ b/client/src/app/+admin/config/edit-custom-config/edit-basic-configuration.component.html @@ -321,6 +321,20 @@ + +
+ + +
+ + {form.value['import']['videoChannelSynchronization']['maxPerUser'], plural, =1 {sync} other {syncs}} +
+ + +
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 7ef04f757..482a66516 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 @@ -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 diff --git a/client/src/app/core/rest/rest-extractor.service.ts b/client/src/app/core/rest/rest-extractor.service.ts index 9541306de..a4ccf13f6 100644 --- a/client/src/app/core/rest/rest-extractor.service.ts +++ b/client/src/app/core/rest/rest-extractor.service.ts @@ -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` } } diff --git a/client/src/app/shared/form-validators/custom-config-validators.ts b/client/src/app/shared/form-validators/custom-config-validators.ts index 519a1480a..bfbdb6fcf 100644 --- a/client/src/app/shared/form-validators/custom-config-validators.ts +++ b/client/src/app/shared/form-validators/custom-config-validators.ts @@ -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: {