mirror of
https://github.com/Ombi-app/Ombi.git
synced 2025-07-12 16:22:55 -07:00
Add quota fields to user view model
This commit is contained in:
parent
cfd9deb17e
commit
9c574fb7e9
7 changed files with 39 additions and 7 deletions
|
@ -23,6 +23,6 @@ namespace Ombi.Core.Engine.Interfaces
|
||||||
Task<int> GetTotal();
|
Task<int> GetTotal();
|
||||||
Task UnSubscribeRequest(int requestId, RequestType type);
|
Task UnSubscribeRequest(int requestId, RequestType type);
|
||||||
Task SubscribeToRequest(int requestId, RequestType type);
|
Task SubscribeToRequest(int requestId, RequestType type);
|
||||||
Task<RequestQuotaCountModel> GetRemainingRequests();
|
Task<RequestQuotaCountModel> GetRemainingRequests(OmbiUser user = null);
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -486,9 +486,13 @@ namespace Ombi.Core.Engine
|
||||||
return new RequestEngineResult {Result = true, Message = $"{movieName} has been successfully added!"};
|
return new RequestEngineResult {Result = true, Message = $"{movieName} has been successfully added!"};
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<RequestQuotaCountModel> GetRemainingRequests()
|
public async Task<RequestQuotaCountModel> GetRemainingRequests(OmbiUser user)
|
||||||
{
|
{
|
||||||
OmbiUser user = await GetUser();
|
if (user == null)
|
||||||
|
{
|
||||||
|
user = await GetUser();
|
||||||
|
}
|
||||||
|
|
||||||
int limit = user.MovieRequestLimit ?? 0;
|
int limit = user.MovieRequestLimit ?? 0;
|
||||||
|
|
||||||
if (limit <= 0)
|
if (limit <= 0)
|
||||||
|
|
|
@ -615,9 +615,13 @@ namespace Ombi.Core.Engine
|
||||||
return new RequestEngineResult { Result = true };
|
return new RequestEngineResult { Result = true };
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<RequestQuotaCountModel> GetRemainingRequests()
|
public async Task<RequestQuotaCountModel> GetRemainingRequests(OmbiUser user)
|
||||||
{
|
{
|
||||||
OmbiUser user = await GetUser();
|
if (user == null)
|
||||||
|
{
|
||||||
|
user = await GetUser();
|
||||||
|
}
|
||||||
|
|
||||||
int limit = user.EpisodeRequestLimit ?? 0;
|
int limit = user.EpisodeRequestLimit ?? 0;
|
||||||
|
|
||||||
if (limit <= 0)
|
if (limit <= 0)
|
||||||
|
|
|
@ -16,6 +16,8 @@ namespace Ombi.Core.Models.UI
|
||||||
public UserType UserType { get; set; }
|
public UserType UserType { get; set; }
|
||||||
public int MovieRequestLimit { get; set; }
|
public int MovieRequestLimit { get; set; }
|
||||||
public int EpisodeRequestLimit { get; set; }
|
public int EpisodeRequestLimit { get; set; }
|
||||||
|
public RequestQuotaCountModel EpisodeRequestQuota { get; set; }
|
||||||
|
public RequestQuotaCountModel MovieRequestQuota { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public class ClaimCheckboxes
|
public class ClaimCheckboxes
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
import { ICheckbox } from ".";
|
import { ICheckbox } from ".";
|
||||||
|
import { IRemainingRequests } from "./IRemainingRequests";
|
||||||
|
|
||||||
export interface IUser {
|
export interface IUser {
|
||||||
id: string;
|
id: string;
|
||||||
|
@ -13,7 +14,10 @@ export interface IUser {
|
||||||
movieRequestLimit: number;
|
movieRequestLimit: number;
|
||||||
episodeRequestLimit: number;
|
episodeRequestLimit: number;
|
||||||
userAccessToken: string;
|
userAccessToken: string;
|
||||||
|
|
||||||
// FOR UI
|
// FOR UI
|
||||||
|
episodeRequestQuota: IRemainingRequests | null;
|
||||||
|
movieRequestQuota: IRemainingRequests | null;
|
||||||
checked: boolean;
|
checked: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -32,6 +32,8 @@ export class UserManagementAddComponent implements OnInit {
|
||||||
episodeRequestLimit: 0,
|
episodeRequestLimit: 0,
|
||||||
movieRequestLimit: 0,
|
movieRequestLimit: 0,
|
||||||
userAccessToken: "",
|
userAccessToken: "",
|
||||||
|
episodeRequestQuota: null,
|
||||||
|
movieRequestQuota: null,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -16,6 +16,7 @@ using Ombi.Api.Plex;
|
||||||
using Ombi.Attributes;
|
using Ombi.Attributes;
|
||||||
using Ombi.Config;
|
using Ombi.Config;
|
||||||
using Ombi.Core.Authentication;
|
using Ombi.Core.Authentication;
|
||||||
|
using Ombi.Core.Engine.Interfaces;
|
||||||
using Ombi.Core.Helpers;
|
using Ombi.Core.Helpers;
|
||||||
using Ombi.Core.Models.UI;
|
using Ombi.Core.Models.UI;
|
||||||
using Ombi.Core.Settings;
|
using Ombi.Core.Settings;
|
||||||
|
@ -60,7 +61,9 @@ namespace Ombi.Controllers
|
||||||
IRepository<IssueComments> issueComments,
|
IRepository<IssueComments> issueComments,
|
||||||
IRepository<NotificationUserId> notificationRepository,
|
IRepository<NotificationUserId> notificationRepository,
|
||||||
IRepository<RequestSubscription> subscriptionRepository,
|
IRepository<RequestSubscription> subscriptionRepository,
|
||||||
ISettingsService<UserManagementSettings> umSettings)
|
ISettingsService<UserManagementSettings> umSettings,
|
||||||
|
IMovieRequestEngine movieRequestEngine,
|
||||||
|
ITvRequestEngine tvRequestEngine)
|
||||||
{
|
{
|
||||||
UserManager = user;
|
UserManager = user;
|
||||||
Mapper = mapper;
|
Mapper = mapper;
|
||||||
|
@ -81,6 +84,8 @@ namespace Ombi.Controllers
|
||||||
_requestSubscriptionRepository = subscriptionRepository;
|
_requestSubscriptionRepository = subscriptionRepository;
|
||||||
_notificationRepository = notificationRepository;
|
_notificationRepository = notificationRepository;
|
||||||
_userManagementSettings = umSettings;
|
_userManagementSettings = umSettings;
|
||||||
|
TvRequestEngine = tvRequestEngine;
|
||||||
|
MovieRequestEngine = movieRequestEngine;
|
||||||
}
|
}
|
||||||
|
|
||||||
private OmbiUserManager UserManager { get; }
|
private OmbiUserManager UserManager { get; }
|
||||||
|
@ -94,6 +99,8 @@ namespace Ombi.Controllers
|
||||||
private IWelcomeEmail WelcomeEmail { get; }
|
private IWelcomeEmail WelcomeEmail { get; }
|
||||||
private IMovieRequestRepository MovieRepo { get; }
|
private IMovieRequestRepository MovieRepo { get; }
|
||||||
private ITvRequestRepository TvRepo { get; }
|
private ITvRequestRepository TvRepo { get; }
|
||||||
|
private IMovieRequestEngine MovieRequestEngine { get; }
|
||||||
|
private ITvRequestEngine TvRequestEngine { get; }
|
||||||
private readonly ILogger<IdentityController> _log;
|
private readonly ILogger<IdentityController> _log;
|
||||||
private readonly IPlexApi _plexApi;
|
private readonly IPlexApi _plexApi;
|
||||||
private readonly ISettingsService<PlexSettings> _plexSettings;
|
private readonly ISettingsService<PlexSettings> _plexSettings;
|
||||||
|
@ -103,7 +110,6 @@ namespace Ombi.Controllers
|
||||||
private readonly IRepository<NotificationUserId> _notificationRepository;
|
private readonly IRepository<NotificationUserId> _notificationRepository;
|
||||||
private readonly IRepository<RequestSubscription> _requestSubscriptionRepository;
|
private readonly IRepository<RequestSubscription> _requestSubscriptionRepository;
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// This is what the Wizard will call when creating the user for the very first time.
|
/// This is what the Wizard will call when creating the user for the very first time.
|
||||||
/// This should never be called after this.
|
/// This should never be called after this.
|
||||||
|
@ -316,6 +322,16 @@ namespace Ombi.Controllers
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (vm.EpisodeRequestLimit > 0)
|
||||||
|
{
|
||||||
|
vm.EpisodeRequestQuota = await TvRequestEngine.GetRemainingRequests(user);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (vm.MovieRequestLimit > 0)
|
||||||
|
{
|
||||||
|
vm.MovieRequestQuota = await MovieRequestEngine.GetRemainingRequests(user);
|
||||||
|
}
|
||||||
|
|
||||||
return vm;
|
return vm;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue