From 56cf1b56cc1eb1ec77b3dac160521f2bc8ef8ad7 Mon Sep 17 00:00:00 2001 From: Dhruv Bhavsar Date: Sat, 26 Aug 2017 14:11:04 -0400 Subject: [PATCH 1/5] Clean up Requests page code by moving children request to old component, remove additional REST calls when merging and update component names to make more sense. --- .../ClientApp/app/requests/requests.module.ts | 9 +- ...html => tvrequest-children.component.html} | 19 +-- ...ent.ts => tvrequest-children.component.ts} | 41 +----- .../app/requests/tvrequests.component.html | 137 +----------------- .../app/requests/tvrequests.component.ts | 1 - 5 files changed, 14 insertions(+), 193 deletions(-) rename src/Ombi/ClientApp/app/requests/{tvrequest-manage.component.html => tvrequest-children.component.html} (90%) rename src/Ombi/ClientApp/app/requests/{tvrequest-manage.component.ts => tvrequest-children.component.ts} (50%) diff --git a/src/Ombi/ClientApp/app/requests/requests.module.ts b/src/Ombi/ClientApp/app/requests/requests.module.ts index eaedf9618..b250602e4 100644 --- a/src/Ombi/ClientApp/app/requests/requests.module.ts +++ b/src/Ombi/ClientApp/app/requests/requests.module.ts @@ -12,9 +12,8 @@ import { ButtonModule, DialogModule } from 'primeng/primeng'; import { RequestComponent } from './request.component'; import { MovieRequestsComponent } from './movierequests.component'; import { TvRequestsComponent } from './tvrequests.component'; -import { TvRequestManageComponent } from './tvrequest-manage.component'; -//import { RequestGridComponent } from '../request-grid/request-grid.component'; -// import { RequestCardComponent } from '../request-grid/request-card.component'; +import { TvRequestChildrenComponent } from './tvrequest-children.component'; + import { TreeTableModule } from 'primeng/primeng'; import { IdentityService } from '../services/identity.service'; @@ -24,7 +23,7 @@ import { AuthGuard } from '../auth/auth.guard'; const routes: Routes = [ { path: 'requests', component: RequestComponent, canActivate: [AuthGuard] }, - { path: 'requests/:id', component: TvRequestManageComponent, canActivate: [AuthGuard] }, + { path: 'requests/:id', component: TvRequestChildrenComponent, canActivate: [AuthGuard] }, ]; @NgModule({ @@ -42,7 +41,7 @@ const routes: Routes = [ RequestComponent, MovieRequestsComponent, TvRequestsComponent, - TvRequestManageComponent, + TvRequestChildrenComponent, ], exports: [ RouterModule diff --git a/src/Ombi/ClientApp/app/requests/tvrequest-manage.component.html b/src/Ombi/ClientApp/app/requests/tvrequest-children.component.html similarity index 90% rename from src/Ombi/ClientApp/app/requests/tvrequest-manage.component.html rename to src/Ombi/ClientApp/app/requests/tvrequest-children.component.html index 649cdbebf..ef5d1a463 100644 --- a/src/Ombi/ClientApp/app/requests/tvrequest-manage.component.html +++ b/src/Ombi/ClientApp/app/requests/tvrequest-children.component.html @@ -1,25 +1,10 @@ 
+
Requested By: {{child.requestedUser.userName}} - - - - - - - -
@@ -92,8 +77,6 @@ Not Yet Requested - - diff --git a/src/Ombi/ClientApp/app/requests/tvrequest-manage.component.ts b/src/Ombi/ClientApp/app/requests/tvrequest-children.component.ts similarity index 50% rename from src/Ombi/ClientApp/app/requests/tvrequest-manage.component.ts rename to src/Ombi/ClientApp/app/requests/tvrequest-children.component.ts index d55e614e5..92fe9fc13 100644 --- a/src/Ombi/ClientApp/app/requests/tvrequest-manage.component.ts +++ b/src/Ombi/ClientApp/app/requests/tvrequest-children.component.ts @@ -1,42 +1,17 @@ -import { Component } from '@angular/core'; -import { ActivatedRoute } from '@angular/router'; - +import { Component, Input } from '@angular/core'; import { RequestService } from '../services/request.service'; -import { IdentityService } from '../services/identity.service'; - -import { IChildRequests, IEpisodesRequests, INewSeasonRequests } from '../interfaces/IRequestModel'; +import { IChildRequests, IEpisodesRequests } from '../interfaces/IRequestModel'; @Component({ - templateUrl: './tvrequest-manage.component.html' + selector:'tvrequests-children', + templateUrl: './tvrequest-children.component.html' }) -export class TvRequestManageComponent { - constructor(private requestService: RequestService, private identityService: IdentityService, - private route: ActivatedRoute) { - - this.route.params - .subscribe(params => { - this.tvId = +params['id']; // (+) converts string 'id' to a number - this.requestService.getChildRequests(this.tvId).subscribe(x => { - this.childRequests = this.fixEpisodeSort(x); - }); - }); - - this.isAdmin = this.identityService.hasRole('admin'); +export class TvRequestChildrenComponent { + constructor(private requestService: RequestService) { } - tvId: number; - childRequests: IChildRequests[]; - isAdmin: boolean; - public fixEpisodeSort(items: IChildRequests[]) { - items.forEach(function (value) { - value.seasonRequests.forEach(function (requests: INewSeasonRequests) { - requests.episodes.sort(function (a: IEpisodesRequests, b: IEpisodesRequests) { - return a.episodeNumber - b.episodeNumber; - }) - }) - }) - return items; - } + @Input() childRequests: IChildRequests[]; + @Input() isAdmin: boolean; public removeRequest(request: IChildRequests) { this.requestService.deleteChild(request) .subscribe(); diff --git a/src/Ombi/ClientApp/app/requests/tvrequests.component.html b/src/Ombi/ClientApp/app/requests/tvrequests.component.html index a0d9be84e..3b7914515 100644 --- a/src/Ombi/ClientApp/app/requests/tvrequests.component.html +++ b/src/Ombi/ClientApp/app/requests/tvrequests.component.html @@ -65,145 +65,10 @@
-
-
-
-
- -
- Requested By: {{child.requestedUser.userName}} -
- - -
- -
- -
-
- -
-
- -
-
-
-
- - -
- - -

Season: {{season.seasonNumber}}

- - - - - - - - - - - - - - - - - - - - -
- - # - - - - Title - - - - Air Date - - - - Status - -
- {{ep.episodeNumber}} - - {{ep.title}} - - {{ep.airDate | date: 'dd/MM/yyyy' }} - - Available - Processing Request -
- - Pending Approval - - - - Not Yet Requested - -
-
-
-
-
-
-
-
-
-
- -
+
- - - -
diff --git a/src/Ombi/ClientApp/app/requests/tvrequests.component.ts b/src/Ombi/ClientApp/app/requests/tvrequests.component.ts index 70b922eba..b4fbc0834 100644 --- a/src/Ombi/ClientApp/app/requests/tvrequests.component.ts +++ b/src/Ombi/ClientApp/app/requests/tvrequests.component.ts @@ -79,7 +79,6 @@ export class TvRequestsComponent implements OnInit, OnDestroy { leaf: false }); }, this) - console.log(temp); return temp; } private subscriptions = new Subject(); From 87b5451f26e0df0aaf3504e2cc394045bb64b5a6 Mon Sep 17 00:00:00 2001 From: Dhruv Bhavsar Date: Sat, 26 Aug 2017 14:31:02 -0400 Subject: [PATCH 2/5] Upstream Changes... --- .../app/requests/tvrequests.component.html | 107 ++++++++++++++++-- 1 file changed, 96 insertions(+), 11 deletions(-) diff --git a/src/Ombi/ClientApp/app/requests/tvrequests.component.html b/src/Ombi/ClientApp/app/requests/tvrequests.component.html index 3b7914515..fa4a16e24 100644 --- a/src/Ombi/ClientApp/app/requests/tvrequests.component.html +++ b/src/Ombi/ClientApp/app/requests/tvrequests.component.html @@ -43,18 +43,9 @@ {{node.data.status}}
-
- Request status: - Available - Processing Request - Request Denied - - Pending Approval - -
+
Release Date: {{node.data.releaseDate | date}}

