mirror of
https://github.com/Ombi-app/Ombi.git
synced 2025-07-16 02:02:55 -07:00
Added the root folders and qualities per user!
This commit is contained in:
parent
78091ff15e
commit
91b6dfe2b7
9 changed files with 1313 additions and 40 deletions
|
@ -1,5 +1,6 @@
|
|||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Ombi.Api.CouchPotato;
|
||||
using Ombi.Api.DogNzb.Models;
|
||||
|
@ -9,6 +10,8 @@ using Ombi.Helpers;
|
|||
using Ombi.Settings.Settings.Models.External;
|
||||
using Ombi.Store.Entities.Requests;
|
||||
using Ombi.Api.DogNzb;
|
||||
using Ombi.Store.Entities;
|
||||
using Ombi.Store.Repository;
|
||||
|
||||
namespace Ombi.Core.Senders
|
||||
{
|
||||
|
@ -16,7 +19,7 @@ namespace Ombi.Core.Senders
|
|||
{
|
||||
public MovieSender(ISettingsService<RadarrSettings> radarrSettings, IRadarrApi api, ILogger<MovieSender> log,
|
||||
ISettingsService<DogNzbSettings> dogSettings, IDogNzbApi dogApi, ISettingsService<CouchPotatoSettings> cpSettings,
|
||||
ICouchPotatoApi cpApi)
|
||||
ICouchPotatoApi cpApi, IRepository<UserQualityProfiles> userProfiles)
|
||||
{
|
||||
RadarrSettings = radarrSettings;
|
||||
RadarrApi = api;
|
||||
|
@ -25,6 +28,7 @@ namespace Ombi.Core.Senders
|
|||
DogNzbApi = dogApi;
|
||||
CouchPotatoSettings = cpSettings;
|
||||
CouchPotatoApi = cpApi;
|
||||
_userProfiles = userProfiles;
|
||||
}
|
||||
|
||||
private ISettingsService<RadarrSettings> RadarrSettings { get; }
|
||||
|
@ -34,6 +38,7 @@ namespace Ombi.Core.Senders
|
|||
private ISettingsService<DogNzbSettings> DogNzbSettings { get; }
|
||||
private ISettingsService<CouchPotatoSettings> CouchPotatoSettings { get; }
|
||||
private ICouchPotatoApi CouchPotatoApi { get; }
|
||||
private readonly IRepository<UserQualityProfiles> _userProfiles;
|
||||
|
||||
public async Task<SenderResult> Send(MovieRequests model)
|
||||
{
|
||||
|
@ -88,13 +93,33 @@ namespace Ombi.Core.Senders
|
|||
|
||||
private async Task<SenderResult> SendToRadarr(MovieRequests model, RadarrSettings settings)
|
||||
{
|
||||
|
||||
var qualityToUse = int.Parse(settings.DefaultQualityProfile);
|
||||
|
||||
var rootFolderPath = settings.DefaultRootPath;
|
||||
|
||||
var profiles = await _userProfiles.GetAll().FirstOrDefaultAsync(x => x.UserId == model.RequestedUserId);
|
||||
if (profiles != null)
|
||||
{
|
||||
if (profiles.SonarrRootPathAnime > 0)
|
||||
{
|
||||
rootFolderPath = await RadarrRootPath(profiles.SonarrRootPathAnime, settings);
|
||||
}
|
||||
if (profiles.SonarrQualityProfileAnime > 0)
|
||||
{
|
||||
qualityToUse = profiles.SonarrQualityProfileAnime;
|
||||
}
|
||||
}
|
||||
|
||||
// Overrides on the request take priority
|
||||
if (model.QualityOverride > 0)
|
||||
{
|
||||
qualityToUse = model.QualityOverride;
|
||||
}
|
||||
|
||||
var rootFolderPath = model.RootPathOverride <= 0 ? settings.DefaultRootPath : await RadarrRootPath(model.RootPathOverride, settings);
|
||||
if (model.RootPathOverride > 0)
|
||||
{
|
||||
rootFolderPath = await RadarrRootPath(model.RootPathOverride, settings);
|
||||
}
|
||||
|
||||
// Check if the movie already exists? Since it could be unmonitored
|
||||
var movies = await RadarrApi.GetMovies(settings.ApiKey, settings.FullUri);
|
||||
|
|
|
@ -169,6 +169,7 @@ namespace Ombi.Core.Senders
|
|||
seriesType = "standard";
|
||||
}
|
||||
|
||||
// Overrides on the request take priority
|
||||
if (model.ParentRequest.QualityOverride.HasValue)
|
||||
{
|
||||
qualityToUse = model.ParentRequest.QualityOverride.Value;
|
||||
|
|
1151
src/Ombi.Store/Migrations/20180920201101_UserQualityProfiles.Designer.cs
generated
Normal file
1151
src/Ombi.Store/Migrations/20180920201101_UserQualityProfiles.Designer.cs
generated
Normal file
File diff suppressed because it is too large
Load diff
|
@ -0,0 +1,46 @@
|
|||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
namespace Ombi.Store.Migrations
|
||||
{
|
||||
public partial class UserQualityProfiles : Migration
|
||||
{
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.CreateTable(
|
||||
name: "UserQualityProfiles",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(nullable: false)
|
||||
.Annotation("Sqlite:Autoincrement", true),
|
||||
UserId = table.Column<string>(nullable: true),
|
||||
SonarrQualityProfileAnime = table.Column<int>(nullable: false),
|
||||
SonarrRootPathAnime = table.Column<int>(nullable: false),
|
||||
SonarrRootPath = table.Column<int>(nullable: false),
|
||||
SonarrQualityProfile = table.Column<int>(nullable: false),
|
||||
RadarrRootPath = table.Column<int>(nullable: false),
|
||||
RadarrQualityProfile = table.Column<int>(nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_UserQualityProfiles", x => x.Id);
|
||||
table.ForeignKey(
|
||||
name: "FK_UserQualityProfiles_AspNetUsers_UserId",
|
||||
column: x => x.UserId,
|
||||
principalTable: "AspNetUsers",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Restrict);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_UserQualityProfiles_UserId",
|
||||
table: "UserQualityProfiles",
|
||||
column: "UserId");
|
||||
}
|
||||
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropTable(
|
||||
name: "UserQualityProfiles");
|
||||
}
|
||||
}
|
||||
}
|
|
@ -890,6 +890,32 @@ namespace Ombi.Store.Migrations
|
|||
b.ToTable("UserNotificationPreferences");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Ombi.Store.Entities.UserQualityProfiles", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd();
|
||||
|
||||
b.Property<int>("RadarrQualityProfile");
|
||||
|
||||
b.Property<int>("RadarrRootPath");
|
||||
|
||||
b.Property<int>("SonarrQualityProfile");
|
||||
|
||||
b.Property<int>("SonarrQualityProfileAnime");
|
||||
|
||||
b.Property<int>("SonarrRootPath");
|
||||
|
||||
b.Property<int>("SonarrRootPathAnime");
|
||||
|
||||
b.Property<string>("UserId");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("UserId");
|
||||
|
||||
b.ToTable("UserQualityProfiles");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Ombi.Store.Repository.Requests.EpisodeRequests", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
|
@ -1095,6 +1121,13 @@ namespace Ombi.Store.Migrations
|
|||
.HasForeignKey("UserId");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Ombi.Store.Entities.UserQualityProfiles", b =>
|
||||
{
|
||||
b.HasOne("Ombi.Store.Entities.OmbiUser", "User")
|
||||
.WithMany()
|
||||
.HasForeignKey("UserId");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Ombi.Store.Repository.Requests.EpisodeRequests", b =>
|
||||
{
|
||||
b.HasOne("Ombi.Store.Repository.Requests.SeasonRequests", "Season")
|
||||
|
|
|
@ -63,8 +63,8 @@
|
|||
</select>
|
||||
<button (click)="getProfiles(form)" type="button" class="btn btn-primary-outline col-md-4 col-md-push-1">Get Quality Profiles <span *ngIf="profilesRunning" class="fa fa-spinner fa-spin"> </span></button>
|
||||
|
||||
<small *ngIf="form.get('defaultQualityProfile').hasError('required')" class="error-text">A Default Quality Profile is required</small>
|
||||
</div>
|
||||
<small *ngIf="form.get('defaultQualityProfile').hasError('required')" class="error-text">A Default Quality Profile is required</small>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
|
@ -102,9 +102,9 @@
|
|||
</select>
|
||||
<button (click)="getMetadataProfiles(form)" type="button" class="btn btn-primary-outline col-md-4 col-md-push-1">Get Metadata <span *ngIf="rootFoldersRunning" class="fa fa-spinner fa-spin"></span></button>
|
||||
|
||||
<small *ngIf="form.get('metadataProfileId').hasError('required')" class="error-text">A Metadata profile is required</small>
|
||||
</div>
|
||||
|
||||
<small *ngIf="form.get('metadataProfileId').hasError('required')" class="error-text">A Metadata profile is required</small>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
|
|
|
@ -139,57 +139,60 @@
|
|||
|
||||
</ng-template>
|
||||
</ngb-panel>
|
||||
<ngb-panel title="Quality & Root Path Preferences" *ngIf="user.userQualityProfiles && false">
|
||||
<ngb-panel title="Quality & Root Path Preferences" *ngIf="user.userQualityProfiles">
|
||||
<ng-template ngbPanelContent>
|
||||
<div class="panel panel-default a">
|
||||
<div class="panel-body">
|
||||
|
||||
<div class="form-group">
|
||||
<label for="sonarrQualityProfile" class="control-label">Sonarr Quality Profile</label>
|
||||
<div>
|
||||
<input type="text" [(ngModel)]="user.userQualityProfiles.sonarrQualityProfile"
|
||||
class="form-control form-control-custom" name="sonarrQualityProfile"
|
||||
value="{{user.userQualityProfiles.sonarrQualityProfile}}">
|
||||
<div class="form-group" *ngIf="user.userQualityProfiles.sonarrQualityProfile">
|
||||
<label for="sonarrQualities" class="control-label">Sonarr Quality Profile</label>
|
||||
<div id="sonarrQualities">
|
||||
<select class="form-control form-control-custom" [(ngModel)]="user.userQualityProfiles.sonarrQualityProfile">
|
||||
<option *ngFor="let folder of sonarrQualities" value="{{folder.id}}">{{folder.name}}</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
|
||||
<div class="form-group" *ngIf="user.userQualityProfiles.sonarrQualityProfileAnime">
|
||||
<label for="sonarrQualityProfileAnime" class="control-label">Sonarr Quality Profile (Anime)</label>
|
||||
<div>
|
||||
<input type="text" [(ngModel)]="user.userQualityProfiles.sonarrQualityProfileAnime"
|
||||
class="form-control form-control-custom" name="sonarrQualityProfileAnime"
|
||||
value="{{user.userQualityProfiles.sonarrQualityProfileAnime}}">
|
||||
<div id="sonarrQualityProfileAnime">
|
||||
<select class="form-control form-control-custom" [(ngModel)]="user.userQualityProfiles.sonarrQualityProfileAnime">
|
||||
<option *ngFor="let folder of sonarrQualities" value="{{folder.id}}">{{folder.name}}</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
|
||||
<div class="form-group" *ngIf="user.userQualityProfiles.sonarrRootPath">
|
||||
<label for="sonarrRootPath" class="control-label">Sonarr Root Folder</label>
|
||||
<div>
|
||||
<input type="text" [(ngModel)]="user.userQualityProfiles.sonarrRootPath"
|
||||
class="form-control form-control-custom" name="sonarrRootPath"
|
||||
value="{{user.userQualityProfiles.sonarrRootPath}}">
|
||||
<div id="sonarrRootPath">
|
||||
<select class="form-control form-control-custom" [(ngModel)]="user.userQualityProfiles.sonarrRootPath">
|
||||
<option *ngFor="let folder of sonarrRootFolders" value="{{folder.id}}">{{folder.path}}</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
|
||||
<div class="form-group" *ngIf="user.userQualityProfiles.sonarrRootPathAnime">
|
||||
<label for="sonarrRootPathAnime" class="control-label">Sonarr Root Folder (Anime)</label>
|
||||
<div>
|
||||
<input type="text" [(ngModel)]="user.userQualityProfiles.sonarrRootPathAnime"
|
||||
class="form-control form-control-custom" name="sonarrRootPathAnime"
|
||||
value="{{user.userQualityProfiles.sonarrRootPathAnime}}">
|
||||
<div id="sonarrRootPathAnime">
|
||||
<select class="form-control form-control-custom" [(ngModel)]="user.userQualityProfiles.sonarrRootPathAnime">
|
||||
<option *ngFor="let folder of sonarrRootFolders" value="{{folder.id}}">{{folder.path}}</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="radarrQualityProfile" class="control-label">Radarr Quality Profile</label>
|
||||
<div>
|
||||
<input type="text" [(ngModel)]="user.userQualityProfiles.radarrQualityProfile"
|
||||
class="form-control form-control-custom" name="radarrQualityProfile"
|
||||
value="{{user.userQualityProfiles.radarrQualityProfile}}">
|
||||
<div class="form-group" *ngIf="user.userQualityProfiles.radarrQualityProfile">
|
||||
<label for="radarrQualityProfile" class="control-label">Radarr Quality Profiles</label>
|
||||
<div id="radarrQualityProfile">
|
||||
<select class="form-control form-control-custom" [(ngModel)]="user.userQualityProfiles.radarrQualityProfile">
|
||||
<option *ngFor="let folder of radarrQualities" value="{{folder.id}}">{{folder.name}}</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<div class="form-group" *ngIf="user.userQualityProfiles.radarrRootPath">
|
||||
<label for="radarrRootPath" class="control-label">Radarr Root Folder</label>
|
||||
<div>
|
||||
<input type="text" [(ngModel)]="user.userQualityProfiles.radarrRootPath"
|
||||
class="form-control form-control-custom" name="radarrRootPath"
|
||||
value="{{user.userQualityProfiles.radarrRootPath}}">
|
||||
<div id="radarrRootPath">
|
||||
<select class="form-control form-control-custom" [(ngModel)]="user.userQualityProfiles.radarrRootPath">
|
||||
<option *ngFor="let folder of radarrRootFolders" value="{{folder.id}}">{{folder.path}}</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
|
|
@ -11,7 +11,7 @@ import { UserManagementUserComponent } from "./usermanagement-user.component";
|
|||
import { UserManagementComponent } from "./usermanagement.component";
|
||||
|
||||
import { PipeModule } from "../pipes/pipe.module";
|
||||
import { IdentityService, PlexService } from "../services";
|
||||
import { IdentityService, PlexService, RadarrService, SonarrService } from "../services";
|
||||
|
||||
import { AuthGuard } from "../auth/auth.guard";
|
||||
|
||||
|
@ -58,6 +58,8 @@ const routes: Routes = [
|
|||
IdentityService,
|
||||
ConfirmationService,
|
||||
PlexService,
|
||||
RadarrService,
|
||||
SonarrService,
|
||||
],
|
||||
|
||||
})
|
||||
|
|
|
@ -585,6 +585,15 @@ namespace Ombi.Controllers
|
|||
{
|
||||
var currentQualityProfiles = await
|
||||
_userQualityProfiles.GetAll().FirstOrDefaultAsync(x => x.UserId == user.Id);
|
||||
var add = false;
|
||||
if (currentQualityProfiles == null)
|
||||
{
|
||||
currentQualityProfiles = new UserQualityProfiles
|
||||
{
|
||||
UserId = user.Id
|
||||
};
|
||||
add = true;
|
||||
}
|
||||
|
||||
currentQualityProfiles.RadarrQualityProfile = ui.UserQualityProfiles.RadarrQualityProfile;
|
||||
currentQualityProfiles.RadarrRootPath = ui.UserQualityProfiles.RadarrRootPath;
|
||||
|
@ -592,7 +601,10 @@ namespace Ombi.Controllers
|
|||
currentQualityProfiles.SonarrQualityProfileAnime = ui.UserQualityProfiles.SonarrQualityProfileAnime;
|
||||
currentQualityProfiles.SonarrRootPath = ui.UserQualityProfiles.SonarrRootPath;
|
||||
currentQualityProfiles.SonarrRootPathAnime = ui.UserQualityProfiles.SonarrRootPathAnime;
|
||||
|
||||
if (add)
|
||||
{
|
||||
await _userQualityProfiles.Add(currentQualityProfiles);
|
||||
}
|
||||
await _userQualityProfiles.SaveChangesAsync();
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue