Merge branch 'develop' of https://github.com/tidusjar/ombi into develop

pull/2295/head
Jamie Rees 7 years ago
commit 8de85091fb

@ -120,8 +120,10 @@ namespace Ombi.Api.Mattermost.Models
var attIndex = outMessages[msgCount].Attachments.Count - 1;
//Get the text lines
if (!String.IsNullOrEmpty(att.Text))
{
lines = att.Text.Split(new[] { "\r\n", "\r", "\n" }, StringSplitOptions.None);
}
foreach (var line in lines)
{
//Get the total length of all attachments on the current outgoing message
@ -153,8 +155,9 @@ namespace Ombi.Api.Mattermost.Models
foreach (var msg in outMessages)
{
var request = new Request("", _webhookUrl.ToString(), HttpMethod.Post);
var request = new Request(_webhookUrl.ToString(), "", HttpMethod.Post);
request.AddJsonBody(msg);
request.AddHeader("Host", _webhookUrl.Host);
await api.Request(request);
}
}

@ -17,7 +17,6 @@ namespace Ombi.Core.Engine.Interfaces
Task<RequestEngineResult> ApproveMovie(MovieRequests request);
Task<RequestEngineResult> ApproveMovieById(int requestId);
Task<RequestEngineResult> DenyMovieById(int modelId);
Task<FilterResult<MovieRequests>> Filter(FilterViewModel vm);
}

@ -1,6 +1,7 @@
using System.Collections.Generic;
using System.Threading.Tasks;
using Ombi.Core.Models.Requests;
using Ombi.Core.Models.UI;
using Ombi.Store.Entities;
namespace Ombi.Core.Engine.Interfaces
@ -12,7 +13,7 @@ namespace Ombi.Core.Engine.Interfaces
//Task<IEnumerable<T>> GetNewRequests();
//Task<IEnumerable<T>> GetAvailableRequests();
RequestCountModel RequestCount();
Task<IEnumerable<T>> GetRequests(int count, int position);
Task<RequestsViewModel<T>> GetRequests(int count, int position, OrderFilterModel model);
Task<IEnumerable<T>> GetRequests();
Task<bool> UserHasRequest(string userId);

