From 56cf1b56cc1eb1ec77b3dac160521f2bc8ef8ad7 Mon Sep 17 00:00:00 2001 From: Dhruv Bhavsar Date: Sat, 26 Aug 2017 14:11:04 -0400 Subject: [PATCH] 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();