mirror of
https://github.com/Ombi-app/Ombi.git
synced 2025-07-13 00:32:57 -07:00
Added paging to the TV Requests page
This commit is contained in:
parent
69e324c670
commit
0b2e488e8f
10 changed files with 73 additions and 17 deletions
|
@ -18,5 +18,6 @@ namespace Ombi.Core.Engine.Interfaces
|
||||||
Task<RequestEngineResult> ApproveMovieById(int requestId);
|
Task<RequestEngineResult> ApproveMovieById(int requestId);
|
||||||
Task<RequestEngineResult> DenyMovieById(int modelId);
|
Task<RequestEngineResult> DenyMovieById(int modelId);
|
||||||
Task<IEnumerable<MovieRequests>> Filter(FilterViewModel vm);
|
Task<IEnumerable<MovieRequests>> Filter(FilterViewModel vm);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -17,5 +17,6 @@ namespace Ombi.Core.Engine.Interfaces
|
||||||
|
|
||||||
Task<RequestEngineResult> MarkUnavailable(int modelId);
|
Task<RequestEngineResult> MarkUnavailable(int modelId);
|
||||||
Task<RequestEngineResult> MarkAvailable(int modelId);
|
Task<RequestEngineResult> MarkAvailable(int modelId);
|
||||||
|
Task<int> GetTotal();
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -144,6 +144,19 @@ namespace Ombi.Core.Engine
|
||||||
return allRequests;
|
return allRequests;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public async Task<int> GetTotal()
|
||||||
|
{
|
||||||
|
var shouldHide = await HideFromOtherUsers();
|
||||||
|
if (shouldHide.Hide)
|
||||||
|
{
|
||||||
|
return await MovieRepository.GetWithUser(shouldHide.UserId).CountAsync();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return await MovieRepository.GetWithUser().CountAsync();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the requests.
|
/// Gets the requests.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
|
@ -432,6 +432,19 @@ namespace Ombi.Core.Engine
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public async Task<int> GetTotal()
|
||||||
|
{
|
||||||
|
var shouldHide = await HideFromOtherUsers();
|
||||||
|
if (shouldHide.Hide)
|
||||||
|
{
|
||||||
|
return await TvRepository.Get(shouldHide.UserId).CountAsync();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return await TvRepository.Get().CountAsync();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private async Task<RequestEngineResult> AddExistingRequest(ChildRequests newRequest, TvRequests existingRequest)
|
private async Task<RequestEngineResult> AddExistingRequest(ChildRequests newRequest, TvRequests existingRequest)
|
||||||
{
|
{
|
||||||
// Add the child
|
// Add the child
|
||||||
|
|
|
@ -213,7 +213,7 @@
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<p-paginator [rows]="10" [totalRecords]="10000" (onPageChange)="paginate($event)"></p-paginator>
|
<p-paginator [rows]="10" [totalRecords]="totalMovies" (onPageChange)="paginate($event)"></p-paginator>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -39,6 +39,7 @@ export class MovieRequestsComponent implements OnInit {
|
||||||
public order: string = "requestedDate";
|
public order: string = "requestedDate";
|
||||||
public reverse = false;
|
public reverse = false;
|
||||||
|
|
||||||
|
public totalMovies: number = 100;
|
||||||
private currentlyLoaded: number;
|
private currentlyLoaded: number;
|
||||||
private amountToLoad: number;
|
private amountToLoad: number;
|
||||||
|
|
||||||
|
@ -269,6 +270,7 @@ export class MovieRequestsComponent implements OnInit {
|
||||||
}
|
}
|
||||||
|
|
||||||
private loadInit() {
|
private loadInit() {
|
||||||
|
this.requestService.getTotalMovies().subscribe(x => this.totalMovies = x);
|
||||||
this.requestService.getMovieRequests(this.amountToLoad, 0)
|
this.requestService.getMovieRequests(this.amountToLoad, 0)
|
||||||
.subscribe(x => {
|
.subscribe(x => {
|
||||||
this.movieRequests = x;
|
this.movieRequests = x;
|
||||||
|
|
|
@ -120,6 +120,7 @@
|
||||||
</p-column>
|
</p-column>
|
||||||
</p-treeTable>
|
</p-treeTable>
|
||||||
|
|
||||||
|
<p-paginator [rows]="10" [totalRecords]="totalTv" (onPageChange)="paginate($event)"></p-paginator>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<issue-report [movie]="false" [visible]="issuesBarVisible" [title]="issueRequest?.title"
|
<issue-report [movie]="false" [visible]="issuesBarVisible" [title]="issueRequest?.title"
|
||||||
|
|
|
@ -14,7 +14,7 @@ import { AuthService } from "../auth/auth.service";
|
||||||
import { NotificationService, RequestService, SonarrService } from "../services";
|
import { NotificationService, RequestService, SonarrService } from "../services";
|
||||||
|
|
||||||
import { TreeNode } from "primeng/primeng";
|
import { TreeNode } from "primeng/primeng";
|
||||||
import { IIssueCategory, ISonarrProfile, ISonarrRootFolder, ITvRequests } from "../interfaces";
|
import { IIssueCategory, IPagenator, ISonarrProfile, ISonarrRootFolder, ITvRequests } from "../interfaces";
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: "tv-requests",
|
selector: "tv-requests",
|
||||||
|
@ -40,6 +40,7 @@ export class TvRequestsComponent implements OnInit {
|
||||||
public sonarrProfiles: ISonarrProfile[] = [];
|
public sonarrProfiles: ISonarrProfile[] = [];
|
||||||
public sonarrRootFolders: ISonarrRootFolder[] = [];
|
public sonarrRootFolders: ISonarrRootFolder[] = [];
|
||||||
|
|
||||||
|
public totalTv: number = 100;
|
||||||
private currentlyLoaded: number;
|
private currentlyLoaded: number;
|
||||||
private amountToLoad: number;
|
private amountToLoad: number;
|
||||||
|
|
||||||
|
@ -105,21 +106,18 @@ export class TvRequestsComponent implements OnInit {
|
||||||
}
|
}
|
||||||
|
|
||||||
public ngOnInit() {
|
public ngOnInit() {
|
||||||
this.amountToLoad = 1000;
|
this.amountToLoad = 10;
|
||||||
this.currentlyLoaded = 1000;
|
this.currentlyLoaded = 10;
|
||||||
this.tvRequests = [];
|
this.tvRequests = [];
|
||||||
this.isAdmin = this.auth.hasRole("admin") || this.auth.hasRole("poweruser");
|
this.isAdmin = this.auth.hasRole("admin") || this.auth.hasRole("poweruser");
|
||||||
|
|
||||||
this.loadInit();
|
this.loadInit();
|
||||||
}
|
}
|
||||||
|
|
||||||
public loadMore() {
|
public paginate(event: IPagenator) {
|
||||||
//TODO: I believe this +1 is causing off by one error skipping loading of tv shows
|
const skipAmount = event.first;
|
||||||
//When removed and scrolling very slowly everything works as expected, however
|
|
||||||
//if you scroll really quickly then you start getting duplicates of movies
|
this.requestService.getTvRequestsTree(this.amountToLoad, skipAmount)
|
||||||
//since it's async and some subsequent results return first and then incrementer
|
|
||||||
//is increased so you see movies which had already been gotten show up...
|
|
||||||
this.requestService.getTvRequestsTree(this.amountToLoad, this.currentlyLoaded + 1)
|
|
||||||
.subscribe(x => {
|
.subscribe(x => {
|
||||||
this.tvRequests = x;
|
this.tvRequests = x;
|
||||||
this.currentlyLoaded = this.currentlyLoaded + this.amountToLoad;
|
this.currentlyLoaded = this.currentlyLoaded + this.amountToLoad;
|
||||||
|
@ -197,6 +195,7 @@ export class TvRequestsComponent implements OnInit {
|
||||||
}
|
}
|
||||||
|
|
||||||
private loadInit() {
|
private loadInit() {
|
||||||
|
this.requestService.getTotalTv().subscribe(x => this.totalTv = x);
|
||||||
this.requestService.getTvRequestsTree(this.amountToLoad, 0)
|
this.requestService.getTvRequestsTree(this.amountToLoad, 0)
|
||||||
.subscribe(x => {
|
.subscribe(x => {
|
||||||
this.tvRequests = x;
|
this.tvRequests = x;
|
||||||
|
|
|
@ -20,6 +20,14 @@ export class RequestService extends ServiceHelpers {
|
||||||
return this.http.post<IRequestEngineResult>(`${this.url}Movie/`, JSON.stringify(movie), {headers: this.headers});
|
return this.http.post<IRequestEngineResult>(`${this.url}Movie/`, JSON.stringify(movie), {headers: this.headers});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public getTotalMovies(): Observable<number> {
|
||||||
|
return this.http.get<number>(`${this.url}Movie/total`, {headers: this.headers});
|
||||||
|
}
|
||||||
|
|
||||||
|
public getTotalTv(): Observable<number> {
|
||||||
|
return this.http.get<number>(`${this.url}tv/total`, {headers: this.headers});
|
||||||
|
}
|
||||||
|
|
||||||
public requestTv(tv: ITvRequestViewModel): Observable<IRequestEngineResult> {
|
public requestTv(tv: ITvRequestViewModel): Observable<IRequestEngineResult> {
|
||||||
return this.http.post<IRequestEngineResult>(`${this.url}TV/`, JSON.stringify(tv), {headers: this.headers});
|
return this.http.post<IRequestEngineResult>(`${this.url}TV/`, JSON.stringify(tv), {headers: this.headers});
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,6 +37,15 @@ namespace Ombi.Controllers
|
||||||
return await MovieRequestEngine.GetRequests(count, position);
|
return await MovieRequestEngine.GetRequests(count, position);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the total amount of movie requests.
|
||||||
|
/// </summary>
|
||||||
|
[HttpGet("movie/total")]
|
||||||
|
public async Task<int> GetTotalMovies()
|
||||||
|
{
|
||||||
|
return await MovieRequestEngine.GetTotal();
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets all movie requests.
|
/// Gets all movie requests.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -146,6 +155,15 @@ namespace Ombi.Controllers
|
||||||
return await TvRequestEngine.GetRequestsTreeNode(count, position);
|
return await TvRequestEngine.GetRequestsTreeNode(count, position);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the total amount of TV requests.
|
||||||
|
/// </summary>
|
||||||
|
[HttpGet("tv/total")]
|
||||||
|
public async Task<int> GetTotalTV()
|
||||||
|
{
|
||||||
|
return await TvRequestEngine.GetTotal();
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the tv requests.
|
/// Gets the tv requests.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue