From ce155951bf03f508967c210e567ef2093085a554 Mon Sep 17 00:00:00 2001 From: baldo Date: Tue, 21 Jun 2016 14:55:02 +0200 Subject: [PATCH] Show task description in admin panel. --- admin/index.html | 9 ++++++++ admin/js/main.js | 25 ++++++++++++---------- server/jobs/mailQueueJob.js | 2 ++ server/jobs/monitoringMailsSendingJob.js | 2 ++ server/jobs/nodeInformationCleanupJob.js | 2 ++ server/jobs/nodeInformationRetrievalJob.js | 2 ++ server/jobs/scheduler.js | 1 + server/resources/taskResource.js | 1 + 8 files changed, 33 insertions(+), 11 deletions(-) diff --git a/admin/index.html b/admin/index.html index fe419bb..4f6cf63 100644 --- a/admin/index.html +++ b/admin/index.html @@ -14,6 +14,15 @@ text-decoration: line-through; } + .task-description { + max-width: 220px; + } + + .task-schedule { + font-family: monospace; + white-space: nowrap; + } + .mails-pending { color: green; } diff --git a/admin/js/main.js b/admin/js/main.js index a1a6a09..9ca19d5 100644 --- a/admin/js/main.js +++ b/admin/js/main.js @@ -238,11 +238,13 @@ angular.module('ffffngAdmin').config(function(NgAdminConfigurationProvider, Rest admin.addEntity(mails); - function taskClasses(task) { - if (!task) { - return; - } - return task.values.enabled ? 'task-enabled' : 'task-disabled'; + function taskClasses(field) { + return function(task) { + if (!task) { + return; + } + return 'task-' + field + ' ' + (task.values.enabled ? 'task-enabled' : 'task-disabled'); + }; } var tasks = nga.entity('tasks').label('Background-Jobs'); @@ -256,12 +258,13 @@ angular.module('ffffngAdmin').config(function(NgAdminConfigurationProvider, Rest .batchActions([]) .exportFields([]) .fields([ - nga.field('id').cssClasses(taskClasses), - nga.field('name').cssClasses(taskClasses), - nga.field('schedule').cssClasses(taskClasses), - nga.field('state').cssClasses(taskClasses), - nga.field('runningSince').map(formatMoment).cssClasses(taskClasses), - nga.field('lastRunStarted').map(formatMoment).cssClasses(taskClasses) + nga.field('id').cssClasses(taskClasses('id')), + nga.field('name').cssClasses(taskClasses('name')), + nga.field('description').cssClasses(taskClasses('description')), + 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')) ]) .filters([ nga.field('q') diff --git a/server/jobs/mailQueueJob.js b/server/jobs/mailQueueJob.js index 1a55264..799e878 100644 --- a/server/jobs/mailQueueJob.js +++ b/server/jobs/mailQueueJob.js @@ -2,6 +2,8 @@ angular.module('ffffng').factory('MailQueueJob', function (MailService, Logger) { return { + description: 'Send pending emails (up to 5 attempts in case of failures).', + run: function (callback) { MailService.sendPendingMails(function (err) { if (err) { diff --git a/server/jobs/monitoringMailsSendingJob.js b/server/jobs/monitoringMailsSendingJob.js index e630e0a..2c2d101 100644 --- a/server/jobs/monitoringMailsSendingJob.js +++ b/server/jobs/monitoringMailsSendingJob.js @@ -2,6 +2,8 @@ angular.module('ffffng').factory('MonitoringMailsSendingJob', function (MonitoringService, Logger) { return { + description: 'Sends monitoring emails depending on the monitoring state of nodes retrieved by the NodeInformationRetrievalJob.', + run: function (callback) { MonitoringService.sendMonitoringMails(function (err) { if (err) { diff --git a/server/jobs/nodeInformationCleanupJob.js b/server/jobs/nodeInformationCleanupJob.js index 4772c06..5bb9e55 100644 --- a/server/jobs/nodeInformationCleanupJob.js +++ b/server/jobs/nodeInformationCleanupJob.js @@ -2,6 +2,8 @@ angular.module('ffffng').factory('NodeInformationCleanupJob', function (MonitoringService, Logger) { return { + description: 'Cleanup monitoring status entries for nodes no longer having monitoring enabled.', + run: function (callback) { MonitoringService.cleanupNodeInformation(function (err) { if (err) { diff --git a/server/jobs/nodeInformationRetrievalJob.js b/server/jobs/nodeInformationRetrievalJob.js index 9563fe6..133e65b 100644 --- a/server/jobs/nodeInformationRetrievalJob.js +++ b/server/jobs/nodeInformationRetrievalJob.js @@ -2,6 +2,8 @@ angular.module('ffffng').factory('NodeInformationRetrievalJob', function (MonitoringService, Logger) { return { + description: 'Fetches the nodes.json and calculates and stores the monitoring status for nodes with active monitoring.', + run: function (callback) { MonitoringService.retrieveNodeInformation(function (err) { if (err) { diff --git a/server/jobs/scheduler.js b/server/jobs/scheduler.js index 879f076..ddb7748 100644 --- a/server/jobs/scheduler.js +++ b/server/jobs/scheduler.js @@ -33,6 +33,7 @@ angular.module('ffffng').factory('Scheduler', function ($injector, Logger, confi var task = { id: id, name: jobName, + description: job.description, schedule: expr, job: job, runningSince: false, diff --git a/server/resources/taskResource.js b/server/resources/taskResource.js index 1567019..698c134 100644 --- a/server/resources/taskResource.js +++ b/server/resources/taskResource.js @@ -15,6 +15,7 @@ angular.module('ffffng').factory('TaskResource', function ( return { id: task.id, name: task.name, + description: task.description, schedule: task.schedule, runningSince: task.runningSince && task.runningSince.unix(), lastRunStarted: task.lastRunStarted && task.lastRunStarted.unix(),