overseer/src/routes/home.js
Gregory Ballantine d95be2e185
Some checks failed
ci/woodpecker/push/woodpecker Pipeline failed
Added ability to limit dashboard results
2024-05-24 12:35:01 -04:00

37 lines
728 B
JavaScript

const db = require('../models');
const Item = db.items;
const License = db.licenses;
// GET - /
exports.getIndex = async function(req, res) {
// check if there's a limit set
if (isset(req.body['limit'])) {
const limit = req.body.limit;
} else {
const limit = 10;
}
// fetch inventory items from database
const items = await Item.findAll({
limit: limit,
order: [
['updatedAt', 'DESC'],
],
});
// fetch licenses from database
const licenses = await License.findAll({
limit: limit,
order: [
['updatedAt', 'DESC'],
],
});
// req.flash('info', 'This is a test flash message.');
res.render('index.twig', {
inventory: items,
licenses: licenses,
});
};