This commit is contained in:
tidusjar 2017-05-13 23:21:50 +01:00
commit a278917dcd
8 changed files with 157 additions and 139 deletions

View file

@ -4,6 +4,7 @@ using System.Globalization;
using System.Linq; using System.Linq;
using System.Security.Principal; using System.Security.Principal;
using System.Threading.Tasks; using System.Threading.Tasks;
using AutoMapper;
using Hangfire; using Hangfire;
using Ombi.Api.TvMaze; using Ombi.Api.TvMaze;
using Ombi.Core.Models.Requests; using Ombi.Core.Models.Requests;
@ -17,13 +18,15 @@ namespace Ombi.Core.Engine
{ {
public class TvRequestEngine : BaseMediaEngine, ITvRequestEngine public class TvRequestEngine : BaseMediaEngine, ITvRequestEngine
{ {
public TvRequestEngine(ITvMazeApi tvApi, IRequestServiceMain requestService, IPrincipal user, INotificationService notificationService) : base(user, requestService) public TvRequestEngine(ITvMazeApi tvApi, IRequestServiceMain requestService, IPrincipal user, INotificationService notificationService, IMapper map) : base(user, requestService)
{ {
TvApi = tvApi; TvApi = tvApi;
NotificationService = notificationService; NotificationService = notificationService;
Mapper = map;
} }
private INotificationService NotificationService { get; } private INotificationService NotificationService { get; }
private ITvMazeApi TvApi { get; } private ITvMazeApi TvApi { get; }
private IMapper Mapper { get; }
public async Task<RequestEngineResult> RequestTvShow(SearchTvShowViewModel tv) public async Task<RequestEngineResult> RequestTvShow(SearchTvShowViewModel tv)
{ {
@ -166,6 +169,16 @@ namespace Ombi.Core.Engine
newRequest.SeasonRequests = episodeDifference; newRequest.SeasonRequests = episodeDifference;
} }
if (!existingRequest.HasChildRequests)
{
// So this is the first child request, we will want to convert the original request to a child
var originalRequest = Mapper.Map<TvRequestModel>(existingRequest);
existingRequest.ChildRequests.Add(originalRequest);
existingRequest.RequestedUsers.Clear();
existingRequest.Approved = false;
existingRequest.Available = false;
}
existingRequest.ChildRequests.Add(newRequest); existingRequest.ChildRequests.Add(newRequest);
TvRequestService.UpdateRequest(existingRequest); TvRequestService.UpdateRequest(existingRequest);

View file

@ -1,4 +1,4 @@
<p-growl [value]="notificationService.messages" [life]="1000"></p-growl> <p-growl [value]="notificationService.messages" ></p-growl>
<nav *ngIf="showNav" class="navbar navbar-default navbar-fixed-top"> <nav *ngIf="showNav" class="navbar navbar-default navbar-fixed-top">
<div class="container-fluid"> <div class="container-fluid">

View file

@ -2,7 +2,7 @@
export interface ISearchTvResult { export interface ISearchTvResult {
id: number, id: number,
title: string, title: string, // used in the request
aliases: string[], aliases: string[],
banner: string, banner: string,
seriesId: number, seriesId: number,

View file

@ -3,9 +3,9 @@
<input type="text" class="form-control form-control-custom" placeholder="Search" (keyup)="search($event)"> <input type="text" class="form-control form-control-custom" placeholder="Search" (keyup)="search($event)">
</div> </div>
</div> </div>
<br/> <br />
<div infinite-scroll <div infinite-scroll
[infiniteScrollDistance]="1" [infiniteScrollDistance]="1"
[infiniteScrollThrottle]="100" [infiniteScrollThrottle]="100"
(scrolled)="loadMore()"> (scrolled)="loadMore()">
@ -32,7 +32,7 @@
<span>Status: </span> <span>Status: </span>
<span class="label label-success">{{request.status}}</span> <span class="label label-success">{{request.status}}</span>
</div> </div>
<div *ngIf="!request.hasChildRequests">
<div> <div>
<span>Request status: </span> <span>Request status: </span>
<span *ngIf="request.available" class="label label-success">Available</span> <span *ngIf="request.available" class="label label-success">Available</span>
@ -49,7 +49,7 @@
<div>Release Date: {{request.releaseDate | date}}</div> <div>Release Date: {{request.releaseDate | date}}</div>
<br/> <br />
<!--{{#if_eq type "tv"}} <!--{{#if_eq type "tv"}}
{{#if episodes}} {{#if episodes}}
@ -75,16 +75,19 @@
{{/if_eq}} {{/if_eq}}
</div>--> </div>-->
</div>
<!--Child Requests--> <!--Child Requests-->
<div *ngIf="request.hasChildRequests"> <div *ngIf="request.hasChildRequests">
<button type="button" class="btn btn-sm btn-info-outline" data-toggle="collapse" [attr.data-target]="'#' + request.id +'childRequests'">Children</button> <button type="button" class="btn btn-sm btn-info-outline" data-toggle="collapse" [attr.data-target]="'#' + request.id +'childRequests'">Children</button>
<div id="{{request.id}}childRequests" class="collapse"> <div id="{{request.id}}childRequests" class="collapse">
<div *ngFor="let child of request.childRequests"> <div *ngFor="let child of request.childRequests">
<hr/> <hr/>
<div *ngIf="request.requestedUsers">Requested By: <span *ngFor="let user of request.requestedUsers">{{user}} </span></div> <div *ngIf="request.requestedUsers">Requested By: <span *ngFor="let user of request.requestedUsers">{{user}} </span>
<div>Seasons Requested: <span *ngFor="let s of request.seasonNumbersRequested">{{s}} </span> </div> </div>
<div>Seasons Requested: <span *ngFor="let s of request.seasonNumbersRequested">{{s}} </span>
</div>
<div> <div>
<span>Request status: </span> <span>Request status: </span>
<span *ngIf="request.available" class="label label-success">Available</span> <span *ngIf="request.available" class="label label-success">Available</span>
@ -146,8 +149,8 @@
<div *ngIf="!request.denied"> <div *ngIf="!request.denied">
<form> <form>
<input name="requestId" type="text" value="{{request.requestId}}" hidden="hidden"/> <input name="requestId" type="text" value="{{request.requestId}}" hidden="hidden" />
<input name="reason" type="text" hidden="hidden"/> <input name="reason" type="text" hidden="hidden" />
<div class="btn-group btn-split"> <div class="btn-group btn-split">
<button type="button" (click)="deny(request)" class="btn btn-sm btn-danger-outline deny"><i class="fa fa-times"></i> Deny</button> <button type="button" (click)="deny(request)" class="btn btn-sm btn-danger-outline deny"><i class="fa fa-times"></i> Deny</button>
<button type="button" class="btn btn-danger-outline dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false"> <button type="button" class="btn btn-danger-outline dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
@ -173,7 +176,7 @@
</div> </div>
<input name="requestId" type="text" value="{{request.requestId}}" hidden="hidden" /> <input name="requestId" type="text" value="{{request.requestId}}" hidden="hidden" />
@ -199,4 +202,4 @@
</div> </div>
</div> </div>

View file

@ -53,7 +53,7 @@ export class SeriesInformationComponent implements OnInit, OnDestroy {
this.result = x as IRequestEngineResult; this.result = x as IRequestEngineResult;
if (this.result.requestAdded) { if (this.result.requestAdded) {
this.notificationService.success("Request Added", this.notificationService.success("Request Added",
`Request for ${this.series.seriesName} has been added successfully`); `Request for ${this.series.title} has been added successfully`);
} else { } else {
this.notificationService.warning("Request Added", this.result.message); this.notificationService.warning("Request Added", this.result.message);
} }

View file

@ -44,7 +44,7 @@
<div> <div>
<a href="http://www.imdb.com/title/{{result.imdbId}}/" target="_blank"> <a href="http://www.imdb.com/title/{{result.imdbId}}/" target="_blank">
<h4>{{result.seriesName}} ({{result.firstAired}})</h4> <h4>{{result.title}} ({{result.firstAired}})</h4>
</a> </a>

View file

@ -13,10 +13,12 @@ import { NotificationService } from '../services/notification.service';
import { ISearchTvResult } from '../interfaces/ISearchTvResult'; import { ISearchTvResult } from '../interfaces/ISearchTvResult';
import { IRequestEngineResult } from '../interfaces/IRequestEngineResult'; import { IRequestEngineResult } from '../interfaces/IRequestEngineResult';
import template from './tvsearch.component.html';
@Component({ @Component({
selector: 'tv-search', selector: 'tv-search',
moduleId: module.id, moduleId: module.id,
templateUrl: './tvsearch.component.html', template: template,
}) })
export class TvSearchComponent implements OnInit, OnDestroy { export class TvSearchComponent implements OnInit, OnDestroy {