From 6d3571f0d243072c65952508b213454fd392096e Mon Sep 17 00:00:00 2001 From: Jamie Rees Date: Sat, 30 May 2020 21:28:50 +0100 Subject: [PATCH] Added issues for non requested iteams --- .../Engine/Interfaces/IMovieEngineV2.cs | 2 + .../Engine/V2/MovieSearchEngineV2.cs | 13 ++++ .../src/app/issues/issuestable.component.html | 6 +- .../movie/movie-details.component.html | 6 +- .../movie/movie-details.component.ts | 68 +++++++++---------- .../shared/interfaces/interfaces.ts | 2 +- .../issues-panel/issues-panel.component.ts | 4 +- .../shared/new-issue/new-issue.component.ts | 3 +- .../components/tv/tv-details.component.html | 4 +- .../components/tv/tv-details.component.ts | 7 +- .../app/media-details/media-details.module.ts | 3 - .../src/app/services/issues.service.ts | 4 ++ .../src/app/services/searchV2.service.ts | 4 ++ src/Ombi/Controllers/V1/IssuesController.cs | 9 +++ src/Ombi/Controllers/V2/SearchController.cs | 10 ++- 15 files changed, 88 insertions(+), 57 deletions(-) diff --git a/src/Ombi.Core/Engine/Interfaces/IMovieEngineV2.cs b/src/Ombi.Core/Engine/Interfaces/IMovieEngineV2.cs index 4012e2ffc..3b8d97dc0 100644 --- a/src/Ombi.Core/Engine/Interfaces/IMovieEngineV2.cs +++ b/src/Ombi.Core/Engine/Interfaces/IMovieEngineV2.cs @@ -24,5 +24,7 @@ namespace Ombi.Core.Engine.Interfaces Task> UpcomingMovies(int currentlyLoaded, int toLoad); Task GetMoviesByActor(int actorId, string langCode); int ResultLimit { get; set; } + + Task GetMovieInfoByImdbId(string imdbId, CancellationToken requestAborted); } } \ No newline at end of file diff --git a/src/Ombi.Core/Engine/V2/MovieSearchEngineV2.cs b/src/Ombi.Core/Engine/V2/MovieSearchEngineV2.cs index 796e0d194..df7f643d7 100644 --- a/src/Ombi.Core/Engine/V2/MovieSearchEngineV2.cs +++ b/src/Ombi.Core/Engine/V2/MovieSearchEngineV2.cs @@ -352,5 +352,18 @@ namespace Ombi.Core.Engine.V2 viewModel.Subscribed = sub != null; } } + + public async Task GetMovieInfoByImdbId(string imdbId, CancellationToken cancellationToken) + { + var langCode = await DefaultLanguageCode(null); + var findResult = await Cache.GetOrAdd(nameof(GetMovieInfoByImdbId) + imdbId + langCode, + async () => await MovieApi.Find(imdbId, ExternalSource.imdb_id), DateTime.Now.AddHours(12), cancellationToken); + + var movie = findResult.movie_results.FirstOrDefault(); + var movieInfo = await Cache.GetOrAdd(nameof(GetMovieInfoByImdbId) + movie.id + langCode, + async () => await MovieApi.GetFullMovieInfo(movie.id, cancellationToken, langCode), DateTime.Now.AddHours(12), cancellationToken); + + return await ProcessSingleMovie(movieInfo); + } } } \ No newline at end of file diff --git a/src/Ombi/ClientApp/src/app/issues/issuestable.component.html b/src/Ombi/ClientApp/src/app/issues/issuestable.component.html index 9dd885cf9..8713d09b2 100644 --- a/src/Ombi/ClientApp/src/app/issues/issuestable.component.html +++ b/src/Ombi/ClientApp/src/app/issues/issuestable.component.html @@ -51,9 +51,9 @@ - - - + + + diff --git a/src/Ombi/ClientApp/src/app/media-details/components/movie/movie-details.component.html b/src/Ombi/ClientApp/src/app/media-details/components/movie/movie-details.component.html index 866adbc74..d6668a8ca 100644 --- a/src/Ombi/ClientApp/src/app/media-details/components/movie/movie-details.component.html +++ b/src/Ombi/ClientApp/src/app/media-details/components/movie/movie-details.component.html @@ -59,7 +59,7 @@ 'MediaDetails.Denied' | translate }} - @@ -109,8 +109,8 @@
-
- +
+
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 202e805d9..bc31afc7d 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 @@ -24,55 +24,55 @@ export class MovieDetailsComponent { public showAdvanced: boolean; // Set on the UI private theMovidDbId: number; + private imdbId: string; constructor(private searchService: SearchV2Service, private route: ActivatedRoute, private sanitizer: DomSanitizer, private imageService: ImageService, public dialog: MatDialog, private requestService: RequestService, public messageService: MessageService, private auth: AuthService) { this.route.params.subscribe((params: any) => { - + debugger; + if (typeof params.movieDbId === 'string' || params.movieDbId instanceof String) { + if (params.movieDbId.startsWith("tt")) { + this.imdbId = params.movieDbId; + } + } this.theMovidDbId = params.movieDbId; - if (params.requestId) { - this.load(+params.requestId); - } else { - this.load(undefined); - } - + this.load(); }); } - public async load(requestId: number|undefined) { + public async load() { this.isAdmin = this.auth.hasRole("admin") || this.auth.hasRole("poweruser"); - if (requestId) { - var result = await this.searchService.getFullMovieDetailsByRequestId(requestId); - this.theMovidDbId = result.id - - this.movie = result; - if (this.movie.requestId > 0) { - // Load up this request - this.hasRequest = true; - this.movieRequest = await this.requestService.getMovieRequest(this.movie.requestId); - } - this.imageService.getMovieBanner(this.theMovidDbId.toString()).subscribe(x => { - this.movie.background = this.sanitizer.bypassSecurityTrustStyle - ("url(" + x + ")"); + if (this.imdbId) { + this.searchService.getMovieByImdbId(this.imdbId).subscribe(async x => { + this.movie = x; + if (this.movie.requestId > 0) { + // Load up this request + this.hasRequest = true; + this.movieRequest = await this.requestService.getMovieRequest(this.movie.requestId); + } + this.imageService.getMovieBanner(this.theMovidDbId.toString()).subscribe(x => { + this.movie.background = this.sanitizer.bypassSecurityTrustStyle + ("url(" + x + ")"); + }); }); } else { - this.searchService.getFullMovieDetails(this.theMovidDbId).subscribe(async x => { - this.movie = x; - if (this.movie.requestId > 0) { - // Load up this request - this.hasRequest = true; - this.movieRequest = await this.requestService.getMovieRequest(this.movie.requestId); - } - this.imageService.getMovieBanner(this.theMovidDbId.toString()).subscribe(x => { - this.movie.background = this.sanitizer.bypassSecurityTrustStyle - ("url(" + x + ")"); + this.searchService.getFullMovieDetails(this.theMovidDbId).subscribe(async x => { + this.movie = x; + if (this.movie.requestId > 0) { + // Load up this request + this.hasRequest = true; + this.movieRequest = await this.requestService.getMovieRequest(this.movie.requestId); + } + this.imageService.getMovieBanner(this.theMovidDbId.toString()).subscribe(x => { + this.movie.background = this.sanitizer.bypassSecurityTrustStyle + ("url(" + x + ")"); + }); }); - }); - } + } } public async request() { @@ -109,7 +109,7 @@ export class MovieDetailsComponent { public async issue() { const dialogRef = this.dialog.open(NewIssueComponent, { width: '500px', - data: {requestId: this.movieRequest ? this.movieRequest.id : null, requestType: RequestType.movie, imdbid: this.movie.imdbId, title: this.movie.title} + data: {requestId: this.movieRequest ? this.movieRequest.id : null, requestType: RequestType.movie, providerId: this.movie.imdbId ? this.movie.imdbId : this.movie.id, title: this.movie.title} }); } diff --git a/src/Ombi/ClientApp/src/app/media-details/components/shared/interfaces/interfaces.ts b/src/Ombi/ClientApp/src/app/media-details/components/shared/interfaces/interfaces.ts index 89b19e453..a2a0b6154 100644 --- a/src/Ombi/ClientApp/src/app/media-details/components/shared/interfaces/interfaces.ts +++ b/src/Ombi/ClientApp/src/app/media-details/components/shared/interfaces/interfaces.ts @@ -9,6 +9,6 @@ export interface IDenyDialogData { export interface IIssueDialogData { requestType: RequestType; requestId: number; - imdbId: string; + providerId: string; title: string; } \ No newline at end of file diff --git a/src/Ombi/ClientApp/src/app/media-details/components/shared/issues-panel/issues-panel.component.ts b/src/Ombi/ClientApp/src/app/media-details/components/shared/issues-panel/issues-panel.component.ts index 2245a07bc..dda7bcb89 100644 --- a/src/Ombi/ClientApp/src/app/media-details/components/shared/issues-panel/issues-panel.component.ts +++ b/src/Ombi/ClientApp/src/app/media-details/components/shared/issues-panel/issues-panel.component.ts @@ -10,7 +10,7 @@ import { TranslateService } from "@ngx-translate/core"; }) export class IssuesPanelComponent implements OnInit { - @Input() public requestId: number; + @Input() public providerId: string; @Input() public isAdmin: boolean; public issuesCount: number; @@ -26,7 +26,7 @@ export class IssuesPanelComponent implements OnInit { } public async ngOnInit() { - this.issues = await this.issuesService.getIssuesByRequestId(this.requestId); + this.issues = await this.issuesService.getIssuesByProviderId(this.providerId); this.issuesCount = this.issues.length; this.calculateOutstanding(); this.settings = await this.settingsService.getIssueSettings().toPromise(); diff --git a/src/Ombi/ClientApp/src/app/media-details/components/shared/new-issue/new-issue.component.ts b/src/Ombi/ClientApp/src/app/media-details/components/shared/new-issue/new-issue.component.ts index 0730ab10d..c42c14fe2 100644 --- a/src/Ombi/ClientApp/src/app/media-details/components/shared/new-issue/new-issue.component.ts +++ b/src/Ombi/ClientApp/src/app/media-details/components/shared/new-issue/new-issue.component.ts @@ -20,6 +20,7 @@ export class NewIssueComponent implements OnInit { private issueService: IssuesService, public messageService: MessageService, private translate: TranslateService) { + debugger; this.issue = { subject: "", description: "", @@ -32,7 +33,7 @@ export class NewIssueComponent implements OnInit { requestId: data.requestId, requestType: data.requestType, title: data.title, - providerId: data.imdbId, + providerId: data.providerId, userReported: undefined, }; } diff --git a/src/Ombi/ClientApp/src/app/media-details/components/tv/tv-details.component.html b/src/Ombi/ClientApp/src/app/media-details/components/tv/tv-details.component.html index 8bacf6f4e..a77708e6a 100644 --- a/src/Ombi/ClientApp/src/app/media-details/components/tv/tv-details.component.html +++ b/src/Ombi/ClientApp/src/app/media-details/components/tv/tv-details.component.html @@ -29,7 +29,7 @@ - @@ -77,7 +77,7 @@
- +
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 9083dc959..a2097d72f 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 @@ -23,7 +23,6 @@ export class TvDetailsComponent implements OnInit { public isAdmin: boolean; private tvdbId: number; - private requestIdFromQuery: number; constructor(private searchService: SearchV2Service, private route: ActivatedRoute, private sanitizer: DomSanitizer, private imageService: ImageService, @@ -32,7 +31,6 @@ export class TvDetailsComponent implements OnInit { this.route.params.subscribe((params: any) => { this.tvdbId = params.tvdbId; this.fromSearch = params.search; - this.requestIdFromQuery = +params.requestId; // Coming from the issues page }); } @@ -46,9 +44,6 @@ export class TvDetailsComponent implements OnInit { if (this.fromSearch) { this.tv = await this.searchService.getTvInfoWithMovieDbId(this.tvdbId); this.tvdbId = this.tv.id; - } else if (this.requestIdFromQuery) { - console.log("REQUESTID" + this.requestIdFromQuery) - this.tv = await this.searchService.getTvInfoWithRequestId(this.requestIdFromQuery); } else { this.tv = await this.searchService.getTvInfo(this.tvdbId); } @@ -68,7 +63,7 @@ export class TvDetailsComponent implements OnInit { public async issue() { const dialogRef = this.dialog.open(NewIssueComponent, { width: '500px', - data: {requestId: this.tvRequest ? this.tv.requestId : null, requestType: RequestType.tvShow, imdbid: this.tv.theTvDbId, title: this.tv.title} + data: {requestId: this.tvRequest ? this.tv.requestId : null, requestType: RequestType.tvShow, providerId: this.tv.theTvDbId, title: this.tv.title} }); } diff --git a/src/Ombi/ClientApp/src/app/media-details/media-details.module.ts b/src/Ombi/ClientApp/src/app/media-details/media-details.module.ts index 5c210fddb..2544a4935 100644 --- a/src/Ombi/ClientApp/src/app/media-details/media-details.module.ts +++ b/src/Ombi/ClientApp/src/app/media-details/media-details.module.ts @@ -12,16 +12,13 @@ import { PipeModule } from "../pipes/pipe.module"; import * as fromComponents from './components'; import { AuthGuard } from "../auth/auth.guard"; -import { RequestServiceV2 } from "../services/requestV2.service"; import { ArtistDetailsComponent } from "./components/artist/artist-details.component"; const routes: Routes = [ { path: "movie/:movieDbId", component: MovieDetailsComponent, canActivate: [AuthGuard] }, - { path: "movie/request/:requestId", component: MovieDetailsComponent, canActivate: [AuthGuard] }, { path: "tv/:tvdbId/:search", component: TvDetailsComponent, canActivate: [AuthGuard] }, { path: "tv/:tvdbId", component: TvDetailsComponent, canActivate: [AuthGuard] }, - { path: "show/request/:requestId", component: TvDetailsComponent, canActivate: [AuthGuard] }, { path: "artist/:artistId", component: ArtistDetailsComponent, canActivate: [AuthGuard] }, ]; @NgModule({ diff --git a/src/Ombi/ClientApp/src/app/services/issues.service.ts b/src/Ombi/ClientApp/src/app/services/issues.service.ts index db9a749ff..eff9ef4ce 100644 --- a/src/Ombi/ClientApp/src/app/services/issues.service.ts +++ b/src/Ombi/ClientApp/src/app/services/issues.service.ts @@ -33,6 +33,10 @@ export class IssuesService extends ServiceHelpers { return this.http.get(`${this.url}request/${requestId}`, {headers: this.headers}).toPromise(); } + public getIssuesByProviderId(providerId: string): Promise { + return this.http.get(`${this.url}provider/${providerId}`, {headers: this.headers}).toPromise(); + } + public getIssuesPage(take: number, skip: number, status: IssueStatus): Observable { return this.http.get(`${this.url}${take}/${skip}/${status}`, {headers: this.headers}); } diff --git a/src/Ombi/ClientApp/src/app/services/searchV2.service.ts b/src/Ombi/ClientApp/src/app/services/searchV2.service.ts index 411620713..f39755041 100644 --- a/src/Ombi/ClientApp/src/app/services/searchV2.service.ts +++ b/src/Ombi/ClientApp/src/app/services/searchV2.service.ts @@ -23,6 +23,10 @@ export class SearchV2Service extends ServiceHelpers { public getFullMovieDetails(theMovieDbId: number): Observable { return this.http.get(`${this.url}/Movie/${theMovieDbId}`); } + + public getMovieByImdbId(imdbId: string): Observable { + return this.http.get(`${this.url}/Movie/imdb/${imdbId}`); + } public getFullMovieDetailsByRequestId(requestId: number): Promise { return this.http.get(`${this.url}/Movie/request/${requestId}`).toPromise(); diff --git a/src/Ombi/Controllers/V1/IssuesController.cs b/src/Ombi/Controllers/V1/IssuesController.cs index e78e46c76..4dfd3781a 100644 --- a/src/Ombi/Controllers/V1/IssuesController.cs +++ b/src/Ombi/Controllers/V1/IssuesController.cs @@ -178,6 +178,15 @@ namespace Ombi.Controllers.V1 .Include(x => x.UserReported).ToListAsync()); } + + [HttpGet("provider/{id}")] + public async Task GetIssueByProviderId([FromRoute] string id) + { + return new OkObjectResult(await _issues.GetAll().Where(x => x.ProviderId == id) + .Include(x => x.IssueCategory) + .Include(x => x.UserReported).ToListAsync()); + } + /// /// Get's all the issue comments by id /// diff --git a/src/Ombi/Controllers/V2/SearchController.cs b/src/Ombi/Controllers/V2/SearchController.cs index ff80dc2f9..587a5621e 100644 --- a/src/Ombi/Controllers/V2/SearchController.cs +++ b/src/Ombi/Controllers/V2/SearchController.cs @@ -61,6 +61,12 @@ namespace Ombi.Controllers.V2 return await _movieEngineV2.GetFullMovieInformation(movieDbId, Request.HttpContext.RequestAborted); } + [HttpGet("movie/imdb/{imdbid}")] + public async Task GetMovieInfoByImdbId(string imdbId) + { + return await _movieEngineV2.GetMovieInfoByImdbId(imdbId, Request.HttpContext.RequestAborted); + } + /// /// Returns details for a single movie /// @@ -354,7 +360,7 @@ namespace Ombi.Controllers.V2 return await _tvSearchEngine.Trending(currentPosition, amountToLoad); } - + /// /// Returns all the movies that is by the actor id /// @@ -365,7 +371,7 @@ namespace Ombi.Controllers.V2 [ProducesDefaultResponseType] public async Task GetMoviesByActor(int actorId) { - return await _movieEngineV2.GetMoviesByActor(actorId, null); + return await _movieEngineV2.GetMoviesByActor(actorId, null); }