Added some sonarr stuff

pull/1425/head
Jamie.Rees 7 years ago
parent 47e2385eaa
commit 3f62d0d5ec

@ -21,9 +21,9 @@ namespace Ombi.Api.Emby
/// </summary>
/// <param name="baseUri"></param>
/// <param name="apiKey"></param>
public async Task<List<EmbyUser>> GetUsers(Uri baseUri, string apiKey)
public async Task<List<EmbyUser>> GetUsers(string baseUri, string apiKey)
{
var request = new Request("emby/users", baseUri.ToString(), HttpMethod.Get);
var request = new Request("emby/users", baseUri, HttpMethod.Get);
AddHeaders(request, apiKey);
var obj = await Api.Request<List<EmbyUser>>(request);
@ -31,9 +31,9 @@ namespace Ombi.Api.Emby
return obj;
}
public async Task<EmbySystemInfo> GetSystemInformation(string apiKey, Uri baseUrl)
public async Task<EmbySystemInfo> GetSystemInformation(string apiKey, string baseUrl)
{
var request = new Request("emby/System/Info", baseUrl.ToString(), HttpMethod.Get);
var request = new Request("emby/System/Info", baseUrl, HttpMethod.Get);
AddHeaders(request, apiKey);
@ -42,9 +42,9 @@ namespace Ombi.Api.Emby
return obj;
}
public async Task<EmbyUser> LogIn(string username, string password, string apiKey, Uri baseUri)
public async Task<EmbyUser> LogIn(string username, string password, string apiKey, string baseUri)
{
var request = new Request("emby/users/authenticatebyname", baseUri.ToString(), HttpMethod.Post);
var request = new Request("emby/users/authenticatebyname", baseUri, HttpMethod.Post);
var body = new

@ -7,8 +7,8 @@ namespace Ombi.Api.Emby
{
public interface IEmbyApi
{
Task<EmbySystemInfo> GetSystemInformation(string apiKey, Uri baseUrl);
Task<List<EmbyUser>> GetUsers(Uri baseUri, string apiKey);
Task<EmbyUser> LogIn(string username, string password, string apiKey, Uri baseUri);
Task<EmbySystemInfo> GetSystemInformation(string apiKey, string baseUrl);
Task<List<EmbyUser>> GetUsers(string baseUri, string apiKey);
Task<EmbyUser> LogIn(string username, string password, string apiKey, string baseUri);
}
}

@ -0,0 +1,12 @@
using System.Collections.Generic;
using System.Threading.Tasks;
using Ombi.Api.Sonarr.Models;
namespace Ombi.Api.Sonarr
{
public interface ISonarrApi
{
Task<IEnumerable<SonarrProfile>> GetProfiles(string apiKey, string baseUrl);
Task<IEnumerable<SonarrRootFolder>> GetRootFolders(string apiKey, string baseUrl);
}
}

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

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

@ -0,0 +1,8 @@
namespace Ombi.Api.Sonarr.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.Sonarr.Models
{
public class SonarrProfile
{
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.Sonarr.Models
{
public class SonarrRootFolder
{
public int id { get; set; }
public string path { get; set; }
public long freespace { get; set; }
}
}

@ -0,0 +1,11 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netstandard1.6</TargetFramework>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\Ombi.Api\Ombi.Api.csproj" />
</ItemGroup>
</Project>

@ -0,0 +1,37 @@
using System.Net.Http;
using System.Collections.Generic;
using System.Threading.Tasks;
using Ombi.Api.Sonarr.Models;
namespace Ombi.Api.Sonarr
{
public class SonarrApi : ISonarrApi
{
public SonarrApi()
{
Api = new Api();
}
private Api Api { get; }
public async Task<IEnumerable<SonarrProfile>> GetProfiles(string apiKey, string baseUrl)
{
var request = new Request(baseUrl, "/api/profile", HttpMethod.Get);
request.AddHeader("X-Api-Key", apiKey);
return await Api.Request<List<SonarrProfile>>(request);
}
public async Task<IEnumerable<SonarrRootFolder>> GetRootFolders(string apiKey, string baseUrl)
{
var request = new Request(baseUrl, "/api/rootfolder", HttpMethod.Get);
request.AddHeader("X-Api-Key", apiKey);
return await Api.Request<List<SonarrRootFolder>>(request);
}
}
}

@ -3,6 +3,8 @@
public enum ContentType
{
Json,
Xml
Xml,
Text,
Html,
}
}

@ -2,13 +2,16 @@
using System.Collections.Generic;
using System.Net.Http;
using System.Text;
using Newtonsoft.Json;
using Newtonsoft.Json.Bson;
namespace Ombi.Api
{
public class Request
{
public Request()
{
}
public Request(string endpoint, string baseUrl, HttpMethod http, ContentType contentType = ContentType.Json)
{
Endpoint = endpoint;

@ -12,17 +12,17 @@ namespace Ombi.Core.Settings.Models.External
public int Port { get; set; }
[JsonIgnore]
public virtual Uri FullUri
public virtual string FullUri
{
get
{
if (!string.IsNullOrEmpty(SubDir))
{
var formattedSubDir = Ip.ReturnUriWithSubDir(Port, Ssl, SubDir);
return formattedSubDir;
return formattedSubDir.ToString();
}
var formatted = Ip.ReturnUri(Port, Ssl);
return formatted;
return formatted.ToString();
}
}
}

@ -0,0 +1,19 @@
namespace Ombi.Core.Settings.Models.External
{
public class SonarrSettings : ExternalSettings
{
public bool Enabled { get; set; }
public string ApiKey { get; set; }
public string QualityProfile { get; set; }
public bool SeasonFolders { get; set; }
/// <summary>
/// This is the root path ID
/// </summary>
/// <value>
/// The root path.
/// </value>
public string RootPath { get; set; }
public string FullRootPath { get; set; }
}
}

@ -6,6 +6,7 @@ using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.DependencyInjection;
using Ombi.Api.Emby;
using Ombi.Api.Plex;
using Ombi.Api.Sonarr;
using Ombi.Core;
using Ombi.Core.Engine;
using Ombi.Core.IdentityResolver;
@ -44,6 +45,7 @@ namespace Ombi.DependencyInjection
services.AddTransient<IMovieDbApi, TheMovieDbApi.TheMovieDbApi>();
services.AddTransient<IPlexApi, PlexApi>();
services.AddTransient<IEmbyApi, EmbyApi>();
services.AddTransient<ISonarrApi, SonarrApi>();
return 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.Sonarr\Ombi.Api.Sonarr.csproj" />
<ProjectReference Include="..\Ombi.Core\Ombi.Core.csproj" />
</ItemGroup>

@ -1,7 +1,7 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.26403.3
VisualStudioVersion = 15.0.26403.7
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Ombi", "Ombi\Ombi.csproj", "{C987AA67-AFE1-468F-ACD3-EAD5A48E1F6A}"
EndProject
@ -38,6 +38,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Ombi.Schedule", "Ombi.Sched
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Ombi.Api.Emby", "Ombi.Api.Emby\Ombi.Api.Emby.csproj", "{08FF107D-31E1-470D-AF86-E09B015CEE06}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Ombi.Api.Sonarr", "Ombi.Api.Sonarr\Ombi.Api.Sonarr.csproj", "{CFB5E008-D0D0-43C0-AA06-89E49D17F384}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@ -88,6 +90,10 @@ Global
{08FF107D-31E1-470D-AF86-E09B015CEE06}.Debug|Any CPU.Build.0 = Debug|Any CPU
{08FF107D-31E1-470D-AF86-E09B015CEE06}.Release|Any CPU.ActiveCfg = Release|Any CPU
{08FF107D-31E1-470D-AF86-E09B015CEE06}.Release|Any CPU.Build.0 = Release|Any CPU
{CFB5E008-D0D0-43C0-AA06-89E49D17F384}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{CFB5E008-D0D0-43C0-AA06-89E49D17F384}.Debug|Any CPU.Build.0 = Debug|Any CPU
{CFB5E008-D0D0-43C0-AA06-89E49D17F384}.Release|Any CPU.ActiveCfg = Release|Any CPU
{CFB5E008-D0D0-43C0-AA06-89E49D17F384}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
@ -99,5 +105,6 @@ Global
{63E63511-1C7F-4162-8F92-8F7391B3C8A3} = {025FB189-2FFB-4F43-A64B-6F1B5A0D2065}
{2E1A7B91-F29B-42BC-8F1E-1CF2DCC389BA} = {9293CA11-360A-4C20-A674-B9E794431BF5}
{08FF107D-31E1-470D-AF86-E09B015CEE06} = {9293CA11-360A-4C20-A674-B9E794431BF5}
{CFB5E008-D0D0-43C0-AA06-89E49D17F384} = {9293CA11-360A-4C20-A674-B9E794431BF5}
EndGlobalSection
EndGlobal

@ -0,0 +1,13 @@
using Microsoft.AspNetCore.Authorization;
namespace Ombi.Attributes
{
public class AdminAttribute : AuthorizeAttribute
{
public AdminAttribute()
{
base.Roles = "Admin";
}
}
}

@ -0,0 +1,12 @@
using Microsoft.AspNetCore.Authorization;
namespace Ombi.Attributes
{
public class PowerUserAttribute : AuthorizeAttribute
{
public PowerUserAttribute()
{
Roles = "Admin, PowerUser";
}
}
}

@ -3,12 +3,13 @@ using System.Threading.Tasks;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Ombi.Api.Emby;
using Ombi.Attributes;
using Ombi.Core.Settings;
using Ombi.Core.Settings.Models.External;
namespace Ombi.Controllers
namespace Ombi.Controllers.External
{
[Authorize]
[Admin]
public class EmbyController : BaseV1ApiController
{
public EmbyController(IEmbyApi emby, ISettingsService<EmbySettings> embySettings)

@ -1,19 +1,16 @@
using System.Collections.Generic;
using System.Linq;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Ombi.Api.Plex;
using Ombi.Api.Plex.Models;
using Ombi.Core.Engine;
using Ombi.Core.Models.Requests;
using Ombi.Core.Models.Search;
using Ombi.Attributes;
using Ombi.Core.Settings;
using Ombi.Core.Settings.Models.External;
namespace Ombi.Controllers
namespace Ombi.Controllers.External
{
[Authorize]
[Admin]
public class PlexController : BaseV1ApiController
{
public PlexController(IPlexApi plexApi, ISettingsService<PlexSettings> plexSettings)
@ -31,7 +28,7 @@ namespace Ombi.Controllers
{
// Do we already have settings?
var settings = await PlexSettings.GetSettingsAsync();
if (settings != null && !string.IsNullOrEmpty(settings.PlexAuthToken)) return null;
if (!string.IsNullOrEmpty(settings?.PlexAuthToken)) return null;
var result = await PlexApi.SignIn(request);
if (!string.IsNullOrEmpty(result.user?.authentication_token))

@ -0,0 +1,37 @@
using System.Collections.Generic;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Ombi.Api.Sonarr;
using Ombi.Api.Sonarr.Models;
using Ombi.Attributes;
using Ombi.Core.Settings;
using Ombi.Core.Settings.Models.External;
namespace Ombi.Controllers.External
{
[Admin]
public class SonarrController : BaseV1ApiController
{
public SonarrController(ISonarrApi sonarr, ISettingsService<SonarrSettings> settings)
{
SonarrApi = sonarr;
SonarrSettings = settings;
}
private ISonarrApi SonarrApi { get; }
private ISettingsService<SonarrSettings> SonarrSettings { get; }
[HttpPost("Profiles")]
public async Task<IEnumerable<SonarrProfile>> GetProfiles([FromBody] SonarrSettings settings)
{
return await SonarrApi.GetProfiles(settings.ApiKey, settings.FullUri);
}
[HttpPost("RootFolders")]
public async Task<IEnumerable<SonarrRootFolder>> GetRootFolders([FromBody] SonarrSettings settings)
{
return await SonarrApi.GetRootFolders(settings.ApiKey, settings.FullUri);
}
}
}

@ -4,6 +4,7 @@ using System.Security.Claims;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Ombi.Attributes;
using Ombi.Core.Claims;
using Ombi.Core.IdentityResolver;
using Ombi.Core.Models;
@ -11,7 +12,7 @@ using Ombi.Models;
namespace Ombi.Controllers
{
[Authorize]
[PowerUser]
public class IdentityController : BaseV1ApiController
{
public IdentityController(IUserIdentityManager identity)

@ -2,12 +2,14 @@
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Ombi.Core;
using Ombi.Core.Models.Search;
namespace Ombi.Controllers
{
[Authorize]
public class SearchController : BaseV1ApiController
{
public SearchController(IMovieEngine movie)

@ -2,13 +2,14 @@
using System.Threading.Tasks;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Ombi.Attributes;
using Ombi.Core.Settings;
using Ombi.Core.Settings.Models;
using Ombi.Core.Settings.Models.External;
namespace Ombi.Controllers
{
[Authorize(Roles = "Admin")]
[Admin]
public class SettingsController : BaseV1ApiController
{
public SettingsController(ISettingsResolver resolver)
@ -30,7 +31,7 @@ namespace Ombi.Controllers
return await Save(ombi);
}
[HttpGet("plex")]
public async Task<PlexSettings> PlexSettings()
{

@ -53,4 +53,10 @@
<Folder Include="Models\Plex\" />
<Folder Include="wwwroot\css\fonts\" />
</ItemGroup>
<ItemGroup>
<Content Update="wwwroot\app\services\request - Copy.service.js.map">
<CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
</Content>
</ItemGroup>
</Project>

@ -14,16 +14,6 @@ namespace Ombi
{
public partial class Startup
{
//public void ConfigureServices(IServiceCollection services)
//{
//}
//public void Configure(IApplicationBuilder app)
//{
// app.UseHangfireServer();
// app.UseHangfireDashboard();
//}
public Startup(IHostingEnvironment env)
{
var builder = new ConfigurationBuilder()

@ -4,6 +4,7 @@
export interface IExternalSettings extends ISettings {
ssl: boolean,
enable:boolean,
subDir: string,
ip: string,
port:number
@ -18,15 +19,21 @@ export interface IOmbiSettings extends ISettings {
}
export interface IEmbySettings extends IExternalSettings {
enable: boolean,
apiKey: string,
administratorId: string,
enableEpisodeSearching:boolean
}
export interface IPlexSettings extends IExternalSettings {
enable: boolean,
enableEpisodeSearching: boolean,
plexAuthToken: string,
machineIdentifier: string
}
export interface ISonarrSettings extends IExternalSettings {
apiKey: string,
qualityProfile: string,
seasonFolders: boolean,
rootPath: string,
fullRootPath:string
}

@ -0,0 +1,27 @@
export interface ISonarrRootFolder {
id: number,
path: string,
freespace:number,
}
export interface ISonarrProfile {
name: string,
id: number,
cutoff: ICutoff,
items:IItem[],
}
export interface ICutoff {
id: number,
name:string,
}
export interface IItem {
allowed: boolean,
quality:IQuality,
}
export interface IQuality {
id: number,
name:string,
}

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

@ -3,7 +3,7 @@ import { AuthHttp } from 'angular2-jwt';
import { Observable } from 'rxjs/Rx';
import { ServiceAuthHelpers } from './service.helpers';
import { IOmbiSettings, IEmbySettings, IPlexSettings } from '../interfaces/ISettings';
import { IOmbiSettings, IEmbySettings, IPlexSettings, ISonarrSettings } from '../interfaces/ISettings';
@Injectable()
export class SettingsService extends ServiceAuthHelpers {
@ -35,4 +35,12 @@ export class SettingsService extends ServiceAuthHelpers {
return this.http.post(`${this.url}/Plex/`, JSON.stringify(settings), { headers: this.headers }).map(this.extractData);
}
getSonarr(): Observable<ISonarrSettings> {
return this.http.get(`${this.url}/Sonarr`).map(this.extractData);
}
saveSonarr(settings: ISonarrSettings): Observable<boolean> {
return this.http.post(`${this.url}/Sonarr`, JSON.stringify(settings), { headers: this.headers }).map(this.extractData);
}
}

@ -1,6 +1,13 @@
<div class="col-sm-8 col-sm-push-1">
<fieldset>
<legend>Emby Configuration</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>
<div class="form-group">
<label for="Ip" class="control-label">Hostname or IP</label>

@ -1,6 +1,14 @@
<div class="col-sm-8 col-sm-push-1">
<fieldset>
<legend>Plex Configuration</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>
<div class="form-group">
<label for="Ip" class="control-label">Hostname or IP</label>

@ -6,6 +6,7 @@ import { RouterModule, Routes } from '@angular/router';
import { AuthService } from '../auth/auth.service';
import { AuthGuard } from '../auth/auth.guard';
import { AuthModule } from '../auth/auth.module';
import { SonarrService } from '../services/applications/sonarr.service';
import { OmbiComponent } from './ombi/ombi.component'
import { PlexComponent } from './plex/plex.component'
@ -41,7 +42,7 @@ const routes: Routes = [
RouterModule
],
providers: [
SonarrService,
AuthService,
AuthGuard,
],

@ -0,0 +1,102 @@
<div class="col-sm-8 col-sm-push-1">
<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,79 @@
import { Component, OnInit } from '@angular/core';
import { ISonarrSettings } from '../../interfaces/ISettings'
import { ISonarrProfile, ISonarrRootFolder } from '../../interfaces/ISonarr'
import { SettingsService } from '../../services/settings.service';
import { SonarrService } from '../../services/applications/sonarr.service';
import { NotificationService } from "../../services/notification.service";
@Component({
selector: 'ombi',
moduleId: module.id,
templateUrl: './sonarr.component.html',
})
export class SonarrComponent implements OnInit {
constructor(private settingsService: SettingsService, private sonarrService: SonarrService, private notificationService: NotificationService) { }
settings: ISonarrSettings;
qualities: ISonarrProfile[];
rootFolders: ISonarrRootFolder[];
selectedRootFolder:ISonarrRootFolder;
selectedQuality: ISonarrProfile;
profilesRunning: boolean;
rootFoldersRunning:boolean;
ngOnInit(): void {
this.settings = {
apiKey: "",
port: 8081,
fullRootPath: "",
rootPath: "",
subDir: "",
ssl: false,
seasonFolders: false,
qualityProfile: "",
ip: "",
enable: false,
id: 0
};
}
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.saveSonarr(this.settings).subscribe(x => {
if (x) {
this.notificationService.success("Settings Saved", "Successfully saved Ombi settings");
} else {
this.notificationService.success("Settings Saved", "There was an error when saving the Ombi settings");
}
});
}
}

@ -0,0 +1,14 @@
"use strict";
System.config({
baseURL: '/lib',
packages: {
'.': {
defaultExtension: 'js'
}
},
map: { app: '../app' }
});
System.import('bundle').then(function () {
System.import('/app/main');
});
//# sourceMappingURL=systemjs.config.js.map

@ -0,0 +1 @@
{"version":3,"file":"systemjs.config.js","sourceRoot":"","sources":["systemjs.config.ts"],"names":[],"mappings":";AAAA,MAAM,CAAC,MAAM,CAAC;IACV,OAAO,EAAE,MAAM;IACf,QAAQ,EAAE;QACN,GAAG,EAAE;YACD,gBAAgB,EAAE,IAAI;SACzB;KACJ;IACD,GAAG,EAAE,EAAE,GAAG,EAAE,QAAQ,EAAE;CACzB,CAAC,CAAA;AAEF,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,IAAI,CAAC;IACzB,MAAM,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC;AAC/B,CAAC,CAAC,CAAA"}
Loading…
Cancel
Save