Started the Radarr Settings #865

pull/1425/head
Jamie.Rees 8 years ago
parent 521f7c3ea0
commit 7595ccf6c4

@ -0,0 +1,15 @@
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using Ombi.Api.Radarr.Models;
namespace Ombi.Api.Radarr
{
public interface IRadarrApi
{
Task<List<MovieResponse>> GetMovies(string apiKey, Uri baseUrl);
Task<List<RadarrProfile>> GetProfiles(string apiKey, Uri baseUrl);
Task<List<RadarrRootFolder>> GetRootFolders(string apiKey, Uri baseUrl);
Task<SystemStatus> SystemStatus(string apiKey, Uri baseUrl);
}
}

@ -0,0 +1,8 @@
namespace Ombi.Api.Radarr.Models
{
public class Cutoff
{
public int id { get; set; }
public string name { get; set; }
}
}

@ -0,0 +1,8 @@
namespace Ombi.Api.Radarr.Models
{
public class Image
{
public string coverType { get; set; }
public string url { get; set; }
}
}

@ -0,0 +1,8 @@
namespace Ombi.Api.Radarr.Models
{
public class Item
{
public Quality quality { get; set; }
public bool allowed { get; set; }
}
}

@ -0,0 +1,38 @@
using System.Collections.Generic;
namespace Ombi.Api.Radarr.Models
{
public class MovieResponse
{
public string title { get; set; }
public string sortTitle { get; set; }
public double sizeOnDisk { get; set; }
public string status { get; set; }
public string overview { get; set; }
public string inCinemas { get; set; }
public string physicalRelease { get; set; }
public List<Image> images { get; set; }
public string website { get; set; }
public bool downloaded { get; set; }
public int year { get; set; }
public bool hasFile { get; set; }
public string youTubeTrailerId { get; set; }
public string studio { get; set; }
public string path { get; set; }
public int profileId { get; set; }
public bool monitored { get; set; }
public int runtime { get; set; }
public string lastInfoSync { get; set; }
public string cleanTitle { get; set; }
public string imdbId { get; set; }
public int tmdbId { get; set; }
public string titleSlug { get; set; }
public List<string> genres { get; set; }
public List<object> tags { get; set; }
public string added { get; set; }
public Ratings ratings { get; set; }
public List<string> alternativeTitles { get; set; }
public int qualityProfileId { get; set; }
public int id { get; set; }
}
}

@ -0,0 +1,8 @@
namespace Ombi.Api.Radarr.Models
{
public class Quality
{
public int id { get; set; }
public string name { get; set; }
}
}

@ -0,0 +1,12 @@
using System.Collections.Generic;
namespace Ombi.Api.Radarr.Models
{
public class RadarrProfile
{
public string name { get; set; }
public Cutoff cutoff { get; set; }
public List<Item> items { get; set; }
public int id { get; set; }
}
}

@ -0,0 +1,9 @@
namespace Ombi.Api.Radarr.Models
{
public class RadarrRootFolder
{
public int id { get; set; }
public string path { get; set; }
public long freespace { get; set; }
}
}

@ -0,0 +1,8 @@
namespace Ombi.Api.Radarr.Models
{
public class Ratings
{
public int votes { get; set; }
public double value { get; set; }
}
}

@ -0,0 +1,25 @@
namespace Ombi.Api.Radarr.Models
{
public class SystemStatus
{
public string version { get; set; }
public string buildTime { get; set; }
public bool isDebug { get; set; }
public bool isProduction { get; set; }
public bool isAdmin { get; set; }
public bool isUserInteractive { get; set; }
public string startupPath { get; set; }
public string appData { get; set; }
public string osVersion { get; set; }
public bool isMonoRuntime { get; set; }
public bool isMono { get; set; }
public bool isLinux { get; set; }
public bool isOsx { get; set; }
public bool isWindows { get; set; }
public string branch { get; set; }
public string authentication { get; set; }
public string sqliteVersion { get; set; }
public string urlBase { get; set; }
public string runtimeVersion { get; set; }
}
}

