diff --git a/src/Ombi.Settings/Settings/Models/External/SickRageSettings.cs b/src/Ombi.Settings/Settings/Models/External/SickRageSettings.cs new file mode 100644 index 000000000..1cb49267d --- /dev/null +++ b/src/Ombi.Settings/Settings/Models/External/SickRageSettings.cs @@ -0,0 +1,26 @@ +using System.Collections.Generic; +using Newtonsoft.Json; + +namespace Ombi.Settings.Settings.Models.External +{ + public class SickRageSettings : ExternalSettings + { + public bool Enabled { get; set; } + public string ApiKey { get; set; } + public string QualityProfile { get; set; } + + [JsonIgnore] + public Dictionary Qualities => new Dictionary + { + { "default", "Use Default" }, + { "sdtv", "SD TV" }, + { "sddvd", "SD DVD" }, + { "hdtv", "HD TV" }, + { "rawhdtv", "Raw HD TV" }, + { "hdwebdl", "HD Web DL" }, + { "fullhdwebdl", "Full HD Web DL" }, + { "hdbluray", "HD Bluray" }, + { "fullhdbluray", "Full HD Bluray" } + }; + } +} \ No newline at end of file diff --git a/src/Ombi/ClientApp/app/interfaces/ICommon.ts b/src/Ombi/ClientApp/app/interfaces/ICommon.ts index c2e1e7e1d..649e94e25 100644 --- a/src/Ombi/ClientApp/app/interfaces/ICommon.ts +++ b/src/Ombi/ClientApp/app/interfaces/ICommon.ts @@ -26,3 +26,7 @@ export interface IUsersModel { id: string; username: string; } + +export interface IDictionary { + [Key: string]: T; +} diff --git a/src/Ombi/ClientApp/app/interfaces/ISettings.ts b/src/Ombi/ClientApp/app/interfaces/ISettings.ts index d5c748e7f..36cad977f 100644 --- a/src/Ombi/ClientApp/app/interfaces/ISettings.ts +++ b/src/Ombi/ClientApp/app/interfaces/ISettings.ts @@ -1,4 +1,4 @@ -import { ISettings } from "./ICommon"; +import { IDictionary, ISettings } from "./ICommon"; export interface IExternalSettings extends ISettings { ssl: boolean; @@ -154,6 +154,13 @@ export interface ICouchPotatoSettings extends IExternalSettings { password: string; } +export interface ISickRageSettings extends IExternalSettings { + enabled: boolean; + apiKey: string; + qualityProfile: string; + qualities: IDictionary; +} + export interface IDogNzbSettings extends ISettings { enabled: boolean; apiKey: string; diff --git a/src/Ombi/ClientApp/app/services/settings.service.ts b/src/Ombi/ClientApp/app/services/settings.service.ts index 951bec4c1..b69cadaf0 100644 --- a/src/Ombi/ClientApp/app/services/settings.service.ts +++ b/src/Ombi/ClientApp/app/services/settings.service.ts @@ -1,4 +1,5 @@ -import { PlatformLocation } from "@angular/common"; +import { ISickRageSettings } from './../interfaces/ISettings'; +import { PlatformLocation } from "@angular/common"; import { Injectable } from "@angular/core"; import { Http } from "@angular/http"; import { AuthHttp } from "angular2-jwt"; @@ -21,6 +22,7 @@ import { IPushbulletNotificationSettings, IPushoverNotificationSettings, IRadarrSettings, + ISickRageSettings, ISlackNotificationSettings, ISonarrSettings, ITelegramNotifcationSettings, @@ -234,7 +236,7 @@ export class SettingsService extends ServiceAuthHelpers { public getTelegramNotificationSettings(): Observable { return this.httpAuth.get(`${this.url}/notifications/telegram`).map(this.extractData).catch(this.handleError); - } + } public saveTelegramNotificationSettings(settings: ITelegramNotifcationSettings): Observable { return this.httpAuth @@ -250,5 +252,15 @@ export class SettingsService extends ServiceAuthHelpers { return this.httpAuth .post(`${this.url}/jobs`, JSON.stringify(settings), { headers: this.headers }) .map(this.extractData).catch(this.handleError); + } + + public getSickRageSettings(): Observable { + return this.httpAuth.get(`${this.url}/sickrage`).map(this.extractData).catch(this.handleError); + } + + public saveSickRageSettings(settings: ISickRageSettings): Observable { + return this.httpAuth + .post(`${this.url}/sickrage`, JSON.stringify(settings), { headers: this.headers }) + .map(this.extractData).catch(this.handleError); } } diff --git a/src/Ombi/ClientApp/app/settings/settings.module.ts b/src/Ombi/ClientApp/app/settings/settings.module.ts index dd0eb4b2c..f7062ade7 100644 --- a/src/Ombi/ClientApp/app/settings/settings.module.ts +++ b/src/Ombi/ClientApp/app/settings/settings.module.ts @@ -29,6 +29,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 { SickRageComponent } from "./sickrage/sickrage.component"; import { SonarrComponent } from "./sonarr/sonarr.component"; import { UpdateComponent } from "./update/update.component"; import { UserManagementComponent } from "./usermanagement/usermanagement.component"; @@ -59,6 +60,7 @@ const routes: Routes = [ { path: "Settings/DogNzb", component: DogNzbComponent, canActivate: [AuthGuard] }, { path: "Settings/Telegram", component: TelegramComponent, canActivate: [AuthGuard] }, { path: "Settings/Jobs", component: JobsComponent, canActivate: [AuthGuard] }, + { path: "Settings/SickRage", component: SickRageComponent, canActivate: [AuthGuard] }, ]; @NgModule({ @@ -103,6 +105,7 @@ const routes: Routes = [ WikiComponent, CouchPotatoComponent, DogNzbComponent, + SickRageComponent, TelegramComponent, ], exports: [ diff --git a/src/Ombi/ClientApp/app/settings/sickrage/sickrage.component.html b/src/Ombi/ClientApp/app/settings/sickrage/sickrage.component.html new file mode 100644 index 000000000..94b7e4f91 --- /dev/null +++ b/src/Ombi/ClientApp/app/settings/sickrage/sickrage.component.html @@ -0,0 +1,78 @@ + + +
+
+ SickRage Settings +
+ +
+
+
+ + +
+
+ +
+ + + + The IP/Hostname is required +
+ +
+ + + + The Port is required +
+ + +
+ + + + The API Key is required +
+
+
+ + + +
+
+
+ +
+ +
+
+
+
+
+ +
+ +
+ A Default Quality Profile is required + +
+ +
+
+ +
+
+ + +
+
+ +
+
+
+
+
+
diff --git a/src/Ombi/ClientApp/app/settings/sickrage/sickrage.component.ts b/src/Ombi/ClientApp/app/settings/sickrage/sickrage.component.ts new file mode 100644 index 000000000..3f34e0674 --- /dev/null +++ b/src/Ombi/ClientApp/app/settings/sickrage/sickrage.component.ts @@ -0,0 +1,77 @@ +import { Component, OnInit } from "@angular/core"; +import { FormBuilder, FormGroup, Validators } from "@angular/forms"; + +import { ISonarrProfile, ISonarrRootFolder } from "../../interfaces"; + +// import { ISickRageSettings } from "../../interfaces"; +// import { SonarrService } from "../../services"; +// import { TesterService } from "../../services"; +import { NotificationService } from "../../services"; +import { SettingsService } from "../../services"; + +@Component({ + templateUrl: "./sickrage.component.html", +}) +export class SickRageComponent implements OnInit { + + public qualities: ISonarrProfile[]; + public rootFolders: ISonarrRootFolder[]; + public selectedRootFolder: ISonarrRootFolder; + public selectedQuality: ISonarrProfile; + public profilesRunning: boolean; + public rootFoldersRunning: boolean; + public form: FormGroup; + public advanced = false; + + constructor(private settingsService: SettingsService, + private notificationService: NotificationService, + private fb: FormBuilder) { } + + public ngOnInit() { + this.settingsService.getSickRageSettings() + .subscribe(x => { + this.form = this.fb.group({ + enabled: [x.enabled], + apiKey: [x.apiKey, [Validators.required]], + qualityProfile: [x.qualityProfile, [Validators.required]], + qualities: [x.qualities], + ssl: [x.ssl], + subDir: [x.subDir], + ip: [x.ip, [Validators.required]], + port: [x.port, [Validators.required]], + }); + + }); + } + + public test(form: FormGroup) { + if (form.invalid) { + this.notificationService.error("Please check your entered values"); + return; + } + // const settings = form.value; + // this.testerService.sonarrTest(settings).subscribe(x => { + // if (x) { + // this.notificationService.success("Successfully connected to SickRage!"); + // } else { + // this.notificationService.error("We could not connect to SickRage!"); + // } + // }); + } + + public onSubmit(form: FormGroup) { + if (form.invalid) { + this.notificationService.error("Please check your entered values"); + return; + } + + this.settingsService.saveSickRageSettings(form.value) + .subscribe(x => { + if (x) { + this.notificationService.success("Successfully saved SickRage settings"); + } else { + this.notificationService.error("There was an error when saving the SickRage settings"); + } + }); + } +} diff --git a/src/Ombi/Controllers/SettingsController.cs b/src/Ombi/Controllers/SettingsController.cs index 0f3d760b2..d4130d55d 100644 --- a/src/Ombi/Controllers/SettingsController.cs +++ b/src/Ombi/Controllers/SettingsController.cs @@ -424,6 +424,27 @@ namespace Ombi.Controllers return await Save(settings); } + /// + /// Save the SickRage settings. + /// + /// The settings. + /// + [HttpPost("SickRage")] + public async Task SickRageSettings([FromBody]SickRageSettings settings) + { + return await Save(settings); + } + + /// + /// Gets the SickRage Settings. + /// + /// + [HttpGet("SickRage")] + public async Task SickRageSettings() + { + return await Get(); + } + /// /// Gets the JobSettings Settings. ///