mirror of
https://github.com/NginxProxyManager/nginx-proxy-manager.git
synced 2025-04-26 00:52:28 +00:00
53 lines
1.3 KiB
JavaScript
53 lines
1.3 KiB
JavaScript
'use strict';
|
|
|
|
const auditLogModel = require('../models/audit-log');
|
|
|
|
const internalAuditLog = {
|
|
|
|
/**
|
|
* Internal use only
|
|
*
|
|
* @param {Object} data
|
|
* @returns {Promise}
|
|
*/
|
|
create: data => {
|
|
// TODO
|
|
},
|
|
|
|
/**
|
|
* All logs
|
|
*
|
|
* @param {Access} access
|
|
* @param {Array} [expand]
|
|
* @param {String} [search_query]
|
|
* @returns {Promise}
|
|
*/
|
|
getAll: (access, expand, search_query) => {
|
|
return access.can('auditlog:list')
|
|
.then(() => {
|
|
let query = auditLogModel
|
|
.query()
|
|
.orderBy('created_on', 'DESC')
|
|
.limit(100);
|
|
|
|
// Query is used for searching
|
|
if (typeof search_query === 'string') {
|
|
/*
|
|
query.where(function () {
|
|
this.where('name', 'like', '%' + search_query + '%')
|
|
.orWhere('email', 'like', '%' + search_query + '%');
|
|
});
|
|
*/
|
|
}
|
|
|
|
if (typeof expand !== 'undefined' && expand !== null) {
|
|
query.eager('[' + expand.join(', ') + ']');
|
|
}
|
|
|
|
return query;
|
|
});
|
|
}
|
|
};
|
|
|
|
module.exports = internalAuditLog;
|