Done the TV Request Grid

pull/3895/head
Jamie Rees 6 years ago
parent f80ef6bb24
commit e1d2d1da20

@ -23,6 +23,6 @@ namespace Ombi.Core.Engine.Interfaces
Task<IEnumerable<TvRequests>> GetRequestsLite();
Task UpdateQualityProfile(int requestId, int profileId);
Task UpdateRootPath(int requestId, int rootPath);
Task<RequestsViewModel<TvRequests>> GetRequests(int count, int position, string sortProperty, string sortOrder);
Task<RequestsViewModel<ChildRequests>> GetRequests(int count, int position, string sortProperty, string sortOrder);
}
}

@ -226,44 +226,38 @@ namespace Ombi.Core.Engine
}
public async Task<RequestsViewModel<TvRequests>> GetRequests(int count, int position, string sortProperty, string sortOrder)
public async Task<RequestsViewModel<ChildRequests>> GetRequests(int count, int position, string sortProperty, string sortOrder)
{
var shouldHide = await HideFromOtherUsers();
List<TvRequests> allRequests = null;
List<ChildRequests> allRequests;
if (shouldHide.Hide)
{
var tv = TvRepository.GetLite(shouldHide.UserId);
if (tv.Any() && tv.Select(x => x.ChildRequests).Any())
{
allRequests = await tv.OrderByDescending(x => x.ChildRequests.Select(y => y.RequestedDate).FirstOrDefault()).Skip(position).Take(count).ToListAsync();
}
allRequests = await TvRepository.GetChild(shouldHide.UserId).ToListAsync();
// Filter out children
FilterChildren(allRequests, shouldHide);
}
else
{
var tv = TvRepository.GetLite();
if (tv.Any() && tv.Select(x => x.ChildRequests).Any())
{
allRequests = await tv.OrderByDescending(x => x.ChildRequests.Select(y => y.RequestedDate).FirstOrDefault()).Skip(position).Take(count).ToListAsync();
}
allRequests = await TvRepository.GetChild().ToListAsync();
}
if (allRequests == null)
{
return new RequestsViewModel<TvRequests>();
return new RequestsViewModel<ChildRequests>();
}
var total = allRequests.Count;
var prop = TypeDescriptor.GetProperties(typeof(TvRequests)).Find(sortProperty, true);
var prop = TypeDescriptor.GetProperties(typeof(ChildRequests)).Find(sortProperty, true);
if (sortProperty.Contains('.'))
{
// This is a navigation property currently not supported
prop = TypeDescriptor.GetProperties(typeof(TvRequests)).Find("Title", true);
prop = TypeDescriptor.GetProperties(typeof(ChildRequests)).Find("Title", true);
//var properties = sortProperty.Split(new []{'.'}, StringSplitOptions.RemoveEmptyEntries);
//var firstProp = TypeDescriptor.GetProperties(typeof(MovieRequests)).Find(properties[0], true);
//var propType = firstProp.PropertyType;
@ -275,7 +269,7 @@ namespace Ombi.Core.Engine
allRequests.ForEach(async r => { await CheckForSubscription(shouldHide, r); });
return new RequestsViewModel<TvRequests>
return new RequestsViewModel<ChildRequests>
{
Collection = allRequests,
Total = total,

@ -28,7 +28,6 @@ export class MyNavComponent {
public navItems: INavBar[] = [
{ name: "NavigationBar.Discover", icon: "find_replace", link: "/discover" },
{ name: "NavigationBar.Search", icon: "search", link: "/search" },
{ name: "NavigationBar.Requests", icon: "list", link: "/requests" },
{ name: "NavigationBar.Settings", icon: "settings", link: "/Settings/About" },
]

@ -15,42 +15,49 @@
matSortDisableClear matSortDirection="desc">
<ng-container matColumnDef="title">
<th mat-header-cell *matHeaderCellDef mat-sort-header disableClear> Title </th>
<td mat-cell *matCellDef="let element"> {{element.title}} </td>
<ng-container matColumnDef="series">
<th mat-header-cell *matHeaderCellDef> Series </th>
<td mat-cell *matCellDef="let element"> {{element.parentRequest.title}} </td>
</ng-container>
<ng-container matColumnDef="requestCount">
<th mat-header-cell *matHeaderCellDef > Request Count </th>
<td mat-cell *matCellDef="let element"> {{element.childRequests.length}} </td>
<ng-container matColumnDef="requestedBy">
<th mat-header-cell *matHeaderCellDef > Requested By </th>
<td mat-cell *matCellDef="let element"> {{element.requestedUser.userAlias}} </td>
</ng-container>
<ng-container matColumnDef="overview">
<th mat-header-cell *matHeaderCellDef > Overview </th>
<td mat-cell *matCellDef="let element">
<small>{{element.overview}}</small>
</td>
</ng-container>
<ng-container matColumnDef="status">
<th mat-header-cell *matHeaderCellDef mat-sort-header disableClear> Status </th>
<th mat-header-cell *matHeaderCellDef > Status </th>
<td mat-cell *matCellDef="let element">
<small>{{element.status}}</small>
{{element.parentRequest.status}}
</td>
</ng-container>
<ng-container matColumnDef="releaseDate">
<th mat-header-cell *matHeaderCellDef mat-sort-header disableClear> Release Date </th>
<ng-container matColumnDef="requestedDate">
<th mat-header-cell *matHeaderCellDef mat-sort-header disableClear> Requested Date </th>
<td mat-cell *matCellDef="let element">
<small>{{element.releaseDate | amLocal | amDateFormat: 'LL'}}</small>
{{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.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="actions">
<th mat-header-cell *matHeaderCellDef> </th>
<td mat-cell *matCellDef="let element">
<button mat-raised-button color="primary" [routerLink]="'/details/movie/' + element.theMovieDbId">Details</button>
<button mat-raised-button color="primary" [routerLink]="'/details/tv/' + element.parentRequest.tvDbId">Details</button>
</td>
</ng-container>

@ -1,5 +1,5 @@
import { Component, AfterViewInit, ViewChild } from "@angular/core";
import { IRequestsViewModel, ITvRequests } from "../../../interfaces";
import { IRequestsViewModel, ITvRequests, IChildRequests } from "../../../interfaces";
import { MatPaginator, MatSort } from "@angular/material";
import { merge, Observable, of as observableOf } from 'rxjs';
import { catchError, map, startWith, switchMap } from 'rxjs/operators';
@ -12,10 +12,10 @@ import { RequestServiceV2 } from "../../../services/requestV2.service";
styleUrls: ["../requests-list.component.scss"]
})
export class TvGridComponent implements AfterViewInit {
public dataSource: ITvRequests[] = [];
public dataSource: IChildRequests[] = [];
public resultsLength: number;
public isLoadingResults = true;
public displayedColumns: string[] = ['title', 'overview', 'status', 'requestCount', 'releaseDate','actions'];
public displayedColumns: string[] = ['series', 'requestedBy', 'status', 'requestStatus', 'requestedDate','actions'];
public gridCount: string = "15";
@ViewChild(MatPaginator) paginator: MatPaginator;
@ -37,7 +37,7 @@ export class TvGridComponent implements AfterViewInit {
this.isLoadingResults = true;
return this.requestService.getTvRequests(+this.gridCount, this.paginator.pageIndex * +this.gridCount, this.sort.active, this.sort.direction);
}),
map((data: IRequestsViewModel<ITvRequests>) => {
map((data: IRequestsViewModel<IChildRequests>) => {
// Flip flag to show that loading has finished.
this.isLoadingResults = false;
this.resultsLength = data.total;

@ -4,7 +4,7 @@ import { Injectable } from "@angular/core";
import { HttpClient } from "@angular/common/http";
import { Observable } from "rxjs";
import { ServiceHelpers } from "./service.helpers";
import { IRequestsViewModel, IMovieRequests, ITvRequests } from "../interfaces";
import { IRequestsViewModel, IMovieRequests, ITvRequests, IChildRequests } from "../interfaces";
@Injectable()
@ -17,8 +17,8 @@ export class RequestServiceV2 extends ServiceHelpers {
return this.http.get<IRequestsViewModel<IMovieRequests>>(`${this.url}movie/${count}/${position}/${sortProperty}/${order}`, {headers: this.headers});
}
public getTvRequests(count: number, position: number, sortProperty: string , order: string): Observable<IRequestsViewModel<ITvRequests>> {
return this.http.get<IRequestsViewModel<ITvRequests>>(`${this.url}tv/${count}/${position}/${sortProperty}/${order}`, {headers: this.headers});
public getTvRequests(count: number, position: number, sortProperty: string , order: string): Observable<IRequestsViewModel<IChildRequests>> {
return this.http.get<IRequestsViewModel<IChildRequests>>(`${this.url}tv/${count}/${position}/${sortProperty}/${order}`, {headers: this.headers});
}
}

@ -45,7 +45,7 @@ namespace Ombi.Controllers.V2
/// <param name="sort">The item to sort on e.g. "requestDate"</param>
/// <param name="sortOrder">asc or desc</param>
[HttpGet("tv/{count:int}/{position:int}/{sort}/{sortOrder}")]
public async Task<RequestsViewModel<TvRequests>> GetTvRequests(int count, int position, string sort, string sortOrder)
public async Task<RequestsViewModel<ChildRequests>> GetTvRequests(int count, int position, string sort, string sortOrder)
{
return await _tvRequestEngine.GetRequests(count, position, sort, sortOrder);
}

Loading…
Cancel
Save