mirror of
https://github.com/Ombi-app/Ombi.git
synced 2025-07-10 23:42:36 -07:00
Stoped users from spamming the request button
This commit is contained in:
parent
6940311b29
commit
96131b255a
2 changed files with 58 additions and 14 deletions
|
@ -31,10 +31,15 @@ $("#tvSearchContent").on("input", function () {
|
||||||
|
|
||||||
// Click TV dropdown option
|
// Click TV dropdown option
|
||||||
$(document).on("click", ".dropdownTv", function (e) {
|
$(document).on("click", ".dropdownTv", function (e) {
|
||||||
var buttonId = e.target.id;
|
|
||||||
$("#" + buttonId).prop("disabled", true);
|
|
||||||
|
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
|
var buttonId = e.target.id;
|
||||||
|
if ($("#" + buttonId).attr('disabled')) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$("#" + buttonId).prop("disabled", true);
|
||||||
|
loadingButton(buttonId, "primary");
|
||||||
|
|
||||||
|
|
||||||
var $form = $('#form' + buttonId);
|
var $form = $('#form' + buttonId);
|
||||||
var data = $form.serialize();
|
var data = $form.serialize();
|
||||||
|
@ -53,15 +58,19 @@ $(document).on("click", ".dropdownTv", function (e) {
|
||||||
var url = $form.prop('action');
|
var url = $form.prop('action');
|
||||||
|
|
||||||
sendRequestAjax(data, type, url, buttonId);
|
sendRequestAjax(data, type, url, buttonId);
|
||||||
$("#" + buttonId).prop("disabled", false);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
// Click Request for movie
|
// Click Request for movie
|
||||||
$(document).on("click", ".requestMovie", function (e) {
|
$(document).on("click", ".requestMovie", function (e) {
|
||||||
|
e.preventDefault();
|
||||||
var buttonId = e.target.id;
|
var buttonId = e.target.id;
|
||||||
|
if ($("#" + buttonId).attr('disabled')) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
$("#" + buttonId).prop("disabled", true);
|
$("#" + buttonId).prop("disabled", true);
|
||||||
loadingButton(buttonId, "primary");
|
loadingButton(buttonId, "primary");
|
||||||
e.preventDefault();
|
|
||||||
|
|
||||||
var $form = $('#form' + buttonId);
|
var $form = $('#form' + buttonId);
|
||||||
|
|
||||||
|
@ -70,7 +79,7 @@ $(document).on("click", ".requestMovie", function (e) {
|
||||||
var data = $form.serialize();
|
var data = $form.serialize();
|
||||||
|
|
||||||
sendRequestAjax(data, type, url, buttonId);
|
sendRequestAjax(data, type, url, buttonId);
|
||||||
$("#" + buttonId).prop("disabled", false);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
function sendRequestAjax(data, type, url, buttonId) {
|
function sendRequestAjax(data, type, url, buttonId) {
|
||||||
|
@ -90,6 +99,9 @@ function sendRequestAjax(data, type, url, buttonId) {
|
||||||
$('#' + buttonId).addClass("btn-success-outline");
|
$('#' + buttonId).addClass("btn-success-outline");
|
||||||
} else {
|
} else {
|
||||||
generateNotify(response.message, "warning");
|
generateNotify(response.message, "warning");
|
||||||
|
$('#' + buttonId).html("<i class='fa fa-plus'></i> Request");
|
||||||
|
$('#' + buttonId).attr("data-toggle", "dropdown");
|
||||||
|
$("#" + buttonId).removeAttr("disabled");
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
error: function (e) {
|
error: function (e) {
|
||||||
|
|
|
@ -224,9 +224,11 @@ namespace PlexRequests.UI.Modules
|
||||||
|
|
||||||
Log.Trace("Settings: ");
|
Log.Trace("Settings: ");
|
||||||
Log.Trace(cpSettings.DumpJson);
|
Log.Trace(cpSettings.DumpJson);
|
||||||
|
if (cpSettings.Enabled)
|
||||||
|
{
|
||||||
Log.Info("Adding movie to CP (No approval required)");
|
Log.Info("Adding movie to CP (No approval required)");
|
||||||
var result = CouchPotatoApi.AddMovie(model.ImdbId, cpSettings.ApiKey, model.Title, cpSettings.FullUri, cpSettings.ProfileId);
|
var result = CouchPotatoApi.AddMovie(model.ImdbId, cpSettings.ApiKey, model.Title,
|
||||||
|
cpSettings.FullUri, cpSettings.ProfileId);
|
||||||
Log.Debug("Adding movie to CP result {0}", result);
|
Log.Debug("Adding movie to CP result {0}", result);
|
||||||
if (result)
|
if (result)
|
||||||
{
|
{
|
||||||
|
@ -234,12 +236,42 @@ namespace PlexRequests.UI.Modules
|
||||||
Log.Debug("Adding movie to database requests (No approval required)");
|
Log.Debug("Adding movie to database requests (No approval required)");
|
||||||
RequestService.AddRequest(model);
|
RequestService.AddRequest(model);
|
||||||
|
|
||||||
var notificationModel = new NotificationModel { Title = model.Title, User = model.RequestedBy, DateTime = DateTime.Now, NotificationType = NotificationType.NewRequest };
|
var notificationModel = new NotificationModel
|
||||||
|
{
|
||||||
|
Title = model.Title,
|
||||||
|
User = model.RequestedBy,
|
||||||
|
DateTime = DateTime.Now,
|
||||||
|
NotificationType = NotificationType.NewRequest
|
||||||
|
};
|
||||||
|
NotificationService.Publish(notificationModel);
|
||||||
|
|
||||||
|
return Response.AsJson(new JsonResponseModel {Result = true});
|
||||||
|
}
|
||||||
|
return
|
||||||
|
Response.AsJson(new JsonResponseModel
|
||||||
|
{
|
||||||
|
Result = false,
|
||||||
|
Message =
|
||||||
|
"Something went wrong adding the movie to CouchPotato! Please check your settings."
|
||||||
|
});
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
model.Approved = true;
|
||||||
|
Log.Debug("Adding movie to database requests (No approval required)");
|
||||||
|
RequestService.AddRequest(model);
|
||||||
|
|
||||||
|
var notificationModel = new NotificationModel
|
||||||
|
{
|
||||||
|
Title = model.Title,
|
||||||
|
User = model.RequestedBy,
|
||||||
|
DateTime = DateTime.Now,
|
||||||
|
NotificationType = NotificationType.NewRequest
|
||||||
|
};
|
||||||
NotificationService.Publish(notificationModel);
|
NotificationService.Publish(notificationModel);
|
||||||
|
|
||||||
return Response.AsJson(new JsonResponseModel { Result = true });
|
return Response.AsJson(new JsonResponseModel { Result = true });
|
||||||
}
|
}
|
||||||
return Response.AsJson(new JsonResponseModel { Result = false, Message = "Something went wrong adding the movie to CouchPotato! Please check your settings." });
|
|
||||||
}
|
}
|
||||||
|
|
||||||
try
|
try
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue