mirror of
https://github.com/Ombi-app/Ombi.git
synced 2025-07-12 08:16:05 -07:00
Request Grid test
This commit is contained in:
parent
e0018f63fa
commit
d5ec429893
24 changed files with 583 additions and 71 deletions
131
src/Ombi.Core.Tests/Engine/MovieRequestEngineTests.cs
Normal file
131
src/Ombi.Core.Tests/Engine/MovieRequestEngineTests.cs
Normal file
|
@ -0,0 +1,131 @@
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using Moq;
|
||||||
|
using Ombi.Core.Engine;
|
||||||
|
using Ombi.Core.Models.Requests;
|
||||||
|
using Ombi.Core.Models.Requests.Movie;
|
||||||
|
using Ombi.Core.Requests.Models;
|
||||||
|
using Xunit;
|
||||||
|
|
||||||
|
namespace Ombi.Core.Tests.Engine
|
||||||
|
{
|
||||||
|
public class MovieRequestEngineTests
|
||||||
|
{
|
||||||
|
public MovieRequestEngineTests()
|
||||||
|
{
|
||||||
|
RequestService = new Mock<IRequestService<MovieRequestModel>>();
|
||||||
|
var requestService = new RequestService(null, RequestService.Object);
|
||||||
|
Engine = new MovieRequestEngine(null, requestService, null, null, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
private MovieRequestEngine Engine { get; }
|
||||||
|
private Mock<IRequestService<MovieRequestModel>> RequestService { get; }
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public async Task GetNewRequests_Should_ReturnEmpty_WhenThereAreNoNewRequests()
|
||||||
|
{
|
||||||
|
var requests = new List<MovieRequestModel>
|
||||||
|
{
|
||||||
|
new MovieRequestModel { Available = true },
|
||||||
|
new MovieRequestModel { Approved = true },
|
||||||
|
};
|
||||||
|
RequestService.Setup(x => x.GetAllAsync()).ReturnsAsync(requests);
|
||||||
|
|
||||||
|
var result = await Engine.GetNewRequests();
|
||||||
|
|
||||||
|
Assert.False(result.Any());
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public async Task GetNewRequests_Should_ReturnOnlyNewRequests_WhenThereAreMultipleRequests()
|
||||||
|
{
|
||||||
|
var requests = new List<MovieRequestModel>
|
||||||
|
{
|
||||||
|
new MovieRequestModel { Available = true },
|
||||||
|
new MovieRequestModel { Approved = true },
|
||||||
|
new MovieRequestModel(),
|
||||||
|
};
|
||||||
|
RequestService.Setup(x => x.GetAllAsync()).ReturnsAsync(requests);
|
||||||
|
|
||||||
|
var result = await Engine.GetNewRequests();
|
||||||
|
|
||||||
|
Assert.Equal(result.Count(), 1);
|
||||||
|
Assert.All(result, x =>
|
||||||
|
{
|
||||||
|
Assert.Equal(x.Available, false);
|
||||||
|
Assert.Equal(x.Approved, false);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public async Task GetApprovedRequests_Should_ReturnEmpty_WhenThereAreNoApprovedRequests()
|
||||||
|
{
|
||||||
|
var requests = new List<MovieRequestModel>
|
||||||
|
{
|
||||||
|
new MovieRequestModel { Available = true },
|
||||||
|
};
|
||||||
|
RequestService.Setup(x => x.GetAllAsync()).ReturnsAsync(requests);
|
||||||
|
|
||||||
|
var result = await Engine.GetApprovedRequests();
|
||||||
|
|
||||||
|
Assert.False(result.Any());
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public async Task GetApprovedRequests_Should_ReturnOnlyApprovedRequests_WhenThereAreMultipleRequests()
|
||||||
|
{
|
||||||
|
var requests = new List<MovieRequestModel>
|
||||||
|
{
|
||||||
|
new MovieRequestModel { Available = true },
|
||||||
|
new MovieRequestModel { Approved = true },
|
||||||
|
new MovieRequestModel(),
|
||||||
|
};
|
||||||
|
RequestService.Setup(x => x.GetAllAsync()).ReturnsAsync(requests);
|
||||||
|
|
||||||
|
var result = await Engine.GetApprovedRequests();
|
||||||
|
|
||||||
|
Assert.Equal(result.Count(), 1);
|
||||||
|
Assert.All(result, x =>
|
||||||
|
{
|
||||||
|
Assert.Equal(x.Available, false);
|
||||||
|
Assert.Equal(x.Approved, true);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public async Task GetAvailableRequests_Should_ReturnEmpty_WhenThereAreNoAvailableRequests()
|
||||||
|
{
|
||||||
|
var requests = new List<MovieRequestModel>
|
||||||
|
{
|
||||||
|
new MovieRequestModel { Approved = true },
|
||||||
|
};
|
||||||
|
RequestService.Setup(x => x.GetAllAsync()).ReturnsAsync(requests);
|
||||||
|
|
||||||
|
var result = await Engine.GetAvailableRequests();
|
||||||
|
|
||||||
|
Assert.False(result.Any());
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public async Task GetAvailableRequests_Should_ReturnOnlyAvailableRequests_WhenThereAreMultipleRequests()
|
||||||
|
{
|
||||||
|
var requests = new List<MovieRequestModel>
|
||||||
|
{
|
||||||
|
new MovieRequestModel { Available = true },
|
||||||
|
new MovieRequestModel { Approved = true },
|
||||||
|
new MovieRequestModel(),
|
||||||
|
};
|
||||||
|
RequestService.Setup(x => x.GetAllAsync()).ReturnsAsync(requests);
|
||||||
|
|
||||||
|
var result = await Engine.GetAvailableRequests();
|
||||||
|
|
||||||
|
Assert.Equal(result.Count(), 1);
|
||||||
|
Assert.All(result, x =>
|
||||||
|
{
|
||||||
|
Assert.Equal(x.Available, true);
|
||||||
|
Assert.Equal(x.Approved, false);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
130
src/Ombi.Core.Tests/Engine/TvRequestEngineTests.cs
Normal file
130
src/Ombi.Core.Tests/Engine/TvRequestEngineTests.cs
Normal file
|
@ -0,0 +1,130 @@
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using Moq;
|
||||||
|
using Ombi.Core.Engine;
|
||||||
|
using Ombi.Core.Models.Requests;
|
||||||
|
using Ombi.Core.Requests.Models;
|
||||||
|
using Xunit;
|
||||||
|
|
||||||
|
namespace Ombi.Core.Tests.Engine
|
||||||
|
{
|
||||||
|
public class TvRequestEngineTests
|
||||||
|
{
|
||||||
|
public TvRequestEngineTests()
|
||||||
|
{
|
||||||
|
RequestService = new Mock<IRequestService<TvRequestModel>>();
|
||||||
|
var requestService = new RequestService(RequestService.Object, null);
|
||||||
|
Engine = new TvRequestEngine(null, requestService, null, null, null, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
private TvRequestEngine Engine { get; }
|
||||||
|
private Mock<IRequestService<TvRequestModel>> RequestService { get; }
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public async Task GetNewRequests_Should_ReturnEmpty_WhenThereAreNoNewRequests()
|
||||||
|
{
|
||||||
|
var requests = new List<TvRequestModel>
|
||||||
|
{
|
||||||
|
new TvRequestModel { Available = true },
|
||||||
|
new TvRequestModel { Approved = true },
|
||||||
|
};
|
||||||
|
RequestService.Setup(x => x.GetAllAsync()).ReturnsAsync(requests);
|
||||||
|
|
||||||
|
var result = await Engine.GetNewRequests();
|
||||||
|
|
||||||
|
Assert.False(result.Any());
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public async Task GetNewRequests_Should_ReturnOnlyNewRequests_WhenThereAreMultipleRequests()
|
||||||
|
{
|
||||||
|
var requests = new List<TvRequestModel>
|
||||||
|
{
|
||||||
|
new TvRequestModel { Available = true },
|
||||||
|
new TvRequestModel { Approved = true },
|
||||||
|
new TvRequestModel(),
|
||||||
|
};
|
||||||
|
RequestService.Setup(x => x.GetAllAsync()).ReturnsAsync(requests);
|
||||||
|
|
||||||
|
var result = await Engine.GetNewRequests();
|
||||||
|
|
||||||
|
Assert.Equal(result.Count(), 1);
|
||||||
|
Assert.All(result, x =>
|
||||||
|
{
|
||||||
|
Assert.Equal(x.Available, false);
|
||||||
|
Assert.Equal(x.Approved, false);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public async Task GetApprovedRequests_Should_ReturnEmpty_WhenThereAreNoApprovedRequests()
|
||||||
|
{
|
||||||
|
var requests = new List<TvRequestModel>
|
||||||
|
{
|
||||||
|
new TvRequestModel { Available = true },
|
||||||
|
};
|
||||||
|
RequestService.Setup(x => x.GetAllAsync()).ReturnsAsync(requests);
|
||||||
|
|
||||||
|
var result = await Engine.GetApprovedRequests();
|
||||||
|
|
||||||
|
Assert.False(result.Any());
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public async Task GetApprovedRequests_Should_ReturnOnlyApprovedRequests_WhenThereAreMultipleRequests()
|
||||||
|
{
|
||||||
|
var requests = new List<TvRequestModel>
|
||||||
|
{
|
||||||
|
new TvRequestModel { Available = true },
|
||||||
|
new TvRequestModel { Approved = true },
|
||||||
|
new TvRequestModel(),
|
||||||
|
};
|
||||||
|
RequestService.Setup(x => x.GetAllAsync()).ReturnsAsync(requests);
|
||||||
|
|
||||||
|
var result = await Engine.GetApprovedRequests();
|
||||||
|
|
||||||
|
Assert.Equal(result.Count(), 1);
|
||||||
|
Assert.All(result, x =>
|
||||||
|
{
|
||||||
|
Assert.Equal(x.Available, false);
|
||||||
|
Assert.Equal(x.Approved, true);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public async Task GetAvailableRequests_Should_ReturnEmpty_WhenThereAreNoAvailableRequests()
|
||||||
|
{
|
||||||
|
var requests = new List<TvRequestModel>
|
||||||
|
{
|
||||||
|
new TvRequestModel { Approved = true },
|
||||||
|
};
|
||||||
|
RequestService.Setup(x => x.GetAllAsync()).ReturnsAsync(requests);
|
||||||
|
|
||||||
|
var result = await Engine.GetAvailableRequests();
|
||||||
|
|
||||||
|
Assert.False(result.Any());
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public async Task GetAvailableRequests_Should_ReturnOnlyAvailableRequests_WhenThereAreMultipleRequests()
|
||||||
|
{
|
||||||
|
var requests = new List<TvRequestModel>
|
||||||
|
{
|
||||||
|
new TvRequestModel { Available = true },
|
||||||
|
new TvRequestModel { Approved = true },
|
||||||
|
new TvRequestModel(),
|
||||||
|
};
|
||||||
|
RequestService.Setup(x => x.GetAllAsync()).ReturnsAsync(requests);
|
||||||
|
|
||||||
|
var result = await Engine.GetAvailableRequests();
|
||||||
|
|
||||||
|
Assert.Equal(result.Count(), 1);
|
||||||
|
Assert.All(result, x =>
|
||||||
|
{
|
||||||
|
Assert.Equal(x.Available, true);
|
||||||
|
Assert.Equal(x.Approved, false);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,11 +1,11 @@
|
||||||
using Ombi.Core.Rule.Rules;
|
|
||||||
using Xunit;
|
|
||||||
using System.Security.Principal;
|
using System.Security.Principal;
|
||||||
using Moq;
|
using Moq;
|
||||||
using Ombi.Core.Models.Requests;
|
|
||||||
using Ombi.Core.Claims;
|
using Ombi.Core.Claims;
|
||||||
|
using Ombi.Core.Models.Requests;
|
||||||
|
using Ombi.Core.Rule.Rules;
|
||||||
|
using Xunit;
|
||||||
|
|
||||||
namespace Ombi.Core.Tests
|
namespace Ombi.Core.Tests.Rule
|
||||||
{
|
{
|
||||||
public class AutoApproveRuleTests
|
public class AutoApproveRuleTests
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
using Ombi.Core.Rule.Rules;
|
|
||||||
using Xunit;
|
|
||||||
using System.Security.Principal;
|
using System.Security.Principal;
|
||||||
using Moq;
|
using Moq;
|
||||||
using Ombi.Core.Models.Requests;
|
|
||||||
using Ombi.Core.Claims;
|
using Ombi.Core.Claims;
|
||||||
|
using Ombi.Core.Models.Requests;
|
||||||
|
using Ombi.Core.Rule.Rules;
|
||||||
|
using Xunit;
|
||||||
|
|
||||||
namespace Ombi.Core.Tests
|
namespace Ombi.Core.Tests.Rule
|
||||||
{
|
{
|
||||||
public class CanRequestRuleTests
|
public class CanRequestRuleTests
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,26 +1,23 @@
|
||||||
using Ombi.Core.Models.Requests;
|
using System.Collections.Generic;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using Ombi.Core.Models.Requests;
|
||||||
using Ombi.Core.Models.Requests.Movie;
|
using Ombi.Core.Models.Requests.Movie;
|
||||||
using Ombi.Core.Models.Search;
|
using Ombi.Core.Models.Search;
|
||||||
using Ombi.Store.Entities;
|
using Ombi.Store.Entities;
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace Ombi.Core.Engine
|
namespace Ombi.Core.Engine.Interfaces
|
||||||
{
|
{
|
||||||
public interface IMovieRequestEngine
|
public interface IMovieRequestEngine : IRequestEngine<MovieRequestModel>
|
||||||
{
|
{
|
||||||
Task<RequestEngineResult> RequestMovie(SearchMovieViewModel model);
|
Task<RequestEngineResult> RequestMovie(SearchMovieViewModel model);
|
||||||
|
|
||||||
bool ShouldAutoApprove(RequestType requestType);
|
bool ShouldAutoApprove(RequestType requestType);
|
||||||
|
|
||||||
Task<IEnumerable<MovieRequestModel>> GetMovieRequests(int count, int position);
|
|
||||||
|
|
||||||
Task<IEnumerable<MovieRequestModel>> SearchMovieRequest(string search);
|
Task<IEnumerable<MovieRequestModel>> SearchMovieRequest(string search);
|
||||||
|
|
||||||
Task RemoveMovieRequest(int requestId);
|
Task RemoveMovieRequest(int requestId);
|
||||||
|
|
||||||
Task<MovieRequestModel> UpdateMovieRequest(MovieRequestModel request);
|
Task<MovieRequestModel> UpdateMovieRequest(MovieRequestModel request);
|
||||||
|
|
||||||
RequestCountModel RequestCount();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
17
src/Ombi.Core/Engine/Interfaces/IRequestEngine.cs
Normal file
17
src/Ombi.Core/Engine/Interfaces/IRequestEngine.cs
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using Ombi.Core.Models.Requests;
|
||||||
|
|
||||||
|
namespace Ombi.Core.Engine.Interfaces
|
||||||
|
{
|
||||||
|
public interface IRequestEngine<T>
|
||||||
|
{
|
||||||
|
|
||||||
|
Task<IEnumerable<T>> GetApprovedRequests();
|
||||||
|
Task<IEnumerable<T>> GetNewRequests();
|
||||||
|
Task<IEnumerable<T>> GetAvailableRequests();
|
||||||
|
RequestCountModel RequestCount();
|
||||||
|
Task<IEnumerable<T>> GetRequests(int count, int position);
|
||||||
|
Task<IEnumerable<T>> GetRequests();
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,13 +1,12 @@
|
||||||
using Ombi.Core.Models.Requests;
|
using System.Collections.Generic;
|
||||||
using Ombi.Core.Models.Search;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
using Ombi.Core.Models.Requests;
|
||||||
|
using Ombi.Core.Models.Search;
|
||||||
|
|
||||||
namespace Ombi.Core.Engine
|
namespace Ombi.Core.Engine.Interfaces
|
||||||
{
|
{
|
||||||
public interface ITvRequestEngine
|
public interface ITvRequestEngine : IRequestEngine<TvRequestModel>
|
||||||
{
|
{
|
||||||
Task<IEnumerable<TvRequestModel>> GetTvRequests(int count, int position);
|
|
||||||
|
|
||||||
Task RemoveTvRequest(int requestId);
|
Task RemoveTvRequest(int requestId);
|
||||||
|
|
||||||
|
@ -16,7 +15,5 @@ namespace Ombi.Core.Engine
|
||||||
Task<IEnumerable<TvRequestModel>> SearchTvRequest(string search);
|
Task<IEnumerable<TvRequestModel>> SearchTvRequest(string search);
|
||||||
|
|
||||||
Task<TvRequestModel> UpdateTvRequest(TvRequestModel request);
|
Task<TvRequestModel> UpdateTvRequest(TvRequestModel request);
|
||||||
|
|
||||||
RequestCountModel RequestCount();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -14,6 +14,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 Ombi.Core.Engine.Interfaces;
|
||||||
|
|
||||||
namespace Ombi.Core.Engine
|
namespace Ombi.Core.Engine
|
||||||
{
|
{
|
||||||
|
@ -160,12 +161,18 @@ namespace Ombi.Core.Engine
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<IEnumerable<MovieRequestModel>> GetMovieRequests(int count, int position)
|
public async Task<IEnumerable<MovieRequestModel>> GetRequests(int count, int position)
|
||||||
{
|
{
|
||||||
var allRequests = await MovieRequestService.GetAllAsync(count, position);
|
var allRequests = await MovieRequestService.GetAllAsync(count, position);
|
||||||
return allRequests;
|
return allRequests;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public async Task<IEnumerable<MovieRequestModel>> GetRequests()
|
||||||
|
{
|
||||||
|
var allRequests = await MovieRequestService.GetAllAsync();
|
||||||
|
return allRequests;
|
||||||
|
}
|
||||||
|
|
||||||
public async Task<IEnumerable<MovieRequestModel>> SearchMovieRequest(string search)
|
public async Task<IEnumerable<MovieRequestModel>> SearchMovieRequest(string search)
|
||||||
{
|
{
|
||||||
var allRequests = await MovieRequestService.GetAllAsync();
|
var allRequests = await MovieRequestService.GetAllAsync();
|
||||||
|
@ -256,5 +263,23 @@ namespace Ombi.Core.Engine
|
||||||
|
|
||||||
return new RequestEngineResult {RequestAdded = true};
|
return new RequestEngineResult {RequestAdded = true};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public async Task<IEnumerable<MovieRequestModel>> GetApprovedRequests()
|
||||||
|
{
|
||||||
|
var allRequests = await MovieRequestService.GetAllAsync();
|
||||||
|
return allRequests.Where(x => x.Approved && !x.Available);
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<IEnumerable<MovieRequestModel>> GetNewRequests()
|
||||||
|
{
|
||||||
|
var allRequests = await MovieRequestService.GetAllAsync();
|
||||||
|
return allRequests.Where(x => !x.Approved && !x.Available);
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<IEnumerable<MovieRequestModel>> GetAvailableRequests()
|
||||||
|
{
|
||||||
|
var allRequests = await MovieRequestService.GetAllAsync();
|
||||||
|
return allRequests.Where(x => !x.Approved && x.Available);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -14,6 +14,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 Ombi.Core.Engine.Interfaces;
|
||||||
|
|
||||||
namespace Ombi.Core.Engine
|
namespace Ombi.Core.Engine
|
||||||
{
|
{
|
||||||
|
@ -51,7 +52,7 @@ namespace Ombi.Core.Engine
|
||||||
Status = showInfo.status,
|
Status = showInfo.status,
|
||||||
RequestedDate = DateTime.UtcNow,
|
RequestedDate = DateTime.UtcNow,
|
||||||
Approved = false,
|
Approved = false,
|
||||||
RequestedUsers = new List<string> {Username},
|
RequestedUsers = new List<string> { Username },
|
||||||
Issues = IssueState.None,
|
Issues = IssueState.None,
|
||||||
ProviderId = tv.Id,
|
ProviderId = tv.Id,
|
||||||
RequestAll = tv.RequestAll,
|
RequestAll = tv.RequestAll,
|
||||||
|
@ -124,12 +125,18 @@ namespace Ombi.Core.Engine
|
||||||
return await AddRequest(model);
|
return await AddRequest(model);
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<IEnumerable<TvRequestModel>> GetTvRequests(int count, int position)
|
public async Task<IEnumerable<TvRequestModel>> GetRequests(int count, int position)
|
||||||
{
|
{
|
||||||
var allRequests = await TvRequestService.GetAllAsync(count, position);
|
var allRequests = await TvRequestService.GetAllAsync(count, position);
|
||||||
return allRequests;
|
return allRequests;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public async Task<IEnumerable<TvRequestModel>> GetRequests()
|
||||||
|
{
|
||||||
|
var allRequests = await TvRequestService.GetAllAsync();
|
||||||
|
return allRequests;
|
||||||
|
}
|
||||||
|
|
||||||
public async Task<IEnumerable<TvRequestModel>> SearchTvRequest(string search)
|
public async Task<IEnumerable<TvRequestModel>> SearchTvRequest(string search)
|
||||||
{
|
{
|
||||||
var allRequests = await TvRequestService.GetAllAsync();
|
var allRequests = await TvRequestService.GetAllAsync();
|
||||||
|
@ -234,7 +241,25 @@ namespace Ombi.Core.Engine
|
||||||
// await RequestLimitRepo.UpdateAsync(usersLimit);
|
// await RequestLimitRepo.UpdateAsync(usersLimit);
|
||||||
//}
|
//}
|
||||||
|
|
||||||
return new RequestEngineResult {RequestAdded = true};
|
return new RequestEngineResult { RequestAdded = true };
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<IEnumerable<TvRequestModel>> GetApprovedRequests()
|
||||||
|
{
|
||||||
|
var allRequests = await TvRequestService.GetAllAsync();
|
||||||
|
return allRequests.Where(x => x.Approved && !x.Available);
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<IEnumerable<TvRequestModel>> GetNewRequests()
|
||||||
|
{
|
||||||
|
var allRequests = await TvRequestService.GetAllAsync();
|
||||||
|
return allRequests.Where(x => !x.Approved && !x.Available);
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<IEnumerable<TvRequestModel>> GetAvailableRequests()
|
||||||
|
{
|
||||||
|
var allRequests = await TvRequestService.GetAllAsync();
|
||||||
|
return allRequests.Where(x => x.Available);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,12 +1,14 @@
|
||||||
using System;
|
using Microsoft.AspNetCore.Authorization;
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using Microsoft.AspNetCore.Authorization;
|
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using Ombi.Core.Engine;
|
using Ombi.Core.Engine;
|
||||||
|
using Ombi.Core.Engine.Interfaces;
|
||||||
using Ombi.Core.Models.Requests;
|
using Ombi.Core.Models.Requests;
|
||||||
using Ombi.Core.Models.Requests.Movie;
|
using Ombi.Core.Models.Requests.Movie;
|
||||||
using Ombi.Core.Models.Search;
|
using Ombi.Core.Models.Search;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using Ombi.Models;
|
||||||
|
|
||||||
namespace Ombi.Controllers
|
namespace Ombi.Controllers
|
||||||
{
|
{
|
||||||
|
@ -22,15 +24,20 @@ namespace Ombi.Controllers
|
||||||
private IMovieRequestEngine MovieRequestEngine { get; }
|
private IMovieRequestEngine MovieRequestEngine { get; }
|
||||||
private ITvRequestEngine TvRequestEngine { get; }
|
private ITvRequestEngine TvRequestEngine { get; }
|
||||||
|
|
||||||
|
|
||||||
[HttpGet("movie/{count:int}/{position:int}")]
|
[HttpGet("movie/{count:int}/{position:int}")]
|
||||||
public async Task<IEnumerable<MovieRequestModel>> GetRequests(int count, int position)
|
public async Task<IEnumerable<MovieRequestModel>> GetRequests(int count, int position)
|
||||||
{
|
{
|
||||||
return await MovieRequestEngine.GetMovieRequests(count, position);
|
return await MovieRequestEngine.GetRequests(count, position);
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpGet("movie")]
|
||||||
|
public async Task<IEnumerable<MovieRequestModel>> GetRequests()
|
||||||
|
{
|
||||||
|
return await MovieRequestEngine.GetRequests();
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpPost("movie")]
|
[HttpPost("movie")]
|
||||||
public async Task<RequestEngineResult> RequestMovie([FromBody]SearchMovieViewModel movie)
|
public async Task<RequestEngineResult> RequestMovie([FromBody] SearchMovieViewModel movie)
|
||||||
{
|
{
|
||||||
return await MovieRequestEngine.RequestMovie(movie);
|
return await MovieRequestEngine.RequestMovie(movie);
|
||||||
}
|
}
|
||||||
|
@ -38,7 +45,6 @@ namespace Ombi.Controllers
|
||||||
[HttpGet("movie/search/{searchTerm}")]
|
[HttpGet("movie/search/{searchTerm}")]
|
||||||
public async Task<IEnumerable<MovieRequestModel>> Search(string searchTerm)
|
public async Task<IEnumerable<MovieRequestModel>> Search(string searchTerm)
|
||||||
{
|
{
|
||||||
|
|
||||||
return await MovieRequestEngine.SearchMovieRequest(searchTerm);
|
return await MovieRequestEngine.SearchMovieRequest(searchTerm);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -49,7 +55,7 @@ namespace Ombi.Controllers
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpPut("movie")]
|
[HttpPut("movie")]
|
||||||
public async Task<MovieRequestModel> UpdateRequest([FromBody]MovieRequestModel model)
|
public async Task<MovieRequestModel> UpdateRequest([FromBody] MovieRequestModel model)
|
||||||
{
|
{
|
||||||
return await MovieRequestEngine.UpdateMovieRequest(model);
|
return await MovieRequestEngine.UpdateMovieRequest(model);
|
||||||
}
|
}
|
||||||
|
@ -57,28 +63,24 @@ namespace Ombi.Controllers
|
||||||
[HttpGet("tv/{count:int}/{position:int}")]
|
[HttpGet("tv/{count:int}/{position:int}")]
|
||||||
public async Task<IEnumerable<TvRequestModel>> GetTvRequests(int count, int position)
|
public async Task<IEnumerable<TvRequestModel>> GetTvRequests(int count, int position)
|
||||||
{
|
{
|
||||||
try
|
return await TvRequestEngine.GetRequests(count, position);
|
||||||
{
|
}
|
||||||
return await TvRequestEngine.GetTvRequests(count, position);
|
|
||||||
}
|
[HttpGet("tv")]
|
||||||
catch (Exception e)
|
public async Task<IEnumerable<TvRequestModel>> GetTvRequests()
|
||||||
{
|
{
|
||||||
Console.WriteLine(e);
|
return await TvRequestEngine.GetRequests();
|
||||||
throw;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpPost("tv")]
|
[HttpPost("tv")]
|
||||||
public async Task<RequestEngineResult> RequestTv([FromBody]SearchTvShowViewModel tv)
|
public async Task<RequestEngineResult> RequestTv([FromBody] SearchTvShowViewModel tv)
|
||||||
{
|
{
|
||||||
return await TvRequestEngine.RequestTvShow(tv);
|
return await TvRequestEngine.RequestTvShow(tv);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
[HttpGet("tv/search/{searchTerm}")]
|
[HttpGet("tv/search/{searchTerm}")]
|
||||||
public async Task<IEnumerable<TvRequestModel>> SearchTv(string searchTerm)
|
public async Task<IEnumerable<TvRequestModel>> SearchTv(string searchTerm)
|
||||||
{
|
{
|
||||||
|
|
||||||
return await TvRequestEngine.SearchTvRequest(searchTerm);
|
return await TvRequestEngine.SearchTvRequest(searchTerm);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -89,7 +91,7 @@ namespace Ombi.Controllers
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpPut("tv")]
|
[HttpPut("tv")]
|
||||||
public async Task<TvRequestModel> UpdateRequest([FromBody]TvRequestModel model)
|
public async Task<TvRequestModel> UpdateRequest([FromBody] TvRequestModel model)
|
||||||
{
|
{
|
||||||
return await TvRequestEngine.UpdateTvRequest(model);
|
return await TvRequestEngine.UpdateTvRequest(model);
|
||||||
}
|
}
|
||||||
|
@ -101,5 +103,30 @@ namespace Ombi.Controllers
|
||||||
// Doesn't matter if we use the TvEngine or MovieEngine, this method is in the base class
|
// Doesn't matter if we use the TvEngine or MovieEngine, this method is in the base class
|
||||||
return TvRequestEngine.RequestCount();
|
return TvRequestEngine.RequestCount();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[HttpGet("tv/grid")]
|
||||||
|
public async Task<RequestGridModel<TvRequestModel>> GetTvRequestsGrid()
|
||||||
|
{
|
||||||
|
return await GetGrid(TvRequestEngine);
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpGet("movie/grid")]
|
||||||
|
public async Task<RequestGridModel<MovieRequestModel>> GetMovieRequestsGrid()
|
||||||
|
{
|
||||||
|
return await GetGrid(MovieRequestEngine);
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task<RequestGridModel<T>> GetGrid<T>(IRequestEngine<T> engine) where T : BaseRequestModel
|
||||||
|
{
|
||||||
|
var allRequests = await engine.GetRequests();
|
||||||
|
var r = allRequests.ToList();
|
||||||
|
var model = new RequestGridModel<T>
|
||||||
|
{
|
||||||
|
Available = r.Where(x => x.Available && !x.Approved),
|
||||||
|
Approved = r.Where(x => x.Approved && !x.Available),
|
||||||
|
New = r.Where(x => !x.Available && !x.Approved)
|
||||||
|
};
|
||||||
|
return model;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
12
src/Ombi/Models/RequestGridModel.cs
Normal file
12
src/Ombi/Models/RequestGridModel.cs
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using Ombi.Core.Models.Requests;
|
||||||
|
|
||||||
|
namespace Ombi.Models
|
||||||
|
{
|
||||||
|
public class RequestGridModel<T> where T : BaseRequestModel
|
||||||
|
{
|
||||||
|
public IEnumerable<T> Available { get; set; }
|
||||||
|
public IEnumerable<T> New { get; set; }
|
||||||
|
public IEnumerable<T> Approved { get; set; }
|
||||||
|
}
|
||||||
|
}
|
|
@ -64,6 +64,36 @@
|
||||||
<Content Update="wwwroot\app\interfaces\ISonarr - Copy.ts">
|
<Content Update="wwwroot\app\interfaces\ISonarr - Copy.ts">
|
||||||
<CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
|
<CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
|
||||||
</Content>
|
</Content>
|
||||||
|
<Content Update="wwwroot\app\requests\request - Copy.component.js">
|
||||||
|
<CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
|
||||||
|
</Content>
|
||||||
|
<Content Update="wwwroot\app\requests\request - Copy.component.js.map">
|
||||||
|
<CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
|
||||||
|
</Content>
|
||||||
|
<Content Update="wwwroot\app\requests\request - Copy.component.ts">
|
||||||
|
<CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
|
||||||
|
</Content>
|
||||||
|
<Content Update="wwwroot\app\requests\request-grid - Copy.component.html">
|
||||||
|
<CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
|
||||||
|
</Content>
|
||||||
|
<Content Update="wwwroot\app\requests\request-card.component.js">
|
||||||
|
<DependentUpon>request-card.component.ts</DependentUpon>
|
||||||
|
</Content>
|
||||||
|
<Content Update="wwwroot\app\requests\request-grid - Copy.component.js">
|
||||||
|
<DependentUpon>request-grid - Copy.component.ts</DependentUpon>
|
||||||
|
<CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
|
||||||
|
</Content>
|
||||||
|
<Content Update="wwwroot\app\requests\request-card.component.js.map">
|
||||||
|
<DependentUpon>request-card.component.js</DependentUpon>
|
||||||
|
</Content>
|
||||||
|
<Content Update="wwwroot\app\requests\request-grid - Copy.component.js.map">
|
||||||
|
<DependentUpon>request-grid - Copy.component.js</DependentUpon>
|
||||||
|
<CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
|
||||||
|
</Content>
|
||||||
|
<Content Update="wwwroot\app\requests\request-grid - Copy.component.ts">
|
||||||
|
<DependentUpon>request-grid - Copy.component.html</DependentUpon>
|
||||||
|
<CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
|
||||||
|
</Content>
|
||||||
<Content Update="wwwroot\app\services\applications\sonarr - Copy.service.js">
|
<Content Update="wwwroot\app\services\applications\sonarr - Copy.service.js">
|
||||||
<CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
|
<CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
|
||||||
</Content>
|
</Content>
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
@import "./bootstrap.css";
|
@import "./bootstrap.css";
|
||||||
//@import "./lib/tether.css";
|
//@import "./lib/tether.css";
|
||||||
@import "../node_modules/primeng/resources/themes/omega/theme.scss";
|
@import "../node_modules/primeng/resources/themes/omega/theme.scss";
|
||||||
|
@import "../node_modules/@angular/material/prebuilt-themes/deeppurple-amber";
|
||||||
@import "./lib/primeng.css";
|
@import "./lib/primeng.css";
|
||||||
|
|
||||||
$fa-font-path: "../fonts/lib";
|
$fa-font-path: "../fonts/lib";
|
||||||
|
|
|
@ -57,7 +57,8 @@ var paths = {
|
||||||
'./bower_components/PACE/pace.js',
|
'./bower_components/PACE/pace.js',
|
||||||
'./node_modules/bootstrap/dist/js/bootstrap.js',
|
'./node_modules/bootstrap/dist/js/bootstrap.js',
|
||||||
'./node_modules/tether/dist/js/tether.js',
|
'./node_modules/tether/dist/js/tether.js',
|
||||||
'./node_modules/angular2-jwt/angular2-jwt.js'
|
'./node_modules/angular2-jwt/angular2-jwt.js',
|
||||||
|
|
||||||
],
|
],
|
||||||
dest: './lib/'
|
dest: './lib/'
|
||||||
},
|
},
|
||||||
|
@ -74,6 +75,7 @@ var paths = {
|
||||||
'./node_modules/primeng/resources/primeng.css',
|
'./node_modules/primeng/resources/primeng.css',
|
||||||
'./node_modules/tether/dist/css/tether.css',
|
'./node_modules/tether/dist/css/tether.css',
|
||||||
'./node_modules/@angular/material/prebuilt-themes/deeppurple-amber.css',
|
'./node_modules/@angular/material/prebuilt-themes/deeppurple-amber.css',
|
||||||
|
'./node_modules/dragula/dist/dragula.css'
|
||||||
],
|
],
|
||||||
dest: './css/lib/'
|
dest: './css/lib/'
|
||||||
},
|
},
|
||||||
|
@ -125,6 +127,11 @@ var paths = {
|
||||||
name: 'primeng',
|
name: 'primeng',
|
||||||
src: './node_modules/primeng/**/*.js',
|
src: './node_modules/primeng/**/*.js',
|
||||||
dest: './lib/primeng/'
|
dest: './lib/primeng/'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'ng2-dragula',
|
||||||
|
src: './node_modules/ng2-dragula/**/*.js',
|
||||||
|
dest: './lib/ng2-dragula/'
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
sass: // Simple sass->css compilation
|
sass: // Simple sass->css compilation
|
||||||
|
|
|
@ -37,6 +37,7 @@
|
||||||
"jquery": "2.2.1",
|
"jquery": "2.2.1",
|
||||||
"merge-stream": "^1.0.1",
|
"merge-stream": "^1.0.1",
|
||||||
"nanoscroller": "^0.8.7",
|
"nanoscroller": "^0.8.7",
|
||||||
|
"ng2-dragula": "^1.3.1",
|
||||||
"ngx-infinite-scroll": "^0.4.1",
|
"ngx-infinite-scroll": "^0.4.1",
|
||||||
"primeng": "^2.0.5",
|
"primeng": "^2.0.5",
|
||||||
"run-sequence": "^1.2.2",
|
"run-sequence": "^1.2.2",
|
||||||
|
|
|
@ -2,17 +2,20 @@ import { NgModule } from '@angular/core';
|
||||||
import { BrowserModule } from '@angular/platform-browser';
|
import { BrowserModule } from '@angular/platform-browser';
|
||||||
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
|
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
|
||||||
import { FormsModule } from '@angular/forms';
|
import { FormsModule } from '@angular/forms';
|
||||||
import { MdButtonModule } from '@angular/material';
|
import { MdButtonModule, MdCardModule } from '@angular/material';
|
||||||
import { NgbModule } from '@ng-bootstrap/ng-bootstrap';
|
|
||||||
|
|
||||||
import { AppComponent } from './app.component';
|
|
||||||
|
|
||||||
import { RouterModule, Routes } from '@angular/router';
|
import { RouterModule, Routes } from '@angular/router';
|
||||||
import { HttpModule } from '@angular/http';
|
import { HttpModule } from '@angular/http';
|
||||||
|
|
||||||
import { InfiniteScrollModule } from 'ngx-infinite-scroll'
|
// Third Party
|
||||||
|
import { ButtonModule, DialogModule } from 'primeng/primeng';
|
||||||
|
import { GrowlModule } from 'primeng/components/growl/growl';
|
||||||
|
import { DataTableModule, SharedModule } from 'primeng/primeng';
|
||||||
|
import { InfiniteScrollModule } from 'ngx-infinite-scroll';
|
||||||
|
import { DragulaModule, DragulaService } from 'ng2-dragula/ng2-dragula';
|
||||||
|
import { NgbModule } from '@ng-bootstrap/ng-bootstrap';
|
||||||
|
|
||||||
// Components
|
// Components
|
||||||
|
import { AppComponent } from './app.component';
|
||||||
// Search
|
// Search
|
||||||
import { SearchComponent } from './search/search.component';
|
import { SearchComponent } from './search/search.component';
|
||||||
import { MovieSearchComponent } from './search/moviesearch.component';
|
import { MovieSearchComponent } from './search/moviesearch.component';
|
||||||
|
@ -23,6 +26,8 @@ import { SeriesInformationComponent } from './search/seriesinformation.component
|
||||||
import { RequestComponent } from './requests/request.component';
|
import { RequestComponent } from './requests/request.component';
|
||||||
import { MovieRequestsComponent } from './requests/movierequests.component';
|
import { MovieRequestsComponent } from './requests/movierequests.component';
|
||||||
import { TvRequestsComponent } from './requests/tvrequests.component';
|
import { TvRequestsComponent } from './requests/tvrequests.component';
|
||||||
|
import { RequestGridComponent } from './requests/request-grid.component';
|
||||||
|
import { RequestCardComponent } from './requests/request-card.component';
|
||||||
|
|
||||||
import { LoginComponent } from './login/login.component';
|
import { LoginComponent } from './login/login.component';
|
||||||
import { LandingPageComponent } from './landingpage/landingpage.component';
|
import { LandingPageComponent } from './landingpage/landingpage.component';
|
||||||
|
@ -45,16 +50,13 @@ import { StatusService } from './services/status.service';
|
||||||
import { SettingsModule } from './settings/settings.module';
|
import { SettingsModule } from './settings/settings.module';
|
||||||
import { WizardModule } from './wizard/wizard.module';
|
import { WizardModule } from './wizard/wizard.module';
|
||||||
|
|
||||||
import { ButtonModule, DialogModule } from 'primeng/primeng';
|
|
||||||
import { GrowlModule } from 'primeng/components/growl/growl';
|
|
||||||
import { DataTableModule, SharedModule } from 'primeng/primeng';
|
|
||||||
|
|
||||||
const routes: Routes = [
|
const routes: Routes = [
|
||||||
{ path: '*', component: PageNotFoundComponent },
|
{ path: '*', component: PageNotFoundComponent },
|
||||||
{ path: '', redirectTo: '/search', pathMatch: 'full' },
|
{ path: '', redirectTo: '/search', pathMatch: 'full' },
|
||||||
{ path: 'search', component: SearchComponent, canActivate: [AuthGuard] },
|
{ path: 'search', component: SearchComponent, canActivate: [AuthGuard] },
|
||||||
{ path: 'search/show/:id', component: SeriesInformationComponent, canActivate: [AuthGuard] },
|
{ path: 'search/show/:id', component: SeriesInformationComponent, canActivate: [AuthGuard] },
|
||||||
{ path: 'requests', component: RequestComponent, canActivate: [AuthGuard] },
|
{ path: 'requests', component: RequestComponent, canActivate: [AuthGuard] },
|
||||||
|
{ path: 'requests-grid', component: RequestGridComponent },
|
||||||
{ path: 'login', component: LoginComponent },
|
{ path: 'login', component: LoginComponent },
|
||||||
{ path: 'landingpage', component: LandingPageComponent },
|
{ path: 'landingpage', component: LandingPageComponent },
|
||||||
{ path: 'usermanagement', component: UserManagementComponent, canActivate: [AuthGuard] },
|
{ path: 'usermanagement', component: UserManagementComponent, canActivate: [AuthGuard] },
|
||||||
|
@ -78,6 +80,8 @@ const routes: Routes = [
|
||||||
DialogModule,
|
DialogModule,
|
||||||
MdButtonModule,
|
MdButtonModule,
|
||||||
NgbModule.forRoot(),
|
NgbModule.forRoot(),
|
||||||
|
DragulaModule,
|
||||||
|
MdCardModule
|
||||||
],
|
],
|
||||||
declarations: [
|
declarations: [
|
||||||
AppComponent,
|
AppComponent,
|
||||||
|
@ -92,6 +96,8 @@ const routes: Routes = [
|
||||||
MovieRequestsComponent,
|
MovieRequestsComponent,
|
||||||
TvRequestsComponent,
|
TvRequestsComponent,
|
||||||
SeriesInformationComponent,
|
SeriesInformationComponent,
|
||||||
|
RequestGridComponent,
|
||||||
|
RequestCardComponent,
|
||||||
],
|
],
|
||||||
providers: [
|
providers: [
|
||||||
SearchService,
|
SearchService,
|
||||||
|
@ -101,7 +107,8 @@ const routes: Routes = [
|
||||||
AuthGuard,
|
AuthGuard,
|
||||||
SettingsService,
|
SettingsService,
|
||||||
IdentityService,
|
IdentityService,
|
||||||
StatusService
|
StatusService,
|
||||||
|
DragulaService
|
||||||
],
|
],
|
||||||
bootstrap: [AppComponent]
|
bootstrap: [AppComponent]
|
||||||
})
|
})
|
||||||
|
|
|
@ -69,3 +69,9 @@ export interface IRequestsPageScroll {
|
||||||
count: number,
|
count: number,
|
||||||
position: number
|
position: number
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface IRequestGrid<T> {
|
||||||
|
available: T[],
|
||||||
|
new: T[],
|
||||||
|
approved:T[]
|
||||||
|
}
|
|
@ -0,0 +1,3 @@
|
||||||
|
<div *ngIf="request">
|
||||||
|
{{request.title}}
|
||||||
|
</div>
|
12
src/Ombi/wwwroot/app/requests/request-card.component.ts
Normal file
12
src/Ombi/wwwroot/app/requests/request-card.component.ts
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
import { Component, Input } from '@angular/core';
|
||||||
|
|
||||||
|
import { IMediaBase } from '../interfaces/IRequestModel';
|
||||||
|
|
||||||
|
@Component({
|
||||||
|
selector: 'request-card',
|
||||||
|
moduleId: module.id,
|
||||||
|
templateUrl: './request-card.component.html'
|
||||||
|
})
|
||||||
|
export class RequestCardComponent {
|
||||||
|
@Input() request: IMediaBase;
|
||||||
|
}
|
39
src/Ombi/wwwroot/app/requests/request-grid.component.html
Normal file
39
src/Ombi/wwwroot/app/requests/request-grid.component.html
Normal file
|
@ -0,0 +1,39 @@
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<div *ngIf="tvRequests">
|
||||||
|
<div class="col-md-4">
|
||||||
|
<md-card>
|
||||||
|
<md-card-title>Title</md-card-title>
|
||||||
|
<div [dragula]='"requests"' [dragulaModel]="tvRequests.new">
|
||||||
|
<br />
|
||||||
|
<br />
|
||||||
|
<request-card *ngFor="let item of tvRequests.new" [request]="item" [attr.data.id]="item.id"></request-card>
|
||||||
|
</div>
|
||||||
|
</md-card>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="col-md-4">
|
||||||
|
<md-card>
|
||||||
|
<md-card-title>Title</md-card-title>
|
||||||
|
<div [dragula]='"requests"' [dragulaModel]="tvRequests.approved">
|
||||||
|
<br />
|
||||||
|
<br />
|
||||||
|
<request-card *ngFor="let item of tvRequests.approved" [request]="item" [attr.data.id]="item.id"></request-card>
|
||||||
|
</div>
|
||||||
|
</md-card>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="col-md-4">
|
||||||
|
<md-card>
|
||||||
|
<md-card-title>Title</md-card-title>
|
||||||
|
<div style="border: dashed">
|
||||||
|
<div [dragula]='"requests"' [dragulaModel]="tvRequests.available">
|
||||||
|
<br />
|
||||||
|
<br />
|
||||||
|
<request-card *ngFor="let item of tvRequests.available" [request]="item" [attr.data.id]="item.id"></request-card>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</md-card>
|
||||||
|
</div>
|
||||||
|
</div>
|
37
src/Ombi/wwwroot/app/requests/request-grid.component.ts
Normal file
37
src/Ombi/wwwroot/app/requests/request-grid.component.ts
Normal file
|
@ -0,0 +1,37 @@
|
||||||
|
import { Component, OnInit } from '@angular/core';
|
||||||
|
import { DragulaService } from 'ng2-dragula/ng2-dragula';
|
||||||
|
import { RequestService } from '../services/request.service';
|
||||||
|
import { ITvRequestModel, IMovieRequestModel, IRequestGrid } from '../interfaces/IRequestModel';
|
||||||
|
|
||||||
|
@Component({
|
||||||
|
moduleId: module.id,
|
||||||
|
templateUrl: './request-grid.component.html'
|
||||||
|
})
|
||||||
|
export class RequestGridComponent implements OnInit {
|
||||||
|
|
||||||
|
constructor(private dragulaService: DragulaService, private requestService: RequestService) {
|
||||||
|
this.dragulaService.setOptions('requests', {
|
||||||
|
removeOnSpill: false,
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
this.dragulaService.drop.subscribe((value: any) => {
|
||||||
|
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
ngOnInit(): void {
|
||||||
|
this.requestService.getMovieGrid().subscribe(x => {
|
||||||
|
this.movieRequests = x;
|
||||||
|
});
|
||||||
|
this.requestService.getTvGrid().subscribe(x => {
|
||||||
|
this.tvRequests = x;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
movieRequests: IRequestGrid<IMovieRequestModel>;
|
||||||
|
tvRequests: IRequestGrid<ITvRequestModel>;
|
||||||
|
|
||||||
|
}
|
|
@ -7,7 +7,7 @@ import { ServiceAuthHelpers } from './service.helpers';
|
||||||
import { IRequestEngineResult } from '../interfaces/IRequestEngineResult';
|
import { IRequestEngineResult } from '../interfaces/IRequestEngineResult';
|
||||||
import { ISearchMovieResult } from '../interfaces/ISearchMovieResult';
|
import { ISearchMovieResult } from '../interfaces/ISearchMovieResult';
|
||||||
import { ISearchTvResult } from '../interfaces/ISearchTvResult';
|
import { ISearchTvResult } from '../interfaces/ISearchTvResult';
|
||||||
import { IMovieRequestModel, ITvRequestModel, IRequestCountModel } from '../interfaces/IRequestModel';
|
import { IMovieRequestModel, ITvRequestModel, IRequestCountModel, IRequestGrid } from '../interfaces/IRequestModel';
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class RequestService extends ServiceAuthHelpers {
|
export class RequestService extends ServiceAuthHelpers {
|
||||||
|
@ -58,4 +58,12 @@ export class RequestService extends ServiceAuthHelpers {
|
||||||
getRequestsCount(): Observable<IRequestCountModel> {
|
getRequestsCount(): Observable<IRequestCountModel> {
|
||||||
return this.basicHttp.get(`${this.url}count`).map(this.extractData);
|
return this.basicHttp.get(`${this.url}count`).map(this.extractData);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
getMovieGrid(): Observable<IRequestGrid<IMovieRequestModel>> {
|
||||||
|
return this.http.get(`${this.url}movie/grid`).map(this.extractData);
|
||||||
|
}
|
||||||
|
|
||||||
|
getTvGrid(): Observable<IRequestGrid<ITvRequestModel>> {
|
||||||
|
return this.http.get(`${this.url}tv/grid`).map(this.extractData);
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -51,7 +51,7 @@
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<div>
|
<div>
|
||||||
<button type="submit" (click)="getProfiles()" class="btn btn-primary-outline">Get Quality Profiles <div *ngIf="profilesRunning" class="fa fa-spinner fa-spin" /></button>
|
<button type="submit" (click)="getProfiles()" class="btn btn-primary-outline">Get Quality Profiles <span *ngIf="profilesRunning" class="fa fa-spinner fa-spin"> </span></button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
|
@ -65,7 +65,7 @@
|
||||||
|
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<div>
|
<div>
|
||||||
<button type="submit" (click)="getRootFolders()" class="btn btn-primary-outline">Get Root Folders <div *ngIf="rootFoldersRunning" class="fa fa-spinner fa-spin" /></button>
|
<button type="submit" (click)="getRootFolders()" class="btn btn-primary-outline">Get Root Folders <span *ngIf="rootFoldersRunning" class="fa fa-spinner fa-spin" ></span></button>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
@ -89,7 +89,7 @@
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<div>
|
<div>
|
||||||
<button (click)="test()" type="submit" class="btn btn-primary-outline">Test Connectivity <div id="spinner" /></button>
|
<button (click)="test()" type="submit" class="btn btn-primary-outline">Test Connectivity <span id="spinner" ></span></button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
|
@ -51,7 +51,7 @@
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<div>
|
<div>
|
||||||
<button type="submit" (click)="getProfiles()" class="btn btn-primary-outline">Get Quality Profiles <div *ngIf="profilesRunning" class="fa fa-spinner fa-spin" /></button>
|
<button type="submit" (click)="getProfiles()" class="btn btn-primary-outline">Get Quality Profiles <span *ngIf="profilesRunning" class="fa fa-spinner fa-spin"></span></button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
|
@ -65,7 +65,7 @@
|
||||||
|
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<div>
|
<div>
|
||||||
<button type="submit" (click)="getRootFolders()" class="btn btn-primary-outline">Get Root Folders <div *ngIf="rootFoldersRunning" class="fa fa-spinner fa-spin" /></button>
|
<button type="submit" (click)="getRootFolders()" class="btn btn-primary-outline">Get Root Folders <span *ngIf="rootFoldersRunning" class="fa fa-spinner fa-spin" ></span></button>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
@ -89,7 +89,7 @@
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<div>
|
<div>
|
||||||
<button (click)="test()" type="submit" class="btn btn-primary-outline">Test Connectivity <div id="spinner" /></button>
|
<button (click)="test()" type="submit" class="btn btn-primary-outline">Test Connectivity <span id="spinner"> </span></button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue