The DTP Sites web app development engine.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

57 lines
1.3 KiB

// admin/log.js
// Copyright (C) 2022 DTP Technologies, LLC
// License: Apache-2.0
'use strict';
const DTP_COMPONENT_NAME = 'admin:log';
const express = require('express');
const { SiteController } = require('../../../lib/site-lib');
class LogController extends SiteController {
constructor (dtp) {
super(dtp, DTP_COMPONENT_NAME);
}
async start ( ) {
const router = express.Router();
router.use(async (req, res, next) => {
res.locals.currentView = 'admin';
res.locals.adminView = 'log';
return next();
});
router.get('/', this.getIndex.bind(this));
return router;
}
async getIndex (req, res, next) {
const { log: logService } = this.dtp.services;
try {
res.locals.query = req.query;
res.locals.components = await logService.getComponentNames();
res.locals.pagination = this.getPaginationParameters(req, 25);
const search = { };
if (req.query.component) {
search.componentName = req.query.component;
}
res.locals.logs = await logService.getRecords(search, res.locals.pagination);
res.locals.totalLogCount = await logService.getTotalCount();
res.render('admin/log/index');
} catch (error) {
return next(error);
}
}
}
module.exports = async (dtp) => {
let controller = new LogController(dtp);
return controller;
};