fix(radarr): 🐛 Enable validation on the radarr settings page

pull/5174/head
Jamie Rees 5 months ago
parent fc1ad67246
commit 0af3511e81

@ -105,7 +105,6 @@
"options": { "options": {
"tsConfig": [ "tsConfig": [
"src/tsconfig.json" "src/tsconfig.json"
"src/tsconfig.json"
], ],
"exclude": [ "exclude": [
"**/node_modules/**" "**/node_modules/**"

@ -293,7 +293,6 @@ export class CarouselListComponent implements OnInit {
} }
this.discoverResults.push(...tempResults); this.discoverResults.push(...tempResults);
this.carousel.ngAfterContentInit();
this.finishLoading(); this.finishLoading();
} }

@ -28,10 +28,12 @@
<mat-form-field appearance="outline" > <mat-form-field appearance="outline" >
<mat-label>Hostname or IP</mat-label> <mat-label>Hostname or IP</mat-label>
<input matInput formControlName="ip"> <input matInput formControlName="ip">
<mat-error>Please enter a valid hostname or ip address</mat-error>
</mat-form-field> </mat-form-field>
<mat-form-field appearance="outline" > <mat-form-field appearance="outline" >
<mat-label>Port</mat-label> <mat-label>Port</mat-label>
<input matInput formControlName="port"> <input matInput formControlName="port">
<mat-error>Please enter a valid port number</mat-error>
</mat-form-field> </mat-form-field>
<mat-slide-toggle formControlName="ssl"> <mat-slide-toggle formControlName="ssl">
SSL SSL
@ -42,6 +44,7 @@
<mat-form-field appearance="outline" > <mat-form-field appearance="outline" >
<mat-label>API key</mat-label> <mat-label>API key</mat-label>
<input matInput formControlName="apiKey"> <input matInput formControlName="apiKey">
<mat-error>Please enter an API Key</mat-error>
</mat-form-field> </mat-form-field>
</div> </div>
<div class="md-form-field"> <div class="md-form-field">
@ -65,6 +68,7 @@
{{quality.name}} {{quality.name}}
</mat-option> </mat-option>
</mat-select> </mat-select>
<mat-error>Please select a value</mat-error>
</mat-form-field> </mat-form-field>
</div> </div>
@ -80,6 +84,7 @@
{{folder.path}} {{folder.path}}
</mat-option> </mat-option>
</mat-select> </mat-select>
<mat-error>Please select a value</mat-error>
</mat-form-field> </mat-form-field>
</div> </div>
@ -95,6 +100,7 @@
{{tag.label}} {{tag.label}}
</mat-option> </mat-option>
</mat-select> </mat-select>
<mat-error>Please select a value</mat-error>
</mat-form-field> </mat-form-field>
</div> </div>
@ -107,6 +113,7 @@
{{min.name}} {{min.name}}
</mat-option> </mat-option>
</mat-select> </mat-select>
<mat-error>Please select a value</mat-error>
</mat-form-field> </mat-form-field>
</div> </div>
</div> </div>

@ -63,14 +63,14 @@ export class RadarrFormComponent implements OnInit {
} }
public toggleValidators() { public toggleValidators() {
debugger;
const enabled = this.form.controls.enabled.value as boolean; const enabled = this.form.controls.enabled.value as boolean;
this.form.controls.apiKey.setValidators(enabled ? [Validators.required] : null); this.form.controls.apiKey.setValidators(enabled ? [Validators.required] : null);
this.form.controls.defaultQualityProfile.setValidators(enabled ? [Validators.required] : null); this.form.controls.defaultQualityProfile.setValidators(enabled ? [Validators.required, Validators.min(1)] : null);
this.form.controls.defaultRootPath.setValidators(enabled ? [Validators.required] : null); this.form.controls.defaultRootPath.setValidators(enabled ? [Validators.required] : null);
this.form.controls.ip.setValidators(enabled ? [Validators.required] : null); this.form.controls.ip.setValidators(enabled ? [Validators.required] : null);
this.form.controls.port.setValidators(enabled ? [Validators.required] : null); this.form.controls.port.setValidators(enabled ? [Validators.required, Validators.min(1)] : null);
this.form.controls.minimumAvailability.setValidators(enabled ? [Validators.required] : null); this.form.controls.minimumAvailability.setValidators(enabled ? [Validators.required] : null);
enabled ? this.form.markAllAsTouched() : this.form.markAsUntouched();
} }
public getProfiles(form: UntypedFormGroup) { public getProfiles(form: UntypedFormGroup) {
@ -120,6 +120,7 @@ export class RadarrFormComponent implements OnInit {
this.notificationService.success("Successfully connected to Radarr!"); this.notificationService.success("Successfully connected to Radarr!");
} else if (result.expectedSubDir) { } else if (result.expectedSubDir) {
this.notificationService.error("Your Radarr Base URL must be set to " + result.expectedSubDir); this.notificationService.error("Your Radarr Base URL must be set to " + result.expectedSubDir);
form.controls.subDir.setValue(result.expectedSubDir);
} else { } else {
this.notificationService.error("We could not connect to Radarr!"); this.notificationService.error("We could not connect to Radarr!");
} }

Loading…
Cancel
Save