mirror of
https://github.com/Ombi-app/Ombi.git
synced 2025-07-16 02:02:55 -07:00
Done the TV Request Grid
This commit is contained in:
parent
f80ef6bb24
commit
e1d2d1da20
7 changed files with 44 additions and 44 deletions
|
@ -23,6 +23,6 @@ namespace Ombi.Core.Engine.Interfaces
|
||||||
Task<IEnumerable<TvRequests>> GetRequestsLite();
|
Task<IEnumerable<TvRequests>> GetRequestsLite();
|
||||||
Task UpdateQualityProfile(int requestId, int profileId);
|
Task UpdateQualityProfile(int requestId, int profileId);
|
||||||
Task UpdateRootPath(int requestId, int rootPath);
|
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();
|
var shouldHide = await HideFromOtherUsers();
|
||||||
List<TvRequests> allRequests = null;
|
List<ChildRequests> allRequests;
|
||||||
if (shouldHide.Hide)
|
if (shouldHide.Hide)
|
||||||
{
|
{
|
||||||
var tv = TvRepository.GetLite(shouldHide.UserId);
|
allRequests = await TvRepository.GetChild(shouldHide.UserId).ToListAsync();
|
||||||
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();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Filter out children
|
// Filter out children
|
||||||
|
|
||||||
FilterChildren(allRequests, shouldHide);
|
FilterChildren(allRequests, shouldHide);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
var tv = TvRepository.GetLite();
|
allRequests = await TvRepository.GetChild().ToListAsync();
|
||||||
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();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (allRequests == null)
|
if (allRequests == null)
|
||||||
{
|
{
|
||||||
return new RequestsViewModel<TvRequests>();
|
return new RequestsViewModel<ChildRequests>();
|
||||||
}
|
}
|
||||||
|
|
||||||
var total = allRequests.Count;
|
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('.'))
|
if (sortProperty.Contains('.'))
|
||||||
{
|
{
|
||||||
// This is a navigation property currently not supported
|
// 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 properties = sortProperty.Split(new []{'.'}, StringSplitOptions.RemoveEmptyEntries);
|
||||||
//var firstProp = TypeDescriptor.GetProperties(typeof(MovieRequests)).Find(properties[0], true);
|
//var firstProp = TypeDescriptor.GetProperties(typeof(MovieRequests)).Find(properties[0], true);
|
||||||
//var propType = firstProp.PropertyType;
|
//var propType = firstProp.PropertyType;
|
||||||
|
@ -275,7 +269,7 @@ namespace Ombi.Core.Engine
|
||||||
allRequests.ForEach(async r => { await CheckForSubscription(shouldHide, r); });
|
allRequests.ForEach(async r => { await CheckForSubscription(shouldHide, r); });
|
||||||
|
|
||||||
|
|
||||||
return new RequestsViewModel<TvRequests>
|
return new RequestsViewModel<ChildRequests>
|
||||||
{
|
{
|
||||||
Collection = allRequests,
|
Collection = allRequests,
|
||||||
Total = total,
|
Total = total,
|
||||||
|
|
|
@ -28,7 +28,6 @@ export class MyNavComponent {
|
||||||
|
|
||||||
public navItems: INavBar[] = [
|
public navItems: INavBar[] = [
|
||||||
{ name: "NavigationBar.Discover", icon: "find_replace", link: "/discover" },
|
{ name: "NavigationBar.Discover", icon: "find_replace", link: "/discover" },
|
||||||
{ name: "NavigationBar.Search", icon: "search", link: "/search" },
|
|
||||||
{ name: "NavigationBar.Requests", icon: "list", link: "/requests" },
|
{ name: "NavigationBar.Requests", icon: "list", link: "/requests" },
|
||||||
{ name: "NavigationBar.Settings", icon: "settings", link: "/Settings/About" },
|
{ name: "NavigationBar.Settings", icon: "settings", link: "/Settings/About" },
|
||||||
]
|
]
|
||||||
|
|
|
@ -15,42 +15,49 @@
|
||||||
matSortDisableClear matSortDirection="desc">
|
matSortDisableClear matSortDirection="desc">
|
||||||
|
|
||||||
|
|
||||||
<ng-container matColumnDef="title">
|
<ng-container matColumnDef="series">
|
||||||
<th mat-header-cell *matHeaderCellDef mat-sort-header disableClear> Title </th>
|
<th mat-header-cell *matHeaderCellDef> Series </th>
|
||||||
<td mat-cell *matCellDef="let element"> {{element.title}} </td>
|
<td mat-cell *matCellDef="let element"> {{element.parentRequest.title}} </td>
|
||||||
</ng-container>
|
</ng-container>
|
||||||
|
|
||||||
<ng-container matColumnDef="requestCount">
|
<ng-container matColumnDef="requestedBy">
|
||||||
<th mat-header-cell *matHeaderCellDef > Request Count </th>
|
<th mat-header-cell *matHeaderCellDef > Requested By </th>
|
||||||
<td mat-cell *matCellDef="let element"> {{element.childRequests.length}} </td>
|
<td mat-cell *matCellDef="let element"> {{element.requestedUser.userAlias}} </td>
|
||||||
</ng-container>
|
</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">
|
<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">
|
<td mat-cell *matCellDef="let element">
|
||||||
<small>{{element.status}}</small>
|
{{element.parentRequest.status}}
|
||||||
</td>
|
</td>
|
||||||
</ng-container>
|
</ng-container>
|
||||||
|
|
||||||
<ng-container matColumnDef="releaseDate">
|
<ng-container matColumnDef="requestedDate">
|
||||||
<th mat-header-cell *matHeaderCellDef mat-sort-header disableClear> Release Date </th>
|
<th mat-header-cell *matHeaderCellDef mat-sort-header disableClear> Requested Date </th>
|
||||||
<td mat-cell *matCellDef="let element">
|
<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>
|
</td>
|
||||||
</ng-container>
|
</ng-container>
|
||||||
|
|
||||||
<ng-container matColumnDef="actions">
|
<ng-container matColumnDef="actions">
|
||||||
<th mat-header-cell *matHeaderCellDef> </th>
|
<th mat-header-cell *matHeaderCellDef> </th>
|
||||||
<td mat-cell *matCellDef="let element">
|
<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>
|
</td>
|
||||||
</ng-container>
|
</ng-container>
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import { Component, AfterViewInit, ViewChild } from "@angular/core";
|
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 { MatPaginator, MatSort } from "@angular/material";
|
||||||
import { merge, Observable, of as observableOf } from 'rxjs';
|
import { merge, Observable, of as observableOf } from 'rxjs';
|
||||||
import { catchError, map, startWith, switchMap } from 'rxjs/operators';
|
import { catchError, map, startWith, switchMap } from 'rxjs/operators';
|
||||||
|
@ -12,10 +12,10 @@ import { RequestServiceV2 } from "../../../services/requestV2.service";
|
||||||
styleUrls: ["../requests-list.component.scss"]
|
styleUrls: ["../requests-list.component.scss"]
|
||||||
})
|
})
|
||||||
export class TvGridComponent implements AfterViewInit {
|
export class TvGridComponent implements AfterViewInit {
|
||||||
public dataSource: ITvRequests[] = [];
|
public dataSource: IChildRequests[] = [];
|
||||||
public resultsLength: number;
|
public resultsLength: number;
|
||||||
public isLoadingResults = true;
|
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";
|
public gridCount: string = "15";
|
||||||
|
|
||||||
@ViewChild(MatPaginator) paginator: MatPaginator;
|
@ViewChild(MatPaginator) paginator: MatPaginator;
|
||||||
|
@ -37,7 +37,7 @@ export class TvGridComponent implements AfterViewInit {
|
||||||
this.isLoadingResults = true;
|
this.isLoadingResults = true;
|
||||||
return this.requestService.getTvRequests(+this.gridCount, this.paginator.pageIndex * +this.gridCount, this.sort.active, this.sort.direction);
|
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.
|
// Flip flag to show that loading has finished.
|
||||||
this.isLoadingResults = false;
|
this.isLoadingResults = false;
|
||||||
this.resultsLength = data.total;
|
this.resultsLength = data.total;
|
||||||
|
|
|
@ -4,7 +4,7 @@ import { Injectable } from "@angular/core";
|
||||||
import { HttpClient } from "@angular/common/http";
|
import { HttpClient } from "@angular/common/http";
|
||||||
import { Observable } from "rxjs";
|
import { Observable } from "rxjs";
|
||||||
import { ServiceHelpers } from "./service.helpers";
|
import { ServiceHelpers } from "./service.helpers";
|
||||||
import { IRequestsViewModel, IMovieRequests, ITvRequests } from "../interfaces";
|
import { IRequestsViewModel, IMovieRequests, ITvRequests, IChildRequests } from "../interfaces";
|
||||||
|
|
||||||
|
|
||||||
@Injectable()
|
@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});
|
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>> {
|
public getTvRequests(count: number, position: number, sortProperty: string , order: string): Observable<IRequestsViewModel<IChildRequests>> {
|
||||||
return this.http.get<IRequestsViewModel<ITvRequests>>(`${this.url}tv/${count}/${position}/${sortProperty}/${order}`, {headers: this.headers});
|
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="sort">The item to sort on e.g. "requestDate"</param>
|
||||||
/// <param name="sortOrder">asc or desc</param>
|
/// <param name="sortOrder">asc or desc</param>
|
||||||
[HttpGet("tv/{count:int}/{position:int}/{sort}/{sortOrder}")]
|
[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);
|
return await _tvRequestEngine.GetRequests(count, position, sort, sortOrder);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue