Fixed the overrides #1539 also display it on screen now too

pull/1551/head
tidusjar 7 years ago
parent cd418e5e2d
commit 23f0ef3b0d

@ -197,6 +197,8 @@ namespace Ombi.Core.Engine
results.Issues = request.Issues;
results.Overview = request.Overview;
results.PosterPath = request.PosterPath;
results.QualityOverride = request.QualityOverride;
results.RootPathOverride = request.RootPathOverride;
await MovieRepository.Update(results);
return results;

@ -81,6 +81,9 @@ export interface IMovieRequests extends IFullBaseRequest {
theMovieDbId: number;
rootPathOverride: number;
qualityOverride: number;
rootPathOverrideTitle: string;
qualityOverrideTitle: string;
}
export interface IFullBaseRequest extends IBaseRequest {

@ -55,24 +55,13 @@
<div>Release Date: {{request.releaseDate | date}}</div>
<div>Requested Date: {{request.requestedDate | date}}</div>
<br />
<div *ngIf="isAdmin">
<div *ngIf="request.qualityOverrideTitle">Quality Override: <span>{{request.qualityOverrideTitle}} </span></div>
<div *ngIf="request.rootPathOverrideTitle">Root Folder Override: <span>{{request.rootPathOverrideTitle}} </span></div>
</div>
<div *ngIf="request.requestedUsers">Requested By: <span *ngFor="let user of request.requestedUsers">{{user}} </span></div>
<div>Requested Date: {{request.requestedDate | date}}</div>
<!--{{#if admin}}
{{#if currentRootPath}}
<div class="{{requestId}}rootPathMain">Root Path: <span id="{{requestId}}currentRootPath">{{currentRootPath}}</span></div>
{{/if}}
{{/if}}
<div>
{{#if_eq issueId 0}}
@*Nothing*@
{{else}}
@UI.Issues_Issue: <a href="@formAction/issues/{{issueId}}"><i class="fa fa-check"></i></a>
{{/if_eq}}
</div>-->
</div>
<div class="col-sm-3 col-sm-push-3">
<div *ngIf="isAdmin">
@ -83,25 +72,25 @@
<!--Radarr Root Folder-->
<div *ngIf="radarrRootFolders" class="btn-group btn-split">
<button type="button" class="btn btn-sm btn-success-outline"><i class="fa fa-plus"></i> Change Root Folder</button>
<button type="button" class="btn btn-success-outline dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
<button type="button" class="btn btn-sm btn-warning-outline"><i class="fa fa-plus"></i> Change Root Folder</button>
<button type="button" class="btn btn-warning-outline dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
<span class="caret"></span>
<span class="sr-only">Toggle Dropdown</span>
</button>
<ul class="dropdown-menu">
<li *ngFor="let folder of radarrRootFolders"><a href="#" (click)="selectRootFolder(request, folder)">{{folder.path}}</a></li>
<li *ngFor="let folder of radarrRootFolders"><a href="#" (click)="selectRootFolder(request, folder, $event)">{{folder.path}}</a></li>
</ul>
</div>
<!--Radarr Quality Profiles -->
<div *ngIf="radarrProfiles" class="btn-group btn-split">
<button type="button" class="btn btn-sm btn-success-outline"><i class="fa fa-plus"></i> Change Quality Profile</button>
<button type="button" class="btn btn-success-outline dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
<button type="button" class="btn btn-sm btn-warning-outline"><i class="fa fa-plus"></i> Change Quality Profile</button>
<button type="button" class="btn btn-warning-outline dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
<span class="caret"></span>
<span class="sr-only">Toggle Dropdown</span>
</button>
<ul class="dropdown-menu">
<li *ngFor="let profile of radarrProfiles"><a href="#" (click)="selectQualityProfile(request, profile)">{{profile.name}}</a></li>
<li *ngFor="let profile of radarrProfiles"><a href="#" (click)="selectQualityProfile(request, profile, $event)">{{profile.name}}</a></li>
</ul>
</div>
@ -124,7 +113,7 @@
</div>
<!--<div class="dropdown">
<button id="{{request.requestId}}" class="btn btn-sm btn-primary-outline dropdown-toggle" type="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="true">
<i class="fa fa-plus"></i> Report Issue

@ -19,7 +19,7 @@ export class MovieRequestsComponent implements OnInit {
public searchChanged: Subject<string> = new Subject<string>();
public searchText: string;
public isAdmin: boolean;
public isAdmin: boolean; // Also PowerUser
public radarrProfiles: IRadarrProfile[];
public radarrRootFolders: IRadarrRootFolder[];
@ -41,14 +41,13 @@ export class MovieRequestsComponent implements OnInit {
return;
}
this.requestService.searchMovieRequests(this.searchText)
.subscribe(m => this.movieRequests = m);
.subscribe(m => {
this.movieRequests = m;
});
});
}
public ngOnInit() {
this.radarrService.getQualityProfilesFromSettings().subscribe(x => this.radarrProfiles = x);
this.radarrService.getRootFoldersFromSettings().subscribe(x => this.radarrRootFolders = x);
this.amountToLoad = 5;
this.currentlyLoaded = 5;
this.loadInit();
@ -87,17 +86,24 @@ export class MovieRequestsComponent implements OnInit {
this.updateRequest(request);
}
public selectRootFolder(searchResult: IMovieRequests, rootFolderSelected: IRadarrRootFolder) {
public selectRootFolder(searchResult: IMovieRequests, rootFolderSelected: IRadarrRootFolder, event: any) {
event.preventDefault();
searchResult.rootPathOverride = rootFolderSelected.id;
this.setOverride(searchResult);
this.updateRequest(searchResult);
}
public selectQualityProfile(searchResult: IMovieRequests, profileSelected: IRadarrProfile) {
public selectQualityProfile(searchResult: IMovieRequests, profileSelected: IRadarrProfile, event: any) {
event.preventDefault();
searchResult.qualityOverride = profileSelected.id;
this.setOverride(searchResult);
this.updateRequest(searchResult);
}
private loadRequests(amountToLoad: number, currentlyLoaded: number) {
this.requestService.getMovieRequests(amountToLoad, currentlyLoaded + 1)
.subscribe(x => {
this.setOverrides(x);
this.movieRequests.push.apply(this.movieRequests, x);
this.currentlyLoaded = currentlyLoaded + amountToLoad;
});
@ -105,7 +111,10 @@ export class MovieRequestsComponent implements OnInit {
private updateRequest(request: IMovieRequests) {
this.requestService.updateMovieRequest(request)
.subscribe(x => request = x);
.subscribe(x => {
this.setOverride(x);
request = x;
});
}
private approveRequest(request: IMovieRequests) {
@ -124,7 +133,17 @@ export class MovieRequestsComponent implements OnInit {
private loadInit() {
this.requestService.getMovieRequests(this.amountToLoad, 0)
.subscribe(x => this.movieRequests = x);
.subscribe(x => {
this.movieRequests = x;
this.radarrService.getQualityProfilesFromSettings().subscribe(c => {
this.radarrProfiles = c;
this.movieRequests.forEach((req) => this.setQualityOverrides(req));
});
this.radarrService.getRootFoldersFromSettings().subscribe(c => {
this.radarrRootFolders = c;
this.movieRequests.forEach((req) => this.setRootFolderOverrides(req));
});
});
}
private resetSearch() {
@ -138,4 +157,36 @@ export class MovieRequestsComponent implements OnInit {
this.movieRequests.splice(index, 1);
}
}
private setOverrides(requests: IMovieRequests[]): void {
requests.forEach((req) => {
this.setOverride(req);
});
}
private setQualityOverrides(req: IMovieRequests): void {
if (this.radarrProfiles) {
const profile = this.radarrProfiles.filter((p) => {
return p.id === req.qualityOverride;
});
if (profile.length > 0) {
req.qualityOverrideTitle = profile[0].name;
}
}
}
private setRootFolderOverrides(req: IMovieRequests): void {
if (this.radarrRootFolders) {
const path = this.radarrRootFolders.filter((folder) => {
return folder.id === req.rootPathOverride;
});
if (path.length > 0) {
req.rootPathOverrideTitle = path[0].path;
}
}
}
private setOverride(req: IMovieRequests): void {
this.setQualityOverrides(req);
this.setRootFolderOverrides(req);
}
}

Loading…
Cancel
Save