@ -13,6 +13,7 @@ using Microsoft.Extensions.Logging;
using Ombi.Api.TheMovieDb.Models;
using Ombi.Core.Authentication;
using Ombi.Core.Engine.Interfaces;
using Ombi.Core.Models.UI;
using Ombi.Core.Rule.Interfaces;
using Ombi.Core.Settings;
using Ombi.Settings.Settings.Models;
@ -25,7 +26,8 @@ namespace Ombi.Core.Engine
{
public MovieRequestEngine(IMovieDbApi movieApi, IRequestServiceMain requestService, IPrincipal user,
INotificationHelper helper, IRuleEvaluator r, IMovieSender sender, ILogger<MovieRequestEngine> log,
OmbiUserManager manager, IRepository<RequestLog> rl, ICacheService cache, ISettingsService<OmbiSettings> ombiSettings, IRepository<RequestSubscription> sub)
OmbiUserManager manager, IRepository<RequestLog> rl, ICacheService cache,
ISettingsService<OmbiSettings> ombiSettings, IRepository<RequestSubscription> sub)
: base(user, requestService, r, manager, cache, ombiSettings, sub)
{
MovieApi = movieApi;
@ -58,6 +60,7 @@ namespace Ombi.Core.Engine
ErrorMessage = $"Please try again later"
};
}
var fullMovieName =
$"{movieInfo.Title}{(!string.IsNullOrEmpty(movieInfo.ReleaseDate) ? $" ({DateTime.Parse(movieInfo.ReleaseDate).Year})" : string.Empty)}";
@ -82,7 +85,8 @@ namespace Ombi.Core.Engine
};
var usDates = movieInfo.ReleaseDates?.Results?.FirstOrDefault(x => x.IsoCode == "US");
requestModel.DigitalReleaseDate = usDates?.ReleaseDate?.FirstOrDefault(x => x.Type == ReleaseDateType.Digital)?.ReleaseDate;
requestModel.DigitalReleaseDate = usDates?.ReleaseDate
?.FirstOrDefault(x => x.Type == ReleaseDateType.Digital)?.ReleaseDate;
var ruleResults = (await RunRequestRules(requestModel)).ToList();
if (ruleResults.Any(x => !x.Success))
@ -125,25 +129,93 @@ namespace Ombi.Core.Engine
/// </summary>
/// <param name="count">The count.</param>
/// <param name="position">The position.</param>
/// <param name="orderFilter">The order/filter type.</param>
/// <returns></returns>
public async Task<IEnumerable<MovieRequests>> GetRequests(int count, int position)
public async Task<RequestsViewModel<MovieRequests>> GetRequests(int count, int position,
OrderFilterModel orderFilter)
{
var shouldHide = await HideFromOtherUsers();
List<MovieRequests> allRequests;
IQueryable<MovieRequests> allRequests;
if (shouldHide.Hide)
{
allRequests = await MovieRepository.GetWithUser(shouldHide.UserId).Skip(position).Take(count).OrderByDescending(x => x.ReleaseDate).ToListAsync();
allRequests =
MovieRepository.GetWithUser(shouldHide
.UserId); //.Skip(position).Take(count).OrderByDescending(x => x.ReleaseDate).ToListAsync();
}
else
{
allRequests = await MovieRepository.GetWithUser().Skip(position).Take(count).OrderByDescending(x => x.ReleaseDate).ToListAsync();
allRequests =
MovieRepository
.GetWithUser(); //.Skip(position).Take(count).OrderByDescending(x => x.ReleaseDate).ToListAsync();
}
allRequests.ForEach(async x =>
switch (orderFilter.AvailabilityFilter)
{
case FilterType.None:
break;
case FilterType.Available:
allRequests = allRequests.Where(x => x.Available);
break;
case FilterType.NotAvailable:
allRequests = allRequests.Where(x => !x.Available);
break;
default:
throw new ArgumentOutOfRangeException();
}
switch (orderFilter.StatusFilter)
{
case FilterType.None:
break;
case FilterType.Approved:
allRequests = allRequests.Where(x => x.Approved);
break;
case FilterType.Processing:
allRequests = allRequests.Where(x => x.Approved && !x.Available);
break;
case FilterType.PendingApproval:
allRequests = allRequests.Where(x => !x.Approved && !x.Available && !(x.Denied ?? false));
break;
default:
throw new ArgumentOutOfRangeException();
}
var total = allRequests.Count();
var requests = await (OrderMovies(allRequests, orderFilter.OrderType)).Skip(position).Take(count)
.ToListAsync();
requests.ForEach(async x =>
{
x.PosterPath = PosterPathHelper.FixPosterPath(x.PosterPath);
await CheckForSubscription(shouldHide, x);
});
return allRequests;
return new RequestsViewModel<MovieRequests>
{
Collection = requests,
Total = total
};
}
private IQueryable<MovieRequests> OrderMovies(IQueryable<MovieRequests> allRequests, OrderType type)
{
switch (type)
{
case OrderType.RequestedDateAsc:
return allRequests.OrderBy(x => x.RequestedDate);
case OrderType.RequestedDateDesc:
return allRequests.OrderByDescending(x => x.RequestedDate);
case OrderType.TitleAsc:
return allRequests.OrderBy(x => x.Title);
case OrderType.TitleDesc:
return allRequests.OrderByDescending(x => x.Title);
case OrderType.StatusAsc:
return allRequests.OrderBy(x => x.Status);
case OrderType.StatusDesc:
return allRequests.OrderByDescending(x => x.Status);
default:
throw new ArgumentOutOfRangeException(nameof(type), type, null);
}
}
public async Task<int> GetTotal()
@ -216,6 +288,7 @@ namespace Ombi.Core.Engine
{
allRequests = await MovieRepository.GetWithUser().ToListAsync();
}
var results = allRequests.Where(x => x.Title.Contains(search, CompareOptions.IgnoreCase)).ToList();
results.ForEach(async x =>
{
@ -241,6 +314,7 @@ namespace Ombi.Core.Engine
ErrorMessage = "Request does not exist"
};
}
request.Denied = true;
// We are denying a request
NotificationHelper.Notify(request, NotificationType.RequestDeclined);
@ -261,6 +335,7 @@ namespace Ombi.Core.Engine
ErrorMessage = "Request does not exist"
};
}
request.Approved = true;
request.Denied = false;
await MovieRepository.Update(request);
@ -281,6 +356,7 @@ namespace Ombi.Core.Engine
Result = true
};
}
if (!result.Success)
{
Logger.LogWarning("Tried auto sending movie but failed. Message: {0}", result.Message);
@ -291,6 +367,7 @@ namespace Ombi.Core.Engine
Result = false
};
}
// If there are no providers then it's successful but movie has not been sent
}
@ -352,6 +429,7 @@ namespace Ombi.Core.Engine
ErrorMessage = "Request does not exist"
};
}
request.Available = false;
await MovieRepository.Update(request);
@ -372,6 +450,7 @@ namespace Ombi.Core.Engine
ErrorMessage = "Request does not exist"
};
}
request.Available = true;
NotificationHelper.Notify(request, NotificationType.RequestAvailable);
await MovieRepository.Update(request);
@ -403,53 +482,5 @@ namespace Ombi.Core.Engine
return new RequestEngineResult {Result = true, Message = $"{movieName} has been successfully added!"};
}
public async Task<FilterResult<MovieRequests>> Filter(FilterViewModel vm)
{
var shouldHide = await HideFromOtherUsers();
var requests = shouldHide.Hide
? MovieRepository.GetWithUser(shouldHide.UserId)
: MovieRepository.GetWithUser();
switch (vm.AvailabilityFilter)
{
case FilterType.None:
break;
case FilterType.Available:
requests = requests.Where(x => x.Available);
break;
case FilterType.NotAvailable:
requests = requests.Where(x => !x.Available);
break;
default:
throw new ArgumentOutOfRangeException();
}
switch (vm.StatusFilter)
{
case FilterType.None:
break;
case FilterType.Approved:
requests = requests.Where(x => x.Approved);
break;
case FilterType.Processing:
requests = requests.Where(x => x.Approved && !x.Available);
break;
case FilterType.PendingApproval:
requests = requests.Where(x => !x.Approved && !x.Available && !(x.Denied ?? false));
break;
default:
throw new ArgumentOutOfRangeException();
}
var count = await requests.CountAsync();
requests = requests.Skip(vm.Position).Take(vm.Count);
var retVal = new FilterResult<MovieRequests>
{
Total = count,
Collection = requests
};
return retVal;
}
}
}

