diff --git a/admin/js/main.js b/admin/js/main.js index b0a157a..49bcc30 100644 --- a/admin/js/main.js +++ b/admin/js/main.js @@ -23,6 +23,10 @@ angular.module('ffffngAdmin').config(function(NgAdminConfigurationProvider, Rest return unix ? moment.unix(unix).fromNow() : 'N/A'; } + function formatDuration(duration) { + return typeof duration === 'number' ? moment.duration(duration).humanize() : 'N/A'; + } + function nodeConstraint(field) { var constraint = Constraints.node[field]; var result = { @@ -351,7 +355,8 @@ angular.module('ffffngAdmin').config(function(NgAdminConfigurationProvider, Rest nga.field('schedule').cssClasses(taskClasses('schedule')), nga.field('state').cssClasses(taskClasses('state')), nga.field('runningSince').map(formatMoment).cssClasses(taskClasses('runningSince')), - nga.field('lastRunStarted').map(formatMoment).cssClasses(taskClasses('lastRunStarted')) + nga.field('lastRunStarted').map(formatMoment).cssClasses(taskClasses('lastRunStarted')), + nga.field('lastRunDuration').map(formatDuration).cssClasses(taskClasses('lastRunDuration')) ]) .filters([ nga.field('q') diff --git a/server/jobs/scheduler.js b/server/jobs/scheduler.js index 0519b97..6d9e9a3 100644 --- a/server/jobs/scheduler.js +++ b/server/jobs/scheduler.js @@ -38,6 +38,7 @@ angular.module('ffffng').factory('Scheduler', function ($injector, Logger, confi job: job, runningSince: false, lastRunStarted: false, + lastRunDuration: null, state: 'idle', enabled: true }; @@ -54,8 +55,11 @@ angular.module('ffffng').factory('Scheduler', function ($injector, Logger, confi job.run(function () { var now = moment(); - Logger.tag('jobs').profile('[%sms]\t%s', now.diff(task.runningSince), task.name); + var duration = now.diff(task.runningSince); + Logger.tag('jobs').profile('[%sms]\t%s', duration, task.name); + task.runningSince = false; + task.lastRunDuration = duration; task.state = 'idle'; }); }; diff --git a/server/resources/taskResource.js b/server/resources/taskResource.js index 009b2ec..74317b9 100644 --- a/server/resources/taskResource.js +++ b/server/resources/taskResource.js @@ -19,6 +19,7 @@ angular.module('ffffng').factory('TaskResource', function ( schedule: task.schedule, runningSince: task.runningSince && task.runningSince.unix(), lastRunStarted: task.lastRunStarted && task.lastRunStarted.unix(), + lastRunDuration: task.lastRunDuration || undefined, state: task.state, enabled: task.enabled };