@ -0,0 +1,17 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netstandard1.6</TargetFramework>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\Ombi.Api\Ombi.Api.csproj" />
</ItemGroup>
<ItemGroup>
<Reference Include="Microsoft.Extensions.Logging.Abstractions">
<HintPath>..\..\..\..\..\.nuget\packages\microsoft.extensions.logging.abstractions\1.1.1\lib\netstandard1.1\Microsoft.Extensions.Logging.Abstractions.dll</HintPath>
</Reference>
</ItemGroup>
</Project>

@ -0,0 +1,63 @@
using System;
using System.Collections.Generic;
using System.Net.Http;
using System.Threading.Tasks;
using Microsoft.Extensions.Logging;
using Ombi.Api.Radarr.Models;
namespace Ombi.Api.Radarr
{
public class RadarrApi : IRadarrApi
{
public RadarrApi(ILogger<RadarrApi> logger)
{
Api = new Api();
Logger = logger;
}
private Api Api { get; }
private ILogger<RadarrApi> Logger { get; }
public async Task<List<RadarrProfile>> GetProfiles(string apiKey, Uri baseUrl)
{
var request = new Request(baseUrl.ToString(), "/api/profile", HttpMethod.Get);
AddHeaders(request, apiKey);
return await Api.Request<List<RadarrProfile>>(request);
}
public async Task<List<RadarrRootFolder>> GetRootFolders(string apiKey, Uri baseUrl)
{
var request = new Request(baseUrl.ToString(), "/api/rootfolder", HttpMethod.Get);
AddHeaders(request, apiKey);
return await Api.Request<List<RadarrRootFolder>>(request);
}
public async Task<SystemStatus> SystemStatus(string apiKey, Uri baseUrl)
{
var request = new Request(baseUrl.ToString(), "/api/system/status", HttpMethod.Get);
AddHeaders(request, apiKey);
return await Api.Request<SystemStatus>(request);
}
public async Task<List<MovieResponse>> GetMovies(string apiKey, Uri baseUrl)
{
var request = new Request(baseUrl.ToString(), "/api/movie", HttpMethod.Get);
AddHeaders(request, apiKey);
return await Api.Request<List<MovieResponse>>(request);
}
/// <summary>
/// Adds the required headers and also the authorization header
/// </summary>
/// <param name="request"></param>
/// <param name="key"></param>
private void AddHeaders(Request request, string key)
{
request.AddHeader("X-Api-Key", key);
}
}
}

@ -6,6 +6,7 @@ using System.Threading.Tasks;
using Ombi.Core.Claims;
using Ombi.Core.Engine.Interfaces;
using Ombi.Core.Models.Requests;
using Ombi.Core.Models.Requests.Movie;
using Ombi.Core.Requests.Models;
using Ombi.Helpers;

@ -1,6 +1,7 @@
using System.Collections.Generic;
using System.Threading.Tasks;
using Ombi.Core.Models.Requests;
using Ombi.Core.Models.Requests.Movie;
using Ombi.Core.Models.Search;
using Ombi.Store.Entities;

@ -8,6 +8,7 @@ using Hangfire;
using Ombi.Api.TheMovieDb;
using Ombi.Api.TvMaze;
using Ombi.Core.Models.Requests;
using Ombi.Core.Models.Requests.Movie;
using Ombi.Core.Models.Search;
using Ombi.Core.Requests.Models;
using Ombi.Store.Entities;

@ -8,6 +8,7 @@ using Ombi.Api.TheMovieDb;
using Ombi.Api.TheMovieDb.Models;
using Ombi.Core.IdentityResolver;
using Ombi.Core.Models.Requests;
using Ombi.Core.Models.Requests.Movie;
using Ombi.Core.Models.Search;
using Ombi.Core.Requests.Models;
using Ombi.Core.Settings;

