mirror of https://github.com/Ombi-app/Ombi
parent
b68e9fc080
commit
9fae71d32c
@ -1,78 +1,79 @@
|
|||||||
<mat-accordion class="mat-elevation-z8">
|
<mat-accordion class="mat-elevation-z8">
|
||||||
|
|
||||||
<mat-expansion-panel *ngFor="let request of tvRequest">
|
<mat-expansion-panel *ngFor="let request of tvRequest">
|
||||||
<mat-expansion-panel-header>
|
<mat-expansion-panel-header>
|
||||||
<mat-panel-title>
|
<mat-panel-title>
|
||||||
<div *ngIf="request.approved && !request.available">{{'Common.ProcessingRequest' | translate}}</div>
|
<div *ngIf="request.approved && !request.available && !request.denied">{{'Common.ProcessingRequest' | translate}}</div>
|
||||||
<div *ngIf="request.requested && !request.approved && !request.available">
|
<div *ngIf="request.denied && !request.available">{{'Common.Denied' | translate}}</div>
|
||||||
{{'Common.PendingApproval' | translate}}
|
<div *ngIf="request.requested && !request.approved && !request.available">
|
||||||
</div>
|
{{'Common.PendingApproval' | translate}}
|
||||||
<div *ngIf="!request.requested && !request.available && !request.approved">
|
</div>
|
||||||
{{'Common.NotRequested' | translate}}
|
<div *ngIf="!request.requested && !request.available && !request.approved">
|
||||||
</div>
|
{{'Common.NotRequested' | translate}}
|
||||||
<div *ngIf="request.available">{{'Common.Available' | translate}}
|
</div>
|
||||||
</div>
|
<div *ngIf="request.available">{{'Common.Available' | translate}}
|
||||||
</mat-panel-title>
|
</div>
|
||||||
<mat-panel-description>
|
</mat-panel-title>
|
||||||
Requested By '{{request.requestedUser.userAlias}}' on
|
<mat-panel-description>
|
||||||
{{request.requestedDate | amLocal | amDateFormat: 'LL' }}
|
Requested By '{{request.requestedUser.userAlias}}' on
|
||||||
</mat-panel-description>
|
{{request.requestedDate | amLocal | amDateFormat: 'LL' }}
|
||||||
</mat-expansion-panel-header>
|
<span *ngIf="request.denied"> - {{request.deniedReason}}</span>
|
||||||
|
</mat-panel-description>
|
||||||
|
</mat-expansion-panel-header>
|
||||||
<mat-tab-group *ngFor="let season of request.seasonRequests">
|
|
||||||
<mat-tab label="{{ 'Requests.Season' | translate }} {{season.seasonNumber}}">
|
|
||||||
|
<mat-tab-group>
|
||||||
<table mat-table [dataSource]="season.episodes" class="mat-elevation-z8">
|
<mat-tab *ngFor="let season of request.seasonRequests" label="{{ 'Requests.Season' | translate }} {{season.seasonNumber}}">
|
||||||
|
|
||||||
|
<table mat-table [dataSource]="season.episodes" class="mat-elevation-z8">
|
||||||
<ng-container matColumnDef="number">
|
|
||||||
<th mat-header-cell *matHeaderCellDef> {{ 'Requests.Number' | translate }} </th>
|
|
||||||
<td mat-cell *matCellDef="let element"> {{element.episodeNumber}} </td>
|
<ng-container matColumnDef="number">
|
||||||
</ng-container>
|
<th mat-header-cell *matHeaderCellDef> {{ 'Requests.Number' | translate }} </th>
|
||||||
|
<td mat-cell *matCellDef="let element"> {{element.episodeNumber}} </td>
|
||||||
<ng-container matColumnDef="title">
|
</ng-container>
|
||||||
<th mat-header-cell *matHeaderCellDef> {{ 'Requests.GridTitle' | translate }} </th>
|
|
||||||
<td mat-cell *matCellDef="let element"> {{element.title}} </td>
|
<ng-container matColumnDef="title">
|
||||||
</ng-container>
|
<th mat-header-cell *matHeaderCellDef> {{ 'Requests.GridTitle' | translate }} </th>
|
||||||
|
<td mat-cell *matCellDef="let element"> {{element.title}} </td>
|
||||||
<ng-container matColumnDef="airDate">
|
</ng-container>
|
||||||
<th mat-header-cell *matHeaderCellDef> {{ 'Requests.AirDate' | translate }} </th>
|
|
||||||
<td mat-cell *matCellDef="let element"> {{element.airDate | amLocal | amDateFormat: 'L' }}</td>
|
<ng-container matColumnDef="airDate">
|
||||||
</ng-container>
|
<th mat-header-cell *matHeaderCellDef> {{ 'Requests.AirDate' | translate }} </th>
|
||||||
|
<td mat-cell *matCellDef="let element"> {{element.airDate | amLocal | amDateFormat: 'L' }}</td>
|
||||||
<ng-container matColumnDef="status">
|
</ng-container>
|
||||||
<th mat-header-cell *matHeaderCellDef> {{ 'Requests.GridStatus' | translate }} </th>
|
|
||||||
<td mat-cell *matCellDef="let ep">
|
<ng-container matColumnDef="status">
|
||||||
|
<th mat-header-cell *matHeaderCellDef> {{ 'Requests.GridStatus' | translate }} </th>
|
||||||
<span *ngIf="request.denied" class="label label-danger" id="deniedLabel"
|
<td mat-cell *matCellDef="let ep">
|
||||||
[translate]="'Common.Denied'">
|
|
||||||
<i class="fa fa-check" matTooltip="{{request.deniedReason}}"></i>
|
<span *ngIf="request.denied" id="deniedLabel" [translate]="'Common.Denied'">
|
||||||
</span>
|
</span>
|
||||||
<span *ngIf="!request.denied && ep.available" class="label label-success"
|
<span *ngIf="!request.denied && ep.available" id="availableLabel" [translate]="'Common.Available'"></span>
|
||||||
id="availableLabel" [translate]="'Common.Available'"></span>
|
<span *ngIf="!request.denied &&ep.approved && !ep.available" class="label label-info" id="processingRequestLabel"
|
||||||
<span *ngIf="!request.denied &&ep.approved && !ep.available" class="label label-info"
|
[translate]="'Common.ProcessingRequest'"></span>
|
||||||
id="processingRequestLabel" [translate]="'Common.ProcessingRequest'"></span>
|
<div *ngIf="!request.denied && !ep.approved">
|
||||||
<div *ngIf="!request.denied && !ep.approved">
|
<div *ngIf="!ep.available"><span class="label label-warning" id="pendingApprovalLabel" [translate]="'Common.PendingApproval'"></span></div>
|
||||||
<div *ngIf="!ep.available"><span class="label label-warning" id="pendingApprovalLabel"
|
</div>
|
||||||
[translate]="'Common.PendingApproval'"></span></div>
|
</td>
|
||||||
</div>
|
</ng-container>
|
||||||
</td>
|
|
||||||
</ng-container>
|
<tr mat-header-row *matHeaderRowDef="displayedColumns"></tr>
|
||||||
|
<tr mat-row *matRowDef="let row; columns: displayedColumns;"></tr>
|
||||||
<tr mat-header-row *matHeaderRowDef="displayedColumns"></tr>
|
</table>
|
||||||
<tr mat-row *matRowDef="let row; columns: displayedColumns;"></tr>
|
</mat-tab>
|
||||||
</table>
|
|
||||||
</mat-tab>
|
</mat-tab-group>
|
||||||
|
|
||||||
</mat-tab-group>
|
<div *ngIf="isAdmin">
|
||||||
|
<button *ngIf="!request.approved" mat-raised-button color="accent" (click)="approve(request);"> {{ 'Common.Approve' | translate }}</button>
|
||||||
|
<button *ngIf="!request.available" mat-raised-button color="warn" (click)="changeAvailability(request, true);">{{ 'Requests.MarkAvailable' | translate }}</button>
|
||||||
<button mat-raised-button color="accent">Approve</button>
|
<button *ngIf="request.available" mat-raised-button color="warn" (click)="changeAvailability(request, false);">{{ 'Requests.MarkUnavailable' | translate }}</button>
|
||||||
|
<button *ngIf="!request.denied" mat-raised-button color="danger" (click)="deny(request);">{{ 'Requests.Deny' | translate }}</button>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
</mat-expansion-panel>
|
|
||||||
|
</mat-expansion-panel>
|
||||||
|
|
||||||
</mat-accordion>
|
</mat-accordion>
|
@ -1,16 +1,87 @@
|
|||||||
import { Component, ViewEncapsulation, Input, OnInit } from "@angular/core";
|
import { Component, Input } from "@angular/core";
|
||||||
import { IChildRequests } from "../../../../../interfaces";
|
import { IChildRequests, RequestType } from "../../../../../interfaces";
|
||||||
|
import { RequestService } from "../../../../../services/request.service";
|
||||||
|
import { MessageService } from "../../../../../services";
|
||||||
|
import { MatDialog } from "@angular/material";
|
||||||
|
import { DenyDialogComponent } from "../../../shared/deny-dialog/deny-dialog.component";
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
templateUrl: "./tv-requests-panel.component.html",
|
templateUrl: "./tv-requests-panel.component.html",
|
||||||
styleUrls: ["./tv-requests-panel.component.scss"],
|
styleUrls: ["./tv-requests-panel.component.scss"],
|
||||||
selector: "tv-requests-panel"
|
selector: "tv-requests-panel"
|
||||||
})
|
})
|
||||||
export class TvRequestsPanelComponent implements OnInit {
|
export class TvRequestsPanelComponent {
|
||||||
@Input() public tvRequest: IChildRequests[];
|
@Input() public tvRequest: IChildRequests[];
|
||||||
|
@Input() public isAdmin: boolean;
|
||||||
|
|
||||||
public displayedColumns: string[] = ['number', 'title', 'airDate', 'status'];
|
public displayedColumns: string[] = ['number', 'title', 'airDate', 'status'];
|
||||||
public ngOnInit(): void {
|
|
||||||
//
|
constructor(private requestService: RequestService, private messageService: MessageService,
|
||||||
|
public dialog: MatDialog) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public async approve(request: IChildRequests) {
|
||||||
|
const result = await this.requestService.approveChild({
|
||||||
|
id: request.id
|
||||||
|
}).toPromise();
|
||||||
|
|
||||||
|
if (result.result) {
|
||||||
|
request.approved = true;
|
||||||
|
request.denied = false;
|
||||||
|
request.seasonRequests.forEach((season) => {
|
||||||
|
season.episodes.forEach((ep) => {
|
||||||
|
ep.approved = true;
|
||||||
|
});
|
||||||
|
});
|
||||||
|
this.messageService.send("Request has been approved", "Ok");
|
||||||
|
} else {
|
||||||
|
this.messageService.send(result.errorMessage, "Ok");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public changeAvailability(request: IChildRequests, available: boolean) {
|
||||||
|
request.available = available;
|
||||||
|
request.seasonRequests.forEach((season) => {
|
||||||
|
season.episodes.forEach((ep) => {
|
||||||
|
ep.available = available;
|
||||||
|
});
|
||||||
|
});
|
||||||
|
if (available) {
|
||||||
|
this.requestService.markTvAvailable({ id: request.id }).subscribe(x => {
|
||||||
|
if (x.result) {
|
||||||
|
this.messageService.send(
|
||||||
|
`This request is now available`);
|
||||||
|
} else {
|
||||||
|
this.messageService.send("Request Available", x.message ? x.message : x.errorMessage);
|
||||||
|
request.approved = false;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
this.requestService.markTvUnavailable({ id: request.id }).subscribe(x => {
|
||||||
|
if (x.result) {
|
||||||
|
this.messageService.send(
|
||||||
|
`This request is now unavailable`);
|
||||||
|
} else {
|
||||||
|
this.messageService.send("Request Available", x.message ? x.message : x.errorMessage);
|
||||||
|
request.approved = false;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public async deny(request: IChildRequests) {
|
||||||
|
const dialogRef = this.dialog.open(DenyDialogComponent, {
|
||||||
|
width: '250px',
|
||||||
|
data: {requestId: request.id, requestType: RequestType.tvShow}
|
||||||
|
});
|
||||||
|
|
||||||
|
dialogRef.afterClosed().subscribe(result => {
|
||||||
|
request.denied = true;
|
||||||
|
request.seasonRequests.forEach((season) => {
|
||||||
|
season.episodes.forEach((ep) => {
|
||||||
|
ep.approved = false;
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in new issue