-
Requested Date: {{node.data.requestedDate | date}}
@@ -65,7 +56,101 @@
- +
+
+
+
+ +
+ Requested By: {{child.requestedUser.userName}} +
+ + +
+ +
+ +
+
+ +
+
+ +
+
+
+
+ + +
+ + +

Season: {{season.seasonNumber}}

+ + + + + + + + + + + + + + + + + + + + +
+ + # + + + + Title + + + + Air Date + + + + Status + +
+ {{ep.episodeNumber}} + + {{ep.title}} + + {{ep.airDate | date: 'dd/MM/yyyy' }} + + Available + Processing Request +
+ + Pending Approval + + + + Not Yet Requested + +
+
+
+
+
+
+
+
+
+
+ +
From d1da6ca9b462f8c029009995cbf09d6ccc3f6387 Mon Sep 17 00:00:00 2001 From: Dhruv Bhavsar Date: Sat, 26 Aug 2017 14:35:20 -0400 Subject: [PATCH 3/5] Fix merge conflict for TvRequests component. --- .../app/requests/tvrequests.component.html | 97 +------------------ 1 file changed, 1 insertion(+), 96 deletions(-) diff --git a/src/Ombi/ClientApp/app/requests/tvrequests.component.html b/src/Ombi/ClientApp/app/requests/tvrequests.component.html index fa4a16e24..e5161c8c5 100644 --- a/src/Ombi/ClientApp/app/requests/tvrequests.component.html +++ b/src/Ombi/ClientApp/app/requests/tvrequests.component.html @@ -50,107 +50,12 @@
-
-
-
-
-
- -
- Requested By: {{child.requestedUser.userName}} -
- - -
- -
- -
-
- -
-
- -
-
-
-
- - -
- - -

