|
|
@ -1,7 +1,5 @@
|
|
|
|
import { Component, OnDestroy, OnInit } from "@angular/core";
|
|
|
|
import { Component, OnInit } from "@angular/core";
|
|
|
|
import { FormBuilder, FormGroup, Validators } from "@angular/forms";
|
|
|
|
import { FormBuilder, FormGroup, Validators } from "@angular/forms";
|
|
|
|
import "rxjs/add/operator/takeUntil";
|
|
|
|
|
|
|
|
import { Subject } from "rxjs/Subject";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import { ISonarrProfile, ISonarrRootFolder } from "../../interfaces";
|
|
|
|
import { ISonarrProfile, ISonarrRootFolder } from "../../interfaces";
|
|
|
|
|
|
|
|
|
|
|
@ -14,7 +12,7 @@ import { SettingsService } from "../../services";
|
|
|
|
@Component({
|
|
|
|
@Component({
|
|
|
|
templateUrl: "./sonarr.component.html",
|
|
|
|
templateUrl: "./sonarr.component.html",
|
|
|
|
})
|
|
|
|
})
|
|
|
|
export class SonarrComponent implements OnInit, OnDestroy {
|
|
|
|
export class SonarrComponent implements OnInit {
|
|
|
|
|
|
|
|
|
|
|
|
public qualities: ISonarrProfile[];
|
|
|
|
public qualities: ISonarrProfile[];
|
|
|
|
public rootFolders: ISonarrRootFolder[];
|
|
|
|
public rootFolders: ISonarrRootFolder[];
|
|
|
@ -25,8 +23,6 @@ export class SonarrComponent implements OnInit, OnDestroy {
|
|
|
|
public form: FormGroup;
|
|
|
|
public form: FormGroup;
|
|
|
|
public advanced = false;
|
|
|
|
public advanced = false;
|
|
|
|
|
|
|
|
|
|
|
|
private subscriptions = new Subject<void>();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
constructor(private settingsService: SettingsService,
|
|
|
|
constructor(private settingsService: SettingsService,
|
|
|
|
private sonarrService: SonarrService,
|
|
|
|
private sonarrService: SonarrService,
|
|
|
|
private notificationService: NotificationService,
|
|
|
|
private notificationService: NotificationService,
|
|
|
@ -36,9 +32,7 @@ export class SonarrComponent implements OnInit, OnDestroy {
|
|
|
|
public ngOnInit() {
|
|
|
|
public ngOnInit() {
|
|
|
|
|
|
|
|
|
|
|
|
this.settingsService.getSonarr()
|
|
|
|
this.settingsService.getSonarr()
|
|
|
|
.takeUntil(this.subscriptions)
|
|
|
|
|
|
|
|
.subscribe(x => {
|
|
|
|
.subscribe(x => {
|
|
|
|
|
|
|
|
|
|
|
|
this.form = this.fb.group({
|
|
|
|
this.form = this.fb.group({
|
|
|
|
enabled: [x.enabled],
|
|
|
|
enabled: [x.enabled],
|
|
|
|
apiKey: [x.apiKey, [Validators.required]],
|
|
|
|
apiKey: [x.apiKey, [Validators.required]],
|
|
|
@ -59,29 +53,33 @@ export class SonarrComponent implements OnInit, OnDestroy {
|
|
|
|
this.getRootFolders(this.form);
|
|
|
|
this.getRootFolders(this.form);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
this.rootFolders = [];
|
|
|
|
|
|
|
|
this.qualities = [];
|
|
|
|
|
|
|
|
this.rootFolders.push({ path: "Please Select", id: -1 });
|
|
|
|
|
|
|
|
this.qualities.push({ name: "Please Select", id: -1 });
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public getProfiles(form: FormGroup) {
|
|
|
|
public getProfiles(form: FormGroup) {
|
|
|
|
this.profilesRunning = true;
|
|
|
|
this.profilesRunning = true;
|
|
|
|
this.sonarrService.getQualityProfiles(form.value)
|
|
|
|
this.sonarrService.getQualityProfiles(form.value)
|
|
|
|
.takeUntil(this.subscriptions)
|
|
|
|
|
|
|
|
.subscribe(x => {
|
|
|
|
.subscribe(x => {
|
|
|
|
this.qualities = x;
|
|
|
|
this.qualities = x;
|
|
|
|
|
|
|
|
this.qualities.unshift({ name: "Please Select", id: -1 });
|
|
|
|
|
|
|
|
|
|
|
|
this.profilesRunning = false;
|
|
|
|
this.profilesRunning = false;
|
|
|
|
this.notificationService.success("Quality Profiles", "Successfully retrevied the Quality Profiles");
|
|
|
|
this.notificationService.success("Quality Profiles", "Successfully retrieved the Quality Profiles");
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public getRootFolders(form: FormGroup) {
|
|
|
|
public getRootFolders(form: FormGroup) {
|
|
|
|
this.rootFoldersRunning = true;
|
|
|
|
this.rootFoldersRunning = true;
|
|
|
|
this.sonarrService.getRootFolders(form.value)
|
|
|
|
this.sonarrService.getRootFolders(form.value)
|
|
|
|
.takeUntil(this.subscriptions)
|
|
|
|
|
|
|
|
.subscribe(x => {
|
|
|
|
.subscribe(x => {
|
|
|
|
this.rootFolders = x;
|
|
|
|
this.rootFolders = x;
|
|
|
|
|
|
|
|
this.rootFolders.unshift({ path: "Please Select", id: -1 });
|
|
|
|
|
|
|
|
|
|
|
|
this.rootFoldersRunning = false;
|
|
|
|
this.rootFoldersRunning = false;
|
|
|
|
this.notificationService.success("Settings Saved", "Successfully retrevied the Root Folders");
|
|
|
|
this.notificationService.success("Settings Saved", "Successfully retrieved the Root Folders");
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -105,8 +103,11 @@ export class SonarrComponent implements OnInit, OnDestroy {
|
|
|
|
this.notificationService.error("Please check your entered values");
|
|
|
|
this.notificationService.error("Please check your entered values");
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if(form.controls.defaultQualityProfile.value === "-1" || form.controls.defaultRootPath.value === "Please Select") {
|
|
|
|
|
|
|
|
this.notificationService.error("Please check your entered values");
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
this.settingsService.saveSonarr(form.value)
|
|
|
|
this.settingsService.saveSonarr(form.value)
|
|
|
|
.takeUntil(this.subscriptions)
|
|
|
|
|
|
|
|
.subscribe(x => {
|
|
|
|
.subscribe(x => {
|
|
|
|
if (x) {
|
|
|
|
if (x) {
|
|
|
|
this.notificationService.success("Settings Saved", "Successfully saved Sonarr settings");
|
|
|
|
this.notificationService.success("Settings Saved", "Successfully saved Sonarr settings");
|
|
|
@ -115,9 +116,4 @@ export class SonarrComponent implements OnInit, OnDestroy {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public ngOnDestroy() {
|
|
|
|
|
|
|
|
this.subscriptions.next();
|
|
|
|
|
|
|
|
this.subscriptions.complete();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|