diff --git a/admin/js/config.js b/admin/js/config.js index 1774ad2..53376f3 100644 --- a/admin/js/config.js +++ b/admin/js/config.js @@ -34,7 +34,7 @@ angular.module('ffffngAdmin').config(function(NgAdminConfigurationProvider, Cons nodes .listView() .title('Nodes') - .perPage(5) + .perPage(30) .actions([]) .batchActions([]) .exportFields([]) @@ -103,6 +103,7 @@ angular.module('ffffngAdmin').config(function(NgAdminConfigurationProvider, Cons tasks .listView() .title('Background-Jobs') + .perPage(30) .actions([]) .batchActions([]) .exportFields([]) diff --git a/server/jobs/scheduler.js b/server/jobs/scheduler.js index b5c8843..879f076 100644 --- a/server/jobs/scheduler.js +++ b/server/jobs/scheduler.js @@ -31,6 +31,7 @@ angular.module('ffffng').factory('Scheduler', function ($injector, Logger, confi var id = nextTaskId(); var task = { + id: id, name: jobName, schedule: expr, job: job, diff --git a/server/resources/nodeResource.js b/server/resources/nodeResource.js index 82b640b..8215471 100644 --- a/server/resources/nodeResource.js +++ b/server/resources/nodeResource.js @@ -108,7 +108,6 @@ angular.module('ffffng').factory('NodeResource', function ( } res.set('X-Total-Count', total); - return Resources.success(res, nodes); }); }); diff --git a/server/resources/taskResource.js b/server/resources/taskResource.js index 10b944a..b2ef6bd 100644 --- a/server/resources/taskResource.js +++ b/server/resources/taskResource.js @@ -11,9 +11,9 @@ angular.module('ffffng').factory('TaskResource', function ( ) { var isValidId = Validator.forConstraint(Constraints.id); - function toExternalTask(task, id) { + function toExternalTask(task) { return { - id: id, + id: task.id, name: task.name, schedule: task.schedule, runningSince: task.runningSince && task.runningSince.unix(), @@ -55,31 +55,47 @@ angular.module('ffffng').factory('TaskResource', function ( return callback(err); } - callback(null, id, task); + callback(null, task); }); }); } function setTaskEnabled(req, res, enable) { - withTask(req, res, function (err, id, task) { + withTask(req, res, function (err, task) { if (err) { return Resources.error(res, err); } task.enabled = !!enable; // ensure boolean - return Resources.success(res, toExternalTask(task, id)); + return Resources.success(res, toExternalTask(task)); }); } return { getAll: function (req, res) { - var tasks = Scheduler.getTasks(); - return Resources.success(res, _.map(tasks, toExternalTask)); + Resources.getValidRestParams('list', req, function (err, restParams) { + if (err) { + return Resources.error(res, err); + } + + // TODO: Sort + + var tasks = _.values(Scheduler.getTasks()); + var total = tasks.length; + + var page = restParams._page; + var perPage = restParams._perPage; + + var pageTasks = tasks.slice((page - 1) * perPage, page * perPage); + + res.set('X-Total-Count', total); + return Resources.success(res, _.map(pageTasks, toExternalTask)); + }); }, run: function (req, res) { - withTask(req, res, function (err, id, task) { + withTask(req, res, function (err, task) { if (err) { return Resources.error(res, err); } @@ -90,7 +106,7 @@ angular.module('ffffng').factory('TaskResource', function ( task.run(); - return Resources.success(res, toExternalTask(task, id)); + return Resources.success(res, toExternalTask(task)); }); },