From e418cbae572cf4f713b36ec284064a0b3b630ae0 Mon Sep 17 00:00:00 2001 From: Jamie Rees Date: Thu, 7 Mar 2019 10:26:56 +0000 Subject: [PATCH] Fixed the movies page --- .../app/media-details/media-details.module.ts | 3 ++- .../movie/movie-details.component.ts | 26 ++++++++++--------- .../services/applications/radarr.service.ts | 11 +++++--- .../V1/External/RadarrController.cs | 13 ++++++++-- 4 files changed, 34 insertions(+), 19 deletions(-) diff --git a/src/Ombi/ClientApp/src/app/media-details/media-details.module.ts b/src/Ombi/ClientApp/src/app/media-details/media-details.module.ts index 8264be785..b726c3afe 100644 --- a/src/Ombi/ClientApp/src/app/media-details/media-details.module.ts +++ b/src/Ombi/ClientApp/src/app/media-details/media-details.module.ts @@ -1,7 +1,7 @@ import { NgModule } from "@angular/core"; import { RouterModule, Routes } from "@angular/router"; -import { SearchService, RequestService } from "../services"; +import { SearchService, RequestService, RadarrService } from "../services"; import {CarouselModule} from 'primeng/carousel'; @@ -41,6 +41,7 @@ const routes: Routes = [ providers: [ SearchService, RequestService, + RadarrService, ], }) diff --git a/src/Ombi/ClientApp/src/app/media-details/movie/movie-details.component.ts b/src/Ombi/ClientApp/src/app/media-details/movie/movie-details.component.ts index 08dc3d8f9..d00a0f2de 100644 --- a/src/Ombi/ClientApp/src/app/media-details/movie/movie-details.component.ts +++ b/src/Ombi/ClientApp/src/app/media-details/movie/movie-details.component.ts @@ -36,24 +36,26 @@ export class MovieDetailsComponent { } public load() { - + this.isAdmin = this.auth.hasRole("admin") || this.auth.hasRole("poweruser"); this.searchService.getFullMovieDetails(this.theMovidDbId).subscribe(async x => { this.movie = x; - if(this.movie.requestId > 0) { + if (this.movie.requestId > 0) { // Load up this request this.hasRequest = true; this.movieRequest = await this.requestService.getMovieRequest(this.movie.requestId); if (this.isAdmin) { - this.radarrService.getQualityProfilesFromSettings().subscribe(c => { - this.radarrProfiles = c; - this.setQualityOverrides(); - }); - this.radarrService.getRootFoldersFromSettings().subscribe(c => { - this.radarrRootFolders = c; - this.setRootFolderOverrides(); - }); + if (await this.radarrService.isRadarrEnabled()) { + this.radarrService.getQualityProfilesFromSettings().subscribe(c => { + this.radarrProfiles = c; + this.setQualityOverrides(); + }); + this.radarrService.getRootFoldersFromSettings().subscribe(c => { + this.radarrRootFolders = c; + this.setRootFolderOverrides(); + }); + } } } @@ -83,7 +85,7 @@ export class MovieDetailsComponent { } public async deny() { - const result = await this.requestService.denyMovie({id: this.theMovidDbId, reason: ""}).toPromise(); + const result = await this.requestService.denyMovie({ id: this.theMovidDbId, reason: "" }).toPromise(); if (result.result) { this.movie.approved = false; this.messageService.send(result.message, "Ok"); @@ -93,7 +95,7 @@ export class MovieDetailsComponent { } public async approve() { - const result = await this.requestService.approveMovie({id: this.theMovidDbId}).toPromise(); + const result = await this.requestService.approveMovie({ id: this.theMovidDbId }).toPromise(); if (result.result) { this.movie.approved = false; this.messageService.send(result.message, "Ok"); diff --git a/src/Ombi/ClientApp/src/app/services/applications/radarr.service.ts b/src/Ombi/ClientApp/src/app/services/applications/radarr.service.ts index 140a59d28..90f1dac48 100644 --- a/src/Ombi/ClientApp/src/app/services/applications/radarr.service.ts +++ b/src/Ombi/ClientApp/src/app/services/applications/radarr.service.ts @@ -14,16 +14,19 @@ export class RadarrService extends ServiceHelpers { } public getRootFolders(settings: IRadarrSettings): Observable { - return this.http.post(`${this.url}/RootFolders/`, JSON.stringify(settings), {headers: this.headers}); + return this.http.post(`${this.url}/RootFolders/`, JSON.stringify(settings), { headers: this.headers }); } public getQualityProfiles(settings: IRadarrSettings): Observable { - return this.http.post(`${this.url}/Profiles/`, JSON.stringify(settings), {headers: this.headers}); + return this.http.post(`${this.url}/Profiles/`, JSON.stringify(settings), { headers: this.headers }); } public getRootFoldersFromSettings(): Observable { - return this.http.get(`${this.url}/RootFolders/`, {headers: this.headers}); + return this.http.get(`${this.url}/RootFolders/`, { headers: this.headers }); } public getQualityProfilesFromSettings(): Observable { - return this.http.get(`${this.url}/Profiles/`, {headers: this.headers}); + return this.http.get(`${this.url}/Profiles/`, { headers: this.headers }); + } + public isRadarrEnabled(): Promise { + return this.http.get(`${this.url}/enabled/`, { headers: this.headers }).toPromise(); } } diff --git a/src/Ombi/Controllers/V1/External/RadarrController.cs b/src/Ombi/Controllers/V1/External/RadarrController.cs index e200c83ca..fbad769a4 100644 --- a/src/Ombi/Controllers/V1/External/RadarrController.cs +++ b/src/Ombi/Controllers/V1/External/RadarrController.cs @@ -13,9 +13,10 @@ namespace Ombi.Controllers.V1.External { [Authorize] [ApiV1] + [ApiController] [Produces("application/json")] - public class RadarrController : Controller - { + public class RadarrController : ControllerBase + { public RadarrController(IRadarrApi radarr, ISettingsService settings, ICacheService mem) { @@ -39,6 +40,14 @@ namespace Ombi.Controllers.V1.External return await RadarrApi.GetProfiles(settings.ApiKey, settings.FullUri); } + [HttpGet("enabled")] + [PowerUser] + public async Task Enabled() + { + var settings = await RadarrSettings.GetSettingsAsync(); + return settings.Enabled; + } + /// /// Gets the Radarr root folders. ///