Work on the TV request. the `latest` parameter is not being passed into the requestTvshow

pull/13/head
tidusjar 9 years ago
parent 3d6da12fb5
commit 70362b908f

@ -1,26 +1,69 @@
var searchSource = $("#search-template").html();
Handlebars.registerHelper('if_eq', function (a, b, opts) {
if (a == b)
return opts.fn(this);
else
return opts.inverse(this);
});
var searchSource = $("#search-template").html();
var searchTemplate = Handlebars.compile(searchSource);
var movieTimer = 0;
var tvimer = 0;
$("#movieSearchContent").on("keyup", function (e) {
$("#movieSearchContent").keypress(function (e) {
if (movieTimer) {
clearTimeout(movieTimer);
}
movieTimer = setTimeout(movieSearch, 400);
});
$("#tvSearchContent").on("keyup", function (e) {
$("#tvSearchContent").keypress(function (e) {
if (tvimer) {
clearTimeout(tvimer);
}
tvimer = setTimeout(tvSearch(), 400);
});
$("#test").click(function (e) {
$(document).on("click", ".dropdownTv", function (e) {
var formData = [];
e.preventDefault();
console.log(e.target.id);
var $form = $('#form'+e.target.id);
var data = $form.serialize();
var seasons = $(this).attr("season-select");
console.log(data);
formData.push(data);
if (seasons === "1") {
formData.push("latest=true");
} else {
data.latest = false;
}
$.ajax({
type: $form.prop('method'),
url: $form.prop('action'),
data: data,
dataType: "json",
success: function (response) {
console.log(response);
if (response.result === true) {
generateNotify("Success!", "success");
} else {
generateNotify(response.message, "warning");
}
},
error: function (e) {
console.log(e);
generateNotify("Something went wrong!", "danger");
}
});
});
$(document).on("click", ".requesttv", function (e) {
e.preventDefault();
console.log(e.target.id);
var $form = $('#form' + e.target.id);
$.ajax({
type: $form.prop('method'),
@ -29,10 +72,10 @@ $("#test").click(function (e) {
dataType: "json",
success: function (response) {
console.log(response);
if (response.Result === true) {
if (response.result === true) {
generateNotify("Success!", "success");
} else {
generateNotify(response.Message, "warning");
generateNotify(response.message, "warning");
}
},
error: function (e) {

@ -1,7 +1,4 @@

function generateNotify(message, type) {
function generateNotify(message, type) {
// type = danger, warning, info, successs
$.notify({
// options

@ -37,7 +37,7 @@ namespace RequestPlex.UI.Modules
Post["search/request/tv"] = parameters =>
{
var tvShowId = (int)Request.Form.tvId;
var latest = (bool)Request.Form.latestSeason;
var latest = (bool)Request.Form.latest;
return RequestTvShow(tvShowId, latest);
};
}
@ -94,6 +94,10 @@ namespace RequestPlex.UI.Modules
{
// Latest send to Sonarr and no need to store in DB
var s = new SettingsService();
if (s.CheckRequest(showId))
{
return Response.AsJson(new { Result = false, Message = "TV Show has already been requested!" });
}
s.AddRequest(showId, RequestType.TvShow);
return Response.AsJson(new {Result = true });
}

@ -25,7 +25,7 @@ namespace RequestPlex.UI
var service = new SettingsServiceV2<RequestPlexSettings>(new JsonRepository(new DbConfiguration(new SqliteFactory()), new MemoryCacheProvider()));
var settings = service.GetSettings();
if (settings != null)
if (settings.Port != 0)
{
uri = $"http://localhost:{settings.Port}";
}

@ -63,8 +63,22 @@
<small>Vote Average: {{voteAverage}}</small>
<small>Vote Count: {{voteCount}}</small>
<form method="POST" action="/search/request/{{type}}" id="form{{id}}">
<input name="{{type}}Id" type="text" value="{{id}}" hidden="hidden"/>
<button id="test" style="text-align: right" class="btn btn-primary bottom-align-text requestClass" type="submit"><i class="fa fa-plus"></i>Request</button>
<input name="{{type}}Id" type="text" value="{{id}}" hidden="hidden" />
{{#if_eq type "movie"}}
<button id="{{id}}" style="text-align: right" class="btn btn-primary bottom-align-text requestMovie" type="submit"><i class="fa fa-plus"></i>Request</button>
{{/if_eq}}
{{#if_eq type "tv"}}
<div class="dropdown">
<button class="btn btn-primary bottom-align-text dropdown-toggle" type="button" id="dropdownMenu1" data-toggle="dropdown" aria-haspopup="true" aria-expanded="true">
<i class="fa fa-plus"></i>Request
<span class="caret"></span>
</button>
<ul class="dropdown-menu" aria-labelledby="dropdownMenu1">
<li><a id="{{id}}" season-select="0" class="dropdownTv" href="#">All Seasons</a></li>
<li><a id="{{id}}" season-select="1" class="dropdownTv" href="#">Latest Season</a></li>
</ul>
</div>
{{/if_eq}}
</form>
</div>

Loading…
Cancel
Save