Merge pull request #1488 from dhruvb14/DotNetCore

Update Request Management UI
pull/1510/head
Jamie 7 years ago committed by GitHub
commit 03e9852330

@ -0,0 +1,5 @@
{
"sdk": {
"version": "1.1.0"
}
}

@ -15,6 +15,7 @@ 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 { TreeTableModule } from 'primeng/primeng';
import { IdentityService } from '../services/identity.service';
import { RequestService } from '../services/request.service';
@ -35,6 +36,7 @@ const routes: Routes = [
InfiniteScrollModule,
ButtonModule,
DialogModule,
TreeTableModule
],
declarations: [
RequestComponent,

@ -5,7 +5,13 @@
<div class="col-md-2">
<span>Requested By: {{child.requestedUser.userName}}</span>
<div *ngFor="let season of child.seasonRequests">
<!--<div *ngFor="let season of child.seasonRequests">
<span>Season {{season.seasonNumber}}</span>
<div>Episodes:</div>
<span *ngFor="let episode of season.episodes">
@ -13,10 +19,12 @@
</span>
<br />
<br />
</div>
</div>-->
</div>
<div class="col-md-1 col-md-push-9"> <!--// TODO ADMIN-->
<div class="col-md-1 col-md-push-9">
<!--// TODO ADMIN-->
<form>
<button style="text-align: right" *ngIf="child.CanApprove" (click)="approve(child)" class="btn btn-sm btn-success-outline" type="submit"><i class="fa fa-plus"></i> Approve</button>
</form>
@ -28,8 +36,75 @@
</form>
</div>
</div>
<div class="col-md-12">
<ngb-tabset>
<div *ngFor="let season of child.seasonRequests">
<ngb-tab [id]="season.seasonNumber" [title]="season.seasonNumber">
<ng-template ngbTabContent>
<h2>Season: {{season.seasonNumber}}</h2>
<table class="table table-striped table-hover table-responsive table-condensed">
<thead>
<tr>
<th>
<a>
#
</a>
</th>
<th>
<a>
Title
</a>
</th>
<th>
<a>
Air Date
</a>
</th>
<th>
<a>
Status
</a>
</th>
</tr>
</thead>
<tbody>
<tr *ngFor="let ep of season.episodes">
<td>
{{ep.episodeNumber}}
</td>
<td>
{{ep.title}}
</td>
<td>
{{ep.airDate | date: 'dd/MM/yyyy' }}
</td>
<td>
<span *ngIf="ep.available" class="label label-success">Available</span>
<span *ngIf="ep.approved && !ep.available" class="label label-info">Processing Request</span>
<div *ngIf="ep.requested && !ep.available; then requested else notRequested"></div>
<ng-template #requested>
<span *ngIf="!ep.available" class="label label-warning">Pending Approval</span>
</ng-template>
<ng-template #notRequested>
<span *ngIf="!ep.available" class="label label-danger">Not Yet Requested</span>
</ng-template>
</td>
</tr>
</tbody>
</table>
</ng-template>
</ngb-tab>
</div>
</ngb-tabset>
</div>
<br />
<br />
<hr />
</div>
</div>

@ -4,7 +4,7 @@ import { ActivatedRoute } from '@angular/router';
import { RequestService } from '../services/request.service';
import { IdentityService } from '../services/identity.service';
import { IChildRequests, IEpisodesRequests } from '../interfaces/IRequestModel';
import { IChildRequests, IEpisodesRequests, INewSeasonRequests } from '../interfaces/IRequestModel';
@Component({
templateUrl: './tvrequest-manage.component.html'
@ -17,7 +17,7 @@ export class TvRequestManageComponent {
.subscribe(params => {
this.tvId = +params['id']; // (+) converts string 'id' to a number
this.requestService.getChildRequests(this.tvId).subscribe(x => {
this.childRequests = x;
this.childRequests = this.fixEpisodeSort(x);
});
});
@ -27,7 +27,16 @@ export class TvRequestManageComponent {
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;
}
public removeRequest(request: IChildRequests) {
this.requestService.deleteChild(request)
.subscribe();
@ -60,12 +69,10 @@ export class TvRequestManageComponent {
}
public getColour(ep: IEpisodesRequests): string {
if (ep.available)
{
if (ep.available) {
return "lime";
}
if (ep.approved)
{
if (ep.approved) {
return "#00c0ff";
}
return "white";

@ -9,48 +9,201 @@
[infiniteScrollDistance]="1"
[infiniteScrollThrottle]="100"
(scrolled)="loadMore()">
<!--<div>-->
<p-treeTable [value]="tvRequests">
<!--<p-column>
<ng-template let-col let-node="rowData" pTemplate="body">
<img src="{{node.data.data.banner}}" class="img-responsive poster" width="150" />
</ng-template>
</p-column>-->
<div *ngFor="let request of tvRequests">
<p-column>
<ng-template let-col let-node="rowData" pTemplate="header">
Results
</ng-template>
<ng-template let-col let-node="rowData" pTemplate="body">
<!--This is the section that holds the parent level results set-->
<div *ngIf="!node.leaf">
<div class="row">
<div class="col-sm-2">
<img class="img-responsive poster" src="{{request.posterPath}}" alt="poster">
<img class="img-responsive poster" src="{{node.data.posterPath}}" alt="poster">
</div>
<div class="col-sm-5 ">
<div>
<a href="http://www.imdb.com/title/{{request.imdbId}}/" target="_blank">
<h4 class="request-title">{{request.title}} ({{request.releaseDate | date: 'yyyy'}})</h4>
<a href="http://www.imdb.com/title/{{node.data.imdbId}}/" target="_blank">
<h4 class="request-title">{{node.data.title}} ({{node.data.releaseDate | date: 'yyyy'}})</h4>
</a>
</div>
<br />
<div>
<span>Status: </span>
<span class="label label-success">{{request.status}}</span>
<span class="label label-success">{{node.data.status}}</span>
</div>
<div>
<span>Request status: </span>
<span *ngIf="request.available" class="label label-success">Available</span>
<span *ngIf="request.approved && !request.available" class="label label-info">Processing Request</span>
<span *ngIf="request.denied" class="label label-danger">Request Denied</span>
<span *ngIf="request.deniedReason" title="{{request.deniedReason}}"><i class="fa fa-info-circle"></i></span>
<span *ngIf="!request.approved && !request.availble && !request.denied" class="label label-warning">Pending Approval</span>
<span *ngIf="node.data.available" class="label label-success">Available</span>
<span *ngIf="node.data.approved && !node.data.available" class="label label-info">Processing Request</span>
<span *ngIf="node.data.denied" class="label label-danger">Request Denied</span>
<span *ngIf="node.data.deniedReason" title="{{node.data.deniedReason}}"><i class="fa fa-info-circle"></i></span>
<span *ngIf="!node.data.approved && !node.data.availble && !node.data.denied" class="label label-warning">Pending Approval</span>
</div>
<div>Release Date: {{request.releaseDate | date}}</div>
<div>Release Date: {{node.data.releaseDate | date}}</div>
<br />
<div>Requested Date: {{request.requestedDate | date}}</div>
<div>Requested Date: {{node.data.requestedDate | date}}</div>
</div>
<div class="col-sm-3 col-sm-push-3">
<button [routerLink]="[request.id]" style="text-align: right" class="btn btn-sm btn-success-outline" type="submit"><i class="fa fa-plus"></i> View</button>
<button style="text-align: right" class="btn btn-sm btn-success-outline" (click)="openClosestTab($event)"><i class="fa fa-plus"></i> View</button>
<!--<button [routerLink]="[node.data.id]" style="text-align: right" class="btn btn-sm btn-success-outline" type="submit"><i class="fa fa-plus"></i> View</button>-->
</div>
</div>
</div>
<!--This is the section that holds the child seasons if they want to specify specific episodes-->
<div *ngIf="node.leaf">
<hr />
<div *ngIf="node.data">
<div *ngFor="let child of node.data">
<div class="col-md-12">
<div class="col-md-2">
<span>Requested By: {{child.requestedUser.userName}}</span>
</div>
<div class="col-md-1 col-md-push-9">
<!--// TODO ADMIN-->
<form>
<button style="text-align: right" *ngIf="child.CanApprove" (click)="approve(child)" class="btn btn-sm btn-success-outline" type="submit"><i class="fa fa-plus"></i> Approve</button>
</form>
<form>
<button type="button" (click)="deny(child)" class="btn btn-sm btn-danger-outline deny"><i class="fa fa-times"></i> Deny</button>
</form>
<form>
<button type="button" (click)="deny(child)" class="btn btn-sm btn-danger-outline deny"><i class="fa fa-times"></i> Remove</button>
</form>
</div>
</div>
<div class="col-md-12">
<ngb-tabset>
<div *ngFor="let season of child.seasonRequests">
<ngb-tab [id]="season.seasonNumber" [title]="season.seasonNumber">
<ng-template ngbTabContent>
<h2>Season: {{season.seasonNumber}}</h2>
<table class="table table-striped table-hover table-responsive table-condensed">
<thead>
<tr>
<th>
<a>
#
</a>
</th>
<th>
<a>
Title
</a>
</th>
<th>
<a>
Air Date
</a>
</th>
<th>
<a>
Status
</a>
</th>
</tr>
</thead>
<tbody>
<tr *ngFor="let ep of season.episodes">
<td>
{{ep.episodeNumber}}
</td>
<td>
{{ep.title}}
</td>
<td>
{{ep.airDate | date: 'dd/MM/yyyy' }}
</td>
<td>
<span *ngIf="ep.available" class="label label-success">Available</span>
<span *ngIf="ep.approved && !ep.available" class="label label-info">Processing Request</span>
<div *ngIf="ep.requested && !ep.available; then requested else notRequested"></div>
<ng-template #requested>
<span *ngIf="!ep.available" class="label label-warning">Pending Approval</span>
</ng-template>
<ng-template #notRequested>
<span *ngIf="!ep.available" class="label label-danger">Not Yet Requested</span>
</ng-template>
</td>
</tr>
</tbody>
</table>
</ng-template>
</ngb-tab>
</div>
</ngb-tabset>
</div>
<br />
<br />
<hr />
</div>
</div>
</div>
</ng-template>
</p-column>
</p-treeTable>
<!--<div *ngFor="let request of tvRequests">-->
<!--<div class="row">
<div class="col-sm-2">
<img class="img-responsive poster" src="{{node.data.posterPath}}" alt="poster">
</div>
<div class="col-sm-5 ">
<div>
<a href="http://www.imdb.com/title/{{node.data.imdbId}}/" target="_blank">
<h4 class="request-title">{{node.data.title}} ({{node.data.releaseDate | date: 'yyyy'}})</h4>
</a>
</div>
<br />
<div>
<span>Status: </span>
<span class="label label-success">{{node.data.status}}</span>
</div>
<div>
<span>Request status: </span>
<span *ngIf="node.data.available" class="label label-success">Available</span>
<span *ngIf="node.data.approved && !node.data.available" class="label label-info">Processing Request</span>
<span *ngIf="node.data.denied" class="label label-danger">Request Denied</span>
<span *ngIf="node.data.deniedReason" title="{{node.data.deniedReason}}"><i class="fa fa-info-circle"></i></span>
<span *ngIf="!node.data.approved && !node.data.availble && !node.data.denied" class="label label-warning">Pending Approval</span>
</div>
<div>Release Date: {{node.data.releaseDate | date}}</div>
<br />
<div>Requested Date: {{node.data.requestedDate | date}}</div>
</div>
<div class="col-sm-3 col-sm-push-3">
<button [routerLink]="[node.data.id]" style="text-align: right" class="btn btn-sm btn-success-outline" type="submit"><i class="fa fa-plus"></i> View</button>
</div>
</div>
<hr />-->
<!--</div>-->
</div>

@ -0,0 +1,14 @@
table.ui-widget-content {
border: 1px solid #1f1f1f !important;
background: #1f1f1f !important;
}
.ui-widget-content {
color: #ffffff;
}
.ui-state-default.ui-unselectable-text{
display:none;
}
.ui-treetable-toggler.fa.fa-fw.ui-c.fa-caret-right,
.ui-treetable-toggler.fa.fa-fw.ui-c.fa-caret-down {
display: none;
}

@ -1,4 +1,4 @@
import { Component, OnInit, OnDestroy } from '@angular/core';
import { Component, OnInit, OnDestroy, ViewEncapsulation } from '@angular/core';
import { Subject } from 'rxjs/Subject';
import 'rxjs/add/operator/debounceTime';
import 'rxjs/add/operator/distinctUntilChanged';
@ -12,11 +12,17 @@ import 'rxjs/add/operator/map';
import { RequestService } from '../services/request.service';
import { IdentityService } from '../services/identity.service';
import { ITvRequests, IChildRequests } from '../interfaces/IRequestModel';
import { ITvRequests, IChildRequests, INewSeasonRequests, IEpisodesRequests } from '../interfaces/IRequestModel';
import { TreeNode, } from "primeng/primeng";
@Component({
selector: 'tv-requests',
templateUrl: './tvrequests.component.html'
templateUrl: './tvrequests.component.html',
styleUrls: ['./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 TvRequestsComponent implements OnInit, OnDestroy {
constructor(private requestService: RequestService, private identityService: IdentityService) {
@ -32,11 +38,50 @@ export class TvRequestsComponent implements OnInit, OnDestroy {
}
this.requestService.searchTvRequests(this.searchText)
.takeUntil(this.subscriptions)
.subscribe(m => this.tvRequests = m);
.subscribe(m => this.tvRequests = this.transformData(m));
});
}
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: ITvRequests[]): any {
var temp: TreeNode[] = [];
datain.forEach(function (value) {
temp.push({
"data": value,
"children": [{
"data": this.fixEpisodeSort(value.childRequests), leaf: true
}],
leaf: false
});
}, this)
console.log(temp);
return <TreeNode[]>temp;
}
private subscriptions = new Subject<void>();
tvRequests: ITvRequests[];
@ -52,15 +97,23 @@ export class TvRequestsComponent implements OnInit, OnDestroy {
public showChildDialogue = false; // This is for the child modal popup
public selectedSeason: ITvRequests;
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;
}
ngOnInit() {
this.amountToLoad = 5;
this.currentlyLoaded = 5;
this.tvRequests = [];
this.loadInit();
}
public loadMore() {
this.requestService.getTvRequests(this.amountToLoad, this.currentlyLoaded + 1)
.takeUntil(this.subscriptions)
@ -78,6 +131,11 @@ 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;
@ -85,16 +143,29 @@ export class TvRequestsComponent implements OnInit, OnDestroy {
//this.updateRequest(request);
}
//Was already here but not sure what's using it...'
//public approve(request: IChildRequests) {
// request.approved = true;
// request.denied = false;
// //this.updateRequest(request);
//}
public approve(request: IChildRequests) {
request.approved = true;
request.denied = false;
//this.updateRequest(request);
this.requestService.updateChild(request)
.subscribe();
}
//Was already here but not sure what's using it...'
//public deny(request: IChildRequests) {
// request.approved = false;
// request.denied = true;
// //this.updateRequest(request);
//}
public deny(request: IChildRequests) {
request.approved = false;
request.denied = true;
//this.updateRequest(request);
this.requestService.updateChild(request)
.subscribe();
}
public approveSeasonRequest(request: IChildRequests) {
@ -110,12 +181,28 @@ 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;
this.showChildDialogue = true;
}
public getColour(ep: IEpisodesRequests): string {
if (ep.available) {
return "lime";
}
if (ep.approved) {
return "#00c0ff";
}
return "white";
}
//private updateRequest(request: ITvRequests) {
// this.requestService.updateTvRequest(request)
// .takeUntil(this.subscriptions)
@ -126,7 +213,7 @@ export class TvRequestsComponent implements OnInit, OnDestroy {
this.requestService.getTvRequests(this.amountToLoad, 0)
.takeUntil(this.subscriptions)
.subscribe(x => {
this.tvRequests = x;
this.tvRequests = this.transformData(x);
});
this.isAdmin = this.identityService.hasRole("Admin");
}
@ -142,6 +229,14 @@ 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();

Loading…
Cancel
Save