Removed projects; added tests
This commit is contained in:
@ -1,6 +1,6 @@
|
||||
// load routes
|
||||
const topRoutes = require('./toplevel');
|
||||
const projectRoutes = require('./project');
|
||||
const testRoutes = require('./test');
|
||||
const hardwareRoutes = require('./hardware');
|
||||
const benchmarkRoutes = require('./benchmark');
|
||||
|
||||
@ -9,13 +9,6 @@ module.exports = function(app) {
|
||||
// top-level routes
|
||||
app.get('/', topRoutes.getIndex);
|
||||
|
||||
// project routes
|
||||
app.get('/project', projectRoutes.getIndex);
|
||||
app.get('/project/list', projectRoutes.getList);
|
||||
app.get('/project/add', projectRoutes.getAdd);
|
||||
app.post('/project/add', projectRoutes.postAdd);
|
||||
app.get('/project/:project_id', projectRoutes.getView);
|
||||
|
||||
// hardware routes
|
||||
app.get('/hardware', hardwareRoutes.getIndex);
|
||||
app.get('/hardware/list', hardwareRoutes.getList);
|
||||
@ -30,4 +23,11 @@ module.exports = function(app) {
|
||||
app.post('/benchmark/add', benchmarkRoutes.postAdd);
|
||||
app.get('/benchmark/:benchmark_id', benchmarkRoutes.getView);
|
||||
|
||||
// test routes
|
||||
app.get('/test', testRoutes.getIndex);
|
||||
app.get('/test/list', testRoutes.getList);
|
||||
app.get('/test/add', testRoutes.getAdd);
|
||||
app.post('/test/add', testRoutes.postAdd);
|
||||
app.get('/test/:test_id', testRoutes.getView);
|
||||
|
||||
};
|
||||
|
@ -1,41 +0,0 @@
|
||||
const Project = require('../models').models.Project;
|
||||
|
||||
// GET /project - redirects to project list
|
||||
exports.getIndex = async function(req, res) {
|
||||
res.redirect('/project/list');
|
||||
};
|
||||
|
||||
// GET /project/list - list of projects
|
||||
exports.getList = async function(req, res) {
|
||||
var projects = await Project.findAll();
|
||||
res.render('project/list', {
|
||||
projects: projects
|
||||
});
|
||||
};
|
||||
|
||||
// GET /project/:project_id - view information about a project
|
||||
exports.getView = async function(req, res) {
|
||||
var project = await Project.findAll({
|
||||
where: {
|
||||
id: req.params.project_id
|
||||
}
|
||||
});
|
||||
res.render('project/view', {
|
||||
project: project[0]
|
||||
});
|
||||
};
|
||||
|
||||
// GET /project/add - add a new project
|
||||
exports.getAdd = async function(req, res) {
|
||||
res.render('project/add');
|
||||
};
|
||||
|
||||
// POST /project/add - add the project to the database
|
||||
exports.postAdd = async function(req, res) {
|
||||
var project = await Project.create({
|
||||
title: req.body.project_title,
|
||||
description: req.body.project_description
|
||||
});
|
||||
|
||||
res.redirect('/project');
|
||||
};
|
59
src/routes/test.js
Normal file
59
src/routes/test.js
Normal file
@ -0,0 +1,59 @@
|
||||
const Test = require('../models').models.Test;
|
||||
const Hardware = require('../models').models.Hardware;
|
||||
const Benchmark = require('../models').models.Benchmark;
|
||||
|
||||
// GET /test - redirects to test list
|
||||
exports.getIndex = async function(req, res) {
|
||||
res.redirect('/test/list');
|
||||
};
|
||||
|
||||
// GET /test/list - list of tests
|
||||
exports.getList = async function(req, res) {
|
||||
var tests = await Test.findAll();
|
||||
res.render('test/list', {
|
||||
tests: tests
|
||||
});
|
||||
};
|
||||
|
||||
// GET /test/:test_id - view information about a test
|
||||
exports.getView = async function(req, res) {
|
||||
var test = await Test.findAll({
|
||||
where: {
|
||||
id: req.params.test_id
|
||||
}
|
||||
});
|
||||
res.render('test/view', {
|
||||
test: test[0]
|
||||
});
|
||||
};
|
||||
|
||||
// GET /test/add - add a new test
|
||||
exports.getAdd = async function(req, res) {
|
||||
var hardware = await Hardware.findAll();
|
||||
var benchmarks = await Benchmark.findAll();
|
||||
|
||||
res.render('test/add', {
|
||||
hardware: hardware,
|
||||
benchmarks: benchmarks
|
||||
});
|
||||
};
|
||||
|
||||
// POST /test/add - add the test to the database
|
||||
exports.postAdd = async function(req, res) {
|
||||
var test = await Test.create({
|
||||
dateTag: req.body.test_date_tag,
|
||||
description: req.body.test_description,
|
||||
});
|
||||
|
||||
// add link to hardware
|
||||
let hardware = await Hardware.findByPk(req.body.test_hardware);
|
||||
test.setHardware(hardware);
|
||||
|
||||
// add links to benchmarks
|
||||
for (let b = 0; b < req.body.test_benchmarks.length; b++) {
|
||||
let benchmark = await Benchmark.findByPk(req.body.test_benchmarks[b]);
|
||||
test.addBenchmark(benchmark);
|
||||
}
|
||||
|
||||
res.redirect('/test/' + test.id);
|
||||
};
|
@ -1,9 +1,9 @@
|
||||
const Project = require('../models').models.Project;
|
||||
const Test = require('../models').models.Test;
|
||||
|
||||
// GET / - primary app dashboard
|
||||
exports.getIndex = async function(req, res) {
|
||||
var projects = await Project.findAll();
|
||||
var tests = await Test.findAll();
|
||||
res.render('index/dashboard', {
|
||||
projects: projects
|
||||
tests: tests
|
||||
});
|
||||
};
|
||||
|
Reference in New Issue
Block a user