mirror of https://github.com/Ombi-app/Ombi
pull/3895/head
parent
10ac48e608
commit
23cafa4d10
@ -1,47 +1,57 @@
|
|||||||
<table *ngIf="dataSource" mat-table [dataSource]="dataSource.collection" class="mat-elevation-z8 table">
|
<div class="example-table-container mat-elevation-z8 ">
|
||||||
|
<div class="example-loading-shade" *ngIf="isLoadingResults">
|
||||||
<!--- Note that these columns can be defined in any order.
|
<mat-spinner *ngIf="isLoading"></mat-spinner>
|
||||||
The actual rendered columns are set as a property on the row definition" -->
|
</div>
|
||||||
|
|
||||||
<ng-container matColumnDef="requestedBy">
|
<table mat-table [dataSource]="dataSource" class="table" matSort matSortActive="requestedDate"
|
||||||
<th mat-header-cell *matHeaderCellDef> Requested By </th>
|
matSortDisableClear matSortDirection="desc">
|
||||||
<td mat-cell *matCellDef="let element"> {{element.requestedUser.userAlias}} </td>
|
|
||||||
</ng-container>
|
|
||||||
|
<ng-container matColumnDef="requestedBy">
|
||||||
<ng-container matColumnDef="title">
|
<th mat-header-cell *matHeaderCellDef mat-sort-header disableClear> Requested By </th>
|
||||||
<th mat-header-cell *matHeaderCellDef> Title </th>
|
<td mat-cell *matCellDef="let element"> {{element.requestedUser?.userAlias}} </td>
|
||||||
<td mat-cell *matCellDef="let element"> {{element.title}} ({{element.releaseDate | amLocal | amDateFormat: 'YYYY'}}) </td>
|
</ng-container>
|
||||||
</ng-container>
|
|
||||||
|
<ng-container matColumnDef="title">
|
||||||
<ng-container matColumnDef="requestedDate">
|
<th mat-header-cell *matHeaderCellDef mat-sort-header disableClear> Title </th>
|
||||||
<th mat-header-cell *matHeaderCellDef> Request Date </th>
|
<td mat-cell *matCellDef="let element"> {{element.title}} ({{element.releaseDate | amLocal | amDateFormat:
|
||||||
<td mat-cell *matCellDef="let element"> {{element.requestedDate | amLocal | amDateFormat: 'LL'}} </td>
|
'YYYY'}}) </td>
|
||||||
</ng-container>
|
</ng-container>
|
||||||
|
|
||||||
<ng-container matColumnDef="status">
|
<ng-container matColumnDef="requestedDate">
|
||||||
<th mat-header-cell *matHeaderCellDef> Status </th>
|
<th mat-header-cell *matHeaderCellDef mat-sort-header disableClear> Request Date </th>
|
||||||
<td mat-cell *matCellDef="let element"> {{element.status}} </td>
|
<td mat-cell *matCellDef="let element"> {{element.requestedDate | amLocal | amDateFormat: 'LL'}} </td>
|
||||||
</ng-container>
|
</ng-container>
|
||||||
|
|
||||||
|
<ng-container matColumnDef="status">
|
||||||
<ng-container matColumnDef="requestStatus">
|
<th mat-header-cell *matHeaderCellDef> Status </th>
|
||||||
<th mat-header-cell *matHeaderCellDef> Request Status </th>
|
<td mat-cell *matCellDef="let element"> {{element.status}} </td>
|
||||||
<td mat-cell *matCellDef="let element">
|
</ng-container>
|
||||||
<div *ngIf="element.approved && !element.available">{{'Common.ProcessingRequest' | translate}}</div>
|
|
||||||
<div *ngIf="element.requested && !element.approved && !element.available">{{'Common.PendingApproval' | translate}}
|
|
||||||
</div>
|
<ng-container matColumnDef="requestStatus">
|
||||||
<div *ngIf="!element.requested && !element.available && !element.approved">{{'Common.NotRequested' | translate}}
|
<th mat-header-cell *matHeaderCellDef mat-sort-header disableClear> Request Status </th>
|
||||||
</div>
|
<td mat-cell *matCellDef="let element">
|
||||||
</td>
|
<div *ngIf="element.approved && !element.available">{{'Common.ProcessingRequest' | translate}}</div>
|
||||||
</ng-container>
|
<div *ngIf="element.requested && !element.approved && !element.available">{{'Common.PendingApproval' |
|
||||||
|
translate}}
|
||||||
<ng-container matColumnDef="actions">
|
</div>
|
||||||
<th mat-header-cell *matHeaderCellDef> </th>
|
<div *ngIf="!element.requested && !element.available && !element.approved">{{'Common.NotRequested' |
|
||||||
<td mat-cell *matCellDef="let element">
|
translate}}
|
||||||
<button mat-raised-button color="primary" [routerLink]="">Details</button>
|
</div>
|
||||||
</td>
|
</td>
|
||||||
</ng-container>
|
</ng-container>
|
||||||
|
|
||||||
<tr mat-header-row *matHeaderRowDef="displayedColumns"></tr>
|
<ng-container matColumnDef="actions">
|
||||||
<tr mat-row *matRowDef="let row; columns: displayedColumns;"></tr>
|
<th mat-header-cell *matHeaderCellDef> </th>
|
||||||
</table>
|
<td mat-cell *matCellDef="let element">
|
||||||
|
<button mat-raised-button color="primary" [routerLink]="">Details</button>
|
||||||
|
</td>
|
||||||
|
</ng-container>
|
||||||
|
|
||||||
|
<tr mat-header-row *matHeaderRowDef="displayedColumns"></tr>
|
||||||
|
<tr mat-row *matRowDef="let row; columns: displayedColumns;"></tr>
|
||||||
|
</table>
|
||||||
|
|
||||||
|
<mat-paginator [length]="resultsLength" [pageSize]="30"></mat-paginator>
|
||||||
|
</div>
|
||||||
|
@ -1,23 +1,59 @@
|
|||||||
import { Component, OnInit } from "@angular/core";
|
import { Component, AfterViewInit, ViewChild } from "@angular/core";
|
||||||
import { RequestService } from "../../../services";
|
import { RequestService } from "../../../services";
|
||||||
import { IMovieRequests, OrderType, FilterType, IRequestsViewModel } from "../../../interfaces";
|
import { IMovieRequests, OrderType, FilterType, IRequestsViewModel } from "../../../interfaces";
|
||||||
|
import { MatPaginator, MatSort } from "@angular/material";
|
||||||
|
import { merge, Observable, of as observableOf } from 'rxjs';
|
||||||
|
import { catchError, map, startWith, switchMap } from 'rxjs/operators';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
templateUrl: "./movies-grid.component.html",
|
templateUrl: "./movies-grid.component.html",
|
||||||
selector: "movies-grid",
|
selector: "movies-grid",
|
||||||
styleUrls: ["../requests-list.component.scss"]
|
styleUrls: ["../requests-list.component.scss"]
|
||||||
})
|
})
|
||||||
export class MoviesGridComponent implements OnInit {
|
export class MoviesGridComponent implements AfterViewInit {
|
||||||
public dataSource: IRequestsViewModel<IMovieRequests>;
|
public dataSource: IMovieRequests[] = [];
|
||||||
|
public resultsLength: number;
|
||||||
|
public isLoadingResults = true;
|
||||||
public displayedColumns: string[] = ['requestedBy', 'title', 'requestedDate', 'status', 'requestStatus', 'actions'];
|
public displayedColumns: string[] = ['requestedBy', 'title', 'requestedDate', 'status', 'requestStatus', 'actions'];
|
||||||
|
public gridCount = 30;
|
||||||
|
|
||||||
|
@ViewChild(MatPaginator) paginator: MatPaginator;
|
||||||
|
@ViewChild(MatSort) sort: MatSort;
|
||||||
|
|
||||||
constructor(private requestService: RequestService) {
|
constructor(private requestService: RequestService) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public async ngOnInit() {
|
public async ngAfterViewInit() {
|
||||||
this.dataSource = await this.requestService.getMovieRequests(30,0, OrderType.RequestedDateDesc,
|
// const results = await this.requestService.getMovieRequests(this.gridCount, 0, OrderType.RequestedDateDesc,
|
||||||
{availabilityFilter: FilterType.None, statusFilter: FilterType.None}).toPromise();
|
// { availabilityFilter: FilterType.None, statusFilter: FilterType.None }).toPromise();
|
||||||
|
// this.dataSource = results.collection;
|
||||||
|
// this.resultsLength = results.total;
|
||||||
|
|
||||||
|
// If the user changes the sort order, reset back to the first page.
|
||||||
|
this.sort.sortChange.subscribe(() => this.paginator.pageIndex = 0);
|
||||||
|
|
||||||
|
merge(this.sort.sortChange, this.paginator.page)
|
||||||
|
.pipe(
|
||||||
|
startWith({}),
|
||||||
|
switchMap(() => {
|
||||||
|
this.isLoadingResults = true;
|
||||||
|
// eturn this.exampleDatabase!.getRepoIssues(
|
||||||
|
// this.sort.active, this.sort.direction, this.paginator.pageIndex);
|
||||||
|
return this.requestService.getMovieRequests(this.gridCount, this.paginator.pageIndex * this.gridCount, OrderType.RequestedDateDesc,
|
||||||
|
{ availabilityFilter: FilterType.None, statusFilter: FilterType.None});
|
||||||
|
}),
|
||||||
|
map((data: IRequestsViewModel<IMovieRequests>) => {
|
||||||
|
// Flip flag to show that loading has finished.
|
||||||
|
this.isLoadingResults = false;
|
||||||
|
this.resultsLength = data.total;
|
||||||
|
|
||||||
|
return data.collection;
|
||||||
|
}),
|
||||||
|
catchError((err) => {
|
||||||
|
this.isLoadingResults = false;
|
||||||
|
return observableOf([]);
|
||||||
|
})
|
||||||
|
).subscribe(data => this.dataSource = data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in new issue