@ -1,10 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using Newtonsoft.Json;
using Ombi.Store.Entities;
namespace Ombi.Core.Models.Requests
namespace Ombi.Core.Models.Requests.Movie
{
public class MovieRequestModel : BaseRequestModel
{

@ -1,4 +1,5 @@
using Ombi.Core.Requests.Models;
using Ombi.Core.Models.Requests.Movie;
using Ombi.Core.Requests.Models;
namespace Ombi.Core.Models.Requests
{

@ -0,0 +1,72 @@
using System.Threading.Tasks;
using Ombi.Core.Models.Requests;
using Ombi.Core.Models.Requests.Movie;
using Ombi.Core.Settings;
using Ombi.Settings.Settings.Models.External;
namespace Ombi.Core
{
public class MovieSender
{
public MovieSender(ISettingsService<RadarrSettings> radarrSettings)
{
RadarrSettings = radarrSettings;
}
private ISettingsService<RadarrSettings> RadarrSettings { get; }
public async Task<MovieSenderResult> Send(MovieRequestModel model, string qualityId = "")
{
//var cpSettings = await CouchPotatoSettings.GetSettingsAsync();
//var watcherSettings = await WatcherSettings.GetSettingsAsync();
var radarrSettings = await RadarrSettings.GetSettingsAsync();
//if (cpSettings.Enabled)
//{
// return SendToCp(model, cpSettings, string.IsNullOrEmpty(qualityId) ? cpSettings.ProfileId : qualityId);
//}
//if (watcherSettings.Enabled)
//{
// return SendToWatcher(model, watcherSettings);
//}
if (radarrSettings.Enabled)
{
//return SendToRadarr(model, radarrSettings, qualityId);
}
return new MovieSenderResult { Success = false, MovieSent = false, Message = "There are no movie providers enabled!"};
}
//private MovieSenderResult SendToRadarr(MovieRequestModel model, RadarrSettings settings, string qualityId)
//{
// var qualityProfile = 0;
// if (!string.IsNullOrEmpty(qualityId)) // try to parse the passed in quality, otherwise use the settings default quality
// {
// int.TryParse(qualityId, out qualityProfile);
// }
// if (qualityProfile <= 0)
// {
// int.TryParse(settings.QualityProfile, out qualityProfile);
// }
// var rootFolderPath = model.RootFolderSelected <= 0 ? settings.FullRootPath : GetRootPath(model.RootFolderSelected, settings);
// var result = RadarrApi.AddMovie(model.ProviderId, model.Title, model.ReleaseDate.Year, qualityProfile, rootFolderPath, settings.ApiKey, settings.FullUri, true);
// if (!string.IsNullOrEmpty(result.Error?.message))
// {
// Log.Error(result.Error.message);
// return new MovieSenderResult { Result = false, Error = true, MovieSendingEnabled = true };
// }
// if (!string.IsNullOrEmpty(result.title))
// {
// return new MovieSenderResult { Result = true, MovieSendingEnabled = true };
// }
// return new MovieSenderResult { Result = false, MovieSendingEnabled = true };
//}
}
}

@ -0,0 +1,9 @@
namespace Ombi.Core
{
public class MovieSenderResult
{
public bool Success { get; set; }
public string Message { get; set; }
public bool MovieSent { get; set; }
}
}

@ -1,4 +1,5 @@
using Ombi.Core.Requests.Models;
using Ombi.Core.Models.Requests.Movie;
using Ombi.Core.Requests.Models;
namespace Ombi.Core.Models.Requests
{

@ -4,6 +4,7 @@ using Microsoft.AspNetCore.Authorization;
using Microsoft.Extensions.DependencyInjection;
using Ombi.Api.Emby;
using Ombi.Api.Plex;
using Ombi.Api.Radarr;
using Ombi.Api.Sonarr;
using Ombi.Api.TheMovieDb;
using Ombi.Api.Trakt;
@ -55,6 +56,7 @@ namespace Ombi.DependencyInjection
services.AddTransient<ISonarrApi, SonarrApi>();
services.AddTransient<ITvMazeApi, TvMazeApi>();
services.AddTransient<ITraktApi, TraktApi>();
services.AddTransient<IRadarrApi, RadarrApi>();
}
public static void RegisterStore(this IServiceCollection services)

@ -13,6 +13,7 @@
<ItemGroup>
<ProjectReference Include="..\Ombi.Api.Emby\Ombi.Api.Emby.csproj" />
<ProjectReference Include="..\Ombi.Api.Plex\Ombi.Api.Plex.csproj" />
<ProjectReference Include="..\Ombi.Api.Radarr\Ombi.Api.Radarr.csproj" />
<ProjectReference Include="..\Ombi.Api.Sonarr\Ombi.Api.Sonarr.csproj" />
<ProjectReference Include="..\Ombi.Api.Trakt\Ombi.Api.Trakt.csproj" />
<ProjectReference Include="..\Ombi.Api.TvMaze\Ombi.Api.TvMaze.csproj" />

@ -0,0 +1,13 @@
using Ombi.Core.Settings.Models.External;
namespace Ombi.Settings.Settings.Models.External
{
public class RadarrSettings : ExternalSettings
{
public bool Enabled { get; set; }
public string ApiKey { get; set; }
public string DefaultQualityProfile { get; set; }
public string DefaultRootPath { get; set; }
public string FullRootPath { get; set; }
}
}

@ -59,6 +59,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Ombi.Api.Trakt", "Ombi.Api.
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Ombi.Core.Tests", "Ombi.Core.Tests\Ombi.Core.Tests.csproj", "{FC6A8F7C-9722-4AE4-960D-277ACB0E81CB}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Ombi.Api.Radarr", "Ombi.Api.Radarr\Ombi.Api.Radarr.csproj", "{94D04C1F-E35A-499C-B0A0-9FADEBDF8336}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@ -141,6 +143,10 @@ Global
{FC6A8F7C-9722-4AE4-960D-277ACB0E81CB}.Debug|Any CPU.Build.0 = Debug|Any CPU
{FC6A8F7C-9722-4AE4-960D-277ACB0E81CB}.Release|Any CPU.ActiveCfg = Release|Any CPU
{FC6A8F7C-9722-4AE4-960D-277ACB0E81CB}.Release|Any CPU.Build.0 = Release|Any CPU
{94D04C1F-E35A-499C-B0A0-9FADEBDF8336}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{94D04C1F-E35A-499C-B0A0-9FADEBDF8336}.Debug|Any CPU.Build.0 = Debug|Any CPU
{94D04C1F-E35A-499C-B0A0-9FADEBDF8336}.Release|Any CPU.ActiveCfg = Release|Any CPU
{94D04C1F-E35A-499C-B0A0-9FADEBDF8336}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
@ -159,5 +165,6 @@ Global
{6EE01B17-0966-4E11-8BC1-A5318A92AB1D} = {EA30DD15-6280-4687-B370-2956EC2E54E5}
{3880375C-1A7E-4D75-96EC-63B954C42FEA} = {9293CA11-360A-4C20-A674-B9E794431BF5}
{FC6A8F7C-9722-4AE4-960D-277ACB0E81CB} = {6F42AB98-9196-44C4-B888-D5E409F415A1}
{94D04C1F-E35A-499C-B0A0-9FADEBDF8336} = {9293CA11-360A-4C20-A674-B9E794431BF5}
EndGlobalSection
EndGlobal

@ -5,6 +5,7 @@ using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Ombi.Core.Engine;
using Ombi.Core.Models.Requests;
using Ombi.Core.Models.Requests.Movie;
using Ombi.Core.Models.Search;
namespace Ombi.Controllers

@ -6,6 +6,7 @@ using Ombi.Core.Settings;
using Ombi.Core.Settings.Models;
using Ombi.Core.Settings.Models.External;
using Ombi.Settings.Settings.Models;
using Ombi.Settings.Settings.Models.External;
namespace Ombi.Controllers
{
@ -81,6 +82,31 @@ namespace Ombi.Controllers
return await Save(settings);
}
[HttpGet("sonarr")]
[AllowAnonymous]
public async Task<SonarrSettings> SonarrSettings()
{
return await Get<SonarrSettings>();
}
[HttpPost("sonarr")]
public async Task<bool> SonarrSettings([FromBody]SonarrSettings settings)
{
return await Save(settings);
}
[HttpGet("radarr")]
[AllowAnonymous]
public async Task<RadarrSettings> RadarrSettings()
{
return await Get<RadarrSettings>();
}
[HttpPost("radarr")]
public async Task<bool> RadarrSettings([FromBody]RadarrSettings settings)
{
return await Save(settings);
}
private async Task<T> Get<T>()
{

@ -54,5 +54,23 @@
<ProjectReference Include="..\Ombi.TheMovieDbApi\Ombi.Api.TheMovieDb.csproj" />
</ItemGroup>
<ItemGroup>
<Content Update="wwwroot\app\services\applications\sonarr - Copy.service.js">
<CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
</Content>
<Content Update="wwwroot\app\services\applications\sonarr - Copy.service.ts">
<CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
</Content>
<Content Update="wwwroot\app\settings\radarr\sonarr.component.js">
<CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
</Content>
<Content Update="wwwroot\app\settings\radarr\sonarr.component.js.map">
<CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
</Content>
<Content Update="wwwroot\app\settings\radarr\sonarr.component.ts">
<CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
</Content>
</ItemGroup>
</Project>

@ -53,6 +53,14 @@ export interface ISonarrSettings extends IExternalSettings {
fullRootPath:string,
}
export interface IRadarrSettings extends IExternalSettings {
enabled: boolean,
apiKey: string,
defaultQualityProfile: string,
defaultRootPath: string,
fullRootPath:string,
}
export interface ILandingPageSettings extends ISettings {
enabled: boolean,
beforeLogin: boolean,

@ -0,0 +1,20 @@
import { Injectable } from '@angular/core';
import { AuthHttp } from 'angular2-jwt';
//import { Observable } from 'rxjs/Rx';
import { ServiceAuthHelpers } from '../service.helpers';
//import { IRadarrSettings } from '../../interfaces/ISettings';
@Injectable()
export class RadarrService extends ServiceAuthHelpers {
constructor(http: AuthHttp) {
super(http, '/api/v1/Radarr');
}
// getRootFolders(settings: IRadarrSettings): Observable<ISonarrRootFolder[]> {
// return this.http.post(`${this.url}/RootFolders/`, JSON.stringify(settings), { headers: this.headers }).map(this.extractData);
// }
// getQualityProfiles(settings: IRadarrSettings): Observable<ISonarrProfile[]> {
// return this.http.post(`${this.url}/Profiles/`, JSON.stringify(settings), { headers: this.headers }).map(this.extractData);
// }
}

@ -4,14 +4,22 @@ import { Http } from '@angular/http';
import { Observable } from 'rxjs/Rx';
import { ServiceAuthHelpers } from './service.helpers';
import { IOmbiSettings, IEmbySettings, IPlexSettings, ISonarrSettings,ILandingPageSettings, ICustomizationSettings } from '../interfaces/ISettings';
import {
IOmbiSettings,
IEmbySettings,
IPlexSettings,
ISonarrSettings,
ILandingPageSettings,
ICustomizationSettings,
IRadarrSettings
} from '../interfaces/ISettings';
@Injectable()
export class SettingsService extends ServiceAuthHelpers {
constructor(public httpAuth: AuthHttp, private nonAuthHttp: Http) {
super(httpAuth, '/api/v1/Settings');
}
getOmbi(): Observable<IOmbiSettings> {
return this.httpAuth.get(`${this.url}/Ombi/`).map(this.extractData).catch(this.handleError)
}
@ -45,6 +53,15 @@ export class SettingsService extends ServiceAuthHelpers {
return this.httpAuth.post(`${this.url}/Sonarr`, JSON.stringify(settings), { headers: this.headers }).map(this.extractData).catch(this.handleError)
}
getRadarr(): Observable<IRadarrSettings> {
return this.httpAuth.get(`${this.url}/Radarr`).map(this.extractData)
.catch(this.handleError);
}
saveRadarr(settings: IRadarrSettings): Observable<boolean> {
return this.httpAuth.post(`${this.url}/Radarr`, JSON.stringify(settings), { headers: this.headers }).map(this.extractData).catch(this.handleError)
}
// Using http since we need it not to be authenticated to get the landing page settings
getLandingPage(): Observable<ILandingPageSettings> {
return this.nonAuthHttp.get(`${this.url}/LandingPage`).map(this.extractData).catch(this.handleError)

@ -0,0 +1,104 @@

<settings-menu></settings-menu>
<div *ngIf="settings">
<form class="form-horizontal" method="POST" id="mainForm">
<fieldset>
<legend>Sonarr Settings</legend>
<div class="form-group">
<div class="checkbox">
<input type="checkbox" [(ngModel)]="settings.enable" ng-checked="settings.enable">
<label for="enable">Enable</label>
</div>
</div>
<input hidden="hidden" name="FullRootPath" id="fullRootPath" value="settings.enable" />
<div class="form-group">
<label for="Ip" class="control-label">Sonarr Hostname or IP</label>
<div class="">
<input type="text" class="form-control form-control-custom " [(ngModel)]="settings.ip" id="Ip" name="Ip" placeholder="localhost" value="{{settings.ip}}">
</div>
</div>
<div class="form-group">
<label for="portNumber" class="control-label">Port</label>
<div class="">
<input type="text" class="form-control form-control-custom " [(ngModel)]="settings.port" id="portNumber" name="Port" placeholder="Port Number" value="{{settings.port}}">
</div>
</div>
<div class="form-group">
<label for="ApiKey" class="control-label">Sonarr API Key</label>
<div>
<input type="text" class="form-control form-control-custom " [(ngModel)]="settings.apiKey" id="ApiKey" name="ApiKey" value="{{settings.apiKey}}">
</div>
</div>
<div class="form-group">
<div class="checkbox">
<input type="checkbox" id="Ssl" name="Ssl" ng-checked="settings.ssl"><label for="Ssl">SSL</label>
</div>
</div>
<div class="form-group">
<label for="SubDir" class="control-label">Sonarr Base Url</label>
<div>
<input type="text" class="form-control form-control-custom" [(ngModel)]="settings.subDir" id="SubDir" name="SubDir" value="@Model.SubDir">
</div>
</div>
<div class="form-group">
<div>
<button type="submit" (click)="getProfiles()" class="btn btn-primary-outline">Get Quality Profiles <div *ngIf="profilesRunning" class="fa fa-spinner fa-spin" /></button>
</div>
</div>
<div class="form-group">
<label for="select" class="control-label">Quality Profiles</label>
<div id="profiles">
<select class="form-control form-control-custom" id="select" *ngFor='let quality of qualities'>
<option [selected]="qualityProfile === quality.name" [ngValue]="selectedQuality" value='{{quality.id}}'>{{quality.name}}</option>
</select>
</div>
</div>
<div class="form-group">
<div>
<button type="submit" (click)="getRootFolders()" class="btn btn-primary-outline">Get Root Folders <div *ngIf="rootFoldersRunning" class="fa fa-spinner fa-spin" /></button>
</div>
</div>
<div class="form-group">
<label for="rootFolders" class="control-label">Default Root Folders</label>
<div id="rootFolders">
<select class="form-control form-control-custom" *ngFor='let folder of rootFolders'>
<option [selected]="rootPath === folder.name" [ngValue]="selectedRootFolder" value='{{folder.id}}'>{{folder.name}}</option>
</select>
</div>
</div>
<div class="form-group">
<div class="checkbox">
<input type="checkbox" id="SeasonFolders" name="SeasonFolders" ng-checked="settings.seasonFolders">
<label for="SeasonFolders">Enable season folders</label>
</div>
<label>Enabled Season Folders to organize seasons into individual folders within a show.</label>
</div>
<div class="form-group">
<div>
<button (click)="test()" type="submit" class="btn btn-primary-outline">Test Connectivity <div id="spinner" /></button>
</div>
</div>
<div class="form-group">
<div>
<button (click)="save()" type="submit" class="btn btn-primary-outline ">Submit</button>
</div>
</div>
</fieldset>
</form>
</div>

@ -0,0 +1,80 @@
import { Component, OnInit } from '@angular/core';
import { Subject } from 'rxjs/Subject';
import "rxjs/add/operator/takeUntil";
import { IRadarrSettings } from '../../interfaces/ISettings'
import { ISonarrProfile, ISonarrRootFolder } from '../../interfaces/ISonarr'
import { SettingsService } from '../../services/settings.service';
// import { RadarrService } from '../../services/applications/radarr.service';
import { NotificationService } from "../../services/notification.service";
@Component({
selector: 'ombi',
moduleId: module.id,
templateUrl: './radarr.component.html',
})
export class RadarrComponent implements OnInit {
constructor(private settingsService: SettingsService, /*private radarrService: RadarrService,*/ private notificationService: NotificationService) { }
settings: IRadarrSettings;
qualities: ISonarrProfile[];
rootFolders: ISonarrRootFolder[];
selectedRootFolder:ISonarrRootFolder;
selectedQuality: ISonarrProfile;
profilesRunning: boolean;
rootFoldersRunning: boolean;
private subscriptions = new Subject<void>();
ngOnInit(): void {
this.settingsService.getRadarr()
.takeUntil(this.subscriptions)
.subscribe(x => {
this.settings = x;
});
}
getProfiles() {
// this.profilesRunning = true;
// this.sonarrService.getQualityProfiles(this.settings).subscribe(x => {
// this.qualities = x;
//
// this.profilesRunning = false;
// this.notificationService.success("Quality Profiles", "Successfully retrevied the Quality Profiles");
// });
}
getRootFolders() {
// this.rootFoldersRunning = true;
// this.sonarrService.getRootFolders(this.settings).subscribe(x => {
// this.rootFolders = x;
//
// this.rootFoldersRunning = false;
// this.notificationService.success("Settings Saved", "Successfully retrevied the Root Folders");
// });
}
test() {
// TODO
}
save() {
this.settingsService.saveRadarr(this.settings).subscribe(x => {
if (x) {
this.notificationService.success("Settings Saved", "Successfully saved Radarr settings");
} else {
this.notificationService.success("Settings Saved", "There was an error when saving the Radarr settings");
}
});
}
ngOnDestroy(): void {
this.subscriptions.next();
this.subscriptions.complete();
}
}

@ -1,4 +1,6 @@
import { Component, OnInit } from '@angular/core';
import { Component, OnInit, OnDestroy } from '@angular/core';
import { Subject } from 'rxjs/Subject';
import "rxjs/add/operator/takeUntil";
import { ISonarrSettings } from '../../interfaces/ISettings'
import { ISonarrProfile, ISonarrRootFolder } from '../../interfaces/ISonarr'
@ -11,7 +13,7 @@ import { NotificationService } from "../../services/notification.service";
moduleId: module.id,
templateUrl: './sonarr.component.html',
})
export class SonarrComponent implements OnInit {
export class SonarrComponent implements OnInit, OnDestroy {
constructor(private settingsService: SettingsService, private sonarrService: SonarrService, private notificationService: NotificationService) { }
@ -20,32 +22,28 @@ export class SonarrComponent implements OnInit {
qualities: ISonarrProfile[];
rootFolders: ISonarrRootFolder[];
selectedRootFolder:ISonarrRootFolder;
selectedRootFolder: ISonarrRootFolder;
selectedQuality: ISonarrProfile;
profilesRunning: boolean;
rootFoldersRunning:boolean;
rootFoldersRunning: boolean;
private subscriptions = new Subject<void>();
ngOnInit(): void {
this.settings = {
apiKey: "",
port: 8081,
fullRootPath: "",
rootPath: "",
subDir: "",
ssl: false,
seasonFolders: false,
qualityProfile: "",
ip: "",
enable: false,
id: 0
};
this.settingsService.getSonarr()
.takeUntil(this.subscriptions)
.subscribe(x => {
this.settings = x;
});
}
getProfiles() {
this.profilesRunning = true;
this.sonarrService.getQualityProfiles(this.settings).subscribe(x => {
this.sonarrService.getQualityProfiles(this.settings)
.takeUntil(this.subscriptions)
.subscribe(x => {
this.qualities = x;
this.profilesRunning = false;
@ -55,7 +53,9 @@ export class SonarrComponent implements OnInit {
getRootFolders() {
this.rootFoldersRunning = true;
this.sonarrService.getRootFolders(this.settings).subscribe(x => {
this.sonarrService.getRootFolders(this.settings)
.takeUntil(this.subscriptions)
.subscribe(x => {
this.rootFolders = x;
this.rootFoldersRunning = false;
@ -68,12 +68,19 @@ export class SonarrComponent implements OnInit {
}
save() {
this.settingsService.saveSonarr(this.settings).subscribe(x => {
this.settingsService.saveSonarr(this.settings)
.takeUntil(this.subscriptions)
.subscribe(x => {
if (x) {
this.notificationService.success("Settings Saved", "Successfully saved Ombi settings");
this.notificationService.success("Settings Saved", "Successfully saved Sonarr settings");
} else {
this.notificationService.success("Settings Saved", "There was an error when saving the Ombi settings");
this.notificationService.success("Settings Saved", "There was an error when saving the Sonarr settings");
}
});
}
ngOnDestroy(): void {
this.subscriptions.next();
this.subscriptions.complete();
}
}
Loading…
Cancel
Save