Season: {{season.seasonNumber}}

- - - - - - - - - - - - - - - - - - - - -
- - # - - - - Title - - - - Air Date - - - - Status - -
- {{ep.episodeNumber}} - - {{ep.title}} - - {{ep.airDate | date: 'dd/MM/yyyy' }} - - Available - Processing Request -
- - Pending Approval - - - - Not Yet Requested - -
-
-
-
-
-
-
-
-
-
- -
+
From 4215c776208be0ec937065fe5d30c1bd06a518c1 Mon Sep 17 00:00:00 2001 From: Dhruv Bhavsar Date: Sat, 26 Aug 2017 16:27:28 -0400 Subject: [PATCH 4/5] Make Episode picker similar to Requests Child view. #1457 #1463 --- .../app/requests/tvrequests.component.html | 16 +- .../app/requests/tvrequests.component.ts | 11 +- .../ClientApp/app/search/search.module.ts | 5 +- .../search/seriesinformation.component.html | 14 +- .../app/search/seriesinformation.component.ts | 15 +- .../app/search/tvsearch.component.html | 242 +++++++++--------- .../app/search/tvsearch.component.ts | 49 +++- 7 files changed, 204 insertions(+), 148 deletions(-) diff --git a/src/Ombi/ClientApp/app/requests/tvrequests.component.html b/src/Ombi/ClientApp/app/requests/tvrequests.component.html index e5161c8c5..e515ee47a 100644 --- a/src/Ombi/ClientApp/app/requests/tvrequests.component.html +++ b/src/Ombi/ClientApp/app/requests/tvrequests.component.html @@ -4,12 +4,20 @@
+ + + (scrolled)="loadMore()">--> +
+ +
@@ -83,9 +77,5 @@
- - - -
diff --git a/src/Ombi/ClientApp/app/search/seriesinformation.component.ts b/src/Ombi/ClientApp/app/search/seriesinformation.component.ts index 79c2b0128..ad705ecfc 100644 --- a/src/Ombi/ClientApp/app/search/seriesinformation.component.ts +++ b/src/Ombi/ClientApp/app/search/seriesinformation.component.ts @@ -1,5 +1,5 @@ -import { Component, OnInit, OnDestroy } from '@angular/core'; -import { ActivatedRoute } from '@angular/router'; +import { Component, OnInit, OnDestroy, Input} from '@angular/core'; +//import { ActivatedRoute } from '@angular/router'; import { Subject } from 'rxjs/Subject'; import "rxjs/add/operator/takeUntil"; @@ -13,24 +13,19 @@ import { IRequestEngineResult } from '../interfaces/IRequestEngineResult'; import { IEpisodesRequests } from "../interfaces/IRequestModel"; @Component({ + selector: 'seriesinformation', templateUrl: './seriesinformation.component.html', styleUrls: ['./seriesinformation.component.scss'] }) export class SeriesInformationComponent implements OnInit, OnDestroy { - constructor(private searchService: SearchService, private route: ActivatedRoute, - private requestService: RequestService, private notificationService: NotificationService) { - this.route.params - .takeUntil(this.subscriptions) - .subscribe(params => { - this.seriesId = +params['id']; // (+) converts string 'id' to a number - }); + constructor(private searchService: SearchService, private requestService: RequestService, private notificationService: NotificationService) { } private subscriptions = new Subject(); public result : IRequestEngineResult; - private seriesId: number; + @Input() private seriesId: number; public series: ISearchTvResult; requestedEpisodes: IEpisodesRequests[] = []; diff --git a/src/Ombi/ClientApp/app/search/tvsearch.component.html b/src/Ombi/ClientApp/app/search/tvsearch.component.html index b5c727764..5120fee8b 100644 --- a/src/Ombi/ClientApp/app/search/tvsearch.component.html +++ b/src/Ombi/ClientApp/app/search/tvsearch.component.html @@ -32,123 +32,133 @@
Sorry, we didn't find any results!
- -
-
-
- - poster - -
-
-
- - -

