Add more query options for eventlog api

This commit is contained in:
Johannes Zellner
2016-05-06 16:49:17 +02:00
parent e986a67d39
commit 4c7dc5056d
4 changed files with 98 additions and 4 deletions
+15
View File
@@ -6,6 +6,7 @@ exports = module.exports = {
add: add,
get: get,
getAllPaged: getAllPaged,
getByQueryPaged: getByQueryPaged,
// keep in sync with webadmin index.js filter
ACTION_ACTIVATE: 'cloudron.activate',
@@ -97,3 +98,17 @@ function getAllPaged(page, perPage, callback) {
callback(null, boxes);
});
}
function getByQueryPaged(action, search, page, perPage, callback) {
assert(typeof action === 'string' || action === null);
assert(typeof search === 'string' || search === null);
assert.strictEqual(typeof page, 'number');
assert.strictEqual(typeof perPage, 'number');
assert.strictEqual(typeof callback, 'function');
eventlogdb.getByQueryPaged(action, search, page, perPage, function (error, boxes) {
if (error) return callback(new EventLogError(EventLogError.INTERNAL_ERROR, error));
callback(null, boxes);
});
}