From bae8e18424ded528f2471f417a764662679eff24 Mon Sep 17 00:00:00 2001 From: TidusJar Date: Tue, 31 Jul 2018 09:06:38 +0100 Subject: [PATCH] Got Requests page working !wip --- .../ClientApp/app/interfaces/IRequestModel.ts | 4 + .../app/requests/tvrequests.component.html | 45 +++++------ .../app/requests/tvrequests.component.ts | 79 ++++++------------- .../ClientApp/app/services/request.service.ts | 6 +- 4 files changed, 51 insertions(+), 83 deletions(-) diff --git a/src/Ombi/ClientApp/app/interfaces/IRequestModel.ts b/src/Ombi/ClientApp/app/interfaces/IRequestModel.ts index 236e694fc..92c455fc1 100644 --- a/src/Ombi/ClientApp/app/interfaces/IRequestModel.ts +++ b/src/Ombi/ClientApp/app/interfaces/IRequestModel.ts @@ -71,6 +71,10 @@ export interface ITvRequests { status: string; childRequests: IChildRequests[]; qualityOverride: number; + background: any; + totalSeasons: number; + tvDbId: number; + open: boolean; // THIS IS FOR THE UI // For UI display qualityOverrideTitle: string; diff --git a/src/Ombi/ClientApp/app/requests/tvrequests.component.html b/src/Ombi/ClientApp/app/requests/tvrequests.component.html index 954bd6b42..70147ecad 100644 --- a/src/Ombi/ClientApp/app/requests/tvrequests.component.html +++ b/src/Ombi/ClientApp/app/requests/tvrequests.component.html @@ -18,43 +18,40 @@ [infiniteScrollThrottle]="100" (scrolled)="loadMore()">-->
- - - Results - - +
+
-
+
-
+
- poster + poster

Status: - {{node.data.status}} + {{node.status}}
-
Release Date: {{node.data.releaseDate | date}}
+
Release Date: {{node.releaseDate | date}}
-
{{ 'Requests.QualityOverride' | translate }} - {{node.data.qualityOverrideTitle}} +
{{ 'Requests.QualityOverride' | translate }} + {{node.qualityOverrideTitle}}
-
{{ 'Requests.RootFolderOverride' | translate }} - {{node.data.rootPathOverrideTitle}} +
{{ 'Requests.RootFolderOverride' | translate }} + {{node.rootPathOverrideTitle}}
@@ -62,7 +59,7 @@
-
@@ -76,7 +73,7 @@
@@ -92,7 +89,7 @@
@@ -106,7 +103,7 @@
@@ -114,11 +111,11 @@
-
- +
+
- - +
+
diff --git a/src/Ombi/ClientApp/app/requests/tvrequests.component.ts b/src/Ombi/ClientApp/app/requests/tvrequests.component.ts index e59fc5c94..27469af0b 100644 --- a/src/Ombi/ClientApp/app/requests/tvrequests.component.ts +++ b/src/Ombi/ClientApp/app/requests/tvrequests.component.ts @@ -1,12 +1,11 @@ import { PlatformLocation } from "@angular/common"; import { Component, Input, OnInit } from "@angular/core"; import { DomSanitizer } from "@angular/platform-browser"; -import { TreeNode } from "primeng/primeng"; import { Subject } from "rxjs"; import { debounceTime, distinctUntilChanged } from "rxjs/operators"; import { AuthService } from "../auth/auth.service"; -import { IIssueCategory, IPagenator, ISonarrProfile, ISonarrRootFolder, ITvRequests } from "../interfaces"; +import { FilterType, IIssueCategory, IPagenator, IRequestsViewModel, ISonarrProfile, ISonarrRootFolder, ITvRequests, OrderType } from "../interfaces"; import { NotificationService, RequestService, SonarrService } from "../services"; import { ImageService } from "./../services/image.service"; @@ -17,7 +16,7 @@ import { ImageService } from "./../services/image.service"; }) export class TvRequestsComponent implements OnInit { - public tvRequests: TreeNode[]; + public tvRequests: IRequestsViewModel; public searchChanged = new Subject(); public searchText: string; public isAdmin: boolean; @@ -56,11 +55,11 @@ export class TvRequestsComponent implements OnInit { this.resetSearch(); return; } - this.requestService.searchTvRequestsTree(this.searchText) + this.requestService.searchTvRequests(this.searchText) .subscribe(m => { - this.tvRequests = m; - this.tvRequests.forEach((val) => this.loadBackdrop(val)); - this.tvRequests.forEach((val) => this.setOverride(val.data)); + this.tvRequests.collection = m; + this.tvRequests.collection.forEach((val) => this.loadBackdrop(val)); + this.tvRequests.collection.forEach((val) => this.setOverride(val)); }); }); this.defaultPoster = "../../../images/default_tv_poster.png"; @@ -70,47 +69,15 @@ export class TvRequestsComponent implements OnInit { } } - public openClosestTab(el: any) { - const rowclass = "undefined ng-star-inserted"; - el = el.toElement || el.relatedTarget || el.target || el.srcElement; - - if (el.nodeName === "BUTTON") { - - const isButtonAlreadyActive = el.parentElement.querySelector(".active"); - // if a Button already has Class: .active - if (isButtonAlreadyActive) { - isButtonAlreadyActive.classList.remove("active"); - } else { - el.className += " active"; - } - } - - while (el.className !== rowclass) { - // Increment the loop to the parent node until we find the row we need - el = el.parentNode; - } - // At this point, the while loop has stopped and `el` represents the element that has - // the class you specified - - // Then we loop through the children to find the caret which we want to click - const caretright = "fa-caret-right"; - const caretdown = "fa-caret-down"; - for (const value of el.children) { - // the caret from the ui has 2 class selectors depending on if expanded or not - // we search for both since we want to still toggle the clicking - if (value.className.includes(caretright) || value.className.includes(caretdown)) { - // Then we tell JS to click the element even though we hid it from the UI - value.click(); - //Break from loop since we no longer need to continue looking - break; - } - } + public openClosestTab(node: ITvRequests,el: any) { + el.preventDefault(); + node.open = !node.open; } public ngOnInit() { this.amountToLoad = 10; this.currentlyLoaded = 10; - this.tvRequests = []; + this.tvRequests = {collection:[], total:0}; this.isAdmin = this.auth.hasRole("admin") || this.auth.hasRole("poweruser"); this.loadInit(); @@ -119,7 +86,7 @@ export class TvRequestsComponent implements OnInit { public paginate(event: IPagenator) { const skipAmount = event.first; - this.requestService.getTvRequestsTree(this.amountToLoad, skipAmount) + this.requestService.getTvRequests(this.amountToLoad, skipAmount, OrderType.RequestedDateDesc, FilterType.None, FilterType.None) .subscribe(x => { this.tvRequests = x; this.currentlyLoaded = this.currentlyLoaded + this.amountToLoad; @@ -198,13 +165,13 @@ export class TvRequestsComponent implements OnInit { private loadInit() { this.requestService.getTotalTv().subscribe(x => this.totalTv = x); - this.requestService.getTvRequestsTree(this.amountToLoad, 0) + this.requestService.getTvRequests(this.amountToLoad, 0, OrderType.RequestedDateDesc, FilterType.None, FilterType.None) .subscribe(x => { this.tvRequests = x; - this.tvRequests.forEach((val, index) => { + this.tvRequests.collection.forEach((val, index) => { this.setDefaults(val); this.loadBackdrop(val); - this.setOverride(val.data); + this.setOverride(val); }); }); @@ -222,20 +189,20 @@ export class TvRequestsComponent implements OnInit { this.loadInit(); } - private setDefaults(val: any) { - if (val.data.posterPath === null) { - val.data.posterPath = this.defaultPoster; + private setDefaults(val: ITvRequests) { + if (val.posterPath === null) { + val.posterPath = this.defaultPoster; } } - private loadBackdrop(val: TreeNode): void { - if (val.data.background != null) { - val.data.background = this.sanitizer.bypassSecurityTrustStyle - ("url(https://image.tmdb.org/t/p/w1280" + val.data.background + ")"); + private loadBackdrop(val: ITvRequests): void { + if (val.background != null) { + val.background = this.sanitizer.bypassSecurityTrustStyle + ("url(https://image.tmdb.org/t/p/w1280" + val.background + ")"); } else { - this.imageService.getTvBanner(val.data.tvDbId).subscribe(x => { + this.imageService.getTvBanner(val.tvDbId).subscribe(x => { if (x) { - val.data.background = this.sanitizer.bypassSecurityTrustStyle + val.background = this.sanitizer.bypassSecurityTrustStyle ("url(" + x + ")"); } }); diff --git a/src/Ombi/ClientApp/app/services/request.service.ts b/src/Ombi/ClientApp/app/services/request.service.ts index 8a04c5cd3..82acc2bfb 100644 --- a/src/Ombi/ClientApp/app/services/request.service.ts +++ b/src/Ombi/ClientApp/app/services/request.service.ts @@ -5,7 +5,7 @@ import { HttpClient } from "@angular/common/http"; import { Observable } from "rxjs"; import { TreeNode } from "primeng/primeng"; -import { IRequestEngineResult } from "../interfaces"; +import { IRequestEngineResult, FilterType } from "../interfaces"; import { IChildRequests, IFilter, IMovieRequestModel, IMovieRequests, IMovieUpdateModel, IRequestsViewModel, ITvRequests, ITvUpdateModel, OrderType } from "../interfaces"; import { ITvRequestViewModel } from "../interfaces"; import { ServiceHelpers } from "./service.helpers"; @@ -64,8 +64,8 @@ export class RequestService extends ServiceHelpers { return this.http.put(`${this.url}movie/`, JSON.stringify(request), {headers: this.headers}); } - public getTvRequests(count: number, position: number): Observable { - return this.http.get(`${this.url}tv/${count}/${position}`, {headers: this.headers}); + public getTvRequests(count: number, position: number, order: OrderType, status: FilterType, availability: FilterType): Observable> { + return this.http.get>(`${this.url}tv/${count}/${position}/${order}/${status}/${availability}`, {headers: this.headers}); } public getTvRequestsTree(count: number, position: number): Observable {