From 01d4f4d718fe85ac181dae52565fb1b427965b4f Mon Sep 17 00:00:00 2001 From: tidusjar Date: Wed, 20 Oct 2021 22:58:10 +0100 Subject: [PATCH] feat(request-limits): :sparkles: Added the new request limit options into the user importer --- .../Jobs/Emby/EmbyUserImporter.cs | 4 ++ .../Jobs/Plex/PlexUserImporter.cs | 4 ++ .../Settings/Models/UserManagementSettings.cs | 7 +++- .../ClientApp/src/app/interfaces/ISettings.ts | 5 +++ .../usermanagement.component.html | 39 ++++++++++++++++--- .../usermanagement.component.ts | 9 +++-- 6 files changed, 59 insertions(+), 9 deletions(-) diff --git a/src/Ombi.Schedule/Jobs/Emby/EmbyUserImporter.cs b/src/Ombi.Schedule/Jobs/Emby/EmbyUserImporter.cs index 4b684b8ab..e85cdb9c4 100644 --- a/src/Ombi.Schedule/Jobs/Emby/EmbyUserImporter.cs +++ b/src/Ombi.Schedule/Jobs/Emby/EmbyUserImporter.cs @@ -117,7 +117,11 @@ namespace Ombi.Schedule.Jobs.Emby ProviderUserId = embyUser.Id, Alias = isConnectUser ? embyUser.Name : string.Empty, MovieRequestLimit = userManagementSettings.MovieRequestLimit, + MovieRequestLimitType = userManagementSettings.MovieRequestLimitType, EpisodeRequestLimit = userManagementSettings.EpisodeRequestLimit, + EpisodeRequestLimitType = userManagementSettings.EpisodeRequestLimitType, + MusicRequestLimit = userManagementSettings.MusicRequestLimit, + MusicRequestLimitType = userManagementSettings.MusicRequestLimitType, StreamingCountry = userManagementSettings.DefaultStreamingCountry }; var result = await _userManager.CreateAsync(newUser); diff --git a/src/Ombi.Schedule/Jobs/Plex/PlexUserImporter.cs b/src/Ombi.Schedule/Jobs/Plex/PlexUserImporter.cs index 1e484b237..56872c1a8 100644 --- a/src/Ombi.Schedule/Jobs/Plex/PlexUserImporter.cs +++ b/src/Ombi.Schedule/Jobs/Plex/PlexUserImporter.cs @@ -104,7 +104,11 @@ namespace Ombi.Schedule.Jobs.Plex Email = plexUser?.Email ?? string.Empty, Alias = string.Empty, MovieRequestLimit = userManagementSettings.MovieRequestLimit, + MovieRequestLimitType = userManagementSettings.MovieRequestLimitType, EpisodeRequestLimit = userManagementSettings.EpisodeRequestLimit, + EpisodeRequestLimitType = userManagementSettings.EpisodeRequestLimitType, + MusicRequestLimit = userManagementSettings.MusicRequestLimit, + MusicRequestLimitType = userManagementSettings.MusicRequestLimitType, StreamingCountry = userManagementSettings.DefaultStreamingCountry }; _log.LogInformation("Creating Plex user {0}", newUser.UserName); diff --git a/src/Ombi.Settings/Settings/Models/UserManagementSettings.cs b/src/Ombi.Settings/Settings/Models/UserManagementSettings.cs index ff6cff278..3547812ee 100644 --- a/src/Ombi.Settings/Settings/Models/UserManagementSettings.cs +++ b/src/Ombi.Settings/Settings/Models/UserManagementSettings.cs @@ -1,4 +1,5 @@ -using System.Collections.Generic; +using Ombi.Store.Entities; +using System.Collections.Generic; namespace Ombi.Settings.Settings.Models { @@ -9,7 +10,11 @@ namespace Ombi.Settings.Settings.Models public bool ImportEmbyUsers { get; set; } public bool ImportJellyfinUsers { get; set; } public int MovieRequestLimit { get; set; } + public RequestLimitType MovieRequestLimitType { get; set; } = RequestLimitType.Week; public int EpisodeRequestLimit { get; set; } + public RequestLimitType EpisodeRequestLimitType { get; set; } = RequestLimitType.Week; + public int MusicRequestLimit { get; set; } + public RequestLimitType MusicRequestLimitType { get; set; } = RequestLimitType.Week; public string DefaultStreamingCountry { get; set; } = "US"; public List DefaultRoles { get; set; } = new List(); public List BannedPlexUserIds { get; set; } = new List(); diff --git a/src/Ombi/ClientApp/src/app/interfaces/ISettings.ts b/src/Ombi/ClientApp/src/app/interfaces/ISettings.ts index 083425deb..919e6a271 100644 --- a/src/Ombi/ClientApp/src/app/interfaces/ISettings.ts +++ b/src/Ombi/ClientApp/src/app/interfaces/ISettings.ts @@ -1,4 +1,5 @@ import { ISettings } from "./ICommon"; +import { RequestLimitType } from "."; export interface IExternalSettings extends ISettings { ssl: boolean; @@ -247,10 +248,14 @@ export interface IUserManagementSettings extends ISettings { defaultRoles: string[]; movieRequestLimit: number; episodeRequestLimit: number; + musicRequestLimit: number; bannedPlexUserIds: string[]; bannedEmbyUserIds: string[]; bannedJellyfinUserIds: string[]; defaultStreamingCountry: string; + movieRequestLimitType: RequestLimitType; + episodeRequestLimitType: RequestLimitType; + musicRequestLimitType: RequestLimitType; } export interface IAbout { diff --git a/src/Ombi/ClientApp/src/app/settings/usermanagement/usermanagement.component.html b/src/Ombi/ClientApp/src/app/settings/usermanagement/usermanagement.component.html index ca6f22b3b..266c725cb 100644 --- a/src/Ombi/ClientApp/src/app/settings/usermanagement/usermanagement.component.html +++ b/src/Ombi/ClientApp/src/app/settings/usermanagement/usermanagement.component.html @@ -39,18 +39,18 @@
Import Jellyfin Users
- +

Jellyfin Users excluded from Import

- +
-

Default Roles

- +

Default Roles

+
@@ -60,7 +60,10 @@
-

Default Request Limits

+

Default Request Limits

+ +
+
@@ -68,12 +71,38 @@
+ Movie Request Limit Type + + + {{RequestLimitType[value]}} + + +
+ +
+ Episode Request Limit Type + + + {{RequestLimitType[value]}} + + +
+ +
+ +
+ Music Request Limit Type + + + {{RequestLimitType[value]}} + + diff --git a/src/Ombi/ClientApp/src/app/settings/usermanagement/usermanagement.component.ts b/src/Ombi/ClientApp/src/app/settings/usermanagement/usermanagement.component.ts index 7b2a5e3e0..4956d5179 100644 --- a/src/Ombi/ClientApp/src/app/settings/usermanagement/usermanagement.component.ts +++ b/src/Ombi/ClientApp/src/app/settings/usermanagement/usermanagement.component.ts @@ -1,8 +1,8 @@ import { Component, OnInit } from "@angular/core"; +import { EmbyService, IdentityService, JellyfinService, JobService, NotificationService, PlexService, SettingsService } from "../../services"; +import { ICheckbox, IUserManagementSettings, RequestLimitType } from "../../interfaces"; -import { ICheckbox, IUserManagementSettings } from "../../interfaces"; import { IUsersModel } from "../../interfaces"; -import { EmbyService, JellyfinService, IdentityService, JobService, NotificationService, PlexService, SettingsService } from "../../services"; @Component({ templateUrl: "./usermanagement.component.html", @@ -31,6 +31,9 @@ export class UserManagementComponent implements OnInit { public enableImportButton = false; public countries: string[]; + public requestLimitTypes: RequestLimitType[] = [RequestLimitType.Day, RequestLimitType.Week, RequestLimitType.Month]; + public RequestLimitType = RequestLimitType; + constructor(private readonly settingsService: SettingsService, private readonly notificationService: NotificationService, private readonly identityService: IdentityService, @@ -120,7 +123,7 @@ export class UserManagementComponent implements OnInit { if (x === true) { this.notificationService.success("Successfully saved the User Management Settings"); } else { - this.notificationService.success( "There was an error when saving the Ombi settings"); + this.notificationService.success( "There was an error when saving the settings"); } }); }