diff --git a/src/Ombi/ClientApp/app/usermanagement/usermanagement-user.component.ts b/src/Ombi/ClientApp/app/usermanagement/usermanagement-user.component.ts index fda9df8ea..ee02e53f5 100644 --- a/src/Ombi/ClientApp/app/usermanagement/usermanagement-user.component.ts +++ b/src/Ombi/ClientApp/app/usermanagement/usermanagement-user.component.ts @@ -1,8 +1,8 @@ import { Component, OnInit } from "@angular/core"; import { ActivatedRoute, Router } from "@angular/router"; -import { ICheckbox, INotificationAgent, INotificationPreferences, IUser, UserType } from "../interfaces"; -import { IdentityService, NotificationService } from "../services"; +import { ICheckbox, INotificationAgent, INotificationPreferences, IRadarrProfile, IRadarrRootFolder, ISonarrProfile, ISonarrRootFolder, IUser, UserType } from "../interfaces"; +import { IdentityService, NotificationService, RadarrService, SonarrService } from "../services"; import { ConfirmationService } from "primeng/primeng"; @@ -16,6 +16,11 @@ export class UserManagementUserComponent implements OnInit { public availableClaims: ICheckbox[]; public confirmPass: ""; public notificationPreferences: INotificationPreferences[]; + + public sonarrQualities: ISonarrProfile[]; + public sonarrRootFolders: ISonarrRootFolder[]; + public radarrQualities: IRadarrProfile[]; + public radarrRootFolders: IRadarrRootFolder[]; public NotificationAgent = INotificationAgent; public edit: boolean; @@ -24,18 +29,19 @@ export class UserManagementUserComponent implements OnInit { private notificationService: NotificationService, private router: Router, private route: ActivatedRoute, - private confirmationService: ConfirmationService) { - this.route.params - .subscribe((params: any) => { - if(params.id) { - this.userId = params.id; - this.edit = true; - this.identityService.getUserById(this.userId).subscribe(x => { - this.user = x; + private confirmationService: ConfirmationService, + private sonarrService: SonarrService, + private radarrService: RadarrService) { + + this.route.params.subscribe((params: any) => { + if(params.id) { + this.userId = params.id; + this.edit = true; + this.identityService.getUserById(this.userId).subscribe(x => { + this.user = x; + }); + } }); - } - }); - } public ngOnInit() { @@ -45,6 +51,11 @@ export class UserManagementUserComponent implements OnInit { } else { this.identityService.getNotificationPreferences().subscribe(x => this.notificationPreferences = x); } + this.sonarrService.getQualityProfilesWithoutSettings().subscribe(x => this.sonarrQualities = x); + this.sonarrService.getRootFoldersWithoutSettings().subscribe(x => this.sonarrRootFolders = x); + this.radarrService.getQualityProfilesFromSettings().subscribe(x => this.radarrQualities = x); + this.radarrService.getRootFoldersFromSettings().subscribe(x => this.radarrRootFolders = x); + if(!this.edit) { this.user = { alias: "", @@ -64,12 +75,12 @@ export class UserManagementUserComponent implements OnInit { episodeRequestQuota: null, movieRequestQuota: null, userQualityProfiles: { - radarrQualityProfile: "", - radarrRootPath: "", - sonarrQualityProfile: "", - sonarrQualityProfileAnime: "", - sonarrRootPath: "", - sonarrRootPathAnime: "", + radarrQualityProfile: 0, + radarrRootPath: 0, + sonarrQualityProfile: 0, + sonarrQualityProfileAnime: 0, + sonarrRootPath: 0, + sonarrRootPathAnime: 0, }, }; } diff --git a/src/Ombi/Controllers/External/RadarrController.cs b/src/Ombi/Controllers/External/RadarrController.cs index 8e146be50..128b1a9e2 100644 --- a/src/Ombi/Controllers/External/RadarrController.cs +++ b/src/Ombi/Controllers/External/RadarrController.cs @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using System.Threading.Tasks; +using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; using Microsoft.Extensions.Caching.Memory; using Ombi.Api.Radarr; @@ -12,7 +13,7 @@ using Ombi.Settings.Settings.Models.External; namespace Ombi.Controllers.External { - [PowerUser] + [Authorize] [ApiV1] [Produces("application/json")] public class RadarrController : Controller @@ -34,6 +35,7 @@ namespace Ombi.Controllers.External /// The settings. /// [HttpPost("Profiles")] + [PowerUser] public async Task> GetProfiles([FromBody] RadarrSettings settings) { return await RadarrApi.GetProfiles(settings.ApiKey, settings.FullUri); @@ -45,6 +47,7 @@ namespace Ombi.Controllers.External /// The settings. /// [HttpPost("RootFolders")] + [PowerUser] public async Task> GetRootFolders([FromBody] RadarrSettings settings) { return await RadarrApi.GetRootFolders(settings.ApiKey, settings.FullUri); diff --git a/src/Ombi/Controllers/External/SonarrController.cs b/src/Ombi/Controllers/External/SonarrController.cs index 6d8c4d805..94d1e3edf 100644 --- a/src/Ombi/Controllers/External/SonarrController.cs +++ b/src/Ombi/Controllers/External/SonarrController.cs @@ -11,7 +11,7 @@ using Ombi.Settings.Settings.Models.External; namespace Ombi.Controllers.External { - [PowerUser] + [Authorize] [ApiV1] [Produces("application/json")] public class SonarrController : Controller @@ -31,6 +31,7 @@ namespace Ombi.Controllers.External /// The settings. /// [HttpPost("Profiles")] + [PowerUser] public async Task> GetProfiles([FromBody] SonarrSettings settings) { return await SonarrApi.GetProfiles(settings.ApiKey, settings.FullUri); @@ -42,6 +43,7 @@ namespace Ombi.Controllers.External /// The settings. /// [HttpPost("RootFolders")] + [PowerUser] public async Task> GetRootFolders([FromBody] SonarrSettings settings) { return await SonarrApi.GetRootFolders(settings.ApiKey, settings.FullUri);