mirror of
https://github.com/Ombi-app/Ombi.git
synced 2025-07-14 17:22:54 -07:00
We can now delete tv child requests and the parent will get remove #1603
Also we no longer require users to have email addresses
This commit is contained in:
parent
d66e09b98f
commit
3e4f504165
7 changed files with 24 additions and 10 deletions
|
@ -244,6 +244,8 @@ namespace Ombi.Core.Engine
|
|||
public async Task RemoveTvChild(int requestId)
|
||||
{
|
||||
var request = await TvRepository.GetChild().FirstOrDefaultAsync(x => x.Id == requestId);
|
||||
|
||||
TvRepository.Db.ChildRequests.Remove(request);
|
||||
var all = TvRepository.Db.TvRequests.Include(x => x.ChildRequests);
|
||||
var parent = all.FirstOrDefault(x => x.Id == request.ParentRequestId);
|
||||
|
||||
|
@ -255,7 +257,6 @@ namespace Ombi.Core.Engine
|
|||
}
|
||||
await Audit.Record(AuditType.Deleted, AuditArea.TvRequest, $"Deleting Request {request.Title}", Username);
|
||||
|
||||
TvRepository.Db.ChildRequests.Remove(request);
|
||||
await TvRepository.Db.SaveChangesAsync();
|
||||
}
|
||||
|
||||
|
|
|
@ -12,7 +12,7 @@ namespace Ombi.Core.Helpers
|
|||
{
|
||||
_invalid = false;
|
||||
if (string.IsNullOrEmpty(strIn))
|
||||
return false;
|
||||
return true;
|
||||
|
||||
// Use IdnMapping class to convert Unicode domain names.
|
||||
try
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { Component, Input } from "@angular/core";
|
||||
import { Component, EventEmitter, Input, Output } from "@angular/core";
|
||||
import { IChildRequests } from "../interfaces";
|
||||
import { NotificationService, RequestService } from "../services";
|
||||
|
||||
|
@ -9,13 +9,18 @@ import { NotificationService, RequestService } from "../services";
|
|||
export class TvRequestChildrenComponent {
|
||||
@Input() public childRequests: IChildRequests[];
|
||||
@Input() public isAdmin: boolean;
|
||||
|
||||
@Output() public requestDeleted = new EventEmitter<number>();
|
||||
|
||||
constructor(private requestService: RequestService,
|
||||
private notificationService: NotificationService) { }
|
||||
|
||||
public removeRequest(request: IChildRequests) {
|
||||
this.requestService.deleteChild(request)
|
||||
.subscribe();
|
||||
this.removeRequestFromUi(request);
|
||||
.subscribe(x => {
|
||||
this.removeRequestFromUi(request);
|
||||
this.requestDeleted.emit(request.id);
|
||||
});
|
||||
}
|
||||
|
||||
public changeAvailability(request: IChildRequests, available: boolean) {
|
||||
|
|
|
@ -58,7 +58,7 @@
|
|||
</div>
|
||||
<!--This is the section that holds the child seasons if they want to specify specific episodes-->
|
||||
<div *ngIf="node.leaf">
|
||||
<tvrequests-children [childRequests]="node.data" [isAdmin] ="isAdmin" ></tvrequests-children>
|
||||
<tvrequests-children [childRequests]="node.data" [isAdmin] ="isAdmin" (requestDeleted)="childRequestDeleted($event)" ></tvrequests-children>
|
||||
</div>
|
||||
</ng-template>
|
||||
</p-column>
|
||||
|
|
|
@ -101,6 +101,11 @@ export class TvRequestsComponent implements OnInit {
|
|||
this.showChildDialogue = true;
|
||||
}
|
||||
|
||||
public childRequestDeleted(childId: number): void {
|
||||
// Refresh the UI, hackly way around reloading the data
|
||||
this.ngOnInit();
|
||||
}
|
||||
|
||||
private loadInit() {
|
||||
this.requestService.getTvRequestsTree(this.amountToLoad, 0)
|
||||
.subscribe(x => {
|
||||
|
|
|
@ -91,7 +91,7 @@ export class RequestService extends ServiceAuthHelpers {
|
|||
public approveChild(child: ITvUpdateModel): Observable<IRequestEngineResult> {
|
||||
return this.http.post(`${this.url}tv/approve`, JSON.stringify(child), { headers: this.headers }).map(this.extractData);
|
||||
}
|
||||
public deleteChild(child: IChildRequests): Observable<IChildRequests> {
|
||||
public deleteChild(child: IChildRequests): Observable<any> {
|
||||
return this.http.delete(`${this.url}tv/child/${child.id}`, { headers: this.headers }).map(this.extractData);
|
||||
}
|
||||
|
||||
|
|
|
@ -47,9 +47,12 @@ export class ServiceAuthHelpers {
|
|||
}
|
||||
|
||||
protected extractData(res: Response) {
|
||||
const body = res.json();
|
||||
//console.log('extractData', body || {});
|
||||
return body;
|
||||
if(res.text()) {
|
||||
const body = res.json();
|
||||
return body;
|
||||
} else {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
protected handleError(error: any) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue