Added benchmark and hardware models; added routes and views for hardware

This commit is contained in:
2023-11-26 12:54:09 -05:00
parent e5602e660d
commit 2f016d3062
10 changed files with 181 additions and 2 deletions

41
src/routes/hardware.js Normal file
View File

@ -0,0 +1,41 @@
const Hardware = require('../models').models.Hardware;
// GET /hardware - redirects to project list
exports.getIndex = async function(req, res) {
res.redirect('/hardware/list');
};
// GET /hardware/list - list of hardware
exports.getList = async function(req, res) {
var hardware = await Hardware.findAll();
res.render('hardware/list', {
hardware: hardware
});
};
// GET /hardware/:hardware_id - view information about a piece of hardware
exports.getView = async function(req, res) {
var hardware = await Hardware.findAll({
where: {
id: req.params.hardware_id
}
});
res.render('hardware/view', {
hardware: hardware[0]
});
};
// GET /hardware/add - add a new hardware
exports.getAdd = async function(req, res) {
res.render('hardware/add');
};
// POST /hardware/add - add the hardware to the database
exports.postAdd = async function(req, res) {
var hardware = await Hardware.create({
name: req.body.hardware_name,
type: req.body.hardware_type
});
res.redirect('/hardware');
};