mirror of
https://github.com/Ombi-app/Ombi.git
synced 2025-07-16 02:02:55 -07:00
parent
c24652a89f
commit
31615ff69c
4 changed files with 84 additions and 18 deletions
|
@ -182,6 +182,50 @@ $(document).on("click", ".clear", function (e) {
|
|||
|
||||
});
|
||||
|
||||
//change
|
||||
|
||||
// Change Availability
|
||||
$(document).on("click", ".change", function (e) {
|
||||
e.preventDefault();
|
||||
var buttonId = e.target.id;
|
||||
|
||||
var availablity = $("button[custom-availibility='" + buttonId + "']").val();
|
||||
var $form = $('#change' + buttonId);
|
||||
var data = $form.serialize();
|
||||
data = data + "&Available=" + availablity;
|
||||
|
||||
$.ajax({
|
||||
type: $form.prop('method'),
|
||||
url: $form.prop('action'),
|
||||
data: data,
|
||||
dataType: "json",
|
||||
success: function (response) {
|
||||
|
||||
if (checkJsonResponse(response)) {
|
||||
generateNotify("Success! Availibility changed.", "info");
|
||||
var button = $("button[custom-availibility='" + buttonId + "']");
|
||||
var icon = $('#availableIcon'+buttonId);
|
||||
|
||||
if (response.available) {
|
||||
button.text("Mark Unavailable");
|
||||
button.val("false");
|
||||
button.prop("class", "btn btn-sm btn-info-outline change");
|
||||
icon.prop("class", "fa fa-check");
|
||||
} else {
|
||||
button.text("Mark Available");
|
||||
button.prop("class", "btn btn-sm btn-success-outline change");
|
||||
icon.prop("class", "fa fa-times");
|
||||
button.val("true");
|
||||
}
|
||||
}
|
||||
},
|
||||
error: function (e) {
|
||||
console.log(e);
|
||||
generateNotify("Something went wrong!", "danger");
|
||||
}
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
function movieLoad() {
|
||||
$("#movieList").html("");
|
||||
|
|
|
@ -45,11 +45,10 @@ namespace PlexRequests.UI.Modules
|
|||
public class RequestsModule : BaseModule
|
||||
{
|
||||
|
||||
public RequestsModule(IRepository<RequestedModel> service, ISettingsService<PlexRequestSettings> prSettings, ISettingsService<AuthenticationSettings> auth, ISettingsService<PlexSettings> plex) : base("requests")
|
||||
public RequestsModule(IRepository<RequestedModel> service, ISettingsService<PlexRequestSettings> prSettings, ISettingsService<PlexSettings> plex) : base("requests")
|
||||
{
|
||||
Service = service;
|
||||
PrSettings = prSettings;
|
||||
AuthSettings = auth;
|
||||
PlexSettings = plex;
|
||||
|
||||
Get["/"] = _ => LoadRequests();
|
||||
|
@ -61,10 +60,10 @@ namespace PlexRequests.UI.Modules
|
|||
|
||||
Post["/clearissues"] = _ => ClearIssue((int)Request.Form.Id);
|
||||
|
||||
Post["/changeavailability"] = _ => ChangeRequestAvailability((int)Request.Form.Id, (bool)Request.Form.Available);
|
||||
}
|
||||
private IRepository<RequestedModel> Service { get; }
|
||||
private ISettingsService<PlexRequestSettings> PrSettings { get; }
|
||||
private ISettingsService<AuthenticationSettings> AuthSettings { get; }
|
||||
private ISettingsService<PlexSettings> PlexSettings { get; }
|
||||
|
||||
private Negotiator LoadRequests()
|
||||
|
@ -131,14 +130,15 @@ namespace PlexRequests.UI.Modules
|
|||
|
||||
private Response DeleteRequest(int requestid)
|
||||
{
|
||||
if (Context.CurrentUser.IsAuthenticated())
|
||||
if (!Context.CurrentUser.IsAuthenticated())
|
||||
{
|
||||
return Response.AsJson(new JsonResponseModel { Result = false, Message = "You are not an Admin, so you cannot delete any requests." });
|
||||
}
|
||||
|
||||
var currentEntity = Service.Get(requestid);
|
||||
Service.Delete(currentEntity);
|
||||
return Response.AsJson(new JsonResponseModel { Result = true });
|
||||
}
|
||||
return Response.AsJson(new JsonResponseModel { Result = false, Message = "You are not an Admin, so you cannot delete any requests." });
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Reports the issue.
|
||||
|
@ -162,11 +162,9 @@ namespace PlexRequests.UI.Modules
|
|||
|
||||
|
||||
var result = Service.Update(originalRequest);
|
||||
if (result)
|
||||
{
|
||||
return Response.AsJson(new JsonResponseModel { Result = true });
|
||||
}
|
||||
return Response.AsJson(new JsonResponseModel { Result = false, Message = "Could not add issue, please try again or contact the administrator!" });
|
||||
return Response.AsJson(result
|
||||
? new JsonResponseModel { Result = true }
|
||||
: new JsonResponseModel { Result = false, Message = "Could not add issue, please try again or contact the administrator!" });
|
||||
}
|
||||
|
||||
private Response ClearIssue(int requestId)
|
||||
|
@ -189,5 +187,21 @@ namespace PlexRequests.UI.Modules
|
|||
? new JsonResponseModel { Result = true }
|
||||
: new JsonResponseModel { Result = false, Message = "Could not clear issue, please try again or check the logs" });
|
||||
}
|
||||
|
||||
private Response ChangeRequestAvailability(int requestId, bool available)
|
||||
{
|
||||
var originalRequest = Service.Get(requestId);
|
||||
if (originalRequest == null)
|
||||
{
|
||||
return Response.AsJson(new JsonResponseModel { Result = false, Message = "Request does not exist to change the availability!" });
|
||||
}
|
||||
|
||||
originalRequest.Available = available;
|
||||
|
||||
var result = Service.Update(originalRequest);
|
||||
return Response.AsJson(result
|
||||
? new {Result = true, Available = available, Message = string.Empty}
|
||||
: new { Result = false, Available=false, Message = "Could not update the availability, please try again or check the logs" });
|
||||
}
|
||||
}
|
||||
}
|
|
@ -68,8 +68,6 @@ namespace PlexRequests.UI
|
|||
var s = new Setup();
|
||||
s.SetupDb();
|
||||
|
||||
//ConfigureTargets(connection);
|
||||
|
||||
if(string.IsNullOrEmpty(uri))
|
||||
uri = GetStartupUri();
|
||||
|
||||
|
|
|
@ -87,10 +87,10 @@
|
|||
<div>
|
||||
Available
|
||||
{{#if_eq available false}}
|
||||
<i class="fa fa-times"></i>
|
||||
<i id="availableIcon{{requestId}}" class="fa fa-times"></i>
|
||||
{{/if_eq}}
|
||||
{{#if_eq available true}}
|
||||
<i class="fa fa-check"></i>
|
||||
<i id="availableIcon{{requestId}}" class="fa fa-check"></i>
|
||||
{{/if_eq}}
|
||||
</div>
|
||||
<div>Requested By: {{requestedBy}}</div>
|
||||
|
@ -122,6 +122,16 @@
|
|||
<input name="Id" type="text" value="{{requestId}}" hidden="hidden" />
|
||||
<button id="{{requestId}}" style="text-align: right" class="btn btn-sm btn-info-outline clear" type="submit"><i class="fa fa-check"></i> Clear Issues</button>
|
||||
</form>
|
||||
|
||||
<form method="POST" action="/requests/changeavailability" id="change{{requestId}}">
|
||||
<input name="Id" type="text" value="{{requestId}}" hidden="hidden" />
|
||||
{{#if_eq available true}}
|
||||
<button id="{{requestId}}" custom-availibility="{{requestId}}" style="text-align: right" value="false" class="btn btn-sm btn-info-outline change" type="submit">Mark Unavailable</button>
|
||||
{{else}}
|
||||
<button id="{{requestId}}" custom-availibility="{{requestId}}" style="text-align: right" value="true" class="btn btn-sm btn-success-outline change" type="submit">Mark Available</button>
|
||||
{{/if_eq}}
|
||||
</form>
|
||||
|
||||
{{/if_eq}}
|
||||
|
||||
<form method="POST" action="/requests/reportissue/" id="report{{requestId}}">
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue