mirror of
https://github.com/Ombi-app/Ombi.git
synced 2025-08-14 02:26:55 -07:00
fix(sonarr): 🐛 Improved the error handling in the sonarr settings page in the UI
This should hopefully prevent some odd situations where the settings are in a odd state #4877
This commit is contained in:
parent
605e746fce
commit
fcd78fee61
2 changed files with 40 additions and 8 deletions
|
@ -1,7 +1,7 @@
|
|||
import { Component, OnInit } from "@angular/core";
|
||||
import { UntypedFormBuilder, FormControl, UntypedFormGroup, Validators } from "@angular/forms";
|
||||
import { UntypedFormBuilder, UntypedFormGroup, Validators } from "@angular/forms";
|
||||
import { SonarrFacade } from "app/state/sonarr/sonarr.facade";
|
||||
import { finalize, map } from "rxjs";
|
||||
import { catchError, finalize, map, of } from "rxjs";
|
||||
|
||||
import { ILanguageProfiles, ISonarrProfile, ISonarrRootFolder, ITag } from "../../interfaces";
|
||||
|
||||
|
@ -95,7 +95,7 @@ export class SonarrComponent implements OnInit {
|
|||
this.tags = [];
|
||||
this.animeTags = [];
|
||||
|
||||
if (version.length > 0) {
|
||||
if (version?.length > 0) {
|
||||
this.sonarrVersion = version[0];
|
||||
}
|
||||
|
||||
|
@ -132,11 +132,19 @@ export class SonarrComponent implements OnInit {
|
|||
public getProfiles(form: UntypedFormGroup) {
|
||||
this.profilesRunning = true;
|
||||
this.sonarrService.getQualityProfiles(form.value)
|
||||
.pipe(catchError((_) => {
|
||||
this.notificationService.error("Could not load Quality Profiles");
|
||||
return of([]);
|
||||
}))
|
||||
.subscribe(x => {
|
||||
this.profilesRunning = false;
|
||||
if (x.length === 0) {
|
||||
return;
|
||||
}
|
||||
this.qualities = x;
|
||||
this.qualitiesAnime = x;
|
||||
this.qualities.unshift({ name: "Please Select", id: -1 });
|
||||
this.profilesRunning = false;
|
||||
|
||||
this.notificationService.success("Successfully retrieved the Quality Profiles");
|
||||
});
|
||||
}
|
||||
|
@ -144,12 +152,19 @@ export class SonarrComponent implements OnInit {
|
|||
public getRootFolders(form: UntypedFormGroup) {
|
||||
this.rootFoldersRunning = true;
|
||||
this.sonarrService.getRootFolders(form.value)
|
||||
.pipe(catchError((_) => {
|
||||
this.notificationService.error("Could not load Root Folders");
|
||||
return of([]);
|
||||
}))
|
||||
.subscribe(x => {
|
||||
this.rootFoldersRunning = false;
|
||||
if (x.length === 0) {
|
||||
return;
|
||||
}
|
||||
this.rootFolders = x;
|
||||
this.rootFolders.unshift({ path: "Please Select", id: -1 });
|
||||
this.rootFoldersAnime = x;
|
||||
|
||||
this.rootFoldersRunning = false;
|
||||
this.notificationService.success("Successfully retrieved the Root Folders");
|
||||
});
|
||||
}
|
||||
|
@ -157,11 +172,18 @@ export class SonarrComponent implements OnInit {
|
|||
public getLanguageProfiles(form: UntypedFormGroup) {
|
||||
this.langRunning = true;
|
||||
this.sonarrService.getV3LanguageProfiles(form.value)
|
||||
.pipe(catchError((_) => {
|
||||
this.notificationService.error("Could not load Language Profiles");
|
||||
return of([]);
|
||||
}))
|
||||
.subscribe(x => {
|
||||
this.langRunning = false;
|
||||
if (x.length === 0) {
|
||||
return;
|
||||
}
|
||||
this.languageProfiles = x;
|
||||
this.languageProfilesAnime = x;
|
||||
|
||||
this.langRunning = false;
|
||||
this.notificationService.success("Successfully retrieved the Language Profiles");
|
||||
});
|
||||
}
|
||||
|
@ -169,11 +191,18 @@ export class SonarrComponent implements OnInit {
|
|||
public getTags(form: UntypedFormGroup) {
|
||||
this.tagsRunning = true;
|
||||
this.sonarrService.getTags(form.value).pipe(
|
||||
catchError((_) => {
|
||||
this.notificationService.error("Could not load Tags");
|
||||
return of([]);
|
||||
}),
|
||||
finalize(() => {
|
||||
this.tagsRunning = false;
|
||||
if (this.tags.length === 0) {
|
||||
return;
|
||||
}
|
||||
this.animeTags.unshift({ label: "None", id: -1 });
|
||||
this.tags.unshift({ label: "None", id: -1 });
|
||||
this.notificationService.success("Successfully retrieved the Tags");
|
||||
this.notificationService.success("Successfully retrieved the Tags")
|
||||
}),
|
||||
map(result => {
|
||||
this.tags = result;
|
||||
|
@ -204,16 +233,19 @@ export class SonarrComponent implements OnInit {
|
|||
if (form.controls.defaultQualityProfile) {
|
||||
if (form.controls.defaultQualityProfile.value === "-1") {
|
||||
this.notificationService.error("Please check your entered values");
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (form.controls.defaultRootPath) {
|
||||
if (form.controls.defaultRootPath.value === "Please Select") {
|
||||
this.notificationService.error("Please check your entered values");
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (form.controls.languageProfile) {
|
||||
if (form.controls.languageProfile.value === "Please Select") {
|
||||
this.notificationService.error("Please check your entered values");
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (form.controls.animeTag.value == -1) {
|
||||
|
|
|
@ -31,7 +31,7 @@ export class SonarrSettingsState {
|
|||
}
|
||||
|
||||
@Action(UpdateSettings)
|
||||
public enable(ctx: StateContext<SonarrState>, { settings }: UpdateSettings): Observable<SonarrState> {
|
||||
public update(ctx: StateContext<SonarrState>, { settings }: UpdateSettings): Observable<SonarrState> {
|
||||
const state = ctx.getState();
|
||||
return this.settingsService.saveSonarr(settings).pipe(
|
||||
tap((_) => ctx.setState({...state, settings})),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue