Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions src/Hangfire.Core/Dashboard/Content/css/hangfire.css
Original file line number Diff line number Diff line change
Expand Up @@ -531,3 +531,25 @@ div.metric-null {
width: 262.5px;
}
}

.ellipsis {
width: 220px;
overflow: hidden;
text-overflow: ellipsis;
display: inline-block;
cursor: pointer;
}

.ellipsis-wrap {
white-space: nowrap;
}

@media (min-width: 1200px) {
.ellipsis {
width: 420px;
}
}

#paginator-filter {
width: 320px;
}
12 changes: 12 additions & 0 deletions src/Hangfire.Core/Dashboard/Content/js/hangfire.js
Original file line number Diff line number Diff line change
Expand Up @@ -361,6 +361,18 @@
e.preventDefault();
});

$(document).on('change', '#paginator-filter', function(e) {
var filter = $("#paginator-filter").val();
var url = $(this).data('href') + filter;
window.location = url;
e.preventDefault();
});

$(document).on('click', '.toggle-ellipsis', function (e) {
$(this).closest('td').first().toggleClass('ellipsis-wrap');
});


$(document).on('click', '.expander', function (e) {
var $expander = $(this),
$expandable = $expander.closest('tr').next().find('.expandable');
Expand Down
21 changes: 20 additions & 1 deletion src/Hangfire.Core/Dashboard/Content/resx/Strings.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 7 additions & 1 deletion src/Hangfire.Core/Dashboard/Content/resx/Strings.resx
Original file line number Diff line number Diff line change
Expand Up @@ -523,4 +523,10 @@
<data name="HomePage_GraphHover_Succeeded" xml:space="preserve">
<value>Succeeded</value>
</data>
</root>
<data name="Common_Arguments" xml:space="preserve">
<value>Arguments</value>
</data>
<data name="PerPageSelector_All" xml:space="preserve">
<value>All</value>
</data>
</root>
12 changes: 12 additions & 0 deletions src/Hangfire.Core/Dashboard/HtmlHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
using Hangfire.Annotations;
using Hangfire.Dashboard.Pages;
using Hangfire.Dashboard.Resources;
using Newtonsoft.Json;

namespace Hangfire.Dashboard
{
Expand Down Expand Up @@ -80,6 +81,12 @@ public NonEscapedString PerPageSelector([NotNull] Pager pager)
return RenderPartial(new PerPageSelector(pager));
}

public NonEscapedString Filter([NotNull] Pager pager)
{
if (pager == null) throw new ArgumentNullException(nameof(pager));
return RenderPartial(new Filter(pager));
}

public NonEscapedString RenderPartial(RazorPage partialPage)
{
partialPage.Assign(_page);
Expand Down Expand Up @@ -144,6 +151,11 @@ public NonEscapedString JobNameLink(string jobId, Job job)
return Raw($"<a class=\"job-method\" href=\"{_page.Url.JobDetails(jobId)}\">{HtmlEncode(JobName(job))}</a>");
}

public NonEscapedString JobArguments(Job job)
{
var serialized = JsonConvert.SerializeObject(job?.Args, Formatting.Indented);
return Raw($"<a class=\"job-method toggle-ellipsis\">{HtmlEncode(serialized)}</a>");
}
public NonEscapedString RelativeTime(DateTime value)
{
return Raw($"<span data-moment=\"{JobHelper.ToTimestamp(value)}\">{value}</span>");
Expand Down
15 changes: 11 additions & 4 deletions src/Hangfire.Core/Dashboard/Pager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,13 @@ public class Pager
private int _startPageIndex = 1;
private int _endPageIndex = 1;

public Pager(int from, int perPage, long total)
public Pager(int from, int perPage, long total, string filter, int defaultRecordsPerPage)
{
FromRecord = from >= 0 ? from : 0;
RecordsPerPage = perPage > 0 ? perPage : DefaultRecordsPerPage;
RecordsPerPage = perPage > 0 ? perPage : (defaultRecordsPerPage > 0 ? defaultRecordsPerPage : DefaultRecordsPerPage);
TotalRecordCount = total;
CurrentPage = FromRecord / RecordsPerPage + 1;
Filter = filter;
TotalPageCount = (int)Math.Ceiling((double)TotalRecordCount / RecordsPerPage);

PagerItems = GenerateItems();
Expand All @@ -43,6 +44,7 @@ public Pager(int from, int perPage, long total)
public int FromRecord { get; }
public int RecordsPerPage { get; }
public int CurrentPage { get; }
public string Filter { get; }

public int TotalPageCount { get; }
public long TotalRecordCount { get; }
Expand All @@ -53,13 +55,18 @@ public string PageUrl(int page)
{
if (page < 1 || page > TotalPageCount) return "#";

return BasePageUrl + "?from=" + (page - 1) * RecordsPerPage + "&count=" + RecordsPerPage;
return BasePageUrl + "?from=" + (page - 1) * RecordsPerPage + "&count=" + RecordsPerPage + "&filter=" + Filter;
}

public string RecordsPerPageUrl(int perPage)
{
if (perPage <= 0) return "#";
return BasePageUrl + "?from=0&count=" + perPage;
return BasePageUrl + "?from=0&count=" + perPage + "&filter=" + Filter;
}

public string FilterUrl()
{
return BasePageUrl + "?from=0&count=" + RecordsPerPage + "&filter=";
}

private ICollection<Item> GenerateItems()
Expand Down
22 changes: 18 additions & 4 deletions src/Hangfire.Core/Dashboard/Pages/AwaitingJobsPage.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
Layout = new LayoutPage(Strings.AwaitingJobsPage_Title);

int from, perPage;
var filter = Query("filter");

int.TryParse(Query("from"), out from);
int.TryParse(Query("count"), out perPage);
Expand All @@ -24,7 +25,7 @@

if (storageConnection != null)
{
pager = new Pager(from, perPage, storageConnection.GetSetCount("awaiting"));
pager = new Pager(from, perPage, storageConnection.GetSetCount("awaiting"), null, DefaultRecordsPerPage);
jobIds = storageConnection.GetRangeFromSet("awaiting", pager.FromRecord, pager.FromRecord + pager.RecordsPerPage - 1);
}
}
Expand Down Expand Up @@ -63,7 +64,6 @@
@Strings.Common_DeleteSelected
</button>

@Html.PerPageSelector(pager)
</div>

<div class="table-responsive">
Expand All @@ -75,6 +75,10 @@
</th>
<th class="min-width">@Strings.Common_Id</th>
<th>@Strings.Common_Job</th>
@if (DisplayArgumentsInLists)
{
<th class="min-width">@Strings.Common_Arguments</th>
}
<th class="min-width">@Strings.AwaitingJobsPage_Table_Options</th>
<th class="min-width">@Strings.AwaitingJobsPage_Table_Parent</th>
<th class="align-right">@Strings.Common_Created</th>
Expand Down Expand Up @@ -107,13 +111,19 @@
</td>
@if (jobData == null)
{
<td colspan="2"><em>@Strings.Common_JobExpired</em></td>
<td colspan="@(DisplayArgumentsInLists ? 5 : 4)"><em>@Strings.Common_JobExpired</em></td>
}
else
{
<td class="word-break">
@Html.JobNameLink(jobId, jobData.Job)
</td>
@if (DisplayArgumentsInLists)
{
<td class="ellipsis ellipsis-wrap">
@Html.JobArguments(jobData.Job)
</td>
}
<td class="min-width">
@if (stateData != null && stateData.Data.ContainsKey("Options") && !String.IsNullOrWhiteSpace(stateData.Data["Options"]))
{
Expand Down Expand Up @@ -147,7 +157,11 @@
</tbody>
</table>
</div>
@Html.Paginator(pager)
<div class="btn-toolbar">
@Html.Paginator(pager)

@Html.PerPageSelector(pager)
</div>
</div>
}
else
Expand Down
Loading