mirror of https://github.com/Ombi-app/Ombi
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
50 lines
2.0 KiB
50 lines
2.0 KiB
import { Component, Inject } from "@angular/core";
|
|
import { IDenyDialogData } from "../interfaces/interfaces";
|
|
import { MatDialogRef, MAT_DIALOG_DATA } from "@angular/material/dialog";
|
|
import { RequestService, MessageService } from "../../../../services";
|
|
import { TranslateService } from "@ngx-translate/core";
|
|
import { RequestType, IRequestEngineResult } from "../../../../interfaces";
|
|
|
|
@Component({
|
|
selector: "deny-dialog",
|
|
templateUrl: "./deny-dialog.component.html",
|
|
})
|
|
export class DenyDialogComponent {
|
|
constructor(
|
|
public dialogRef: MatDialogRef<DenyDialogComponent>,
|
|
@Inject(MAT_DIALOG_DATA) public data: IDenyDialogData,
|
|
private requestService: RequestService,
|
|
public messageService: MessageService,
|
|
private translate: TranslateService) {}
|
|
|
|
public denyReason: string;
|
|
|
|
public async deny() {
|
|
let result: IRequestEngineResult;
|
|
if(this.data.requestType == RequestType.movie) {
|
|
result = await this.requestService.denyMovie({id: this.data.requestId, reason: this.denyReason }).toPromise();
|
|
}
|
|
if(this.data.requestType == RequestType.tvShow) {
|
|
result = await this.requestService.denyChild({id: this.data.requestId, reason: this.denyReason }).toPromise();
|
|
}
|
|
if(this.data.requestType == RequestType.artist) {
|
|
result = await this.requestService.denyAlbum({id: this.data.requestId, reason: this.denyReason }).toPromise();
|
|
}
|
|
|
|
if (result.result) {
|
|
this.messageService.send(this.translate.instant("Requests.DeniedRequest"), "Ok");
|
|
this.data.denied = true;
|
|
} else {
|
|
this.messageService.sendRequestEngineResultError(result);
|
|
this.data.denied = false;
|
|
}
|
|
|
|
this.dialogRef.close({denied: this.data.denied, reason: this.denyReason});
|
|
}
|
|
|
|
onNoClick(): void {
|
|
this.dialogRef.close();
|
|
this.data.denied = false;
|
|
}
|
|
}
|