mirror of
https://github.com/Cleanuparr/Cleanuparr.git
synced 2026-03-24 09:03:38 -04:00
Fix the Malware Blocker page not displaying validation errors (#473)
This commit is contained in:
@@ -14,8 +14,11 @@ export const errorInterceptor: HttpInterceptorFn = (req, next) => {
|
||||
if (error.error instanceof ErrorEvent) {
|
||||
// Client-side error
|
||||
message = error.error.message;
|
||||
} else if (typeof error.error === 'string') {
|
||||
// Server-side error with plain string body
|
||||
message = error.error;
|
||||
} else {
|
||||
// Server-side error
|
||||
// Server-side error with JSON body
|
||||
message = error.error?.error
|
||||
?? error.error?.message
|
||||
?? error.message
|
||||
|
||||
@@ -70,7 +70,7 @@
|
||||
</app-card>
|
||||
|
||||
@if (enabled()) {
|
||||
<app-accordion header="Arr Blocklists" subtitle="Per-application blocklist configuration" [(expanded)]="arrExpanded">
|
||||
<app-accordion header="Arr Blocklists" subtitle="Per-application blocklist configuration" [(expanded)]="arrExpanded" [error]="noBlocklistError()">
|
||||
@for (name of arrNames; track name) {
|
||||
<div class="arr-blocklist">
|
||||
<h4 class="arr-blocklist__title">{{ capitalize(name) }}</h4>
|
||||
|
||||
@@ -6,6 +6,7 @@ import {
|
||||
type SelectOption,
|
||||
} from '@ui';
|
||||
import { MalwareBlockerApi } from '@core/api/malware-blocker.api';
|
||||
import { ApiError } from '@core/interceptors/error.interceptor';
|
||||
import { ToastService } from '@core/services/toast.service';
|
||||
import { MalwareBlockerConfig, BlocklistSettings, MalwareScheduleOptions } from '@shared/models/malware-blocker-config.model';
|
||||
import { BlocklistType, ScheduleUnit } from '@shared/models/enums';
|
||||
@@ -120,7 +121,18 @@ export class MalwareBlockerComponent implements OnInit, HasPendingChanges {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
readonly noBlocklistError = computed(() => {
|
||||
if (!this.enabled()) return undefined;
|
||||
const blocklists = this.arrBlocklists();
|
||||
const hasAnyEnabled = ARR_NAMES.some(name => blocklists[name]?.enabled);
|
||||
if (!hasAnyEnabled) {
|
||||
return 'At least one blocklist must be configured';
|
||||
}
|
||||
return undefined;
|
||||
});
|
||||
|
||||
readonly hasErrors = computed(() => {
|
||||
if (this.noBlocklistError()) return true;
|
||||
if (this.scheduleEveryError()) return true;
|
||||
if (this.cronError()) return true;
|
||||
if (this.chipInputs().some(c => c.hasUncommittedInput())) return true;
|
||||
@@ -225,8 +237,10 @@ export class MalwareBlockerComponent implements OnInit, HasPendingChanges {
|
||||
setTimeout(() => this.saved.set(false), 1500);
|
||||
this.savedSnapshot.set(this.buildSnapshot());
|
||||
},
|
||||
error: () => {
|
||||
this.toast.error('Failed to save malware blocker settings');
|
||||
error: (err: ApiError) => {
|
||||
this.toast.error(err.statusCode === 400
|
||||
? err.message
|
||||
: 'Failed to save malware blocker settings');
|
||||
this.saving.set(false);
|
||||
},
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user