Feature Request Seite für Features, Bugs und Designvorschläge
This commit is contained in:
parent
8a54feeea4
commit
a2c5699629
41
app.js
41
app.js
|
@ -1103,6 +1103,47 @@ app.post("/deleteMember", requireAuth, async (req, res) => {
|
|||
res.redirect("/teilnehmer");
|
||||
});
|
||||
|
||||
app.get("/feature", requireAuth, async (req, res) => {
|
||||
try {
|
||||
const featureResult = await pool.query(
|
||||
"SELECT * FROM features ORDER BY datetime DESC;"
|
||||
);
|
||||
const features = featureResult.rows;
|
||||
res.render("feature", { features, session: req.session });
|
||||
} catch (error) {
|
||||
console.error("Error:", error);
|
||||
req.session.message = ["Error", error, "error"];
|
||||
res.redirect("/feature");
|
||||
}
|
||||
});
|
||||
|
||||
app.post("/feature", requireAdmin, async (req, res) => {
|
||||
const { title, body, type, urgency, user } = req.body;
|
||||
console.log(user);
|
||||
const userResult = await pool.query(
|
||||
"SELECT id FROM users WHERE username = $1",
|
||||
[user]
|
||||
);
|
||||
console.log(userResult.rows[0].id);
|
||||
try {
|
||||
await pool.query(
|
||||
"INSERT INTO features (title, body, type, urgency, fid_user) VALUES ($1, $2, $3, $4, $5);",
|
||||
[title, body, type, urgency, userResult.rows[0].id]
|
||||
);
|
||||
|
||||
const featureResult = await pool.query(
|
||||
"SELECT * FROM features ORDER BY datetime DESC;"
|
||||
);
|
||||
const features = featureResult.rows;
|
||||
req.session.message = ["Erfolg", "Feature-request gespeichert", "success"];
|
||||
res.render("feature", { features, session: req.session });
|
||||
} catch (error) {
|
||||
console.error("Error:", error);
|
||||
req.session.message = ["Error", error, "error"];
|
||||
res.render("feature", { features, session: req.session });
|
||||
}
|
||||
});
|
||||
|
||||
const server = app.listen(port, "0.0.0.0", () => {
|
||||
log.Info(`Server is running on ${process.env.HOST}:${port}/`);
|
||||
});
|
||||
|
|
|
@ -45,6 +45,9 @@
|
|||
<li class="nav-item">
|
||||
<a class="nav-link" href="/profile">Profil</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href="/feature">Features</a>
|
||||
</li>
|
||||
|
||||
<% } else {%>
|
||||
<li class="nav-item">
|
||||
|
@ -55,9 +58,6 @@
|
|||
<li class="nav-item">
|
||||
<a class="nav-link" href="/spiele">Spiele</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href="/changelog">Changelog</a>
|
||||
</li>
|
||||
<% if (session && session.role === 'admin') { %>
|
||||
<li class="nav-item"><a class="nav-link" href="/admin">Admin</a></li>
|
||||
<% } %>
|
||||
|
|
Loading…
Reference in New Issue