-
Notifications
You must be signed in to change notification settings - Fork 52
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #62 from JossyDevers/issue-dev-36
Create a new status called Jobs Stopped
- Loading branch information
Showing
10 changed files
with
205 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -340,3 +340,4 @@ ASALocalRun/ | |
|
||
# BeatPulse healthcheck temp database | ||
healthchecksdb | ||
samples/Hangfire.Sample/HangfireSampleDb |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
<script type="text/javascript" src="../JobConfiguration/js/vue"></script> | ||
<script type="text/javascript" src="../JobConfiguration/js/axio"></script> | ||
<script type="text/javascript" src="../JobConfiguration/js/vuejsPaginate"></script> | ||
|
||
<div id="app"> | ||
<div class="col-md-3"></div> | ||
<div class="col-md-9"> | ||
<h1 class="page-header">Stopped Jobs</h1> | ||
|
||
<div v-if="getItems.length == 0" class="alert alert-info"> | ||
No stopped jobs found | ||
</div> | ||
<div v-else class="js-jobs-list"> | ||
<div class="table-responsive"> | ||
<table class="table"> | ||
|
||
<thead> | ||
<tr> | ||
<th>Id</th> | ||
<th>Queue</th> | ||
<th>Class</th> | ||
<th>Method</th> | ||
<th>TimeZone</th> | ||
</tr> | ||
</thead> | ||
<tbody> | ||
<tr v-for="job in getItems"> | ||
<td>{{job.Id}}</td> | ||
<td>{{job.Queue}}</td> | ||
<td>{{job.Class}}</td> | ||
<td>{{job.Method}}</td> | ||
<td>{{job.TimeZoneId}}</td> | ||
</tr> | ||
</tbody> | ||
</table> | ||
|
||
<div style="float: right;"> | ||
<paginate :page-count="getPageCount" | ||
:page-range="3" | ||
:margin-pages="2" | ||
:click-handler="clickCallbackPagination" | ||
:prev-text="'<'" | ||
:next-text="'>'" | ||
:container-class="'pagination'" | ||
:page-class="'page-item'"> | ||
</paginate> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
|
||
<script> | ||
var appJob = new Vue({ | ||
el: '#app', | ||
components: { | ||
'paginate': VuejsPaginate | ||
}, | ||
data() { | ||
return { | ||
jobs: null, | ||
pagination: { | ||
parPage: 10, | ||
currentPage: 1 | ||
} | ||
} | ||
}, | ||
methods: { | ||
GetJobs() { | ||
axios.get('GetJobsStopped') | ||
.then(res => (this.jobs = res.data)) | ||
}, | ||
clickCallbackPagination(pageNum) { | ||
this.pagination.currentPage = Number(pageNum); | ||
} | ||
}, | ||
created() { | ||
this.GetJobs(); | ||
}, | ||
computed: { | ||
getItems: function () { | ||
let current = this.pagination.currentPage * this.pagination.parPage; | ||
let start = current - this.pagination.parPage; | ||
if (this.jobs != null) return this.jobs.slice(start, current); | ||
else return null; | ||
}, | ||
getPageCount: function () { | ||
return Math.ceil(this.jobs.length / this.pagination.parPage); | ||
} | ||
} | ||
}); | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 34 additions & 0 deletions
34
src/Hangfire.RecurringJobAdmin/Pages/GetJobsStoppedDispatcher.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
using Hangfire.Annotations; | ||
using Hangfire.RecurringJobAdmin.Core; | ||
using Hangfire.RecurringJobAdmin.Models; | ||
using Hangfire.Storage; | ||
using Newtonsoft.Json; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Threading.Tasks; | ||
|
||
namespace Hangfire.RecurringJobAdmin.Pages | ||
{ | ||
internal sealed class GetJobsStoppedDispatcher : Dashboard.IDashboardDispatcher | ||
{ | ||
private readonly IStorageConnection _connection; | ||
public GetJobsStoppedDispatcher() | ||
{ | ||
_connection = JobStorage.Current.GetConnection(); | ||
} | ||
public async Task Dispatch([NotNull] Dashboard.DashboardContext context) | ||
{ | ||
if (!"GET".Equals(context.Request.Method, StringComparison.InvariantCultureIgnoreCase)) | ||
{ | ||
context.Response.StatusCode = 405; | ||
|
||
return; | ||
} | ||
|
||
var periodicJob = new List<PeriodicJob>(); | ||
periodicJob.AddRange(JobAgent.GetAllJobStopped()); | ||
|
||
await context.Response.WriteAsync(JsonConvert.SerializeObject(periodicJob)); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
using Hangfire.Dashboard; | ||
using Hangfire.Dashboard.Pages; | ||
using Hangfire.RecurringJobAdmin.Core; | ||
|
||
namespace Hangfire.RecurringJobAdmin.Pages | ||
{ | ||
internal sealed class JobsStoppedPage : PageBase | ||
{ | ||
public const string Title = "Stopped Jobs"; | ||
public const string PageRoute = "/jobs/stopped"; | ||
|
||
private static readonly string PageHtml; | ||
|
||
static JobsStoppedPage() | ||
{ | ||
PageHtml = Utility.ReadStringResource("Hangfire.RecurringJobAdmin.Dashboard.JobsStopped.html"); | ||
} | ||
|
||
public override void Execute() | ||
{ | ||
WriteEmptyLine(); | ||
Layout = new LayoutPage(Title); | ||
Write(Html.JobsSidebar()); | ||
WriteLiteralLine(PageHtml); | ||
WriteEmptyLine(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
using Hangfire.Dashboard; | ||
using Hangfire.Dashboard.Pages; | ||
using Hangfire.RecurringJobAdmin.Core; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Text; | ||
|
||
namespace Hangfire.RecurringJobAdmin.Pages | ||
{ | ||
abstract internal class PageBase : RazorPage | ||
{ | ||
public override void Execute() { } | ||
|
||
protected void WriteLiteralLine(string textToAppend) | ||
{ | ||
WriteLiteral(textToAppend); | ||
WriteLiteral("\r\n"); | ||
} | ||
|
||
protected void WriteEmptyLine() | ||
{ | ||
WriteLiteral("\r\n"); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
using Hangfire.Dashboard; | ||
using Hangfire.RecurringJobAdmin.Core; | ||
|
||
namespace Hangfire.RecurringJobAdmin | ||
{ | ||
public static class TagDashboardMetrics | ||
{ | ||
public static readonly DashboardMetric JobsStoppedCount = new DashboardMetric("JobsStopped:count", razorPage => | ||
{ | ||
return new Metric(JobAgent.GetAllJobStopped().Count); | ||
}); | ||
} | ||
} |