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