From 5e6edc2ad81f344bc4456c0d3ea7c1fc188f7454 Mon Sep 17 00:00:00 2001 From: tidusjar Date: Wed, 24 Mar 2021 20:57:35 +0000 Subject: [PATCH] Got TV working nicely --- src/Ombi.Core/Engine/MovieRequestEngine.cs | 2 +- src/Ombi.Core/Engine/TvRequestEngine.cs | 46 +++++++---- .../Helpers/TvShowRequestBuilderV2.cs | 6 +- src/Ombi.Core/Senders/TvSender.cs | 4 + .../actor/discover-actor.component.html | 2 +- .../actor/discover-actor.component.ts | 22 ++---- .../card/discover-card.component.ts | 9 ++- .../discover-collections.component.html | 2 +- .../discover-collections.component.ts | 8 +- .../movie/movie-details.component.ts | 24 ++++-- .../movie-information-panel.component.html | 2 +- .../tv-request-grid.component.ts | 79 +++++++++++-------- .../components/tv/tv-details.component.ts | 2 +- .../admin-request-dialog.component.html | 5 +- .../admin-request-dialog.component.ts | 37 +++------ .../episode-request.component.ts | 48 +++++++---- src/Ombi/wwwroot/translations/en.json | 1 + 17 files changed, 176 insertions(+), 123 deletions(-) diff --git a/src/Ombi.Core/Engine/MovieRequestEngine.cs b/src/Ombi.Core/Engine/MovieRequestEngine.cs index 997702a5c..00a97f766 100644 --- a/src/Ombi.Core/Engine/MovieRequestEngine.cs +++ b/src/Ombi.Core/Engine/MovieRequestEngine.cs @@ -67,7 +67,7 @@ namespace Ombi.Core.Engine $"{movieInfo.Title}{(!string.IsNullOrEmpty(movieInfo.ReleaseDate) ? $" ({DateTime.Parse(movieInfo.ReleaseDate).Year})" : string.Empty)}"; var userDetails = await GetUser(); - var canRequestOnBehalf = false; + var canRequestOnBehalf = model.RequestOnBehalf.HasValue(); var isAdmin = await UserManager.IsInRoleAsync(userDetails, OmbiRoles.PowerUser) || await UserManager.IsInRoleAsync(userDetails, OmbiRoles.Admin); if (model.RequestOnBehalf.HasValue() && !isAdmin) diff --git a/src/Ombi.Core/Engine/TvRequestEngine.cs b/src/Ombi.Core/Engine/TvRequestEngine.cs index 30d6c4e79..9a2ccbf1e 100644 --- a/src/Ombi.Core/Engine/TvRequestEngine.cs +++ b/src/Ombi.Core/Engine/TvRequestEngine.cs @@ -140,7 +140,7 @@ namespace Ombi.Core.Engine ErrorMessage = "This has already been requested" }; } - return await AddExistingRequest(tvBuilder.ChildRequest, existingRequest, tv.RequestOnBehalf); + return await AddExistingRequest(tvBuilder.ChildRequest, existingRequest, tv.RequestOnBehalf, tv.RootFolderOverride.GetValueOrDefault(), tv.QualityPathOverride.GetValueOrDefault()); } // This is a new request @@ -151,21 +151,27 @@ namespace Ombi.Core.Engine public async Task RequestTvShow(TvRequestViewModelV2 tv) { var user = await GetUser(); - var canRequestOnBehalf = false; + var canRequestOnBehalf = tv.RequestOnBehalf.HasValue(); - if (tv.RequestOnBehalf.HasValue()) + var isAdmin = await UserManager.IsInRoleAsync(user, OmbiRoles.PowerUser) || await UserManager.IsInRoleAsync(user, OmbiRoles.Admin); + if (tv.RequestOnBehalf.HasValue() && !isAdmin) { - canRequestOnBehalf = await UserManager.IsInRoleAsync(user, OmbiRoles.PowerUser) || await UserManager.IsInRoleAsync(user, OmbiRoles.Admin); - - if (!canRequestOnBehalf) + return new RequestEngineResult { - return new RequestEngineResult - { - Result = false, - Message = "You do not have the correct permissions to request on behalf of users!", - ErrorMessage = $"You do not have the correct permissions to request on behalf of users!" - }; - } + Result = false, + Message = "You do not have the correct permissions to request on behalf of users!", + ErrorMessage = $"You do not have the correct permissions to request on behalf of users!" + }; + } + + if ((tv.RootFolderOverride.HasValue || tv.QualityPathOverride.HasValue) && !isAdmin) + { + return new RequestEngineResult + { + Result = false, + Message = "You do not have the correct permissions!", + ErrorMessage = $"You do not have the correct permissions!" + }; } var tvBuilder = new TvShowRequestBuilderV2(MovieDbApi); @@ -240,11 +246,11 @@ namespace Ombi.Core.Engine ErrorMessage = "This has already been requested" }; } - return await AddExistingRequest(tvBuilder.ChildRequest, existingRequest, tv.RequestOnBehalf); + return await AddExistingRequest(tvBuilder.ChildRequest, existingRequest, tv.RequestOnBehalf, tv.RootFolderOverride.GetValueOrDefault(), tv.QualityPathOverride.GetValueOrDefault()); } // This is a new request - var newRequest = tvBuilder.CreateNewRequest(tv); + var newRequest = tvBuilder.CreateNewRequest(tv, tv.RootFolderOverride.GetValueOrDefault(), tv.QualityPathOverride.GetValueOrDefault()); return await AddRequest(newRequest.NewRequest, tv.RequestOnBehalf); } @@ -852,10 +858,18 @@ namespace Ombi.Core.Engine } } - private async Task AddExistingRequest(ChildRequests newRequest, TvRequests existingRequest, string requestOnBehalf) + private async Task AddExistingRequest(ChildRequests newRequest, TvRequests existingRequest, string requestOnBehalf, int rootFolder, int qualityProfile) { // Add the child existingRequest.ChildRequests.Add(newRequest); + if (qualityProfile > 0) + { + existingRequest.QualityOverride = qualityProfile; + } + if (rootFolder > 0) + { + existingRequest.RootFolder = rootFolder; + } await TvRepository.Update(existingRequest); diff --git a/src/Ombi.Core/Helpers/TvShowRequestBuilderV2.cs b/src/Ombi.Core/Helpers/TvShowRequestBuilderV2.cs index e6724b482..02150cc4d 100644 --- a/src/Ombi.Core/Helpers/TvShowRequestBuilderV2.cs +++ b/src/Ombi.Core/Helpers/TvShowRequestBuilderV2.cs @@ -217,7 +217,7 @@ namespace Ombi.Core.Helpers } - public TvShowRequestBuilderV2 CreateNewRequest(TvRequestViewModelV2 tv) + public TvShowRequestBuilderV2 CreateNewRequest(TvRequestViewModelV2 tv, int rootPathOverride, int qualityOverride) { int.TryParse(TheMovieDbRecord.ExternalIds?.TvDbId, out var tvdbId); NewRequest = new TvRequests @@ -232,7 +232,9 @@ namespace Ombi.Core.Helpers TvDbId = tvdbId, ChildRequests = new List(), TotalSeasons = tv.Seasons.Count(), - Background = BackdropPath + Background = BackdropPath, + RootFolder = rootPathOverride, + QualityOverride = qualityOverride }; NewRequest.ChildRequests.Add(ChildRequest); diff --git a/src/Ombi.Core/Senders/TvSender.cs b/src/Ombi.Core/Senders/TvSender.cs index 5d5c48555..9cb98a40b 100644 --- a/src/Ombi.Core/Senders/TvSender.cs +++ b/src/Ombi.Core/Senders/TvSender.cs @@ -208,6 +208,10 @@ namespace Ombi.Core.Senders { qualityToUse = model.ParentRequest.QualityOverride.Value; } + if (model.ParentRequest.RootFolder.HasValue) + { + rootFolderPath = await GetSonarrRootPath(model.ParentRequest.RootFolder.Value, s); + } // Are we using v3 sonarr? var sonarrV3 = s.V3; diff --git a/src/Ombi/ClientApp/src/app/discover/components/actor/discover-actor.component.html b/src/Ombi/ClientApp/src/app/discover/components/actor/discover-actor.component.html index 1f17faf59..a7f6a7847 100644 --- a/src/Ombi/ClientApp/src/app/discover/components/actor/discover-actor.component.html +++ b/src/Ombi/ClientApp/src/app/discover/components/actor/discover-actor.component.html @@ -5,7 +5,7 @@
- +
\ No newline at end of file diff --git a/src/Ombi/ClientApp/src/app/discover/components/actor/discover-actor.component.ts b/src/Ombi/ClientApp/src/app/discover/components/actor/discover-actor.component.ts index 83d4d364c..8cdb90436 100644 --- a/src/Ombi/ClientApp/src/app/discover/components/actor/discover-actor.component.ts +++ b/src/Ombi/ClientApp/src/app/discover/components/actor/discover-actor.component.ts @@ -1,25 +1,29 @@ -import { Component, AfterViewInit } from "@angular/core"; +import { Component } from "@angular/core"; import { ActivatedRoute } from "@angular/router"; import { SearchV2Service } from "../../../services"; import { IActorCredits } from "../../../interfaces/ISearchTvResultV2"; import { IDiscoverCardResult } from "../../interfaces"; import { RequestType } from "../../../interfaces"; +import { AuthService } from "../../../auth/auth.service"; @Component({ templateUrl: "./discover-actor.component.html", styleUrls: ["./discover-actor.component.scss"], }) -export class DiscoverActorComponent implements AfterViewInit { +export class DiscoverActorComponent { public actorId: number; public actorCredits: IActorCredits; public loadingFlag: boolean; + public isAdmin: boolean; public discoverResults: IDiscoverCardResult[] = []; constructor(private searchService: SearchV2Service, - private route: ActivatedRoute) { + private route: ActivatedRoute, + private auth: AuthService) { this.route.params.subscribe((params: any) => { this.actorId = params.actorId; + this.isAdmin = this.auth.isAdmin(); this.loading(); this.searchService.getMoviesByActor(this.actorId).subscribe(res => { this.actorCredits = res; @@ -28,18 +32,6 @@ export class DiscoverActorComponent implements AfterViewInit { }); } - public async ngAfterViewInit() { - // this.discoverResults.forEach((result) => { - // this.searchService.getFullMovieDetails(result.id).subscribe(x => { - // result.available = x.available; - // result.approved = x.approved; - // result.rating = x.voteAverage; - // result.requested = x.requested; - // result.url = x.homepage; - // }); - // }); - } - private createModel() { this.finishLoading(); this.discoverResults = []; diff --git a/src/Ombi/ClientApp/src/app/discover/components/card/discover-card.component.ts b/src/Ombi/ClientApp/src/app/discover/components/card/discover-card.component.ts index 3ea3f75bf..8af67ecd7 100644 --- a/src/Ombi/ClientApp/src/app/discover/components/card/discover-card.component.ts +++ b/src/Ombi/ClientApp/src/app/discover/components/card/discover-card.component.ts @@ -118,12 +118,17 @@ export class DiscoverCardComponent implements OnInit { this.loading = true; switch (this.result.type) { case RequestType.tvShow: - const dia = this.dialog.open(EpisodeRequestComponent, { width: "700px", data: { series: this.tvSearchResult }, panelClass: 'modal-panel' }); + const dia = this.dialog.open(EpisodeRequestComponent, { width: "700px", data: { series: this.tvSearchResult, isAdmin: this.isAdmin }, panelClass: 'modal-panel' }); dia.afterClosed().subscribe(x => this.loading = false); return; case RequestType.movie: if (this.isAdmin) { - this.dialog.open(AdminRequestDialogComponent, { width: "700px", data: { type: RequestType.movie, id: this.result.id }, panelClass: 'modal-panel' }); + const dialog = this.dialog.open(AdminRequestDialogComponent, { width: "700px", data: { type: RequestType.movie, id: this.result.id }, panelClass: 'modal-panel' }); + dialog.afterClosed().subscribe((result) => { + if (result) { + this.result.requested = true; + } + }); } else { this.requestService.requestMovie({ theMovieDbId: +this.result.id, languageCode: null, requestOnBehalf: null, qualityPathOverride: null, rootFolderOverride: null }).subscribe(x => { if (x.result) { diff --git a/src/Ombi/ClientApp/src/app/discover/components/collections/discover-collections.component.html b/src/Ombi/ClientApp/src/app/discover/components/collections/discover-collections.component.html index c78378a2d..4bc510b20 100644 --- a/src/Ombi/ClientApp/src/app/discover/components/collections/discover-collections.component.html +++ b/src/Ombi/ClientApp/src/app/discover/components/collections/discover-collections.component.html @@ -15,7 +15,7 @@
- +
\ No newline at end of file diff --git a/src/Ombi/ClientApp/src/app/discover/components/collections/discover-collections.component.ts b/src/Ombi/ClientApp/src/app/discover/components/collections/discover-collections.component.ts index 9d1193c58..82593bab1 100644 --- a/src/Ombi/ClientApp/src/app/discover/components/collections/discover-collections.component.ts +++ b/src/Ombi/ClientApp/src/app/discover/components/collections/discover-collections.component.ts @@ -4,6 +4,7 @@ import { SearchV2Service, RequestService, MessageService } from "../../../servic import { IMovieCollectionsViewModel } from "../../../interfaces/ISearchTvResultV2"; import { IDiscoverCardResult } from "../../interfaces"; import { RequestType } from "../../../interfaces"; +import { AuthService } from "../../../auth/auth.service"; @Component({ templateUrl: "./discover-collections.component.html", @@ -14,13 +15,15 @@ export class DiscoverCollectionsComponent implements OnInit { public collectionId: number; public collection: IMovieCollectionsViewModel; public loadingFlag: boolean; - + public isAdmin: boolean; + public discoverResults: IDiscoverCardResult[] = []; constructor(private searchService: SearchV2Service, private route: ActivatedRoute, private requestService: RequestService, - private messageService: MessageService) { + private messageService: MessageService, + private auth: AuthService) { this.route.params.subscribe((params: any) => { this.collectionId = params.collectionId; }); @@ -28,6 +31,7 @@ export class DiscoverCollectionsComponent implements OnInit { public async ngOnInit() { this.loadingFlag = true; + this.isAdmin = this.auth.isAdmin(); this.collection = await this.searchService.getMovieCollections(this.collectionId); this.createModel(); } diff --git a/src/Ombi/ClientApp/src/app/media-details/components/movie/movie-details.component.ts b/src/Ombi/ClientApp/src/app/media-details/components/movie/movie-details.component.ts index 74f563406..5c3b49d09 100644 --- a/src/Ombi/ClientApp/src/app/media-details/components/movie/movie-details.component.ts +++ b/src/Ombi/ClientApp/src/app/media-details/components/movie/movie-details.component.ts @@ -88,16 +88,28 @@ export class MovieDetailsComponent { if (this.isAdmin) { const dialog = this.dialog.open(AdminRequestDialogComponent, { width: "700px", data: { type: RequestType.movie, id: this.movie.id }, panelClass: 'modal-panel' }); dialog.afterClosed().subscribe(async (result) => { - if (result) { - this.movie.requested = true; - this.movie.requestId = result.requestId; - this.movieRequest = await this.requestService.getMovieRequest(this.movie.requestId); - } - }); + if (result) { + const requestResult = await this.requestService.requestMovie({ theMovieDbId: this.theMovidDbId, + languageCode: null, + qualityPathOverride: result.radarrPathId, + requestOnBehalf: result.username?.id, + rootFolderOverride: result.radarrFolderId, }).toPromise(); + if (requestResult.result) { + this.movie.requested = true; + this.movie.requestId = result.requestId; + this.movieRequest = await this.requestService.getMovieRequest(this.movie.requestId); + this.messageService.send(requestResult.message, "Ok"); + } else { + this.messageService.send(requestResult.errorMessage, "Ok"); + } + } + }); } else { const result = await this.requestService.requestMovie({ theMovieDbId: this.theMovidDbId, languageCode: null, requestOnBehalf: userId, qualityPathOverride: undefined, rootFolderOverride: undefined }).toPromise(); if (result.result) { this.movie.requested = true; + this.movie.requestId = result.requestId; + this.movieRequest = await this.requestService.getMovieRequest(this.movie.requestId); this.messageService.send(result.message, "Ok"); } else { this.messageService.send(result.errorMessage, "Ok"); diff --git a/src/Ombi/ClientApp/src/app/media-details/components/movie/panels/movie-information-panel.component.html b/src/Ombi/ClientApp/src/app/media-details/components/movie/panels/movie-information-panel.component.html index 636e275c5..5ba86e631 100644 --- a/src/Ombi/ClientApp/src/app/media-details/components/movie/panels/movie-information-panel.component.html +++ b/src/Ombi/ClientApp/src/app/media-details/components/movie/panels/movie-information-panel.component.html @@ -45,7 +45,7 @@
{{'Requests.RequestedBy' | translate }}: - {{request.requestedUser.userAlias}} + {{request.requestedUser.userAlias}}
diff --git a/src/Ombi/ClientApp/src/app/media-details/components/tv/panels/tv-request-grid/tv-request-grid.component.ts b/src/Ombi/ClientApp/src/app/media-details/components/tv/panels/tv-request-grid/tv-request-grid.component.ts index d67073069..8c3633cf6 100644 --- a/src/Ombi/ClientApp/src/app/media-details/components/tv/panels/tv-request-grid/tv-request-grid.component.ts +++ b/src/Ombi/ClientApp/src/app/media-details/components/tv/panels/tv-request-grid/tv-request-grid.component.ts @@ -1,5 +1,5 @@ import { Component, Input } from "@angular/core"; -import { IChildRequests, IEpisodesRequests, INewSeasonRequests, ISeasonsViewModel, ITvRequestViewModelV2, RequestType } from "../../../../../interfaces"; +import { IChildRequests, IEpisodesRequests, INewSeasonRequests, IRequestEngineResult, ISeasonsViewModel, ITvRequestViewModelV2, RequestType } from "../../../../../interfaces"; import { RequestService } from "../../../../../services/request.service"; import { MessageService } from "../../../../../services"; import { DenyDialogComponent } from "../../../shared/deny-dialog/deny-dialog.component"; @@ -7,6 +7,7 @@ import { ISearchTvResultV2 } from "../../../../../interfaces/ISearchTvResultV2"; import { MatDialog } from "@angular/material/dialog"; import { SelectionModel } from "@angular/cdk/collections"; import { RequestServiceV2 } from "../../../../../services/requestV2.service"; +import { AdminRequestDialogComponent } from "../../../../../shared/admin-request-dialog/admin-request-dialog.component"; @Component({ templateUrl: "./tv-request-grid.component.html", @@ -59,38 +60,21 @@ export class TvRequestGridComponent { viewModel.seasons.push(seasonsViewModel); }); - const requestResult = await this.requestServiceV2.requestTv(viewModel).toPromise(); - - if (requestResult.result) { - this.notificationService.send( - `Request for ${this.tv.title} has been added successfully`); - - debugger; - this.selection.clear(); - - if (this.tv.firstSeason) { - this.tv.seasonRequests[0].episodes.forEach(ep => { - ep.requested = true; - ep.requestStatus = "Common.PendingApproval"; - }); - } - if (this.tv.requestAll) { - this.tv.seasonRequests.forEach(season => { - season.episodes.forEach(ep => { - ep.requested = true; - ep.requestStatus = "Common.PendingApproval"; - }); - }); - } - if (this.tv.latestSeason) { - this.tv.seasonRequests[this.tv.seasonRequests.length - 1].episodes.forEach(ep => { - ep.requested = true; - ep.requestStatus = "Common.PendingApproval"; - }); - } + if (this.isAdmin) { + const dialog = this.dialog.open(AdminRequestDialogComponent, { width: "700px", data: { type: RequestType.tvShow, id: this.tv.id }, panelClass: 'modal-panel' }); + dialog.afterClosed().subscribe(async (result) => { + if (result) { + viewModel.requestOnBehalf = result.username?.id; + viewModel.qualityPathOverride = result?.sonarrPathId; + viewModel.rootFolderOverride = result?.sonarrFolderId; + const requestResult = await this.requestServiceV2.requestTv(viewModel).toPromise(); + this.postRequest(requestResult); + } + }); } else { - this.notificationService.send(requestResult.errorMessage ? requestResult.errorMessage : requestResult.message); + const requestResult = await this.requestServiceV2.requestTv(viewModel).toPromise(); + this.postRequest(requestResult); } } @@ -236,4 +220,37 @@ export class TvRequestGridComponent { } return ""; } + + private postRequest(requestResult: IRequestEngineResult) { + if (requestResult.result) { + this.notificationService.send( + `Request for ${this.tv.title} has been added successfully`); + + this.selection.clear(); + + if (this.tv.firstSeason) { + this.tv.seasonRequests[0].episodes.forEach(ep => { + ep.requested = true; + ep.requestStatus = "Common.PendingApproval"; + }); + } + if (this.tv.requestAll) { + this.tv.seasonRequests.forEach(season => { + season.episodes.forEach(ep => { + ep.requested = true; + ep.requestStatus = "Common.PendingApproval"; + }); + }); + } + if (this.tv.latestSeason) { + this.tv.seasonRequests[this.tv.seasonRequests.length - 1].episodes.forEach(ep => { + ep.requested = true; + ep.requestStatus = "Common.PendingApproval"; + }); + } + + } else { + this.notificationService.send(requestResult.errorMessage ? requestResult.errorMessage : requestResult.message); + } + } } diff --git a/src/Ombi/ClientApp/src/app/media-details/components/tv/tv-details.component.ts b/src/Ombi/ClientApp/src/app/media-details/components/tv/tv-details.component.ts index e132cabb5..5180a8260 100644 --- a/src/Ombi/ClientApp/src/app/media-details/components/tv/tv-details.component.ts +++ b/src/Ombi/ClientApp/src/app/media-details/components/tv/tv-details.component.ts @@ -76,7 +76,7 @@ export class TvDetailsComponent implements OnInit { } public async request(userId: string) { - this.dialog.open(EpisodeRequestComponent, { width: "800px", data: { series: this.tv, requestOnBehalf: userId }, panelClass: 'modal-panel' }) + this.dialog.open(EpisodeRequestComponent, { width: "800px", data: { series: this.tv, requestOnBehalf: userId, isAdmin: this.isAdmin }, panelClass: 'modal-panel' }) } public async issue() { diff --git a/src/Ombi/ClientApp/src/app/shared/admin-request-dialog/admin-request-dialog.component.html b/src/Ombi/ClientApp/src/app/shared/admin-request-dialog/admin-request-dialog.component.html index 2bf4e32a9..e286b017d 100644 --- a/src/Ombi/ClientApp/src/app/shared/admin-request-dialog/admin-request-dialog.component.html +++ b/src/Ombi/ClientApp/src/app/shared/admin-request-dialog/admin-request-dialog.component.html @@ -3,7 +3,8 @@

{{'MediaDetails.AdvancedOptions' | translate }}

@@ -31,7 +32,7 @@
-
+

Sonarr Overrides

diff --git a/src/Ombi/ClientApp/src/app/shared/admin-request-dialog/admin-request-dialog.component.ts b/src/Ombi/ClientApp/src/app/shared/admin-request-dialog/admin-request-dialog.component.ts index a558951fc..8e16dd87a 100644 --- a/src/Ombi/ClientApp/src/app/shared/admin-request-dialog/admin-request-dialog.component.ts +++ b/src/Ombi/ClientApp/src/app/shared/admin-request-dialog/admin-request-dialog.component.ts @@ -21,12 +21,9 @@ export class AdminRequestDialogComponent implements OnInit { constructor( public dialogRef: MatDialogRef, @Inject(MAT_DIALOG_DATA) public data: IAdminRequestDialogData, - private requestServiceV2: RequestServiceV2, - private notificationService: MessageService, private identityService: IdentityService, private sonarrService: SonarrService, private radarrService: RadarrService, - private requestService: RequestService, private fb: FormBuilder ) {} @@ -38,7 +35,7 @@ export class AdminRequestDialogComponent implements OnInit { public userId: string; public radarrEnabled: boolean; - + public sonarrEnabled: boolean; public sonarrProfiles: ISonarrProfile[]; public sonarrRootFolders: ISonarrRootFolder[]; @@ -63,12 +60,15 @@ export class AdminRequestDialogComponent implements OnInit { ); if (this.data.type === RequestType.tvShow) { + this.sonarrEnabled = await this.sonarrService.isEnabled(); + if (this.sonarrEnabled) { this.sonarrService.getQualityProfilesWithoutSettings().subscribe(c => { this.sonarrProfiles = c; }); this.sonarrService.getRootFoldersWithoutSettings().subscribe(c => { this.sonarrRootFolders = c; }); + } } if (this.data.type === RequestType.movie) { this.radarrEnabled = await this.radarrService.isRadarrEnabled(); @@ -102,29 +102,10 @@ export class AdminRequestDialogComponent implements OnInit { public async submitRequest() { const model = this.form.value; - if (this.data.type === RequestType.movie) { - this.requestService.requestMovie({ - qualityPathOverride: model.radarrPathId, - requestOnBehalf: model.username?.id, - rootFolderOverride: model.radarrFolderId, - theMovieDbId: this.data.id, - languageCode: null - }).subscribe((x) => { - if (x.result) { - this.notificationService.send(x.message, "Ok"); - model.radarrQualityOverrideTitle = this.radarrProfiles?.filter(x => x.id == model.radarrPathId)[0]?.name; - model.radarrRootFolderTitle = this.radarrRootFolders?.filter(x => x.id == model.radarrFolderId)[0]?.path; - - model.requestId = x.requestId; - - this.dialogRef.close(model); - - } else { - this.notificationService.send(x.errorMessage, "Ok"); - } - - }) - } - + model.radarrQualityOverrideTitle = this.radarrProfiles?.filter(x => x.id == model.radarrPathId)[0]?.name; + model.radarrRootFolderTitle = this.radarrRootFolders?.filter(x => x.id == model.radarrFolderId)[0]?.path; + model.sonarrRootFolderTitle = this.sonarrRootFolders?.filter(x => x.id == model.sonarrFolderId)[0]?.path; + model.sonarrQualityOverrideTitle = this.sonarrProfiles?.filter(x => x.id == model.sonarrPathId)[0]?.name; + this.dialogRef.close(model); } } diff --git a/src/Ombi/ClientApp/src/app/shared/episode-request/episode-request.component.ts b/src/Ombi/ClientApp/src/app/shared/episode-request/episode-request.component.ts index 4959aa88a..f6d7a6e92 100644 --- a/src/Ombi/ClientApp/src/app/shared/episode-request/episode-request.component.ts +++ b/src/Ombi/ClientApp/src/app/shared/episode-request/episode-request.component.ts @@ -1,13 +1,15 @@ import { Component, Inject } from "@angular/core"; import { MatCheckboxChange } from "@angular/material/checkbox"; -import { MatDialogRef, MAT_DIALOG_DATA } from "@angular/material/dialog"; +import { MatDialog, MatDialogRef, MAT_DIALOG_DATA } from "@angular/material/dialog"; import { ISearchTvResultV2 } from "../../interfaces/ISearchTvResultV2"; import { MessageService } from "../../services"; -import { ISeasonsViewModel, IEpisodesRequests, INewSeasonRequests, ITvRequestViewModelV2 } from "../../interfaces"; +import { ISeasonsViewModel, IEpisodesRequests, INewSeasonRequests, ITvRequestViewModelV2, IRequestEngineResult, RequestType } from "../../interfaces"; import { RequestServiceV2 } from "../../services/requestV2.service"; +import { AdminRequestDialogComponent } from "../admin-request-dialog/admin-request-dialog.component"; export interface EpisodeRequestData { series: ISearchTvResultV2; + isAdmin: boolean; requestOnBehalf: string | undefined; } @Component({ @@ -21,7 +23,7 @@ export class EpisodeRequestComponent { } constructor(public dialogRef: MatDialogRef, @Inject(MAT_DIALOG_DATA) public data: EpisodeRequestData, - private requestService: RequestServiceV2, private notificationService: MessageService) { } + private requestService: RequestServiceV2, private notificationService: MessageService, private dialog: MatDialog) { } public async submitRequests() { @@ -57,21 +59,23 @@ export class EpisodeRequestComponent { viewModel.seasons.push(seasonsViewModel); }); - const requestResult = await this.requestService.requestTv(viewModel).toPromise(); + if (this.data.isAdmin) { + const dialog = this.dialog.open(AdminRequestDialogComponent, { width: "700px", data: { type: RequestType.tvShow, id: this.data.series.id }, panelClass: 'modal-panel' }); + dialog.afterClosed().subscribe(async (result) => { + if (result) { + viewModel.requestOnBehalf = result.username?.id; + viewModel.qualityPathOverride = result?.sonarrPathId; + viewModel.rootFolderOverride = result?.sonarrFolderId; - if (requestResult.result) { - this.notificationService.send( - `Request for ${this.data.series.title} has been added successfully`); - - this.data.series.seasonRequests.forEach((season) => { - season.episodes.forEach((ep) => { - ep.selected = false; - }); + const requestResult = await this.requestService.requestTv(viewModel).toPromise(); + this.postRequest(requestResult); + } }); - } else { - this.notificationService.send(requestResult.errorMessage ? requestResult.errorMessage : requestResult.message); + const requestResult = await this.requestService.requestTv(viewModel).toPromise(); + this.postRequest(requestResult); } + this.dialogRef.close(); } @@ -114,4 +118,20 @@ export class EpisodeRequestComponent { this.data.series.latestSeason = true; await this.submitRequests(); } + + private postRequest(requestResult: IRequestEngineResult) { + if (requestResult.result) { + this.notificationService.send( + `Request for ${this.data.series.title} has been added successfully`); + + this.data.series.seasonRequests.forEach((season) => { + season.episodes.forEach((ep) => { + ep.selected = false; + }); + }); + + } else { + this.notificationService.send(requestResult.errorMessage ? requestResult.errorMessage : requestResult.message); + } + } } diff --git a/src/Ombi/wwwroot/translations/en.json b/src/Ombi/wwwroot/translations/en.json index b9873e2cc..28565d0f7 100644 --- a/src/Ombi/wwwroot/translations/en.json +++ b/src/Ombi/wwwroot/translations/en.json @@ -253,6 +253,7 @@ "NotEnoughInfo": "Unfortunately there is not enough information about this show yet!", "AdvancedOptions":"Advanced Options", "AutoApproveOptions":"You can configure the request here, once requested it will be send to your DVR application and will be auto approved!", + "AutoApproveOptionsTv":"You can configure the request here, once requested it will be send to your DVR application and will be auto approved! If the request is already in Sonarr, we will not change the root folder or quality profile if you set it!", "QualityProfilesSelect":"Select A Quality Profile", "RootFolderSelect":"Select A Root Folder", "Status":"Status",