mirror of https://github.com/Ombi-app/Ombi
Merge pull request #4143 from Ombi-app/feature/sonarr-language-profiles-enhancements
Sonarr Language Profile Enhancementspull/4150/head v4.0.1332
commit
5bf8703c66
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -1,55 +1,92 @@
|
||||
import { Component, Inject, OnInit } from "@angular/core";
|
||||
import { MatDialogRef, MAT_DIALOG_DATA } from "@angular/material/dialog";
|
||||
import { IAdvancedData, ISonarrProfile, ISonarrRootFolder } from "../../../../../interfaces";
|
||||
import { SonarrService } from "../../../../../services";
|
||||
import {
|
||||
IAdvancedData,
|
||||
ILanguageProfiles,
|
||||
ISonarrProfile,
|
||||
ISonarrRootFolder,
|
||||
ISonarrSettings,
|
||||
} from "../../../../../interfaces";
|
||||
import { SettingsService, SonarrService } from "../../../../../services";
|
||||
|
||||
@Component({
|
||||
templateUrl: "./tv-advanced-options.component.html",
|
||||
selector: "tv-advanced-options",
|
||||
templateUrl: "./tv-advanced-options.component.html",
|
||||
selector: "tv-advanced-options",
|
||||
})
|
||||
export class TvAdvancedOptionsComponent implements OnInit {
|
||||
public sonarrProfiles: ISonarrProfile[];
|
||||
public sonarrRootFolders: ISonarrRootFolder[];
|
||||
public sonarrLanguageProfiles: ILanguageProfiles[];
|
||||
public sonarrEnabled: boolean;
|
||||
|
||||
public sonarrProfiles: ISonarrProfile[];
|
||||
public sonarrRootFolders: ISonarrRootFolder[];
|
||||
constructor(
|
||||
public dialogRef: MatDialogRef<TvAdvancedOptionsComponent>,
|
||||
@Inject(MAT_DIALOG_DATA) public data: IAdvancedData,
|
||||
private sonarrService: SonarrService,
|
||||
private settingsService: SettingsService
|
||||
) {}
|
||||
|
||||
constructor(public dialogRef: MatDialogRef<TvAdvancedOptionsComponent>, @Inject(MAT_DIALOG_DATA) public data: IAdvancedData,
|
||||
private sonarrService: SonarrService
|
||||
) {
|
||||
}
|
||||
public async ngOnInit() {
|
||||
this.settingsService.getSonarr().subscribe((settings: ISonarrSettings) => {
|
||||
if (!settings.enabled) {
|
||||
this.sonarrEnabled = false;
|
||||
return;
|
||||
}
|
||||
|
||||
this.sonarrEnabled = true;
|
||||
this.sonarrService.getQualityProfilesWithoutSettings().subscribe((c) => {
|
||||
this.sonarrProfiles = c;
|
||||
this.data.profiles = c;
|
||||
this.setQualityOverrides();
|
||||
});
|
||||
this.sonarrService.getRootFoldersWithoutSettings().subscribe((c) => {
|
||||
this.sonarrRootFolders = c;
|
||||
this.data.rootFolders = c;
|
||||
this.setRootFolderOverrides();
|
||||
});
|
||||
|
||||
if (settings.v3) {
|
||||
this.sonarrService
|
||||
.getV3LanguageProfiles(settings)
|
||||
.subscribe((profiles: ILanguageProfiles[]) => {
|
||||
this.sonarrLanguageProfiles = profiles;
|
||||
this.data.languages = profiles;
|
||||
this.setLanguageOverride();
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public async ngOnInit() {
|
||||
this.sonarrService.getQualityProfilesWithoutSettings().subscribe(c => {
|
||||
this.sonarrProfiles = c;
|
||||
this.data.profiles = c;
|
||||
this.setQualityOverrides();
|
||||
});
|
||||
this.sonarrService.getRootFoldersWithoutSettings().subscribe(c => {
|
||||
this.sonarrRootFolders = c;
|
||||
this.data.rootFolders = c;
|
||||
this.setRootFolderOverrides();
|
||||
});
|
||||
private setQualityOverrides(): void {
|
||||
if (this.sonarrProfiles) {
|
||||
const profile = this.sonarrProfiles.filter((p) => {
|
||||
return p.id === this.data.tvRequest.qualityOverride;
|
||||
});
|
||||
if (profile.length > 0) {
|
||||
this.data.tvRequest.qualityOverrideTitle = profile[0].name;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private setQualityOverrides(): void {
|
||||
if (this.sonarrProfiles) {
|
||||
const profile = this.sonarrProfiles.filter((p) => {
|
||||
return p.id === this.data.tvRequest.qualityOverride;
|
||||
});
|
||||
if (profile.length > 0) {
|
||||
this.data.movieRequest.qualityOverrideTitle = profile[0].name;
|
||||
}
|
||||
}
|
||||
private setRootFolderOverrides(): void {
|
||||
if (this.sonarrRootFolders) {
|
||||
const path = this.sonarrRootFolders.filter((folder) => {
|
||||
return folder.id === this.data.tvRequest.rootFolder;
|
||||
});
|
||||
if (path.length > 0) {
|
||||
this.data.tvRequest.rootPathOverrideTitle = path[0].path;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private setRootFolderOverrides(): void {
|
||||
if (this.sonarrRootFolders) {
|
||||
const path = this.sonarrRootFolders.filter((folder) => {
|
||||
return folder.id === this.data.tvRequest.rootFolder;
|
||||
});
|
||||
if (path.length > 0) {
|
||||
this.data.movieRequest.rootPathOverrideTitle = path[0].path;
|
||||
}
|
||||
}
|
||||
private setLanguageOverride(): void {
|
||||
if (this.sonarrLanguageProfiles) {
|
||||
const profile = this.sonarrLanguageProfiles.filter((p) => {
|
||||
return p.id === this.data.tvRequest.languageProfile;
|
||||
});
|
||||
if (profile.length > 0) {
|
||||
this.data.tvRequest.languageOverrideTitle = profile[0].name;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in new issue