diff --git a/src/Ombi.Api.Radarr/IRadarrApi.cs b/src/Ombi.Api.Radarr/IRadarrApi.cs index d3a5c8ed9..557aaf613 100644 --- a/src/Ombi.Api.Radarr/IRadarrApi.cs +++ b/src/Ombi.Api.Radarr/IRadarrApi.cs @@ -1,5 +1,4 @@ -using System; -using System.Collections.Generic; +using System.Collections.Generic; using System.Threading.Tasks; using Ombi.Api.Radarr.Models; @@ -7,9 +6,9 @@ namespace Ombi.Api.Radarr { public interface IRadarrApi { - Task> GetMovies(string apiKey, Uri baseUrl); - Task> GetProfiles(string apiKey, Uri baseUrl); - Task> GetRootFolders(string apiKey, Uri baseUrl); - Task SystemStatus(string apiKey, Uri baseUrl); + Task> GetMovies(string apiKey, string baseUrl); + Task> GetProfiles(string apiKey, string baseUrl); + Task> GetRootFolders(string apiKey, string baseUrl); + Task SystemStatus(string apiKey, string baseUrl); } } \ No newline at end of file diff --git a/src/Ombi.Api.Radarr/RadarrApi.cs b/src/Ombi.Api.Radarr/RadarrApi.cs index eb543bb41..006dce00f 100644 --- a/src/Ombi.Api.Radarr/RadarrApi.cs +++ b/src/Ombi.Api.Radarr/RadarrApi.cs @@ -18,33 +18,33 @@ namespace Ombi.Api.Radarr private Api Api { get; } private ILogger Logger { get; } - public async Task> GetProfiles(string apiKey, Uri baseUrl) + public async Task> GetProfiles(string apiKey, string baseUrl) { - var request = new Request(baseUrl.ToString(), "/api/profile", HttpMethod.Get); + var request = new Request(baseUrl, "/api/profile", HttpMethod.Get); AddHeaders(request, apiKey); return await Api.Request>(request); } - public async Task> GetRootFolders(string apiKey, Uri baseUrl) + public async Task> GetRootFolders(string apiKey, string baseUrl) { - var request = new Request(baseUrl.ToString(), "/api/rootfolder", HttpMethod.Get); + var request = new Request(baseUrl, "/api/rootfolder", HttpMethod.Get); AddHeaders(request, apiKey); return await Api.Request>(request); } - public async Task SystemStatus(string apiKey, Uri baseUrl) + public async Task SystemStatus(string apiKey, string baseUrl) { - var request = new Request(baseUrl.ToString(), "/api/system/status", HttpMethod.Get); + var request = new Request(baseUrl, "/api/system/status", HttpMethod.Get); AddHeaders(request, apiKey); return await Api.Request(request); } - public async Task> GetMovies(string apiKey, Uri baseUrl) + public async Task> GetMovies(string apiKey, string baseUrl) { - var request = new Request(baseUrl.ToString(), "/api/movie", HttpMethod.Get); + var request = new Request(baseUrl, "/api/movie", HttpMethod.Get); AddHeaders(request, apiKey); return await Api.Request>(request); diff --git a/src/Ombi/Controllers/External/RadarrController.cs b/src/Ombi/Controllers/External/RadarrController.cs new file mode 100644 index 000000000..94666e9ed --- /dev/null +++ b/src/Ombi/Controllers/External/RadarrController.cs @@ -0,0 +1,36 @@ +using System.Collections.Generic; +using System.Threading.Tasks; +using Microsoft.AspNetCore.Mvc; +using Ombi.Api.Radarr; +using Ombi.Api.Radarr.Models; +using Ombi.Attributes; +using Ombi.Core.Settings; +using Ombi.Settings.Settings.Models.External; + +namespace Ombi.Controllers.External +{ + [Admin] + public class RadarrController : BaseV1ApiController + { + public RadarrController(IRadarrApi radarr, ISettingsService settings) + { + RadarrApi = radarr; + RadarrSettings = settings; + } + + private IRadarrApi RadarrApi { get; } + private ISettingsService RadarrSettings { get; } + + [HttpPost("Profiles")] + public async Task> GetProfiles([FromBody] RadarrSettings settings) + { + return await RadarrApi.GetProfiles(settings.ApiKey, settings.FullUri); + } + + [HttpPost("RootFolders")] + public async Task> GetRootFolders([FromBody] RadarrSettings settings) + { + return await RadarrApi.GetRootFolders(settings.ApiKey, settings.FullUri); + } + } +} \ No newline at end of file diff --git a/src/Ombi/Ombi.csproj b/src/Ombi/Ombi.csproj index bd7ee7ca9..03f67528b 100644 --- a/src/Ombi/Ombi.csproj +++ b/src/Ombi/Ombi.csproj @@ -55,6 +55,15 @@ + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + PreserveNewest diff --git a/src/Ombi/wwwroot/app/interfaces/IRadarr.ts b/src/Ombi/wwwroot/app/interfaces/IRadarr.ts new file mode 100644 index 000000000..f2b694535 --- /dev/null +++ b/src/Ombi/wwwroot/app/interfaces/IRadarr.ts @@ -0,0 +1,27 @@ +export interface IRadarrRootFolder { + id: number, + path: string, + freespace:number, +} + +export interface IRadarrProfile { + 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, +} \ No newline at end of file diff --git a/src/Ombi/wwwroot/app/services/applications/radarr.service.ts b/src/Ombi/wwwroot/app/services/applications/radarr.service.ts index 21696c46f..73149c658 100644 --- a/src/Ombi/wwwroot/app/services/applications/radarr.service.ts +++ b/src/Ombi/wwwroot/app/services/applications/radarr.service.ts @@ -1,9 +1,10 @@ import { Injectable } from '@angular/core'; import { AuthHttp } from 'angular2-jwt'; -//import { Observable } from 'rxjs/Rx'; +import { Observable } from 'rxjs/Rx'; import { ServiceAuthHelpers } from '../service.helpers'; -//import { IRadarrSettings } from '../../interfaces/ISettings'; +import { IRadarrSettings } from '../../interfaces/ISettings'; +import { IRadarrProfile, IRadarrRootFolder } from '../../interfaces/IRadarr'; @Injectable() export class RadarrService extends ServiceAuthHelpers { @@ -11,10 +12,10 @@ export class RadarrService extends ServiceAuthHelpers { super(http, '/api/v1/Radarr'); } - // getRootFolders(settings: IRadarrSettings): Observable { - // return this.http.post(`${this.url}/RootFolders/`, JSON.stringify(settings), { headers: this.headers }).map(this.extractData); - // } - // getQualityProfiles(settings: IRadarrSettings): Observable { - // return this.http.post(`${this.url}/Profiles/`, JSON.stringify(settings), { headers: this.headers }).map(this.extractData); - // } + getRootFolders(settings: IRadarrSettings): Observable { + return this.http.post(`${this.url}/RootFolders/`, JSON.stringify(settings), { headers: this.headers }).map(this.extractData); + } + getQualityProfiles(settings: IRadarrSettings): Observable { + return this.http.post(`${this.url}/Profiles/`, JSON.stringify(settings), { headers: this.headers }).map(this.extractData); + } } \ No newline at end of file diff --git a/src/Ombi/wwwroot/app/settings/radarr/radarr.component.html b/src/Ombi/wwwroot/app/settings/radarr/radarr.component.html index 9c6df9826..62adab4cd 100644 --- a/src/Ombi/wwwroot/app/settings/radarr/radarr.component.html +++ b/src/Ombi/wwwroot/app/settings/radarr/radarr.component.html @@ -3,7 +3,7 @@
- Sonarr Settings + Radarr Settings
@@ -15,7 +15,7 @@
- +
@@ -31,7 +31,7 @@
- +
@@ -44,7 +44,7 @@
- +
diff --git a/src/Ombi/wwwroot/app/settings/radarr/radarr.component.ts b/src/Ombi/wwwroot/app/settings/radarr/radarr.component.ts index 34dbc7920..ca5633097 100644 --- a/src/Ombi/wwwroot/app/settings/radarr/radarr.component.ts +++ b/src/Ombi/wwwroot/app/settings/radarr/radarr.component.ts @@ -2,10 +2,10 @@ import { Subject } from 'rxjs/Subject'; import "rxjs/add/operator/takeUntil"; -import { IRadarrSettings } from '../../interfaces/ISettings' -import { ISonarrProfile, ISonarrRootFolder } from '../../interfaces/ISonarr' +import { IRadarrSettings } from '../../interfaces/ISettings'; +import { IRadarrProfile, IRadarrRootFolder } from '../../interfaces/IRadarr'; import { SettingsService } from '../../services/settings.service'; -// import { RadarrService } from '../../services/applications/radarr.service'; +import { RadarrService } from '../../services/applications/radarr.service'; import { NotificationService } from "../../services/notification.service"; @Component({ @@ -15,15 +15,15 @@ import { NotificationService } from "../../services/notification.service"; }) export class RadarrComponent implements OnInit { - constructor(private settingsService: SettingsService, /*private radarrService: RadarrService,*/ private notificationService: NotificationService) { } + constructor(private settingsService: SettingsService, private radarrService: RadarrService, private notificationService: NotificationService) { } settings: IRadarrSettings; - qualities: ISonarrProfile[]; - rootFolders: ISonarrRootFolder[]; - - selectedRootFolder:ISonarrRootFolder; - selectedQuality: ISonarrProfile; + qualities: IRadarrProfile[]; + rootFolders: IRadarrRootFolder[]; + + selectedRootFolder: IRadarrRootFolder; + selectedQuality: IRadarrProfile; profilesRunning: boolean; rootFoldersRunning: boolean; @@ -40,23 +40,23 @@ export class RadarrComponent implements OnInit { 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"); - // }); + this.profilesRunning = true; + this.radarrService.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"); - // }); + this.rootFoldersRunning = true; + this.radarrService.getRootFolders(this.settings).subscribe(x => { + this.rootFolders = x; + + this.rootFoldersRunning = false; + this.notificationService.success("Settings Saved", "Successfully retrevied the Root Folders"); + }); } test() { diff --git a/src/Ombi/wwwroot/app/settings/settings.module.ts b/src/Ombi/wwwroot/app/settings/settings.module.ts index e5b9e1d4b..9b92d9d1a 100644 --- a/src/Ombi/wwwroot/app/settings/settings.module.ts +++ b/src/Ombi/wwwroot/app/settings/settings.module.ts @@ -8,12 +8,15 @@ 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 { RadarrService } from '../services/applications/radarr.service'; -import { OmbiComponent } from './ombi/ombi.component' -import { PlexComponent } from './plex/plex.component' -import { EmbyComponent } from './emby/emby.component' -import { LandingPageComponent } from './landingpage/landingpage.component' -import { CustomizationComponent } from './customization/customization.component' +import { OmbiComponent } from './ombi/ombi.component'; +import { PlexComponent } from './plex/plex.component'; +import { EmbyComponent } from './emby/emby.component'; +import { SonarrComponent } from './sonarr/sonarr.component'; +import { RadarrComponent } from './radarr/radarr.component'; +import { LandingPageComponent } from './landingpage/landingpage.component'; +import { CustomizationComponent } from './customization/customization.component'; import { SettingsMenuComponent } from './settingsmenu.component'; @@ -23,6 +26,8 @@ const routes: Routes = [ { path: 'Settings/Ombi', component: OmbiComponent, canActivate: [AuthGuard] }, { path: 'Settings/Plex', component: PlexComponent, canActivate: [AuthGuard] }, { path: 'Settings/Emby', component: EmbyComponent, canActivate: [AuthGuard] }, + { path: 'Settings/Sonarr', component: SonarrComponent, canActivate: [AuthGuard] }, + { path: 'Settings/Radarr', component: RadarrComponent, canActivate: [AuthGuard] }, { path: 'Settings/LandingPage', component: LandingPageComponent, canActivate: [AuthGuard] }, { path: 'Settings/Customization', component: CustomizationComponent, canActivate: [AuthGuard] }, ]; @@ -45,6 +50,8 @@ const routes: Routes = [ EmbyComponent, LandingPageComponent, CustomizationComponent, + SonarrComponent, + RadarrComponent ], exports: [ RouterModule @@ -52,6 +59,7 @@ const routes: Routes = [ providers: [ SonarrService, AuthService, + RadarrService, AuthGuard, ],