Skip to content

Commit

Permalink
Done #1012
Browse files Browse the repository at this point in the history
  • Loading branch information
Jamie.Rees authored and Jamie.Rees committed Mar 10, 2017
1 parent beed3e8 commit 6353662
Show file tree
Hide file tree
Showing 3 changed files with 69 additions and 40 deletions.
34 changes: 34 additions & 0 deletions Ombi.UI/Modules/Admin/FaultQueueModule.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,10 @@
// ************************************************************************/
#endregion

using System;
using System.Linq;
using System.Threading.Tasks;
using Nancy;
using Nancy.Responses.Negotiation;
using Ombi.Core;
using Ombi.Core.SettingModels;
Expand All @@ -48,6 +51,7 @@ public FaultQueueModule(ISettingsService<PlexRequestSettings> settingsService, I
Before += (ctx) => Security.AdminLoginRedirect(Permissions.Administrator, ctx);

Get["Index", "/faultqueue"] = x => Index();
Get["DeleteFault", "/deleteFault", true] = async (x,ct) => await DeleteFault(Convert.ToInt32(Request.Form.id));
}

private IRepository<RequestQueue> RequestQueue { get; }
Expand All @@ -69,5 +73,35 @@ private Negotiator Index()

return View["RequestFaultQueue", model];
}

public async Task<Response> DeleteFault(int faultId)
{

if (faultId == 0)
{
return Response.AsJson(new JsonResponseModel
{
Result = true,
Message = "Fault does not exist"
});
}

var fault = await RequestQueue.GetAsync(faultId);
if (fault == null)
{
return Response.AsJson(new JsonResponseModel
{
Result = true,
Message = "Fault does not exist"
});
}

await RequestQueue.DeleteAsync(fault);

return Response.AsJson(new JsonResponseModel
{
Result = true
});
}
}
}
6 changes: 6 additions & 0 deletions Ombi.UI/Views/Admin/SchedulerSettings.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -175,13 +175,19 @@
success: function (response) {
if (response.result === true) {
generateNotify("Success!", "success");
ev.removeClass("fa-spin");
ev.addClass("fa-check");
} else {
generateNotify(response.message, "warning");
ev.removeClass("fa-spin");
ev.addClass("fa-times");
}
},
error: function (e) {
console.log(e);
generateNotify("Something went wrong!", "danger");
ev.removeClass("fa-spin");
ev.addClass("fa-times");
}
});

Expand Down
69 changes: 29 additions & 40 deletions Ombi.UI/Views/FaultQueue/RequestFaultQueue.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@
<th>
Error Description
</th>
<th>
Delete
</th>
</tr>
</thead>
<tbody>
Expand All @@ -44,6 +47,7 @@
<td>
@m.Message
</td>
<td class="delete" id="@m.Id"><i class="fa fa-times"></i></td>
</tr>
}
</tbody>
Expand All @@ -52,57 +56,42 @@
</fieldset>
</div>

@*<script>
<script>
var base = '@Html.GetBaseUrl()';
$('#autoUpdate')
.click(function (e) {
e.preventDefault();
$('body').append("<i class=\"fa fa-spinner fa-spin fa-5x fa-fw\" style=\"position: absolute; top: 20%; left: 50%;\"></i>");
$('#autoUpdate').prop("disabled", "disabled");
document.getElementById("lightbox").style.display = "";
var count = 0;
setInterval(function () {
count++;
var dots = new Array(count % 10).join('.');
document.getElementById('autoUpdate').innerHTML = "Updating" + dots;
}, 1000);
$.ajax({
type: "Post",
url: "autoupdate",
data: { url: "@Model.Status.DownloadUri" },
dataType: "json",
error: function () {
setTimeout(
function () {
location.reload();
}, 30000);
}
});
});
$(function () {
$('#saveSettings').click(function (e) {
e.preventDefault();
var $form = $("#mainForm");
$('.refresh').click(function (e) {
var id = e.currentTarget.id;
var branches = $("#branches option:selected").val();
var ev = $(e.currentTarget.children[0]);
ev.addClass("fa-spin");
var data = $form.serialize();
data = data + "&branch=" + branches;
var url = createLocalUrl("/admin/deleteFault");
$.ajax({
type: $form.prop("method"),
url: $form.prop("action"),
data: data,
type: 'POST',
data: { key: id },
url: url,
dataType: "json",
success: function (response) {
if (response.result === true) {
generateNotify(response.message, "success");
generateNotify("Success!", "success");
ev.removeClass("fa-spin");
ev.addClass("fa-check");
} else {
generateNotify(response.message, "warning");
ev.removeClass("fa-spin");
ev.addClass("fa-exclamation");
}
},
error: function (e) {
console.log(e);
generateNotify("Something went wrong!", "danger");
ev.removeClass("fa-spin");
ev.addClass("fa-exclamation");
}
});
});
</script>*@
});
</script>

0 comments on commit 6353662

Please sign in to comment.