From 121b242159b8b9fa3bba03b48ec55468a57e5208 Mon Sep 17 00:00:00 2001 From: TidusJar Date: Thu, 28 Feb 2019 14:13:20 +0000 Subject: [PATCH] !wip --- .../movie/movie-details.component.html | 25 +++++---- .../movie/movie-details.component.ts | 54 +++++++++++++++++-- 2 files changed, 66 insertions(+), 13 deletions(-) diff --git a/src/Ombi/ClientApp/src/app/media-details/movie/movie-details.component.html b/src/Ombi/ClientApp/src/app/media-details/movie/movie-details.component.html index 02fc5124e..83a39776c 100644 --- a/src/Ombi/ClientApp/src/app/media-details/movie/movie-details.component.html +++ b/src/Ombi/ClientApp/src/app/media-details/movie/movie-details.component.html @@ -68,15 +68,15 @@ - - - + + + - - - + + + @@ -102,8 +102,13 @@ 'Common.Request' | translate }} - + + + + diff --git a/src/Ombi/ClientApp/src/app/media-details/movie/movie-details.component.ts b/src/Ombi/ClientApp/src/app/media-details/movie/movie-details.component.ts index dd871f3ce..08dc3d8f9 100644 --- a/src/Ombi/ClientApp/src/app/media-details/movie/movie-details.component.ts +++ b/src/Ombi/ClientApp/src/app/media-details/movie/movie-details.component.ts @@ -1,12 +1,12 @@ import { Component, ViewEncapsulation } from "@angular/core"; -import { ImageService, SearchV2Service, RequestService, MessageService } from "../../services"; +import { ImageService, SearchV2Service, RequestService, MessageService, RadarrService } from "../../services"; import { ActivatedRoute } from "@angular/router"; import { DomSanitizer } from "@angular/platform-browser"; import { ISearchMovieResultV2 } from "../../interfaces/ISearchMovieResultV2"; import { MatDialog } from "@angular/material"; import { YoutubeTrailerComponent } from "../youtube-trailer.component"; import { AuthService } from "../../auth/auth.service"; -import { IMovieRequests } from "../../interfaces"; +import { IMovieRequests, IRadarrProfile, IRadarrRootFolder } from "../../interfaces"; @Component({ templateUrl: "./movie-details.component.html", @@ -18,12 +18,17 @@ export class MovieDetailsComponent { public hasRequest: boolean; public movieRequest: IMovieRequests; public isAdmin: boolean; + + public radarrProfiles: IRadarrProfile[]; + public radarrRootFolders: IRadarrRootFolder[]; + private theMovidDbId: number; 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) { + public messageService: MessageService, private auth: AuthService, + private radarrService: RadarrService) { this.route.params.subscribe((params: any) => { this.theMovidDbId = params.movieDbId; this.load(); @@ -39,6 +44,18 @@ export class MovieDetailsComponent { // Load up this request this.hasRequest = true; this.movieRequest = await this.requestService.getMovieRequest(this.movie.requestId); + + if (this.isAdmin) { + this.radarrService.getQualityProfilesFromSettings().subscribe(c => { + this.radarrProfiles = c; + this.setQualityOverrides(); + }); + this.radarrService.getRootFoldersFromSettings().subscribe(c => { + this.radarrRootFolders = c; + this.setRootFolderOverrides(); + }); + } + } this.imageService.getMovieBanner(this.theMovidDbId.toString()).subscribe(x => { this.movie.background = this.sanitizer.bypassSecurityTrustStyle @@ -74,4 +91,35 @@ export class MovieDetailsComponent { this.messageService.send(result.errorMessage, "Ok"); } } + + public async approve() { + const result = await this.requestService.approveMovie({id: this.theMovidDbId}).toPromise(); + if (result.result) { + this.movie.approved = false; + this.messageService.send(result.message, "Ok"); + } else { + this.messageService.send(result.errorMessage, "Ok"); + } + } + + private setQualityOverrides(): void { + if (this.radarrProfiles) { + const profile = this.radarrProfiles.filter((p) => { + return p.id === this.movieRequest.qualityOverride; + }); + if (profile.length > 0) { + this.movieRequest.qualityOverrideTitle = profile[0].name; + } + } + } + private setRootFolderOverrides(): void { + if (this.radarrRootFolders) { + const path = this.radarrRootFolders.filter((folder) => { + return folder.id === this.movieRequest.rootPathOverride; + }); + if (path.length > 0) { + this.movieRequest.rootPathOverrideTitle = path[0].path; + } + } + } }