Skip to content

Commit

Permalink
feat(discover): Add deny option to recently requested (#4907)
Browse files Browse the repository at this point in the history
  • Loading branch information
sephrat authored Apr 20, 2023
1 parent 540f14b commit 78f340e
Show file tree
Hide file tree
Showing 6 changed files with 53 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,23 @@ <h3 id="detailed-request-title-{{request.mediaId}}">{{request.title}}</h3>
</div>
<div class="row action-items">
<div class="col-12" *ngIf="isAdmin">
<button *ngIf="!request.approved" id="detailed-request-approve-{{request.mediaId}}" color="accent" mat-raised-button (click)="approve()">{{'Common.Approve' | translate}}</button>
<div *ngIf="!request.approved && !request.denied">
<button
id="detailed-request-approve-{{request.mediaId}}"
color="accent"
mat-raised-button
(click)="approve()"
matTooltip="{{'Common.Approve' | translate}}">
<mat-icon>check-circle</mat-icon>
</button>
<button
id="detailed-request-deny-{{request.mediaId}}"
color="accent"
mat-raised-button
(click)="deny()"
matTooltip="{{'Requests.Deny' | translate}}">
<mat-icon>cancel</mat-icon></button>
</div>
</div>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,5 +50,9 @@
position: absolute;
}
}

.action-items button {
margin: 4px;
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ export class DetailedCardComponent implements OnInit, OnDestroy {
@Input() public isAdmin: boolean = false;
@Output() public onClick: EventEmitter<void> = new EventEmitter<void>();
@Output() public onApprove: EventEmitter<void> = new EventEmitter<void>();
@Output() public onDeny: EventEmitter<void> = new EventEmitter<void>();

public RequestType = RequestType;
public loading: false;
Expand Down Expand Up @@ -65,6 +66,10 @@ export class DetailedCardComponent implements OnInit, OnDestroy {
this.onApprove.emit();
}

public deny() {
this.onDeny.emit();
}

public getClass(request: IRecentlyRequested) {
if (request.denied) {
return "danger";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,14 @@
<p-carousel #carousel [value]="requests" [numVisible]="3" [numScroll]="1"
[responsiveOptions]="responsiveOptions" [page]="0">
<ng-template let-result pTemplate="item">
<ombi-detailed-card [request]="result" [isAdmin]="isAdmin" (onClick)="navigate(result)"
(onApprove)="approve(result)"></ombi-detailed-card>
<ombi-detailed-card
[request]="result"
[isAdmin]="isAdmin"
(onClick)="navigate(result)"
(onApprove)="approve(result)"
(onDeny)="deny(result)">
</ombi-detailed-card>
</ng-template>
</p-carousel>
</div>
</div>
</div>
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import { Router } from "@angular/router";
import { AuthService } from "app/auth/auth.service";
import { NotificationService, RequestService } from "app/services";
import { TranslateService } from "@ngx-translate/core";
import { DenyDialogComponent } from '../../../media-details/components/shared/deny-dialog/deny-dialog.component';
import { MatDialog } from "@angular/material/dialog";

export enum DiscoverType {
Upcoming,
Expand Down Expand Up @@ -42,7 +44,8 @@ export class RecentlyRequestedListComponent implements OnInit, OnDestroy {
private router: Router,
private authService: AuthService,
private notificationService: NotificationService,
private translateService: TranslateService) {
private translateService: TranslateService,
public dialog: MatDialog) {
Carousel.prototype.onTouchMove = () => {};
this.responsiveOptions = ResponsiveOptions;
}
Expand Down Expand Up @@ -81,6 +84,20 @@ export class RecentlyRequestedListComponent implements OnInit, OnDestroy {
}
}

public deny(request: IRecentlyRequested) {
const dialogRef = this.dialog.open(DenyDialogComponent, {
width: '250px',
data: { requestId: request.requestId, is4K: false, requestType: request.type }
});

dialogRef.afterClosed().subscribe(result => {
if (result) {
this.notificationService.success(this.translateService.instant("Requests.SuccessfullyDenied"));
request.denied = true;
}
});
}

private handleApproval(result: IRequestEngineResult, request: IRecentlyRequested) {
if (result.result) {
this.notificationService.success(this.translateService.instant("Requests.SuccessfullyApproved"));
Expand Down
1 change: 1 addition & 0 deletions src/Ombi/wwwroot/translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,7 @@
"Denied": "Successfully denied selected items"
},
"SuccessfullyApproved": "Successfully Approved",
"SuccessfullyDenied": "Successfully Denied",
"SuccessfullyDeleted": "Request successfully deleted",
"NowAvailable": "Request is now available",
"NowUnavailable": "Request is now unavailable",
Expand Down

0 comments on commit 78f340e

Please sign in to comment.