pull in the folder into the ui !wip

This commit is contained in:
TidusJar 2018-09-20 16:07:14 +01:00
commit 78091ff15e
3 changed files with 37 additions and 21 deletions

View file

@ -1,8 +1,8 @@
import { Component, OnInit } from "@angular/core"; import { Component, OnInit } from "@angular/core";
import { ActivatedRoute, Router } from "@angular/router"; import { ActivatedRoute, Router } from "@angular/router";
import { ICheckbox, INotificationAgent, INotificationPreferences, IUser, UserType } from "../interfaces"; import { ICheckbox, INotificationAgent, INotificationPreferences, IRadarrProfile, IRadarrRootFolder, ISonarrProfile, ISonarrRootFolder, IUser, UserType } from "../interfaces";
import { IdentityService, NotificationService } from "../services"; import { IdentityService, NotificationService, RadarrService, SonarrService } from "../services";
import { ConfirmationService } from "primeng/primeng"; import { ConfirmationService } from "primeng/primeng";
@ -17,6 +17,11 @@ export class UserManagementUserComponent implements OnInit {
public confirmPass: ""; public confirmPass: "";
public notificationPreferences: INotificationPreferences[]; public notificationPreferences: INotificationPreferences[];
public sonarrQualities: ISonarrProfile[];
public sonarrRootFolders: ISonarrRootFolder[];
public radarrQualities: IRadarrProfile[];
public radarrRootFolders: IRadarrRootFolder[];
public NotificationAgent = INotificationAgent; public NotificationAgent = INotificationAgent;
public edit: boolean; public edit: boolean;
@ -24,18 +29,19 @@ export class UserManagementUserComponent implements OnInit {
private notificationService: NotificationService, private notificationService: NotificationService,
private router: Router, private router: Router,
private route: ActivatedRoute, private route: ActivatedRoute,
private confirmationService: ConfirmationService) { private confirmationService: ConfirmationService,
this.route.params private sonarrService: SonarrService,
.subscribe((params: any) => { private radarrService: RadarrService) {
if(params.id) {
this.userId = params.id;
this.edit = true;
this.identityService.getUserById(this.userId).subscribe(x => {
this.user = x;
});
}
});
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() { public ngOnInit() {
@ -45,6 +51,11 @@ export class UserManagementUserComponent implements OnInit {
} else { } else {
this.identityService.getNotificationPreferences().subscribe(x => this.notificationPreferences = x); 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) { if(!this.edit) {
this.user = { this.user = {
alias: "", alias: "",
@ -64,12 +75,12 @@ export class UserManagementUserComponent implements OnInit {
episodeRequestQuota: null, episodeRequestQuota: null,
movieRequestQuota: null, movieRequestQuota: null,
userQualityProfiles: { userQualityProfiles: {
radarrQualityProfile: "", radarrQualityProfile: 0,
radarrRootPath: "", radarrRootPath: 0,
sonarrQualityProfile: "", sonarrQualityProfile: 0,
sonarrQualityProfileAnime: "", sonarrQualityProfileAnime: 0,
sonarrRootPath: "", sonarrRootPath: 0,
sonarrRootPathAnime: "", sonarrRootPathAnime: 0,
}, },
}; };
} }

View file

@ -1,6 +1,7 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Threading.Tasks; using System.Threading.Tasks;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Caching.Memory; using Microsoft.Extensions.Caching.Memory;
using Ombi.Api.Radarr; using Ombi.Api.Radarr;
@ -12,7 +13,7 @@ using Ombi.Settings.Settings.Models.External;
namespace Ombi.Controllers.External namespace Ombi.Controllers.External
{ {
[PowerUser] [Authorize]
[ApiV1] [ApiV1]
[Produces("application/json")] [Produces("application/json")]
public class RadarrController : Controller public class RadarrController : Controller
@ -34,6 +35,7 @@ namespace Ombi.Controllers.External
/// <param name="settings">The settings.</param> /// <param name="settings">The settings.</param>
/// <returns></returns> /// <returns></returns>
[HttpPost("Profiles")] [HttpPost("Profiles")]
[PowerUser]
public async Task<IEnumerable<RadarrProfile>> GetProfiles([FromBody] RadarrSettings settings) public async Task<IEnumerable<RadarrProfile>> GetProfiles([FromBody] RadarrSettings settings)
{ {
return await RadarrApi.GetProfiles(settings.ApiKey, settings.FullUri); return await RadarrApi.GetProfiles(settings.ApiKey, settings.FullUri);
@ -45,6 +47,7 @@ namespace Ombi.Controllers.External
/// <param name="settings">The settings.</param> /// <param name="settings">The settings.</param>
/// <returns></returns> /// <returns></returns>
[HttpPost("RootFolders")] [HttpPost("RootFolders")]
[PowerUser]
public async Task<IEnumerable<RadarrRootFolder>> GetRootFolders([FromBody] RadarrSettings settings) public async Task<IEnumerable<RadarrRootFolder>> GetRootFolders([FromBody] RadarrSettings settings)
{ {
return await RadarrApi.GetRootFolders(settings.ApiKey, settings.FullUri); return await RadarrApi.GetRootFolders(settings.ApiKey, settings.FullUri);

View file

@ -11,7 +11,7 @@ using Ombi.Settings.Settings.Models.External;
namespace Ombi.Controllers.External namespace Ombi.Controllers.External
{ {
[PowerUser] [Authorize]
[ApiV1] [ApiV1]
[Produces("application/json")] [Produces("application/json")]
public class SonarrController : Controller public class SonarrController : Controller
@ -31,6 +31,7 @@ namespace Ombi.Controllers.External
/// <param name="settings">The settings.</param> /// <param name="settings">The settings.</param>
/// <returns></returns> /// <returns></returns>
[HttpPost("Profiles")] [HttpPost("Profiles")]
[PowerUser]
public async Task<IEnumerable<SonarrProfile>> GetProfiles([FromBody] SonarrSettings settings) public async Task<IEnumerable<SonarrProfile>> GetProfiles([FromBody] SonarrSettings settings)
{ {
return await SonarrApi.GetProfiles(settings.ApiKey, settings.FullUri); return await SonarrApi.GetProfiles(settings.ApiKey, settings.FullUri);
@ -42,6 +43,7 @@ namespace Ombi.Controllers.External
/// <param name="settings">The settings.</param> /// <param name="settings">The settings.</param>
/// <returns></returns> /// <returns></returns>
[HttpPost("RootFolders")] [HttpPost("RootFolders")]
[PowerUser]
public async Task<IEnumerable<SonarrRootFolder>> GetRootFolders([FromBody] SonarrSettings settings) public async Task<IEnumerable<SonarrRootFolder>> GetRootFolders([FromBody] SonarrSettings settings)
{ {
return await SonarrApi.GetRootFolders(settings.ApiKey, settings.FullUri); return await SonarrApi.GetRootFolders(settings.ApiKey, settings.FullUri);