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

This commit is contained in:
Jamie 2018-08-01 21:46:56 +01:00
parent 0372d5e8d1
commit 5143aacded
5 changed files with 96 additions and 30 deletions

View file

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

View file

@ -328,7 +328,25 @@ namespace Ombi.Core.Engine
return results; 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); await Audit.Record(AuditType.Updated, AuditArea.TvRequest, $"Updated Request {request.Title}", Username);
var allRequests = TvRepository.Get(); var allRequests = TvRepository.Get();

View file

@ -46,6 +46,27 @@ export class TvRequestsComponent implements OnInit {
private sonarrService: SonarrService, private sonarrService: SonarrService,
private notificationService: NotificationService, private notificationService: NotificationService,
private readonly platformLocation: PlatformLocation) { 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( this.searchChanged.pipe(
debounceTime(600), // Wait Xms after the last event before emitting last event debounceTime(600), // Wait Xms after the last event before emitting last event
distinctUntilChanged(), // only emit if value is different from previous value distinctUntilChanged(), // only emit if value is different from previous value
@ -67,18 +88,6 @@ export class TvRequestsComponent implements OnInit {
if (base) { if (base) {
this.defaultPoster = "../../.." + base + "/images/default_tv_poster.png"; 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(); this.loadInit();
} }
@ -111,14 +120,14 @@ export class TvRequestsComponent implements OnInit {
event.preventDefault(); event.preventDefault();
searchResult.rootFolder = rootFolderSelected.id; searchResult.rootFolder = rootFolderSelected.id;
this.setOverride(searchResult); this.setOverride(searchResult);
this.updateRequest(searchResult); this.setRootFolder(searchResult);
} }
public selectQualityProfile(searchResult: ITvRequests, profileSelected: ISonarrProfile, event: any) { public selectQualityProfile(searchResult: ITvRequests, profileSelected: ISonarrProfile, event: any) {
event.preventDefault(); event.preventDefault();
searchResult.qualityOverride = profileSelected.id; searchResult.qualityOverride = profileSelected.id;
this.setOverride(searchResult); this.setOverride(searchResult);
this.updateRequest(searchResult); this.setQualityProfile(searchResult);
} }
public reportIssue(catId: IIssueCategory, req: ITvRequests) { public reportIssue(catId: IIssueCategory, req: ITvRequests) {
@ -133,13 +142,24 @@ export class TvRequestsComponent implements OnInit {
this.setRootFolderOverrides(req); this.setRootFolderOverrides(req);
} }
private updateRequest(request: ITvRequests) { private setQualityProfile(req: ITvRequests) {
this.requestService.updateTvRequest(request) this.requestService.setQualityProfile(req.id, req.qualityOverride).subscribe(x => {
.subscribe(x => { if(x) {
this.notificationService.success("Request Updated"); this.notificationService.success("Quality profile updated");
this.setOverride(x); } else {
request = x; 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 { private setQualityOverrides(req: ITvRequests): void {
@ -174,14 +194,6 @@ export class TvRequestsComponent implements OnInit {
this.setOverride(val); this.setOverride(val);
}); });
}); });
if (this.isAdmin) {
this.sonarrService.getQualityProfilesWithoutSettings()
.subscribe(x => this.sonarrProfiles = x);
this.sonarrService.getRootFoldersWithoutSettings()
.subscribe(x => this.sonarrRootFolders = x);
}
} }
private resetSearch() { private resetSearch() {

View file

@ -126,4 +126,10 @@ export class RequestService extends ServiceHelpers {
public unSubscribeToTv(requestId: number): Observable<boolean> { public unSubscribeToTv(requestId: number): Observable<boolean> {
return this.http.post<boolean>(`${this.url}tv/unsubscribe/${requestId}`, {headers: this.headers}); 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});
}
} }

View file

@ -286,6 +286,34 @@ namespace Ombi.Controllers
return await TvRequestEngine.UpdateTvRequest(model); 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> /// <summary>
/// Updates the a specific child request /// Updates the a specific child request
/// </summary> /// </summary>