From b6fa61b33ddd337379b28ba1c594def4d815dcd9 Mon Sep 17 00:00:00 2001 From: tidusjar Date: Wed, 20 Oct 2021 22:25:33 +0100 Subject: [PATCH 1/3] test: :white_check_mark: Updated automation tests --- tests/cypress/support/commands.ts | 3 ++- .../details/movie/moviedetails-buttons.spec.ts | 14 +++++++++----- .../tests/discover/discover-cards-requests.spec.ts | 4 ++-- 3 files changed, 13 insertions(+), 8 deletions(-) diff --git a/tests/cypress/support/commands.ts b/tests/cypress/support/commands.ts index 35d58a63e..5eba842cc 100644 --- a/tests/cypress/support/commands.ts +++ b/tests/cypress/support/commands.ts @@ -23,6 +23,7 @@ // // -- This will overwrite an existing command -- // Cypress.Commands.overwrite("visit", (originalFn, url, options) => { ... }) + import 'cypress-wait-until'; Cypress.Commands.add("landingSettings", (enabled) => { @@ -66,7 +67,7 @@ Cypress.Commands.add('removeLogin', () => { }); Cypress.Commands.add('verifyNotification', (text) => { - cy.contains(text); + cy.contains(text, {timeout: 10000}); }); Cypress.Commands.add('createUser', (username, password, claims) => { diff --git a/tests/cypress/tests/details/movie/moviedetails-buttons.spec.ts b/tests/cypress/tests/details/movie/moviedetails-buttons.spec.ts index ea175753a..cff77783b 100644 --- a/tests/cypress/tests/details/movie/moviedetails-buttons.spec.ts +++ b/tests/cypress/tests/details/movie/moviedetails-buttons.spec.ts @@ -10,7 +10,7 @@ describe("Movie Details Buttons", () => { Page.adminOptionsDialog.requestButton.click(); - cy.verifyNotification("Tom & Jerry (2021) has been successfully added"); + cy.verifyNotification("Request for Tom & Jerry has been added successfully"); Page.requestedButton.should("be.visible"); }); @@ -26,7 +26,7 @@ describe("Movie Details Buttons", () => { Page.visit("651571"); Page.requestButton.click(); - cy.verifyNotification("Breach (2020) has been successfully added"); + cy.verifyNotification("Request for Breach has been added successfully"); Page.requestedButton.should("be.visible"); }); @@ -62,7 +62,7 @@ describe("Movie Details Buttons", () => { Page.visit("793723"); Page.requestButton.click(); - cy.verifyNotification("Sentinelle (2021) has been successfully added"); + cy.verifyNotification("Request for Sentinelle has been added successfully"); Page.requestedButton.should("be.visible"); @@ -90,7 +90,7 @@ describe("Movie Details Buttons", () => { Page.adminOptionsDialog.isOpen(); Page.adminOptionsDialog.requestButton.click(); cy.verifyNotification( - "Harry Potter and the Deathly Hallows: Part 1 (2010) has been successfully added" + "Request for Harry Potter and the Deathly Hallows: Part 1 has been added successfully" ); cy.reload(); @@ -98,6 +98,10 @@ describe("Movie Details Buttons", () => { Page.markAvailableButton.should("exist"); Page.markAvailableButton.click(); + cy.waitUntil(() => { + return Page.availableButton.should("be.visible"); + }) + cy.verifyNotification("Request is now available"); Page.availableButton.should("exist"); }); @@ -111,7 +115,7 @@ describe("Movie Details Buttons", () => { Page.adminOptionsDialog.isOpen(); Page.adminOptionsDialog.requestButton.click(); cy.verifyNotification( - "Harry Potter and the Philosopher's Stone (2001) has been successfully added" + "Request for Harry Potter and the Philosopher's Stone has been added successfully" ); cy.reload(); diff --git a/tests/cypress/tests/discover/discover-cards-requests.spec.ts b/tests/cypress/tests/discover/discover-cards-requests.spec.ts index d024225f3..6b330dfa5 100644 --- a/tests/cypress/tests/discover/discover-cards-requests.spec.ts +++ b/tests/cypress/tests/discover/discover-cards-requests.spec.ts @@ -42,7 +42,7 @@ describe("Discover Cards Requests Tests", () => { Page.adminOptionsDialog.isOpen(); Page.adminOptionsDialog.requestButton.click(); - cy.verifyNotification("has been successfully added!"); + cy.verifyNotification("has been added successfully"); card.requestButton.should("not.exist"); card.availabilityText.should("have.text", "Pending"); @@ -91,7 +91,7 @@ describe("Discover Cards Requests Tests", () => { card.requestButton.should("be.visible"); card.requestButton.click(); - cy.verifyNotification("has been successfully added!"); + cy.verifyNotification("has been added successfully"); card.requestButton.should("not.exist"); card.availabilityText.should("have.text", "Pending"); From 03bc23a74e4308aa6b4c6b25636edcdeb65c1f0e Mon Sep 17 00:00:00 2001 From: tidusjar Date: Wed, 20 Oct 2021 22:46:28 +0100 Subject: [PATCH 2/3] feat(request-limits): :sparkles: Added the new request limit options to the bulk edit --- .../usermanagement-user.component.html | 6 +-- .../usermanagement.component.html | 41 +++++++++++++++++-- .../usermanagement.component.scss | 4 ++ .../usermanagement.component.ts | 20 ++++++++- 4 files changed, 63 insertions(+), 8 deletions(-) diff --git a/src/Ombi/ClientApp/src/app/usermanagement/usermanagement-user.component.html b/src/Ombi/ClientApp/src/app/usermanagement/usermanagement-user.component.html index 67152f7d9..fa79862fc 100644 --- a/src/Ombi/ClientApp/src/app/usermanagement/usermanagement-user.component.html +++ b/src/Ombi/ClientApp/src/app/usermanagement/usermanagement-user.component.html @@ -50,7 +50,7 @@
Movie Request Limit Type - + {{RequestLimitType[value]}} @@ -65,7 +65,7 @@
Episode Request Limit Type - + {{RequestLimitType[value]}} @@ -80,7 +80,7 @@
Music Request Limit Type - + {{RequestLimitType[value]}} diff --git a/src/Ombi/ClientApp/src/app/usermanagement/usermanagement.component.html b/src/Ombi/ClientApp/src/app/usermanagement/usermanagement.component.html index 02a790145..f79188ae9 100644 --- a/src/Ombi/ClientApp/src/app/usermanagement/usermanagement.component.html +++ b/src/Ombi/ClientApp/src/app/usermanagement/usermanagement.component.html @@ -118,7 +118,7 @@ - +
@@ -129,19 +129,52 @@
- +
+
Movie Request Limit - +
+
+ Movie Request Limit Type + + + {{RequestLimitType[value]}} + + +
+
+
Episode Request Limit +
+
+ Episode Request Limit Type + + + {{RequestLimitType[value]}} + + +
+
+
+
Music Request Limit +
+
+ Music Request Limit Type + + + {{RequestLimitType[value]}} + + +
+
@@ -152,7 +185,7 @@ - +
diff --git a/src/Ombi/ClientApp/src/app/usermanagement/usermanagement.component.scss b/src/Ombi/ClientApp/src/app/usermanagement/usermanagement.component.scss index df34508cf..1d5d51f69 100644 --- a/src/Ombi/ClientApp/src/app/usermanagement/usermanagement.component.scss +++ b/src/Ombi/ClientApp/src/app/usermanagement/usermanagement.component.scss @@ -87,4 +87,8 @@ table { width: 100%; +} + +::ng-deep .p-sidebar { + background: $background-dark !important; } \ No newline at end of file diff --git a/src/Ombi/ClientApp/src/app/usermanagement/usermanagement.component.ts b/src/Ombi/ClientApp/src/app/usermanagement/usermanagement.component.ts index 2bd2b3d89..81cc08485 100644 --- a/src/Ombi/ClientApp/src/app/usermanagement/usermanagement.component.ts +++ b/src/Ombi/ClientApp/src/app/usermanagement/usermanagement.component.ts @@ -1,5 +1,5 @@ import { AfterViewInit, Component, OnInit, ViewChild } from "@angular/core"; -import { ICheckbox, ICustomizationSettings, IEmailNotificationSettings, IUser } from "../interfaces"; +import { ICheckbox, ICustomizationSettings, IEmailNotificationSettings, IUser, RequestLimitType } from "../interfaces"; import { IdentityService, NotificationService, SettingsService } from "../services"; import { CustomizationFacade } from "../state/customization"; @@ -32,6 +32,12 @@ export class UserManagementComponent implements OnInit { public plexEnabled: boolean; public countries: string[]; + public requestLimitTypes: RequestLimitType[] = [RequestLimitType.Day, RequestLimitType.Week, RequestLimitType.Month]; + public RequestLimitType = RequestLimitType; + + public musicRequestLimitType: RequestLimitType; + public episodeRequestLimitType: RequestLimitType; + public movieRequestLimitType: RequestLimitType; constructor(private identityService: IdentityService, private settingsService: SettingsService, @@ -95,6 +101,15 @@ export class UserManagementComponent implements OnInit { if (this.bulkStreaming) { x.streamingCountry = this.bulkStreaming; } + if (this.musicRequestLimitType) { + x.musicRequestLimitType = this.musicRequestLimitType; + } + if (this.episodeRequestLimitType) { + x.episodeRequestLimitType = this.episodeRequestLimitType; + } + if (this.movieRequestLimitType) { + x.movieRequestLimitType = this.movieRequestLimitType; + } this.identityService.updateUser(x).subscribe(y => { if (!y.successful) { this.notificationService.error(`Could not update user ${x.userName}. Reason ${y.errors[0]}`); @@ -108,6 +123,9 @@ export class UserManagementComponent implements OnInit { this.bulkEpisodeLimit = undefined; this.bulkMusicLimit = undefined; this.bulkStreaming = undefined; + this.movieRequestLimitType = undefined; + this.episodeRequestLimitType = undefined; + this.musicRequestLimitType = undefined; } public isAllSelected() { From 01d4f4d718fe85ac181dae52565fb1b427965b4f Mon Sep 17 00:00:00 2001 From: tidusjar Date: Wed, 20 Oct 2021 22:58:10 +0100 Subject: [PATCH 3/3] 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"); } }); }