Skip to content

Commit

Permalink
Merge pull request #1421 from Gabri3lZ/feat-show-on-library-recommended
Browse files Browse the repository at this point in the history
feat: Add "Show on library recommended" option
  • Loading branch information
benscobie authored Dec 15, 2024
2 parents ed9304b + ccc13ba commit 3c9225c
Show file tree
Hide file tree
Showing 8 changed files with 60 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { MigrationInterface, QueryRunner } from 'typeorm';

export class CollectionAddVisibleOnRecommendedField1733583643678
implements MigrationInterface
{
name = 'CollectionAddVisibleOnRecommendedField1733583643678';

public async up(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(
`ALTER TABLE collection ADD COLUMN "visibleOnRecommended" boolean NOT NULL DEFAULT (0)`,
);
}

public async down(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(
`ALTER TABLE collection DROP "visibleOnRecommended"`,
);
}
}
10 changes: 6 additions & 4 deletions server/src/modules/collections/collections.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import { ECollectionLogType } from '../../modules/collections/entities/collectio
interface addCollectionDbResponse {
id: number;
isActive: boolean;
visibleOnRecommended: boolean;
visibleOnHome: boolean;
deleteAfterDays: number;
manualCollection: boolean;
Expand Down Expand Up @@ -252,7 +253,7 @@ export class CollectionsService {
await this.plexApi.UpdateCollectionSettings({
libraryId: collectionObj.libraryId,
collectionId: plexCollection.ratingKey,
recommended: false,
recommended: collection.visibleOnRecommended,
ownHome: collection.visibleOnHome,
sharedHome: collection.visibleOnHome,
});
Expand All @@ -267,7 +268,7 @@ export class CollectionsService {
await this.plexApi.UpdateCollectionSettings({
libraryId: collection.libraryId,
collectionId: plexCollection.ratingKey,
recommended: false,
recommended: collection.visibleOnRecommended,
ownHome: collection.visibleOnHome,
sharedHome: collection.visibleOnHome,
});
Expand Down Expand Up @@ -360,7 +361,7 @@ export class CollectionsService {
await this.plexApi.UpdateCollectionSettings({
libraryId: dbCollection.libraryId,
collectionId: dbCollection.plexId,
recommended: false,
recommended: collection.visibleOnRecommended,
ownHome: collection.visibleOnHome,
sharedHome: collection.visibleOnHome,
});
Expand Down Expand Up @@ -559,7 +560,7 @@ export class CollectionsService {
await this.plexApi.UpdateCollectionSettings({
libraryId: collection.libraryId,
collectionId: collection.plexId,
recommended: false,
recommended: collection.visibleOnRecommended,
ownHome: collection.visibleOnHome,
sharedHome: collection.visibleOnHome,
});
Expand Down Expand Up @@ -918,6 +919,7 @@ export class CollectionsService {
libraryId: collection.libraryId,
arrAction: collection.arrAction ? collection.arrAction : 0,
isActive: collection.isActive,
visibleOnRecommended: collection.visibleOnRecommended,
visibleOnHome: collection.visibleOnHome,
deleteAfterDays: collection.deleteAfterDays,
listExclusions: collection.listExclusions,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ export class Collection {
@Column({ default: 0 })
arrAction: number;

@Column({ default: false })
visibleOnRecommended: boolean;

@Column({ default: false })
visibleOnHome: boolean;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ export interface ICollection {
description?: string;
isActive: boolean;
arrAction: number;
visibleOnRecommended?: boolean;
visibleOnHome?: boolean;
listExclusions?: boolean;
forceOverseerr?: boolean;
Expand Down
2 changes: 2 additions & 0 deletions server/src/modules/rules/rules.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,7 @@ export class RulesService {
forceOverseerr: params.forceOverseerr ? params.forceOverseerr : false,
tautulliWatchedPercentOverride:
params.tautulliWatchedPercentOverride ?? null,
visibleOnRecommended: params.collection?.visibleOnRecommended,
visibleOnHome: params.collection?.visibleOnHome,
deleteAfterDays: +params.collection?.deleteAfterDays,
manualCollection: params.collection?.manualCollection,
Expand Down Expand Up @@ -365,6 +366,7 @@ export class RulesService {
params.tautulliWatchedPercentOverride ?? null,
radarrSettingsId: params.radarrSettingsId ?? null,
sonarrSettingsId: params.sonarrSettingsId ?? null,
visibleOnRecommended: params.collection.visibleOnRecommended,
visibleOnHome: params.collection.visibleOnHome,
deleteAfterDays: +params.collection.deleteAfterDays,
manualCollection: params.collection.manualCollection,
Expand Down
1 change: 1 addition & 0 deletions ui/src/components/AddModal/interfaces.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ export interface ICollectionMedia {
description?: string
isActive?: boolean
arrAction?: number
visibleOnRecommended?: boolean
visibleOnHome?: boolean
deleteAfterDays?: number
type?: EPlexDataType
Expand Down
1 change: 1 addition & 0 deletions ui/src/components/Collection/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ export interface ICollection {
title: string
description?: string
isActive: boolean
visibleOnRecommended?: boolean
visibleOnHome?: boolean
deleteAfterDays?: number
listExclusions?: boolean
Expand Down
27 changes: 27 additions & 0 deletions ui/src/components/Rules/RuleGroup/AddModal/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ interface ICreateApiObject {
radarrSettingsId?: number
sonarrSettingsId?: number
collection: {
visibleOnRecommended: boolean
visibleOnHome: boolean
deleteAfterDays: number
manualCollection?: boolean
Expand Down Expand Up @@ -85,6 +86,7 @@ const AddModal = (props: AddModal) => {
const keepLogsForMonthsRef = useRef<any>()
const tautulliWatchedPercentOverrideRef = useRef<any>()
const manualCollectionNameRef = useRef<any>('My custom collection')
const [showRecommended, setShowRecommended] = useState<boolean>(true)
const [showHome, setShowHome] = useState<boolean>(true)
const [listExclusion, setListExclusion] = useState<boolean>(true)
const [forceOverseerr, setForceOverseerr] = useState<boolean>(false)
Expand Down Expand Up @@ -288,6 +290,7 @@ const AddModal = (props: AddModal) => {

if (collection) {
setCollection(collection)
setShowRecommended(collection.visibleOnRecommended!)
setShowHome(collection.visibleOnHome!)
setListExclusion(collection.listExclusions!)
setForceOverseerr(collection.forceOverseerr!)
Expand Down Expand Up @@ -347,6 +350,7 @@ const AddModal = (props: AddModal) => {
radarrSettingsId: radarrSettingsId,
sonarrSettingsId: sonarrSettingsId,
collection: {
visibleOnRecommended: showRecommended,
visibleOnHome: showHome,
deleteAfterDays: +deleteAfterRef.current.value,
manualCollection: manualCollection,
Expand Down Expand Up @@ -692,6 +696,29 @@ const AddModal = (props: AddModal) => {
</div>
</div>

<div className="form-row">
<label htmlFor="collection_visible" className="text-label">
Show on library recommended
<p className="text-xs font-normal">
Show the collection on the Plex library recommended screen
</p>
</label>
<div className="form-input">
<div className="form-input-field">
<input
type="checkbox"
name="collection_visible_library"
id="collection_visible_library"
className="border-zinc-600 hover:border-zinc-500 focus:border-zinc-500 focus:bg-opacity-100 focus:placeholder-zinc-400 focus:outline-none focus:ring-0"
defaultChecked={showRecommended}
onChange={() => {
setShowRecommended(!showRecommended)
}}
/>
</div>
</div>
</div>

<div className="form-row">
<label htmlFor="collection_visible" className="text-label">
Show on home
Expand Down

0 comments on commit 3c9225c

Please sign in to comment.