@ -15,6 +15,7 @@ using Microsoft.EntityFrameworkCore;
using Ombi.Core.Authentication;
using Ombi.Core.Engine.Interfaces;
using Ombi.Core.Helpers;
using Ombi.Core.Models.UI;
using Ombi.Core.Rule;
using Ombi.Core.Rule.Interfaces;
using Ombi.Core.Senders;
@ -132,7 +133,7 @@ namespace Ombi.Core.Engine
return await AddRequest(newRequest.NewRequest);
}
public async Task<IEnumerable<TvRequests>> GetRequests(int count, int position)
public async Task<RequestsViewModel<TvRequests>> GetRequests(int count, int position, OrderFilterModel type)
{
var shouldHide = await HideFromOtherUsers();
List<TvRequests> allRequests;
@ -161,7 +162,10 @@ namespace Ombi.Core.Engine
allRequests.ForEach(async r => { await CheckForSubscription(shouldHide, r); });
return allRequests;
return new RequestsViewModel<TvRequests>
{
Collection = allRequests
};
}
public async Task<IEnumerable<TreeNode<TvRequests, List<ChildRequests>>>> GetRequestsTreeNode(int count, int position)

@ -0,0 +1,11 @@
using Ombi.Core.Models.Requests;
namespace Ombi.Core.Models.UI
{
public class OrderFilterModel
{
public FilterType AvailabilityFilter { get; set; }
public FilterType StatusFilter { get; set; }
public OrderType OrderType { get; set; }
}
}

@ -0,0 +1,12 @@
namespace Ombi.Core.Models.UI
{
public enum OrderType
{
RequestedDateAsc =1,
RequestedDateDesc =2,
TitleAsc =3,
TitleDesc=4,
StatusAsc=5,
StatusDesc=6
}
}

