From a6e8eefecc803b74a1fe83cbc3397a9af022f362 Mon Sep 17 00:00:00 2001 From: tidusjar Date: Sat, 25 Sep 2021 22:22:19 +0100 Subject: [PATCH] wip --- src/Ombi.DependencyInjection/IocExtensions.cs | 217 +++++++++--------- .../ClientApp/src/app/interfaces/IUser.ts | 11 + .../remaining-requests.component.ts | 2 +- 3 files changed, 121 insertions(+), 109 deletions(-) diff --git a/src/Ombi.DependencyInjection/IocExtensions.cs b/src/Ombi.DependencyInjection/IocExtensions.cs index bbe4bcb7a..0adde9cff 100644 --- a/src/Ombi.DependencyInjection/IocExtensions.cs +++ b/src/Ombi.DependencyInjection/IocExtensions.cs @@ -89,34 +89,34 @@ namespace Ombi.DependencyInjection public static void RegisterEngines(this IServiceCollection services) { - services.AddScoped(); - services.AddScoped(); - services.AddScoped(); - services.AddScoped(); - services.AddScoped(); - services.AddScoped(); - services.AddScoped(); - services.AddScoped(); - services.AddScoped(); - services.AddScoped(); - services.AddScoped(); - services.AddScoped(); - services.AddScoped(); - services.AddScoped(); - services.AddScoped(); - services.AddScoped(); - services.AddScoped(); - services.AddScoped(); + services.AddTransient(); + services.AddTransient(); + services.AddTransient(); + services.AddTransient(); + services.AddTransient(); + services.AddTransient(); + services.AddTransient(); + services.AddTransient(); + services.AddTransient(); + services.AddTransient(); + services.AddTransient(); + services.AddTransient(); + services.AddTransient(); + services.AddTransient(); + services.AddTransient(); + services.AddTransient(); + services.AddTransient(); + services.AddTransient(); } public static void RegisterEnginesV2(this IServiceCollection services) { - services.AddScoped(); - services.AddScoped(); - services.AddScoped(); - services.AddScoped(); - services.AddScoped(); - services.AddScoped(); + services.AddTransient(); + services.AddTransient(); + services.AddTransient(); + services.AddTransient(); + services.AddTransient(); + services.AddTransient(); } public static void RegisterHttp(this IServiceCollection services) @@ -125,7 +125,7 @@ namespace Ombi.DependencyInjection services.AddSingleton(); services.AddScoped(sp => sp.GetService().HttpContext.User); services.AddHttpClient("OmbiClient", client => - { + { client.DefaultRequestHeaders.Add("User-Agent", $"Ombi/{runtimeVersion} (https://ombi.io/)"); }).ConfigurePrimaryHttpMessageHandler(() => { @@ -139,47 +139,48 @@ namespace Ombi.DependencyInjection public static void RegisterApi(this IServiceCollection services) { services.AddScoped(s => new Api.Api(s.GetRequiredService>(), s.GetRequiredService().CreateClient("OmbiClient"))); - services.AddScoped(); - services.AddScoped(); - services.AddScoped(); - services.AddScoped(); - services.AddScoped(); - services.AddScoped(); - services.AddScoped(); - services.AddScoped(); - services.AddScoped(); - services.AddScoped(); - services.AddScoped(); - services.AddScoped(); - services.AddScoped(); - services.AddScoped(); - services.AddScoped(); - services.AddScoped(); - services.AddScoped(); - services.AddScoped(); - services.AddScoped(); - services.AddScoped(); - services.AddScoped(); - services.AddScoped(); - services.AddScoped(); - services.AddScoped(); - services.AddScoped(); - services.AddScoped(); - services.AddScoped(); - services.AddScoped(); - services.AddScoped(); - services.AddScoped(); - services.AddScoped(); - services.AddScoped(); - services.AddScoped(); - services.AddScoped(); + services.AddTransient(); + services.AddTransient(); + services.AddTransient(); + services.AddTransient(); + services.AddTransient(); + services.AddTransient(); + services.AddTransient(); + services.AddTransient(); + services.AddTransient(); + services.AddTransient(); + services.AddTransient(); + services.AddTransient(); + services.AddTransient(); + services.AddTransient(); + services.AddTransient(); + services.AddTransient(); + services.AddTransient(); + services.AddTransient(); + services.AddTransient(); + services.AddTransient(); + services.AddTransient(); + services.AddTransient(); + services.AddTransient(); + services.AddTransient(); + services.AddTransient(); + services.AddTransient(); + services.AddTransient(); + services.AddTransient(); + services.AddTransient(); + services.AddTransient(); + services.AddTransient(); + services.AddTransient(); + services.AddTransient(); + services.AddTransient(); } - public static void RegisterStore(this IServiceCollection services) { + public static void RegisterStore(this IServiceCollection services) + { //services.AddDbContext(); //services.AddDbContext(); //services.AddDbContext(); - + //services.AddScoped(); // https://docs.microsoft.com/en-us/aspnet/core/data/entity-framework-6 //services.AddScoped(); // https://docs.microsoft.com/en-us/aspnet/core/data/entity-framework-6 //services.AddScoped(); // https://docs.microsoft.com/en-us/aspnet/core/data/entity-framework-6 @@ -189,7 +190,7 @@ namespace Ombi.DependencyInjection services.AddScoped(); services.AddScoped(); services.AddScoped(); - + services.AddScoped(); services.AddScoped(); services.AddScoped(); @@ -202,27 +203,27 @@ namespace Ombi.DependencyInjection } public static void RegisterServices(this IServiceCollection services) { - services.AddScoped(); - services.AddScoped(); - services.AddScoped(); - services.AddScoped(); + services.AddTransient(); + services.AddTransient(); + services.AddTransient(); + services.AddTransient(); services.AddSingleton(); services.AddSingleton(); services.AddScoped(); - services.AddSingleton(); + services.AddScoped(); - services.AddScoped(); - services.AddScoped(); - services.AddScoped(); - services.AddScoped(); - services.AddScoped(); - services.AddScoped(); - services.AddScoped(); - services.AddScoped(); - services.AddScoped(); - services.AddScoped(); - services.AddScoped(); - services.AddScoped(); + services.AddTransient(); + services.AddTransient(); + services.AddTransient(); + services.AddTransient(); + services.AddTransient(); + services.AddTransient(); + services.AddTransient(); + services.AddTransient(); + services.AddTransient(); + services.AddTransient(); + services.AddTransient(); + services.AddTransient(); } public static void RegisterJobs(this IServiceCollection services) @@ -230,35 +231,35 @@ namespace Ombi.DependencyInjection services.AddSingleton(); services.AddSingleton(); - services.AddSingleton(); - services.AddSingleton(); - services.AddSingleton(); - services.AddSingleton(); - services.AddSingleton(); - services.AddSingleton(); - services.AddSingleton(); - services.AddSingleton(); - services.AddSingleton(); - services.AddSingleton(); - services.AddSingleton(); - services.AddSingleton(); - services.AddSingleton(); - services.AddSingleton(); - services.AddSingleton(); - services.AddSingleton(); - services.AddSingleton(); - services.AddSingleton(); - services.AddSingleton(); - services.AddSingleton(); - services.AddSingleton(); - services.AddSingleton(); - services.AddSingleton(); - services.AddSingleton(); - services.AddSingleton(); - services.AddSingleton(); - services.AddSingleton(); - services.AddSingleton(); - services.AddSingleton(); + services.AddTransient(); + services.AddTransient(); + services.AddTransient(); + services.AddTransient(); + services.AddTransient(); + services.AddTransient(); + services.AddTransient(); + services.AddTransient(); + services.AddTransient(); + services.AddTransient(); + services.AddTransient(); + services.AddTransient(); + services.AddTransient(); + services.AddTransient(); + services.AddTransient(); + services.AddTransient(); + services.AddTransient(); + services.AddTransient(); + services.AddTransient(); + services.AddTransient(); + services.AddTransient(); + services.AddTransient(); + services.AddTransient(); + services.AddTransient(); + services.AddTransient(); + services.AddTransient(); + services.AddTransient(); + services.AddTransient(); + services.AddTransient(); } } } diff --git a/src/Ombi/ClientApp/src/app/interfaces/IUser.ts b/src/Ombi/ClientApp/src/app/interfaces/IUser.ts index aad167a84..2db5a5de2 100644 --- a/src/Ombi/ClientApp/src/app/interfaces/IUser.ts +++ b/src/Ombi/ClientApp/src/app/interfaces/IUser.ts @@ -20,12 +20,23 @@ export interface IUser { userQualityProfiles: IUserQualityProfiles; streamingCountry: string; + movieRequestLimitType?: RequestLimitType; + episodeRequestLimitType?: RequestLimitType; + musicRequestLimitType?: RequestLimitType; + // FOR UI episodeRequestQuota: IRemainingRequests | null; movieRequestQuota: IRemainingRequests | null; musicRequestQuota: IRemainingRequests | null; } +export enum RequestLimitType +{ + Day = 0, + Week = 1, + Month = 2, +} + export interface IUserDropdown { username: string; id: string; diff --git a/src/Ombi/ClientApp/src/app/shared/remaining-requests/remaining-requests.component.ts b/src/Ombi/ClientApp/src/app/shared/remaining-requests/remaining-requests.component.ts index 8cff9d078..110053e75 100644 --- a/src/Ombi/ClientApp/src/app/shared/remaining-requests/remaining-requests.component.ts +++ b/src/Ombi/ClientApp/src/app/shared/remaining-requests/remaining-requests.component.ts @@ -43,7 +43,7 @@ export class RemainingRequestsComponent implements OnInit { private start() { - const callback = (remaining => { + const callback = ((remaining: IRemainingRequests) => { this.remaining = remaining; if (this.remaining && this.remaining.hasLimit) { this.calculateTime();