mirror of
https://github.com/Ombi-app/Ombi.git
synced 2025-07-12 16:22:55 -07:00
Finished the api changes requested #1601
This commit is contained in:
parent
2f8e96ed87
commit
a74617b70c
10 changed files with 104 additions and 29 deletions
|
@ -10,7 +10,7 @@ namespace Ombi.Core.Engine.Interfaces
|
|||
|
||||
Task RemoveTvRequest(int requestId);
|
||||
Task<RequestEngineResult> RequestTvShow(SearchTvShowViewModel tv);
|
||||
Task<ChildRequests> DenyChildRequest(ChildRequests request);
|
||||
Task<RequestEngineResult> DenyChildRequest(int requestId);
|
||||
Task<ChildRequests> ChangeAvailability(ChildRequests request);
|
||||
Task<IEnumerable<TvRequests>> SearchTvRequest(string search);
|
||||
Task<IEnumerable<TreeNode<TvRequests, List<ChildRequests>>>> SearchTvRequestTree(string search);
|
||||
|
@ -19,6 +19,6 @@ namespace Ombi.Core.Engine.Interfaces
|
|||
Task<IEnumerable<ChildRequests>> GetAllChldren(int tvId);
|
||||
Task<ChildRequests> UpdateChildRequest(ChildRequests request);
|
||||
Task RemoveTvChild(int requestId);
|
||||
Task<RequestEngineResult> ApproveChildRequest(ChildRequests request);
|
||||
Task<RequestEngineResult> ApproveChildRequest(int id);
|
||||
}
|
||||
}
|
|
@ -191,6 +191,7 @@ namespace Ombi.Core.Engine
|
|||
};
|
||||
}
|
||||
request.Approved = true;
|
||||
request.Denied = false;
|
||||
await MovieRepository.Update(request);
|
||||
|
||||
NotificationHelper.Notify(request, NotificationType.RequestApproved);
|
||||
|
|
|
@ -178,9 +178,20 @@ namespace Ombi.Core.Engine
|
|||
return results;
|
||||
}
|
||||
|
||||
public async Task<RequestEngineResult> ApproveChildRequest(ChildRequests request)
|
||||
public async Task<RequestEngineResult> ApproveChildRequest(int id)
|
||||
{
|
||||
var request = await TvRepository.GetChild().FirstOrDefaultAsync(x => x.Id == id);
|
||||
if (request == null)
|
||||
{
|
||||
return new RequestEngineResult
|
||||
{
|
||||
ErrorMessage = "Child Request does not exist"
|
||||
};
|
||||
}
|
||||
request.Approved = true;
|
||||
request.Denied = false;
|
||||
await TvRepository.UpdateChild(request);
|
||||
|
||||
if (request.Approved)
|
||||
{
|
||||
NotificationHelper.Notify(request, NotificationType.RequestApproved);
|
||||
|
@ -194,10 +205,23 @@ namespace Ombi.Core.Engine
|
|||
};
|
||||
}
|
||||
|
||||
public async Task<ChildRequests> DenyChildRequest(ChildRequests request)
|
||||
public async Task<RequestEngineResult> DenyChildRequest(int requestId)
|
||||
{
|
||||
var request = await TvRepository.GetChild().FirstOrDefaultAsync(x => x.Id == requestId);
|
||||
if (request == null)
|
||||
{
|
||||
return new RequestEngineResult
|
||||
{
|
||||
ErrorMessage = "Child Request does not exist"
|
||||
};
|
||||
}
|
||||
request.Denied = true;
|
||||
await TvRepository.UpdateChild(request);
|
||||
NotificationHelper.Notify(request, NotificationType.RequestDeclined);
|
||||
return await UpdateChildRequest(request);
|
||||
return new RequestEngineResult
|
||||
{
|
||||
RequestAdded = true
|
||||
};
|
||||
}
|
||||
|
||||
public async Task<ChildRequests> ChangeAvailability(ChildRequests request)
|
||||
|
|
|
@ -130,6 +130,10 @@ export interface IChildRequests extends IBaseRequest {
|
|||
seasonRequests: INewSeasonRequests[];
|
||||
}
|
||||
|
||||
export interface ITvUpdateModel {
|
||||
id: number;
|
||||
}
|
||||
|
||||
export interface INewSeasonRequests {
|
||||
id: number;
|
||||
seasonNumber: number;
|
||||
|
|
|
@ -80,7 +80,6 @@ export class MovieRequestsComponent implements OnInit {
|
|||
}
|
||||
|
||||
public deny(request: IMovieRequests) {
|
||||
request.approved = false;
|
||||
request.denied = true;
|
||||
this.updateRequest(request);
|
||||
}
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
<form>
|
||||
<button style="text-align: right" *ngIf="child.canApprove && !child.approved" (click)="approve(child)" class="btn btn-sm btn-success-outline" type="submit"><i class="fa fa-plus"></i> Approve</button>
|
||||
</form>
|
||||
<form>
|
||||
<form *ngIf="!child.denied">
|
||||
<button type="button" (click)="deny(child)" class="btn btn-sm btn-danger-outline deny"><i class="fa fa-times"></i> Deny</button>
|
||||
</form>
|
||||
<form>
|
||||
|
@ -65,11 +65,13 @@
|
|||
{{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.approved">
|
||||
<span *ngIf="child.denied" class="label label-danger">Denied</span>
|
||||
<span *ngIf="!child.denied && ep.available" class="label label-success">Available</span>
|
||||
<span *ngIf="!child.denied &&ep.approved && !ep.available" class="label label-info">Processing Request</span>
|
||||
<div *ngIf="!child.denied && !ep.approved">
|
||||
<div *ngIf="!ep.available"><span class="label label-warning">Pending Approval</span></div>
|
||||
</div>
|
||||
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
|
|
|
@ -23,7 +23,6 @@ export class TvRequestChildrenComponent {
|
|||
}
|
||||
|
||||
public deny(request: IChildRequests) {
|
||||
request.approved = false;
|
||||
request.denied = true;
|
||||
|
||||
request.seasonRequests.forEach((season) => {
|
||||
|
@ -31,8 +30,16 @@ export class TvRequestChildrenComponent {
|
|||
ep.approved = false;
|
||||
});
|
||||
});
|
||||
this.requestService.deleteChild(request)
|
||||
.subscribe();
|
||||
this.requestService.denyChild({ id: request.id })
|
||||
.subscribe(x => {
|
||||
if (x.requestAdded) {
|
||||
this.notificationService.success("Request Denied",
|
||||
`Request has been denied successfully`);
|
||||
} else {
|
||||
this.notificationService.warning("Request Denied", x.message ? x.message : x.errorMessage);
|
||||
request.approved = false;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public approve(request: IChildRequests) {
|
||||
|
@ -43,7 +50,7 @@ export class TvRequestChildrenComponent {
|
|||
ep.approved = true;
|
||||
});
|
||||
});
|
||||
this.requestService.approveChild(request)
|
||||
this.requestService.approveChild({ id: request.id })
|
||||
.subscribe(x => {
|
||||
if (x.requestAdded) {
|
||||
this.notificationService.success("Request Approved",
|
||||
|
|
|
@ -6,7 +6,7 @@ import { Observable } from "rxjs/Rx";
|
|||
|
||||
import { TreeNode } from "primeng/primeng";
|
||||
import { IRequestEngineResult } from "../interfaces";
|
||||
import { IChildRequests, IMovieRequests, IMovieUpdateModel, IRequestCountModel, IRequestGrid, ITvRequests } from "../interfaces";
|
||||
import { IChildRequests, IMovieRequests, IMovieUpdateModel, IRequestCountModel, IRequestGrid, ITvRequests, ITvUpdateModel } from "../interfaces";
|
||||
import { ISearchMovieResult } from "../interfaces";
|
||||
import { ISearchTvResult } from "../interfaces";
|
||||
import { ServiceAuthHelpers } from "./service.helpers";
|
||||
|
@ -29,6 +29,10 @@ export class RequestService extends ServiceAuthHelpers {
|
|||
return this.http.post(`${this.url}Movie/Approve`, JSON.stringify(movie), { headers: this.headers }).map(this.extractData);
|
||||
}
|
||||
|
||||
public denyMovie(movie: IMovieUpdateModel): Observable<IRequestEngineResult> {
|
||||
return this.http.put(`${this.url}Movie/Deny`, JSON.stringify(movie), { headers: this.headers }).map(this.extractData);
|
||||
}
|
||||
|
||||
public getMovieRequests(count: number, position: number): Observable<IMovieRequests[]> {
|
||||
return this.http.get(`${this.url}movie/${count}/${position}`).map(this.extractData);
|
||||
}
|
||||
|
@ -78,14 +82,14 @@ export class RequestService extends ServiceAuthHelpers {
|
|||
public updateChild(child: IChildRequests): Observable<IChildRequests> {
|
||||
return this.http.put(`${this.url}tv/child`, JSON.stringify(child), { headers: this.headers }).map(this.extractData);
|
||||
}
|
||||
public denyChild(child: IChildRequests): Observable<IChildRequests> {
|
||||
public denyChild(child: ITvUpdateModel): Observable<IRequestEngineResult> {
|
||||
return this.http.put(`${this.url}tv/deny`, JSON.stringify(child), { headers: this.headers }).map(this.extractData);
|
||||
}
|
||||
public changeAvailabilityChild(child: IChildRequests): Observable<IChildRequests> {
|
||||
return this.http.put(`${this.url}tv/changeavailability`, JSON.stringify(child), { headers: this.headers }).map(this.extractData);
|
||||
}
|
||||
public approveChild(child: IChildRequests): Observable<IRequestEngineResult> {
|
||||
return this.http.post(`${this.url}tv/child/approve`, JSON.stringify(child), { headers: this.headers }).map(this.extractData);
|
||||
public approveChild(child: ITvUpdateModel): Observable<IRequestEngineResult> {
|
||||
return this.http.post(`${this.url}tv/approve`, JSON.stringify(child), { headers: this.headers }).map(this.extractData);
|
||||
}
|
||||
public deleteChild(child: IChildRequests): Observable<IChildRequests> {
|
||||
return this.http.delete(`${this.url}tv/child/${child.id}`, { headers: this.headers }).map(this.extractData);
|
||||
|
|
|
@ -8,6 +8,7 @@ using System.Collections.Generic;
|
|||
using System.Threading.Tasks;
|
||||
using Ombi.Store.Entities.Requests;
|
||||
using System.Diagnostics;
|
||||
using Ombi.Models;
|
||||
|
||||
namespace Ombi.Controllers
|
||||
{
|
||||
|
@ -81,7 +82,7 @@ namespace Ombi.Controllers
|
|||
/// <summary>
|
||||
/// Updates the specified movie request.
|
||||
/// </summary>
|
||||
/// <param name="model">The model.</param>
|
||||
/// <param name="model">The Movie's ID</param>
|
||||
/// <returns></returns>
|
||||
[HttpPut("movie")]
|
||||
public async Task<MovieRequests> UpdateRequest([FromBody] MovieRequests model)
|
||||
|
@ -92,7 +93,7 @@ namespace Ombi.Controllers
|
|||
/// <summary>
|
||||
/// Approves the specified movie request.
|
||||
/// </summary>
|
||||
/// <param name="model">The model.</param>
|
||||
/// <param name="model">The Movie's ID</param>
|
||||
/// <returns></returns>
|
||||
[HttpPost("movie/approve")]
|
||||
public async Task<RequestEngineResult> ApproveMovie([FromBody] MovieUpdateModel model)
|
||||
|
@ -103,9 +104,9 @@ namespace Ombi.Controllers
|
|||
/// <summary>
|
||||
/// Denies the specified movie request.
|
||||
/// </summary>
|
||||
/// <param name="model">The model.</param>
|
||||
/// <param name="model">The Movie's ID</param>
|
||||
/// <returns></returns>
|
||||
[HttpPost("movie/deny")]
|
||||
[HttpPut("movie/deny")]
|
||||
public async Task<RequestEngineResult> DenyMovie([FromBody] MovieUpdateModel model)
|
||||
{
|
||||
return await MovieRequestEngine.DenyMovieById(model.Id);
|
||||
|
@ -214,12 +215,12 @@ namespace Ombi.Controllers
|
|||
/// <summary>
|
||||
/// Denies the a specific child request
|
||||
/// </summary>
|
||||
/// <param name="child">The model.</param>
|
||||
/// <param name="model">This is the child request's ID</param>
|
||||
/// <returns></returns>
|
||||
[HttpPut("tv/deny")]
|
||||
public async Task<ChildRequests> DenyChild([FromBody] ChildRequests child)
|
||||
public async Task<RequestEngineResult> DenyChild([FromBody] TvUpdateModel model)
|
||||
{
|
||||
return await TvRequestEngine.DenyChildRequest(child);
|
||||
return await TvRequestEngine.DenyChildRequest(model.Id);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -236,12 +237,12 @@ namespace Ombi.Controllers
|
|||
/// <summary>
|
||||
/// Updates the a specific child request
|
||||
/// </summary>
|
||||
/// <param name="child">The model.</param>
|
||||
/// <param name="model">This is the child request's ID</param>
|
||||
/// <returns></returns>
|
||||
[HttpPost("tv/child/approve")]
|
||||
public async Task<RequestEngineResult> ApproveChild([FromBody] ChildRequests child)
|
||||
[HttpPost("tv/approve")]
|
||||
public async Task<RequestEngineResult> ApproveChild([FromBody] TvUpdateModel model)
|
||||
{
|
||||
return await TvRequestEngine.ApproveChildRequest(child);
|
||||
return await TvRequestEngine.ApproveChildRequest(model.Id);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
33
src/Ombi/Models/TvUpdateModel.cs
Normal file
33
src/Ombi/Models/TvUpdateModel.cs
Normal file
|
@ -0,0 +1,33 @@
|
|||
#region Copyright
|
||||
// /************************************************************************
|
||||
// Copyright (c) 2017 Jamie Rees
|
||||
// File: TvUpdateModel.cs
|
||||
// Created By: Jamie Rees
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining
|
||||
// a copy of this software and associated documentation files (the
|
||||
// "Software"), to deal in the Software without restriction, including
|
||||
// without limitation the rights to use, copy, modify, merge, publish,
|
||||
// distribute, sublicense, and/or sell copies of the Software, and to
|
||||
// permit persons to whom the Software is furnished to do so, subject to
|
||||
// the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be
|
||||
// included in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
// ************************************************************************/
|
||||
#endregion
|
||||
namespace Ombi.Models
|
||||
{
|
||||
public class TvUpdateModel
|
||||
{
|
||||
public int Id { get; set; }
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue