Made the quality override and root folder override load when we load the show (It will now appear)

pull/2420/head^2
Jamie 6 years ago
parent 0372d5e8d1
commit 5143aacded

@ -21,5 +21,7 @@ namespace Ombi.Core.Engine.Interfaces
Task RemoveTvChild(int requestId);
Task<RequestEngineResult> ApproveChildRequest(int id);
Task<IEnumerable<TvRequests>> GetRequestsLite();
Task UpdateQualityProfile(int requestId, int profileId);
Task UpdateRootPath(int requestId, int rootPath);
}
}

@ -328,7 +328,25 @@ namespace Ombi.Core.Engine
return results;
}
public async Task<TvRequests> UpdateTvRequest(TvRequests request)
public async Task UpdateRootPath(int requestId, int rootPath)
{
var allRequests = TvRepository.Get();
var results = await allRequests.FirstOrDefaultAsync(x => x.Id == requestId);
results.RootFolder = rootPath;
await TvRepository.Update(results);
}
public async Task UpdateQualityProfile(int requestId, int profileId)
{
var allRequests = TvRepository.Get();
var results = await allRequests.FirstOrDefaultAsync(x => x.Id == requestId);
results.QualityOverride = profileId;
await TvRepository.Update(results);
}
public async Task<TvRequests> UpdateTvRequest(TvRequests request)
{
await Audit.Record(AuditType.Updated, AuditArea.TvRequest, $"Updated Request {request.Title}", Username);
var allRequests = TvRepository.Get();

@ -46,6 +46,27 @@ export class TvRequestsComponent implements OnInit {
private sonarrService: SonarrService,
private notificationService: NotificationService,
private readonly platformLocation: PlatformLocation) {
this.isAdmin = this.auth.hasRole("admin") || this.auth.hasRole("poweruser");
if (this.isAdmin) {
this.sonarrService.getQualityProfilesWithoutSettings()
.subscribe(x => this.sonarrProfiles = x);
this.sonarrService.getRootFoldersWithoutSettings()
.subscribe(x => this.sonarrRootFolders = x);
}
}
public openClosestTab(node: ITvRequests,el: any) {
el.preventDefault();
node.open = !node.open;
}
public ngOnInit() {
this.amountToLoad = 10;
this.currentlyLoaded = 10;
this.tvRequests = {collection:[], total:0};
this.searchChanged.pipe(
debounceTime(600), // Wait Xms after the last event before emitting last event
distinctUntilChanged(), // only emit if value is different from previous value
@ -67,18 +88,6 @@ export class TvRequestsComponent implements OnInit {
if (base) {
this.defaultPoster = "../../.." + base + "/images/default_tv_poster.png";
}
}
public openClosestTab(node: ITvRequests,el: any) {
el.preventDefault();
node.open = !node.open;
}
public ngOnInit() {
this.amountToLoad = 10;
this.currentlyLoaded = 10;
this.tvRequests = {collection:[], total:0};
this.isAdmin = this.auth.hasRole("admin") || this.auth.hasRole("poweruser");
this.loadInit();
}
@ -111,14 +120,14 @@ export class TvRequestsComponent implements OnInit {
event.preventDefault();
searchResult.rootFolder = rootFolderSelected.id;
this.setOverride(searchResult);
this.updateRequest(searchResult);
this.setRootFolder(searchResult);
}
public selectQualityProfile(searchResult: ITvRequests, profileSelected: ISonarrProfile, event: any) {
event.preventDefault();
searchResult.qualityOverride = profileSelected.id;
this.setOverride(searchResult);
this.updateRequest(searchResult);
this.setQualityProfile(searchResult);
}
public reportIssue(catId: IIssueCategory, req: ITvRequests) {
@ -133,13 +142,24 @@ export class TvRequestsComponent implements OnInit {
this.setRootFolderOverrides(req);
}
private updateRequest(request: ITvRequests) {
this.requestService.updateTvRequest(request)
.subscribe(x => {
this.notificationService.success("Request Updated");
this.setOverride(x);
request = x;
});
private setQualityProfile(req: ITvRequests) {
this.requestService.setQualityProfile(req.id, req.qualityOverride).subscribe(x => {
if(x) {
this.notificationService.success("Quality profile updated");
} else {
this.notificationService.error("Could not update the quality profile");
}
});
}
private setRootFolder(req: ITvRequests) {
this.requestService.setRootFolder(req.id, req.rootFolder).subscribe(x => {
if(x) {
this.notificationService.success("Quality profile updated");
} else {
this.notificationService.error("Could not update the quality profile");
}
});
}
private setQualityOverrides(req: ITvRequests): void {
@ -174,14 +194,6 @@ export class TvRequestsComponent implements OnInit {
this.setOverride(val);
});
});
if (this.isAdmin) {
this.sonarrService.getQualityProfilesWithoutSettings()
.subscribe(x => this.sonarrProfiles = x);
this.sonarrService.getRootFoldersWithoutSettings()
.subscribe(x => this.sonarrRootFolders = x);
}
}
private resetSearch() {

@ -126,4 +126,10 @@ export class RequestService extends ServiceHelpers {
public unSubscribeToTv(requestId: number): Observable<boolean> {
return this.http.post<boolean>(`${this.url}tv/unsubscribe/${requestId}`, {headers: this.headers});
}
public setQualityProfile(requestId: number, qualityId: number): Observable<boolean> {
return this.http.put<boolean>(`${this.url}tv/quality/${requestId}/${qualityId}`, {headers: this.headers});
}
public setRootFolder(requestId: number, rootFolderId: number): Observable<boolean> {
return this.http.put<boolean>(`${this.url}tv/root/${requestId}/${rootFolderId}`, {headers: this.headers});
}
}

@ -286,6 +286,34 @@ namespace Ombi.Controllers
return await TvRequestEngine.UpdateTvRequest(model);
}
/// <summary>
/// Updates the root path for this tv show
/// </summary>
/// <param name="requestId"></param>
/// <param name="rootFolderId"></param>
/// <returns></returns>
[HttpPut("tv/root/{requestId:int}/{rootFolderId:int}")]
[PowerUser]
public async Task<bool> UpdateRootFolder(int requestId, int rootFolderId)
{
await TvRequestEngine.UpdateRootPath(requestId, rootFolderId);
return true;
}
/// <summary>
/// Updates the quality profile for this tv show
/// </summary>
/// <param name="requestId"></param>
/// <param name="qualityId"></param>
/// <returns></returns>
[HttpPut("tv/quality/{requestId:int}/{qualityId:int}")]
[PowerUser]
public async Task<bool> UpdateQuality(int requestId, int qualityId)
{
await TvRequestEngine.UpdateQualityProfile(requestId, qualityId);
return true;
}
/// <summary>
/// Updates the a specific child request
/// </summary>

Loading…
Cancel
Save