pull/3895/head
TidusJar 6 years ago
parent df9f5cb339
commit 121b242159

@ -102,8 +102,13 @@
'Common.Request' | translate }}</button> 'Common.Request' | translate }}</button>
</ng-template> </ng-template>
</span> </span>
<span *ngIf="isAdmin && hasRequest"><button mat-raised-button class="btn-spacing" color="warn" <span *ngIf="isAdmin && hasRequest">
(click)="deny()">{{ 'Requests.Deny' | translate }}</button></span> <button (click)="approve()" mat-raised-button class="btn-spacing" color="accent">
<i class="fa fa-plus"></i> {{ 'Common.Approve' | translate }}
</button>
<button mat-raised-button class="btn-spacing" color="warn"
(click)="deny()"> <i class="fa fa-times"></i> {{ 'Requests.Deny' | translate }}</button></span>
</div> </div>
</div> </div>

@ -1,12 +1,12 @@
import { Component, ViewEncapsulation } from "@angular/core"; 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 { ActivatedRoute } from "@angular/router";
import { DomSanitizer } from "@angular/platform-browser"; import { DomSanitizer } from "@angular/platform-browser";
import { ISearchMovieResultV2 } from "../../interfaces/ISearchMovieResultV2"; import { ISearchMovieResultV2 } from "../../interfaces/ISearchMovieResultV2";
import { MatDialog } from "@angular/material"; import { MatDialog } from "@angular/material";
import { YoutubeTrailerComponent } from "../youtube-trailer.component"; import { YoutubeTrailerComponent } from "../youtube-trailer.component";
import { AuthService } from "../../auth/auth.service"; import { AuthService } from "../../auth/auth.service";
import { IMovieRequests } from "../../interfaces"; import { IMovieRequests, IRadarrProfile, IRadarrRootFolder } from "../../interfaces";
@Component({ @Component({
templateUrl: "./movie-details.component.html", templateUrl: "./movie-details.component.html",
@ -18,12 +18,17 @@ export class MovieDetailsComponent {
public hasRequest: boolean; public hasRequest: boolean;
public movieRequest: IMovieRequests; public movieRequest: IMovieRequests;
public isAdmin: boolean; public isAdmin: boolean;
public radarrProfiles: IRadarrProfile[];
public radarrRootFolders: IRadarrRootFolder[];
private theMovidDbId: number; private theMovidDbId: number;
constructor(private searchService: SearchV2Service, private route: ActivatedRoute, constructor(private searchService: SearchV2Service, private route: ActivatedRoute,
private sanitizer: DomSanitizer, private imageService: ImageService, private sanitizer: DomSanitizer, private imageService: ImageService,
public dialog: MatDialog, private requestService: RequestService, 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.route.params.subscribe((params: any) => {
this.theMovidDbId = params.movieDbId; this.theMovidDbId = params.movieDbId;
this.load(); this.load();
@ -39,6 +44,18 @@ export class MovieDetailsComponent {
// Load up this request // Load up this request
this.hasRequest = true; this.hasRequest = true;
this.movieRequest = await this.requestService.getMovieRequest(this.movie.requestId); 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.imageService.getMovieBanner(this.theMovidDbId.toString()).subscribe(x => {
this.movie.background = this.sanitizer.bypassSecurityTrustStyle this.movie.background = this.sanitizer.bypassSecurityTrustStyle
@ -74,4 +91,35 @@ export class MovieDetailsComponent {
this.messageService.send(result.errorMessage, "Ok"); 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;
}
}
}
} }

Loading…
Cancel
Save