mirror of
https://github.com/Ombi-app/Ombi.git
synced 2025-08-20 21:33:15 -07:00
Fixed up the TV Grid's request status's
This commit is contained in:
parent
e94af7db79
commit
1c8786ea27
4 changed files with 65 additions and 52 deletions
|
@ -41,11 +41,11 @@
|
|||
<td mat-cell *matCellDef="let element"> {{element.requestStatus | translate}} </td>
|
||||
</ng-container>
|
||||
|
||||
<ng-container matColumnDef="actions">
|
||||
<ng-container matColumnDef="actions" >
|
||||
<th mat-header-cell *matHeaderCellDef> </th>
|
||||
<td mat-cell *matCellDef="let element">
|
||||
<td mat-cell *matCellDef="let element" >
|
||||
<button mat-raised-button color="accent" [routerLink]="'/details/movie/' + element.theMovieDbId">Details</button>
|
||||
<button mat-raised-button color="warn" (click)="openOptions(element)">Options</button>
|
||||
<button mat-raised-button color="warn" (click)="openOptions(element)" *ngIf="isAdmin">Options</button>
|
||||
</td>
|
||||
</ng-container>
|
||||
|
||||
|
|
|
@ -5,6 +5,7 @@ import { merge, Observable, of as observableOf } from 'rxjs';
|
|||
import { catchError, map, startWith, switchMap } from 'rxjs/operators';
|
||||
|
||||
import { RequestServiceV2 } from "../../../services/requestV2.service";
|
||||
import { AuthService } from "../../../auth/auth.service";
|
||||
|
||||
@Component({
|
||||
templateUrl: "./movies-grid.component.html",
|
||||
|
@ -18,13 +19,15 @@ export class MoviesGridComponent implements AfterViewInit {
|
|||
public displayedColumns: string[] = ['requestedUser.requestedBy', 'title', 'requestedDate', 'status', 'requestStatus', 'actions'];
|
||||
public gridCount: string = "15";
|
||||
public showUnavailableRequests: boolean;
|
||||
|
||||
@Output() public onOpenOptions = new EventEmitter<{request: any, filter: any, onChange: any}>();
|
||||
public isAdmin: boolean;
|
||||
|
||||
@Output() public onOpenOptions = new EventEmitter<{ request: any, filter: any, onChange: any }>();
|
||||
|
||||
@ViewChild(MatPaginator, { static: false }) paginator: MatPaginator;
|
||||
@ViewChild(MatSort, { static: false }) sort: MatSort;
|
||||
|
||||
constructor(private requestService: RequestServiceV2, private ref: ChangeDetectorRef) {
|
||||
constructor(private requestService: RequestServiceV2, private ref: ChangeDetectorRef,
|
||||
private auth: AuthService) {
|
||||
|
||||
}
|
||||
|
||||
|
@ -34,6 +37,8 @@ export class MoviesGridComponent implements AfterViewInit {
|
|||
// this.dataSource = results.collection;
|
||||
// this.resultsLength = results.total;
|
||||
|
||||
this.isAdmin = this.auth.hasRole("admin") || this.auth.hasRole("poweruser");
|
||||
|
||||
// If the user changes the sort order, reset back to the first page.
|
||||
this.sort.sortChange.subscribe(() => this.paginator.pageIndex = 0);
|
||||
|
||||
|
@ -69,14 +74,16 @@ export class MoviesGridComponent implements AfterViewInit {
|
|||
}
|
||||
|
||||
public openOptions(request: IMovieRequests) {
|
||||
const filter = () => { this.dataSource = this.dataSource.filter((req) => {
|
||||
const filter = () => {
|
||||
this.dataSource = this.dataSource.filter((req) => {
|
||||
return req.id !== request.id;
|
||||
})};
|
||||
})
|
||||
};
|
||||
|
||||
const onChange = () => {
|
||||
this.ref.detectChanges();
|
||||
};
|
||||
|
||||
this.onOpenOptions.emit({request: request, filter: filter, onChange: onChange});
|
||||
this.onOpenOptions.emit({ request: request, filter: filter, onChange: onChange });
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,18 +1,18 @@
|
|||
<div class="mat-elevation-z8">
|
||||
|
||||
<grid-spinner [loading]="isLoadingResults"></grid-spinner>
|
||||
<grid-spinner [loading]="isLoadingResults"></grid-spinner>
|
||||
|
||||
<mat-form-field>
|
||||
<mat-select placeholder="Requests to Display" [(value)]="gridCount" (selectionChange)="ngAfterViewInit()">
|
||||
<mat-option value="10">10</mat-option>
|
||||
<mat-option value="15">15</mat-option>
|
||||
<mat-option value="30">30</mat-option>
|
||||
<mat-option value="100">100</mat-option>
|
||||
</mat-select>
|
||||
</mat-form-field>
|
||||
<mat-select placeholder="Requests to Display" [(value)]="gridCount" (selectionChange)="ngAfterViewInit()">
|
||||
<mat-option value="10">10</mat-option>
|
||||
<mat-option value="15">15</mat-option>
|
||||
<mat-option value="30">30</mat-option>
|
||||
<mat-option value="100">100</mat-option>
|
||||
</mat-select>
|
||||
</mat-form-field>
|
||||
|
||||
<table mat-table [dataSource]="dataSource" class="table" matSort matSortActive="title"
|
||||
matSortDisableClear matSortDirection="desc">
|
||||
<table mat-table [dataSource]="dataSource" class="table" matSort matSortActive="title" matSortDisableClear
|
||||
matSortDirection="desc">
|
||||
|
||||
|
||||
<ng-container matColumnDef="series">
|
||||
|
@ -21,44 +21,42 @@
|
|||
</ng-container>
|
||||
|
||||
<ng-container matColumnDef="requestedBy">
|
||||
<th mat-header-cell *matHeaderCellDef > Requested By </th>
|
||||
<th mat-header-cell *matHeaderCellDef> Requested By </th>
|
||||
<td mat-cell *matCellDef="let element"> {{element.requestedUser.userAlias}} </td>
|
||||
</ng-container>
|
||||
|
||||
|
||||
|
||||
<ng-container matColumnDef="status">
|
||||
<th mat-header-cell *matHeaderCellDef > Status </th>
|
||||
<td mat-cell *matCellDef="let element">
|
||||
{{element.parentRequest.status}}
|
||||
</td>
|
||||
</ng-container>
|
||||
|
||||
<ng-container matColumnDef="requestedDate">
|
||||
<th mat-header-cell *matHeaderCellDef mat-sort-header disableClear> Requested Date </th>
|
||||
<td mat-cell *matCellDef="let element">
|
||||
{{element.requestedDate | amLocal | amDateFormat: 'LL'}}
|
||||
</td>
|
||||
</ng-container>
|
||||
<ng-container matColumnDef="status">
|
||||
<th mat-header-cell *matHeaderCellDef> Status </th>
|
||||
<td mat-cell *matCellDef="let element">
|
||||
{{element.parentRequest.status}}
|
||||
</td>
|
||||
</ng-container>
|
||||
|
||||
<ng-container matColumnDef="requestStatus">
|
||||
<th mat-header-cell *matHeaderCellDef > Request Status </th>
|
||||
<td mat-cell *matCellDef="let element">
|
||||
<div *ngIf="element.approved && !element.available">{{'Common.ProcessingRequest' | translate}}</div>
|
||||
<div *ngIf="element.requested && !element.approved && !element.available">{{'Common.PendingApproval' |
|
||||
translate}}
|
||||
</div>
|
||||
<div *ngIf="!element.requested && !element.available && !element.approved">{{'Common.NotRequested' |
|
||||
translate}}
|
||||
</div>
|
||||
</td>
|
||||
</ng-container>
|
||||
<ng-container matColumnDef="requestedDate">
|
||||
<th mat-header-cell *matHeaderCellDef mat-sort-header disableClear> Requested Date </th>
|
||||
<td mat-cell *matCellDef="let element">
|
||||
{{element.requestedDate | amLocal | amDateFormat: 'LL'}}
|
||||
</td>
|
||||
</ng-container>
|
||||
|
||||
<ng-container matColumnDef="requestStatus">
|
||||
<th mat-header-cell *matHeaderCellDef> Request Status </th>
|
||||
<td mat-cell *matCellDef="let element">
|
||||
<div *ngIf="element.approved && !element.available">{{'Common.ProcessingRequest' | translate}}</div>
|
||||
<div *ngIf="!element.approved && !element.available">{{'Common.PendingApproval' |translate}}</div>
|
||||
<div *ngIf="element.available">{{'Common.Available' | translate}}</div>
|
||||
|
||||
</td>
|
||||
</ng-container>
|
||||
|
||||
<ng-container matColumnDef="actions">
|
||||
<th mat-header-cell *matHeaderCellDef> </th>
|
||||
<td mat-cell *matCellDef="let element">
|
||||
<button mat-raised-button color="accent" [routerLink]="'/details/tv/' + element.parentRequest.tvDbId">Details</button>
|
||||
<button mat-raised-button color="warn" (click)="openOptions(element)">Options</button>
|
||||
<button mat-raised-button color="accent"
|
||||
[routerLink]="'/details/tv/' + element.parentRequest.tvDbId">Details</button>
|
||||
<button mat-raised-button color="warn" (click)="openOptions(element)" *ngIf="isAdmin">Options</button>
|
||||
</td>
|
||||
</ng-container>
|
||||
|
||||
|
@ -67,4 +65,4 @@
|
|||
</table>
|
||||
|
||||
<mat-paginator [length]="resultsLength" [pageSize]="gridCount"></mat-paginator>
|
||||
</div>
|
||||
</div>
|
|
@ -1,10 +1,11 @@
|
|||
import { Component, AfterViewInit, ViewChild, Output, EventEmitter } from "@angular/core";
|
||||
import { Component, AfterViewInit, ViewChild, Output, EventEmitter, ChangeDetectorRef } from "@angular/core";
|
||||
import { IRequestsViewModel, IChildRequests } from "../../../interfaces";
|
||||
import { MatPaginator, MatSort } from "@angular/material";
|
||||
import { merge, of as observableOf, Observable } from 'rxjs';
|
||||
import { catchError, map, startWith, switchMap } from 'rxjs/operators';
|
||||
|
||||
import { RequestServiceV2 } from "../../../services/requestV2.service";
|
||||
import { AuthService } from "../../../auth/auth.service";
|
||||
|
||||
@Component({
|
||||
templateUrl: "./tv-grid.component.html",
|
||||
|
@ -18,18 +19,21 @@ export class TvGridComponent implements AfterViewInit {
|
|||
public displayedColumns: string[] = ['series', 'requestedBy', 'status', 'requestStatus', 'requestedDate','actions'];
|
||||
public gridCount: string = "15";
|
||||
public showUnavailableRequests: boolean;
|
||||
public isAdmin: boolean;
|
||||
|
||||
@Output() public onOpenOptions = new EventEmitter<{request: any, filter: any}>();
|
||||
@Output() public onOpenOptions = new EventEmitter<{request: any, filter: any, onChange: any}>();
|
||||
|
||||
@ViewChild(MatPaginator, {static: false}) paginator: MatPaginator;
|
||||
@ViewChild(MatSort, {static: false}) sort: MatSort;
|
||||
|
||||
constructor(private requestService: RequestServiceV2) {
|
||||
constructor(private requestService: RequestServiceV2, private auth: AuthService,
|
||||
private ref: ChangeDetectorRef) {
|
||||
|
||||
}
|
||||
|
||||
public async ngAfterViewInit() {
|
||||
|
||||
this.isAdmin = this.auth.hasRole("admin") || this.auth.hasRole("poweruser");
|
||||
// If the user changes the sort order, reset back to the first page.
|
||||
this.sort.sortChange.subscribe(() => this.paginator.pageIndex = 0);
|
||||
|
||||
|
@ -58,8 +62,12 @@ export class TvGridComponent implements AfterViewInit {
|
|||
const filter = () => { this.dataSource = this.dataSource.filter((req) => {
|
||||
return req.id !== request.id;
|
||||
})};
|
||||
|
||||
const onChange = () => {
|
||||
this.ref.detectChanges();
|
||||
};
|
||||
|
||||
this.onOpenOptions.emit({request: request, filter: filter});
|
||||
this.onOpenOptions.emit({request: request, filter: filter, onChange});
|
||||
}
|
||||
|
||||
private loadData(): Observable<IRequestsViewModel<IChildRequests>> {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue