Skip to content

Commit

Permalink
Version 0.9.60
Browse files Browse the repository at this point in the history
- Bring back the live job status column, but show "Last Run" if no active jobs.
  • Loading branch information
jhuckaby committed Oct 4, 2024
1 parent a6328ae commit 8ef1076
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 4 deletions.
54 changes: 51 additions & 3 deletions htdocs/js/pages/Schedule.class.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ Class.subclass( Page.Base, "Page.Schedule", {
'Plugin',
'Target',
'Timing',
'Last Run',
'Status',
'Actions'
];

Expand Down Expand Up @@ -236,24 +236,71 @@ Class.subclass( Page.Base, "Page.Schedule", {
$P().set_search_filters();
}
} );

self.update_live_job_counts();
}, 1 );
},

update_job_last_runs: function() {
// update last run state for all jobs, called when state is updated
if (!app.state.jobCodes) return;

var event_counts = {};

for (var job_id in app.activeJobs) {
var job = app.activeJobs[job_id];
event_counts[job.event] = (event_counts[job.event] || 0) + 1;
}

for (var event_id in app.state.jobCodes) {
var last_code = app.state.jobCodes[event_id];
var status_html = last_code ? '<span class="color_label red clicky"><i class="fa fa-warning">&nbsp;</i>Error</span>' : '<span class="color_label green clicky"><i class="fa fa-check">&nbsp;</i>Success</span>';
if (!(event_id in event_counts)) {
var last_code = app.state.jobCodes[event_id];
var status_html = last_code ? '<span class="color_label red clicky"><i class="fa fa-warning">&nbsp;</i>Error</span>' : '<span class="color_label green clicky"><i class="fa fa-check">&nbsp;</i>Success</span>';
this.div.find('#ss_' + event_id).html( status_html );
}
}
},

update_live_job_counts: function() {
// app.activeJobs
var event_counts = {};

for (var job_id in app.activeJobs) {
var job = app.activeJobs[job_id];
event_counts[job.event] = (event_counts[job.event] || 0) + 1;
}

for (var event_id in event_counts) {
var count = event_counts[event_id];
var status_html = '<span class="color_label blue">Running (' + count + ')</span>';
this.div.find('#ss_' + event_id).html( status_html );
}

this.update_job_last_runs();
},

jump_to_last_job: function(idx) {
// locate ID of latest completed job for event, and redirect to it
var event = this.events[idx];
var event_counts = {};

for (var job_id in app.activeJobs) {
var job = app.activeJobs[job_id];
event_counts[job.event] = (event_counts[job.event] || 0) + 1;
}

if (event_counts[event.id]) {
// if event has active jobs, change behavior of click
// if exactly 1 job, link to it -- if more, do nothing
if (event_counts[event.id] == 1) {
var job = find_object( Object.values(app.activeJobs), { event: event.id } );
if (job) Nav.go( 'JobDetails?id=' + job.id );
return;
}
else return;
}

// jump to last completed job
app.api.post( 'app/get_event_history', { id: event.id, offset: 0, limit: 1 }, function(resp) {
if (resp && resp.rows && resp.rows[0]) {
var job = resp.rows[0];
Expand Down Expand Up @@ -1832,6 +1879,7 @@ Class.subclass( Page.Base, "Page.Schedule", {

onStatusUpdate: function(data) {
// received status update (websocket)
if (data.jobs_changed) this.update_live_job_counts();
},

onResizeDelay: function(size) {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "Cronicle",
"version": "0.9.59",
"version": "0.9.60",
"description": "A simple, distributed task scheduler and runner with a web based UI.",
"author": "Joseph Huckaby <jhuckaby@gmail.com>",
"homepage": "https://github.com/jhuckaby/Cronicle",
Expand Down

0 comments on commit 8ef1076

Please sign in to comment.