{{result.title}} ({{result.firstAired | date: 'yyyy'}})

- -
- - {{result.status}} - - - Air Date: {{result.firstAired}} - - - Release Date: {{result.releaseDate | date: 'dd/MM/yyyy'}} - - Available - Processing Request -
- - Pending Approval - - - - Not Yet Requested - - - - - - HomePage - - Trailer - - -
-
+ + + + Results + + + +
+
+
+ + poster + +
+
+
+ + +

{{node.data.title}} ({{node.data.firstAired | date: 'yyyy'}})

+ +
+ {{node.data.status}} + + + Air Date: {{node.data.firstAired}} + + + Release Date: {{node.data.releaseDate | date: 'dd/MM/yyyy'}} + + Available + Processing Request +
+ + Pending Approval + + + + Not Yet Requested + + + + + + HomePage + + Trailer + + +
+
+
+

{{node.data.overview}}

+
+ + +
+ + + + + + + + + + +
+
+ View On Plex + + +
+ +
+ +
+
-

{{result.overview}}

-
- - -
- - - - - - - - -
-
-
- + + +
\ No newline at end of file diff --git a/src/Ombi/ClientApp/app/search/tvsearch.component.ts b/src/Ombi/ClientApp/app/search/tvsearch.component.ts index f1c2cfa68..bbfd1bf66 100644 --- a/src/Ombi/ClientApp/app/search/tvsearch.component.ts +++ b/src/Ombi/ClientApp/app/search/tvsearch.component.ts @@ -1,4 +1,4 @@ -import { Component, OnInit, OnDestroy } from '@angular/core'; +import { Component, OnInit, OnDestroy, ViewEncapsulation } from '@angular/core'; import {Router} from '@angular/router'; import { Subject } from 'rxjs/Subject'; import 'rxjs/add/operator/debounceTime'; @@ -12,10 +12,16 @@ import { NotificationService } from '../services/notification.service'; import { ISearchTvResult } from '../interfaces/ISearchTvResult'; import { IRequestEngineResult } from '../interfaces/IRequestEngineResult'; +import { TreeNode } from "primeng/primeng"; @Component({ selector: 'tv-search', templateUrl: './tvsearch.component.html', + styleUrls: ['./../requests/tvrequests.component.scss'], + //Was required to turn off encapsulation since CSS only should be overridden for this component + //However when encapsulation is on angular injects prefixes to all classes so css selectors + //Stop working + encapsulation: ViewEncapsulation.None }) export class TvSearchComponent implements OnInit, OnDestroy { @@ -41,11 +47,50 @@ export class TvSearchComponent implements OnInit, OnDestroy { this.searchService.searchTv(this.searchText) .takeUntil(this.subscriptions) .subscribe(x => { - this.tvResults = x; + this.tvResults = this.transformData(x); this.searchApplied = true; }); }); } + openClosestTab(el: any): void { + var rowclass = "undefined"; + el = el.toElement; + while (el.className != rowclass) { + // Increment the loop to the parent node until we find the row we need + el = el.parentNode; + if (!el) { + } + } + // 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 + var caretright = "ui-treetable-toggler fa fa-fw ui-c fa-caret-right"; + var caretdown = "ui-treetable-toggler fa fa-fw ui-c fa-caret-down"; + for (var 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 === caretright || value.className === 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; + } + }; + } + transformData(datain: ISearchTvResult[]): any { + var temp: TreeNode[] = []; + datain.forEach(function (value) { + temp.push({ + "data": value, + "children": [{ + "data": value, leaf: true + }], + leaf: false + }); + }, this) + return temp; + } ngOnInit(): void { this.searchText = ""; From c77ac00eaeabbbaff303a2ee5fa0459d560a5ad7 Mon Sep 17 00:00:00 2001 From: Dhruv Bhavsar Date: Tue, 29 Aug 2017 20:54:54 -0400 Subject: [PATCH 5/5] Remove unused functions --- .../app/requests/tvrequests.component.ts | 25 +++---------------- 1 file changed, 3 insertions(+), 22 deletions(-) diff --git a/src/Ombi/ClientApp/app/requests/tvrequests.component.ts b/src/Ombi/ClientApp/app/requests/tvrequests.component.ts index 279593be8..e30248c24 100644 --- a/src/Ombi/ClientApp/app/requests/tvrequests.component.ts +++ b/src/Ombi/ClientApp/app/requests/tvrequests.component.ts @@ -68,9 +68,9 @@ export class TvRequestsComponent implements OnInit, OnDestroy { } }; } - transformData(datain: ITvRequests[]): any { + transformData(data: ITvRequests[]): TreeNode[] { var temp: TreeNode[] = []; - datain.forEach(function (value) { + data.forEach(function (value) { temp.push({ "data": value, "children": [{ @@ -83,7 +83,7 @@ export class TvRequestsComponent implements OnInit, OnDestroy { } private subscriptions = new Subject(); - tvRequests: ITvRequests[]; + tvRequests: TreeNode[]; searchChanged = new Subject(); searchText: string; @@ -135,11 +135,6 @@ export class TvRequestsComponent implements OnInit, OnDestroy { this.requestService.removeTvRequest(request); this.removeRequestFromUi(request); } - public removeChildRequest(request: IChildRequests) { - this.requestService.deleteChild(request) - .subscribe(); - this.removeChildRequestFromUi(request); - } public changeAvailability(request: IChildRequests, available: boolean) { request.available = available; @@ -185,12 +180,6 @@ export class TvRequestsComponent implements OnInit, OnDestroy { this.requestService.updateTvRequest(this.selectedSeason) .subscribe(); } - public denyChildSeasonRequest(request: IChildRequests) { - request.approved = false; - request.denied = true; - this.requestService.updateChild(request) - .subscribe(); - } public showChildren(request: ITvRequests) { this.selectedSeason = request; @@ -233,14 +222,6 @@ export class TvRequestsComponent implements OnInit, OnDestroy { this.tvRequests.splice(index, 1); } } - private removeChildRequestFromUi(key: IChildRequests) { - //var index = this.childRequests.indexOf(key, 0); - //if (index > -1) { - // this.childRequests.splice(index, 1); - //} - //TODO FIX THIS - } - ngOnDestroy(): void { this.subscriptions.next();