From 2eec6c9c307c2508f5383268e3db51036dbddde6 Mon Sep 17 00:00:00 2001 From: Jamie Date: Thu, 28 Jun 2018 21:43:48 +0100 Subject: [PATCH] Nothing to see here. Move along !wip #2313 --- .../Models/External/LidarrSettings.cs | 12 ++ .../ClientApp/app/interfaces/ISettings.ts | 8 ++ .../app/services/settings.service.ts | 8 ++ .../app/settings/lidarr/lidarr.component.html | 101 +++++++++++++++ .../app/settings/lidarr/lidarr.component.ts | 117 ++++++++++++++++++ .../ClientApp/app/settings/settings.module.ts | 3 + src/Ombi/Controllers/SettingsController.cs | 21 ++++ 7 files changed, 270 insertions(+) create mode 100644 src/Ombi.Settings/Settings/Models/External/LidarrSettings.cs create mode 100644 src/Ombi/ClientApp/app/settings/lidarr/lidarr.component.html create mode 100644 src/Ombi/ClientApp/app/settings/lidarr/lidarr.component.ts diff --git a/src/Ombi.Settings/Settings/Models/External/LidarrSettings.cs b/src/Ombi.Settings/Settings/Models/External/LidarrSettings.cs new file mode 100644 index 000000000..560a6e2d2 --- /dev/null +++ b/src/Ombi.Settings/Settings/Models/External/LidarrSettings.cs @@ -0,0 +1,12 @@ +using Ombi.Core.Settings.Models.External; + +namespace Ombi.Settings.Settings.Models.External +{ + public class LidarrSettings : ExternalSettings + { + public bool Enabled { get; set; } + public string ApiKey { get; set; } + public string DefaultQualityProfile { get; set; } + public string DefaultRootPath { get; set; } + } +} \ No newline at end of file diff --git a/src/Ombi/ClientApp/app/interfaces/ISettings.ts b/src/Ombi/ClientApp/app/interfaces/ISettings.ts index dc1825c83..1495413da 100644 --- a/src/Ombi/ClientApp/app/interfaces/ISettings.ts +++ b/src/Ombi/ClientApp/app/interfaces/ISettings.ts @@ -83,6 +83,14 @@ export interface IRadarrSettings extends IExternalSettings { minimumAvailability: string; } +export interface ILidarrSettings extends IExternalSettings { + enabled: boolean; + apiKey: string; + defaultQualityProfile: string; + defaultRootPath: string; + fullRootPath: string; +} + export interface ILandingPageSettings extends ISettings { enabled: boolean; diff --git a/src/Ombi/ClientApp/app/services/settings.service.ts b/src/Ombi/ClientApp/app/services/settings.service.ts index 726c86d63..51bf149ed 100644 --- a/src/Ombi/ClientApp/app/services/settings.service.ts +++ b/src/Ombi/ClientApp/app/services/settings.service.ts @@ -91,6 +91,14 @@ export class SettingsService extends ServiceHelpers { return this.http.post(`${this.url}/Radarr`, JSON.stringify(settings), {headers: this.headers}); } + public getLidarr(): Observable { + return this.http.get(`${this.url}/Lidarr`, {headers: this.headers}); + } + + public saveLidarr(settings: ILidarrSettings): Observable { + return this.http.post(`${this.url}/Lidarr`, JSON.stringify(settings), {headers: this.headers}); + } + public getAuthentication(): Observable { return this.http.get(`${this.url}/Authentication`, {headers: this.headers}); } diff --git a/src/Ombi/ClientApp/app/settings/lidarr/lidarr.component.html b/src/Ombi/ClientApp/app/settings/lidarr/lidarr.component.html new file mode 100644 index 000000000..d36295038 --- /dev/null +++ b/src/Ombi/ClientApp/app/settings/lidarr/lidarr.component.html @@ -0,0 +1,101 @@ + + +
+
+ Lidarr Settings +
+
+
+
+ + +
+
+ + + +
+ + + + The IP/Hostname is required +
+ +
+ + + + The Port is required +
+ + +
+ + + + The API Key is required +
+
+
+ + + +
+
+
+ +
+ +
+
+
+
+
+
+ +
+
+
+ +
+ +
+ A Default Quality Profile is required +
+ +
+
+ + +
+ +
+
+ +
+ +
+ A Default Root Path is required +
+ + +
+
+ +
+
+ + +
+
+ +
+
+
+
+
+
diff --git a/src/Ombi/ClientApp/app/settings/lidarr/lidarr.component.ts b/src/Ombi/ClientApp/app/settings/lidarr/lidarr.component.ts new file mode 100644 index 000000000..7e5571f14 --- /dev/null +++ b/src/Ombi/ClientApp/app/settings/lidarr/lidarr.component.ts @@ -0,0 +1,117 @@ +import { Component, OnInit } from "@angular/core"; +import { FormBuilder, FormGroup, Validators } from "@angular/forms"; + +import { ILidarrSettings, IMinimumAvailability, IRadarrProfile, IRadarrRootFolder } from "../../interfaces"; +import { IRadarrSettings } from "../../interfaces"; +import { RadarrService } from "../../services"; +import { TesterService } from "../../services"; +import { NotificationService } from "../../services"; +import { SettingsService } from "../../services"; + +@Component({ + templateUrl: "./Lidarr.component.html", +}) +export class LidarrComponent implements OnInit { + + public qualities: IRadarrProfile[]; + public rootFolders: IRadarrRootFolder[]; + public minimumAvailabilityOptions: IMinimumAvailability[]; + public profilesRunning: boolean; + public rootFoldersRunning: boolean; + public advanced = false; + public form: FormGroup; + + constructor(private settingsService: SettingsService, + private radarrService: RadarrService, + private notificationService: NotificationService, + private fb: FormBuilder, + private testerService: TesterService) { } + + public ngOnInit() { + this.settingsService.getLidarr() + .subscribe(x => { + + this.form = this.fb.group({ + enabled: [x.enabled], + apiKey: [x.apiKey, [Validators.required]], + defaultQualityProfile: [x.defaultQualityProfile, [Validators.required]], + defaultRootPath: [x.defaultRootPath, [Validators.required]], + ssl: [x.ssl], + subDir: [x.subDir], + ip: [x.ip, [Validators.required]], + port: [x.port, [Validators.required]], + }); + + if (x.defaultQualityProfile) { + this.getProfiles(this.form); + } + if (x.defaultRootPath) { + this.getRootFolders(this.form); + } + }); + + this.qualities = []; + this.qualities.push({ name: "Please Select", id: -1 }); + + this.rootFolders = []; + this.rootFolders.push({ path: "Please Select", id: -1 }); + } + + public getProfiles(form: FormGroup) { + this.profilesRunning = true; + this.radarrService.getQualityProfiles(form.value).subscribe(x => { + this.qualities = x; + this.qualities.unshift({ name: "Please Select", id: -1 }); + + this.profilesRunning = false; + this.notificationService.success("Successfully retrieved the Quality Profiles"); + }); + } + + public getRootFolders(form: FormGroup) { + this.rootFoldersRunning = true; + this.radarrService.getRootFolders(form.value).subscribe(x => { + this.rootFolders = x; + this.rootFolders.unshift({ path: "Please Select", id: -1 }); + + this.rootFoldersRunning = false; + this.notificationService.success("Successfully retrieved the Root Folders"); + }); + } + + public test(form: FormGroup) { + if (form.invalid) { + this.notificationService.error("Please check your entered values"); + return; + } + const settings = form.value; + this.testerService.radarrTest(settings).subscribe(x => { + if (x === true) { + this.notificationService.success("Successfully connected to Lidarr!"); + } else { + this.notificationService.error("We could not connect to Lidarr!"); + } + }); + } + +public onSubmit(form: FormGroup) { + if (form.invalid) { + this.notificationService.error("Please check your entered values"); + return; + } + if(form.controls.defaultQualityProfile.value === "-1" || form.controls.defaultRootPath.value === "Please Select") { + this.notificationService.error("Please check your entered values"); + return; + } + + const settings = form.value; + this.settingsService.saveLidarr(settings).subscribe(x => { + if (x) { + this.notificationService.success("Successfully saved Lidarr settings"); + } else { + this.notificationService.success("There was an error when saving the Lidarr settings"); + } + }); + + } +} diff --git a/src/Ombi/ClientApp/app/settings/settings.module.ts b/src/Ombi/ClientApp/app/settings/settings.module.ts index 0069cf262..44c1455f0 100644 --- a/src/Ombi/ClientApp/app/settings/settings.module.ts +++ b/src/Ombi/ClientApp/app/settings/settings.module.ts @@ -34,6 +34,7 @@ import { TelegramComponent } from "./notifications/telegram.component"; import { OmbiComponent } from "./ombi/ombi.component"; import { PlexComponent } from "./plex/plex.component"; import { RadarrComponent } from "./radarr/radarr.component"; +import { LidarrComponent } from "./lidarr/lidarr.component"; import { SickRageComponent } from "./sickrage/sickrage.component"; import { SonarrComponent } from "./sonarr/sonarr.component"; import { UpdateComponent } from "./update/update.component"; @@ -71,6 +72,7 @@ const routes: Routes = [ { path: "Mobile", component: MobileComponent, canActivate: [AuthGuard] }, { path: "MassEmail", component: MassEmailComponent, canActivate: [AuthGuard] }, { path: "Newsletter", component: NewsletterComponent, canActivate: [AuthGuard] }, + { path: "Lidarr", component: LidarrComponent, canActivate: [AuthGuard] }, ]; @NgModule({ @@ -122,6 +124,7 @@ const routes: Routes = [ MobileComponent, MassEmailComponent, NewsletterComponent, + LidarrComponent, ], exports: [ RouterModule, diff --git a/src/Ombi/Controllers/SettingsController.cs b/src/Ombi/Controllers/SettingsController.cs index 895621ad3..6c2e7475f 100644 --- a/src/Ombi/Controllers/SettingsController.cs +++ b/src/Ombi/Controllers/SettingsController.cs @@ -301,6 +301,27 @@ namespace Ombi.Controllers return await Get(); } + /// + /// Gets the Lidarr Settings. + /// + /// + [HttpGet("lidarr")] + public async Task LidarrSettings() + { + return await Get(); + } + + /// + /// Save the Lidarr settings. + /// + /// The settings. + /// + [HttpPost("sonarr")] + public async Task LidarrSettings([FromBody]LidarrSettings settings) + { + return await Save(settings); + } + /// /// Save the Authentication settings. ///