@ -0,0 +1,10 @@
using System.Collections.Generic;
namespace Ombi.Core.Models.UI
{
public class RequestsViewModel<T>
{
public IEnumerable<T> Collection { get; set; }
public int Total { get; set; }
}
}

@ -314,9 +314,17 @@ namespace Ombi.Core.Senders
foreach (var seasonRequests in model.SeasonRequests)
{
var srEpisodes = await SickRageApi.GetEpisodesForSeason(tvdbid, seasonRequests.SeasonNumber, settings.ApiKey, settings.FullUri);
while (srEpisodes.message.Equals("Show not found", StringComparison.CurrentCultureIgnoreCase) && srEpisodes.data.Count <= 0)
int retryTimes = 10;
var currentRetry = 0;
while (srEpisodes.message.Equals("Show not found", StringComparison.CurrentCultureIgnoreCase) || srEpisodes.message.Equals("Season not found", StringComparison.CurrentCultureIgnoreCase) && srEpisodes.data.Count <= 0)
{
if (currentRetry > retryTimes)
{
Logger.LogWarning("Couldnt find the SR Season or Show, message: {0}", srEpisodes.message);
break;
}
await Task.Delay(TimeSpan.FromSeconds(1));
currentRetry++;
srEpisodes = await SickRageApi.GetEpisodesForSeason(tvdbid, seasonRequests.SeasonNumber, settings.ApiKey, settings.FullUri);
}

@ -20,7 +20,7 @@ export interface IMovieRequests extends IFullBaseRequest {
qualityOverrideTitle: string;
}
export interface IFilterResult<T> {
export interface IRequestsViewModel<T> {
total: number;
collection: T[];
}
@ -87,6 +87,15 @@ export interface ITvUpdateModel {
id: number;
}
export enum OrderType {
RequestedDateAsc = 1,
RequestedDateDesc = 2,
TitleAsc = 3,
TitleDesc = 4,
StatusAsc = 5,
StatusDesc = 6,
}
export interface INewSeasonRequests {
id: number;
seasonNumber: number;
@ -112,8 +121,6 @@ export interface IMovieRequestModel {
export interface IFilter {
availabilityFilter: FilterType;
statusFilter: FilterType;
position: number;
count: number;
}
export enum FilterType {

@ -47,6 +47,7 @@ export interface IResetPasswordToken {
export interface IMobileUsersViewModel {
username: string;
userId: string;
devices: number;
}

@ -1,4 +1,3 @@
<div class="form-group">
<div class="input-group">
<input type="text" id="search" class="form-control form-control-custom searchwidth" placeholder="Search" (keyup)="search($event)">
@ -8,43 +7,32 @@
</button>
<button class="btn btn-sm btn-primary-outline dropdown-toggle" type="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="true">
<button class="btn btn-sm btn-primary-outline dropdown-toggle" type="button" data-toggle="dropdown" aria-haspopup="true"
aria-expanded="true">
<i class="fa fa-sort"></i> {{ 'Requests.Sort' | translate }}
<span class="caret"></span>
</button>
<ul class="dropdown-menu" aria-labelledby="dropdownMenu2">
<li>
<a class="active" (click)="setOrder('requestedDate', $event)">{{ 'Requests.SortRequestDate' | translate }}
<span *ngIf="order === 'requestedDate'">
<span [hidden]="reverse"><small><i class="fa fa-arrow-down" aria-hidden="true"></i></small></span>
<span [hidden]="!reverse"><small><i class="fa fa-arrow-up" aria-hidden="true"></i></small></span>
</span>
<a (click)="setOrder(OrderType.RequestedDateAsc, $event)">{{ 'Requests.SortRequestDateAsc' | translate }}
</a>
<a (click)="setOrder('title', $event)">{{ 'Requests.SortTitle' | translate}}
<span *ngIf="order === 'title'">
<span [hidden]="reverse"><small><i class="fa fa-arrow-down" aria-hidden="true"></i></small></span>
<span [hidden]="!reverse"><small><i class="fa fa-arrow-up" aria-hidden="true"></i></small></span>
</span>
<a class="active" (click)="setOrder(OrderType.RequestedDateDesc, $event)">{{ 'Requests.SortRequestDateDesc' | translate }}
</a>
<a (click)="setOrder('releaseDate', $event)">{{ 'Requests.TheatricalReleaseSort' | translate }}
<span *ngIf="order === 'releaseDate'">
<span [hidden]="reverse"><small><i class="fa fa-arrow-down" aria-hidden="true"></i></small></span>
<span [hidden]="!reverse"><small><i class="fa fa-arrow-up" aria-hidden="true"></i></small></span>
</span>
<a (click)="setOrder(OrderType.TitleAsc, $event)">{{ 'Requests.SortTitleAsc' | translate}}
</a>
<a (click)="setOrder('requestedUser.userAlias', $event)">{{ 'Requests.SortRequestedBy' | translate }}
<span *ngIf="order === 'requestedUser.userAlias'">
<span [hidden]="reverse"><small><i class="fa fa-arrow-down" aria-hidden="true"></i></small></span>
<span [hidden]="!reverse"><small><i class="fa fa-arrow-up" aria-hidden="true"></i></small></span>
</span>
<a (click)="setOrder(OrderType.TitleDesc, $event)">{{ 'Requests.SortTitleDesc' | translate}}
</a>
<a (click)="setOrder(OrderType.StatusAsc, $event)">{{ 'Requests.SortStatusAsc' | translate}}
<a (click)="setOrder('status', $event)">{{ 'Requests.SortStatus' | translate }}
<span *ngIf="order === 'status'">
<span [hidden]="reverse"><small><i class="fa fa-arrow-down" aria-hidden="true"></i></small></span>
<span [hidden]="!reverse"><small><i class="fa fa-arrow-up" aria-hidden="true"></i></small></span>
</span>
</a>
<a (click)="setOrder(OrderType.StatusDesc, $event)">{{ 'Requests.SortStatusDesc' | translate}}
</a>
</li>
</ul>
</span>
@ -59,9 +47,7 @@
<div>
<div *ngFor="let request of movieRequests | orderBy: order : reverse : 'case-insensitive'">
<div *ngFor="let request of movieRequests">
<div class="row">
<div class="myBg backdrop" [style.background-image]="request.backgroundPath"></div>
<div class="tint" style="background-image: linear-gradient(to bottom, rgba(0,0,0,0.6) 0%,rgba(0,0,0,0.6) 100%);"></div>
@ -128,8 +114,12 @@
<div class="row">
<div class="col-md-2 col-md-push-6">
<a *ngIf="request.showSubscribe && !request.subscribed" style="color:white" (click)="subscribe(request)" pTooltip="Subscribe for notifications"> <i class="fa fa-rss"></i></a>
<a *ngIf="request.showSubscribe && request.subscribed" style="color:red" (click)="unSubscribe(request)" pTooltip="Unsubscribe notification"> <i class="fa fa-rss"></i></a>
<a *ngIf="request.showSubscribe && !request.subscribed" style="color:white" (click)="subscribe(request)" pTooltip="Subscribe for notifications">
<i class="fa fa-rss"></i>
</a>
<a *ngIf="request.showSubscribe && request.subscribed" style="color:red" (click)="unSubscribe(request)" pTooltip="Unsubscribe notification">
<i class="fa fa-rss"></i>
</a>
</div>
</div>
<div *ngIf="isAdmin">
@ -185,10 +175,12 @@
</form>
<form id="markBtnGroup">
<button id="unavailableBtn" *ngIf="request.available" (click)="changeAvailability(request, false)" style="text-align: right" value="false" class="btn btn-sm btn-info-outline change">
<button id="unavailableBtn" *ngIf="request.available" (click)="changeAvailability(request, false)" style="text-align: right"
value="false" class="btn btn-sm btn-info-outline change">
<i class="fa fa-minus"></i> {{ 'Requests.MarkUnavailable' | translate }}
</button>
<button id="availableBtn" *ngIf="!request.available" (click)="changeAvailability(request, true)" style="text-align: right" value="true" class="btn btn-sm btn-success-outline change">
<button id="availableBtn" *ngIf="!request.available" (click)="changeAvailability(request, true)" style="text-align: right"
value="true" class="btn btn-sm btn-success-outline change">
<i class="fa fa-plus"></i> {{ 'Requests.MarkAvailable' | translate }}
</button>
</form>

@ -9,7 +9,7 @@ import { Subject } from "rxjs/Subject";
import { AuthService } from "../auth/auth.service";
import { NotificationService, RadarrService, RequestService } from "../services";
import { FilterType, IFilter, IIssueCategory, IMovieRequests, IPagenator, IRadarrProfile, IRadarrRootFolder } from "../interfaces";
import { FilterType, IFilter, IIssueCategory, IMovieRequests, IPagenator, IRadarrProfile, IRadarrRootFolder, OrderType } from "../interfaces";
@Component({
selector: "movie-requests",
@ -38,8 +38,8 @@ export class MovieRequestsComponent implements OnInit {
public filter: IFilter;
public filterType = FilterType;
public order: string = "requestedDate";
public reverse = true;
public orderType: OrderType = OrderType.RequestedDateDesc;
public OrderType = OrderType;
public totalMovies: number = 100;
private currentlyLoaded: number;
@ -76,19 +76,16 @@ export class MovieRequestsComponent implements OnInit {
public ngOnInit() {
this.amountToLoad = 10;
this.currentlyLoaded = 10;
this.loadInit();
this.isAdmin = this.auth.hasRole("admin") || this.auth.hasRole("poweruser");
this.filter = {
availabilityFilter: FilterType.None,
statusFilter: FilterType.None,
count: this.amountToLoad,
position: 0,
};
this.loadInit();
this.isAdmin = this.auth.hasRole("admin") || this.auth.hasRole("poweruser");
}
public paginate(event: IPagenator) {
const skipAmount = event.first;
this.loadRequests(this.amountToLoad, skipAmount);
}
@ -99,7 +96,7 @@ export class MovieRequestsComponent implements OnInit {
public removeRequest(request: IMovieRequests) {
this.requestService.removeMovieRequest(request);
this.removeRequestFromUi(request);
this.loadRequests(1, this.currentlyLoaded);
this.loadRequests(this.amountToLoad, this.currentlyLoaded = 0);
}
public changeAvailability(request: IMovieRequests, available: boolean) {
@ -183,38 +180,27 @@ export class MovieRequestsComponent implements OnInit {
public filterAvailability(filter: FilterType, el: any) {
this.filterActiveStyle(el);
this.filter.availabilityFilter = filter;
this.requestService.filterMovies(this.filter)
.subscribe(x => {
this.totalMovies = x.total;
this.setOverrides(x.collection);
this.movieRequests = x.collection;
});
this.loadInit();
}
public filterStatus(filter: FilterType, el: any) {
this.filterActiveStyle(el);
this.filter.statusFilter = filter;
this.requestService.filterMovies(this.filter)
.subscribe(x => {
this.totalMovies = x.total;
this.setOverrides(x.collection);
this.movieRequests = x.collection;
});
this.loadInit();
}
public setOrder(value: string, el: any) {
public setOrder(value: OrderType, el: any) {
el = el.toElement || el.relatedTarget || el.target || el.srcElement;
const parent = el.parentElement;
const previousFilter = parent.querySelector(".active");
if (this.order === value) {
this.reverse = !this.reverse;
} else {
previousFilter.className = "";
el.className = "active";
}
this.order = value;
this.orderType = value;
this.loadInit();
}
public subscribe(request: IMovieRequests) {
@ -252,27 +238,17 @@ export class MovieRequestsComponent implements OnInit {
}
private loadRequests(amountToLoad: number, currentlyLoaded: number) {
if(this.filter.availabilityFilter === FilterType.None && this.filter.statusFilter === FilterType.None) {
this.requestService.getMovieRequests(amountToLoad, currentlyLoaded + 1)
this.requestService.getMovieRequests(amountToLoad, currentlyLoaded, this.orderType, this.filter)
.subscribe(x => {
this.setOverrides(x);
this.setOverrides(x.collection);
if(!this.movieRequests) {
this.movieRequests = [];
}
this.movieRequests = x;
this.currentlyLoaded = currentlyLoaded + amountToLoad;
});
} else {
this.filter.position = currentlyLoaded;
this.requestService.filterMovies(this.filter)
.subscribe(x => {
this.setOverrides(x.collection);
this.totalMovies = x.total;
this.movieRequests = x.collection;
this.totalMovies = x.total;
this.currentlyLoaded = currentlyLoaded + amountToLoad;
});
}
}
private updateRequest(request: IMovieRequests) {
this.requestService.updateMovieRequest(request)
@ -310,15 +286,16 @@ export class MovieRequestsComponent implements OnInit {
}
private loadInit() {
this.requestService.getTotalMovies().subscribe(x => this.totalMovies = x);
this.requestService.getMovieRequests(this.amountToLoad, 0)
this.requestService.getMovieRequests(this.amountToLoad, 0, this.orderType, this.filter)
.subscribe(x => {
this.movieRequests = x;
this.movieRequests = x.collection;
this.totalMovies = x.total;
this.movieRequests.forEach((req) => {
this.setBackground(req);
this.setPoster(req);
});
if (this.isAdmin) {
this.radarrService.getQualityProfilesFromSettings().subscribe(c => {
this.radarrProfiles = c;
this.movieRequests.forEach((req) => this.setQualityOverrides(req));
@ -327,6 +304,7 @@ export class MovieRequestsComponent implements OnInit {
this.radarrRootFolders = c;
this.movieRequests.forEach((req) => this.setRootFolderOverrides(req));
});
}
});
}

@ -52,7 +52,7 @@ export class SeriesInformationComponent implements OnInit {
const seasonsViewModel = <ISeasonsViewModel>{seasonNumber: season.seasonNumber, episodes: []};
season.episodes.forEach(ep => {
if(!this.series.latestSeason || !this.series.requestAll || !this.series.firstSeason) {
if(ep.requested) {
if(ep.selected) {
seasonsViewModel.episodes.push({episodeNumber: ep.episodeNumber});
}
}

@ -6,7 +6,7 @@ import { Observable } from "rxjs/Rx";
import { TreeNode } from "primeng/primeng";
import { IRequestEngineResult } from "../interfaces";
import { IChildRequests, IFilter, IFilterResult, IMovieRequestModel, IMovieRequests, IMovieUpdateModel, ITvRequests,ITvUpdateModel } from "../interfaces";
import { IChildRequests, IFilter, IMovieRequestModel, IMovieRequests, IMovieUpdateModel, IRequestsViewModel, ITvRequests,ITvUpdateModel, OrderType } from "../interfaces";
import { ITvRequestViewModel } from "../interfaces";
import { ServiceHelpers } from "./service.helpers";
@ -48,8 +48,8 @@ export class RequestService extends ServiceHelpers {
return this.http.post<IRequestEngineResult>(`${this.url}Movie/unavailable`, JSON.stringify(movie), {headers: this.headers});
}
public getMovieRequests(count: number, position: number): Observable<IMovieRequests[]> {
return this.http.get<IMovieRequests[]>(`${this.url}movie/${count}/${position}`, {headers: this.headers});
public getMovieRequests(count: number, position: number, order: OrderType, filter: IFilter): Observable<IRequestsViewModel<IMovieRequests>> {
return this.http.get<IRequestsViewModel<IMovieRequests>>(`${this.url}movie/${count}/${position}/${order}/${filter.statusFilter}/${filter.availabilityFilter}`, {headers: this.headers});
}
public searchMovieRequests(search: string): Observable<IMovieRequests[]> {
@ -114,9 +114,6 @@ export class RequestService extends ServiceHelpers {
public deleteChild(child: IChildRequests): Observable<boolean> {
return this.http.delete<boolean>(`${this.url}tv/child/${child.id}`, {headers: this.headers});
}
public filterMovies(filter: IFilter): Observable<IFilterResult<IMovieRequests>> {
return this.http.post<IFilterResult<IMovieRequests>>(`${this.url}movie/filter`, JSON.stringify(filter), {headers: this.headers});
}
public subscribeToMovie(requestId: number): Observable<boolean> {
return this.http.post<boolean>(`${this.url}movie/subscribe/${requestId}`, {headers: this.headers});

@ -39,7 +39,7 @@
<div>
<select class="form-control form-control-custom" id="select" [(ngModel)]="testUserId" [ngModelOptions]="{standalone: true}">
<option value="">Please select</option>
<option *ngFor="let x of userList" [value]="x.id">{{x.username}}</option>
<option *ngFor="let x of userList" [value]="x.userId">{{x.username}}</option>
</select>
</div>
</div>

@ -34,7 +34,7 @@ export class MobileComponent implements OnInit {
this.mobileService.getUserDeviceList().subscribe(x => {
if(x.length <= 0) {
this.userList = [];
this.userList.push({username:"None",devices:0});
this.userList.push({username:"None",devices:0, userId:""});
} else {
this.userList = x;
}

@ -68,6 +68,7 @@ namespace Ombi.Controllers
{
vm.Add(new MobileUsersViewModel
{
UserId = u.Id,
Username = u.UserAlias,
Devices = u.NotificationUserIds.Count
});

@ -8,6 +8,7 @@ using System.Collections.Generic;
using System.Threading.Tasks;
using Ombi.Store.Entities.Requests;
using System.Diagnostics;
using Ombi.Core.Models.UI;
using Ombi.Models;
using Ombi.Store.Entities;
@ -32,10 +33,18 @@ namespace Ombi.Controllers
/// </summary>
/// <param name="count">The count of items you want to return.</param>
/// <param name="position">The position.</param>
[HttpGet("movie/{count:int}/{position:int}")]
public async Task<IEnumerable<MovieRequests>> GetRequests(int count, int position)
/// <param name="orderType"> The way we want to order.</param>
/// <param name="statusType"></param>
/// <param name="availabilityType"></param>
[HttpGet("movie/{count:int}/{position:int}/{orderType:int}/{statusType:int}/{availabilityType:int}")]
public async Task<RequestsViewModel<MovieRequests>> GetRequests(int count, int position, int orderType, int statusType, int availabilityType)
{
return await MovieRequestEngine.GetRequests(count, position);
return await MovieRequestEngine.GetRequests(count, position, new OrderFilterModel
{
OrderType = (OrderType)orderType,
AvailabilityFilter = (FilterType)availabilityType,
StatusFilter = (FilterType)statusType,
});
}
/// <summary>
@ -170,11 +179,19 @@ namespace Ombi.Controllers
/// </summary>
/// <param name="count">The count of items you want to return.</param>
/// <param name="position">The position.</param>
/// <param name="orderType"></param>
/// <param name="statusType"></param>
/// <param name="availabilityType"></param>
/// <returns></returns>
[HttpGet("tv/{count:int}/{position:int}")]
public async Task<IEnumerable<TvRequests>> GetTvRequests(int count, int position)
[HttpGet("tv/{count:int}/{position:int}/{orderType:int}/{statusFilterType:int}/{availabilityFilterType:int}")]
public async Task<RequestsViewModel<TvRequests>> GetTvRequests(int count, int position, int orderType, int statusType, int availabilityType)
{
return await TvRequestEngine.GetRequests(count, position, new OrderFilterModel
{
return await TvRequestEngine.GetRequests(count, position);
OrderType = (OrderType)orderType,
AvailabilityFilter = (FilterType) availabilityType,
StatusFilter = (FilterType) statusType,
});
}
/// <summary>
@ -347,17 +364,6 @@ namespace Ombi.Controllers
return movies || tv;
}
/// <summary>
/// Returns a filtered list
/// </summary>
/// <param name="vm"></param>
/// <returns></returns>
[HttpPost("movie/filter")]
public async Task<FilterResult<MovieRequests>> Filter([FromBody] FilterViewModel vm)
{
return await MovieRequestEngine.Filter(vm);
}
/// <summary>
/// Subscribes for notifications to a movie request
/// </summary>

@ -2,6 +2,7 @@
{
public class MobileUsersViewModel
{
public string UserId { get; set; }
public string Username { get; set; }
public int Devices { get; set; }
}

@ -138,10 +138,12 @@
"Filter":"Filter",
"Sort":"Sort",
"SeasonNumberHeading":"Season: {seasonNumber}",
"SortTitle":"Title",
"SortRequestDate": "Request Date",
"SortRequestedBy":"Requested By",
"SortStatus":"Status"
"SortTitleAsc":"Title ▲",
"SortTitleDesc":"Title ▼",
"SortRequestDateAsc": "Request Date ▲",
"SortRequestDateDesc": "Request Date ▼",
"SortStatusAsc":"Status ▲",
"SortStatusDesc":"Status ▼"
},
"Issues":{
"Title":"Issues",

Loading…
Cancel
Save