mirror of
https://github.com/9technologygroup/patchmon.net.git
synced 2025-11-07 07:23:22 +00:00
Made changes to the host details area to add notes
Reconfigured JWT session timeouts
This commit is contained in:
@@ -858,6 +858,7 @@ router.get(
|
||||
auto_update: true,
|
||||
created_at: true,
|
||||
host_group_id: true,
|
||||
notes: true,
|
||||
host_groups: {
|
||||
select: {
|
||||
id: true,
|
||||
@@ -1491,4 +1492,78 @@ router.patch(
|
||||
},
|
||||
);
|
||||
|
||||
// Update host notes (admin only)
|
||||
router.patch(
|
||||
"/:hostId/notes",
|
||||
authenticateToken,
|
||||
requireManageHosts,
|
||||
[
|
||||
body("notes")
|
||||
.optional()
|
||||
.isLength({ max: 1000 })
|
||||
.withMessage("Notes must be less than 1000 characters"),
|
||||
],
|
||||
async (req, res) => {
|
||||
try {
|
||||
const errors = validationResult(req);
|
||||
if (!errors.isEmpty()) {
|
||||
return res.status(400).json({ errors: errors.array() });
|
||||
}
|
||||
|
||||
const { hostId } = req.params;
|
||||
const { notes } = req.body;
|
||||
|
||||
// Check if host exists
|
||||
const existingHost = await prisma.hosts.findUnique({
|
||||
where: { id: hostId },
|
||||
});
|
||||
|
||||
if (!existingHost) {
|
||||
return res.status(404).json({ error: "Host not found" });
|
||||
}
|
||||
|
||||
// Update the notes
|
||||
const updatedHost = await prisma.hosts.update({
|
||||
where: { id: hostId },
|
||||
data: {
|
||||
notes: notes || null,
|
||||
updated_at: new Date(),
|
||||
},
|
||||
select: {
|
||||
id: true,
|
||||
friendly_name: true,
|
||||
hostname: true,
|
||||
ip: true,
|
||||
os_type: true,
|
||||
os_version: true,
|
||||
architecture: true,
|
||||
last_update: true,
|
||||
status: true,
|
||||
host_group_id: true,
|
||||
agent_version: true,
|
||||
auto_update: true,
|
||||
created_at: true,
|
||||
updated_at: true,
|
||||
notes: true,
|
||||
host_groups: {
|
||||
select: {
|
||||
id: true,
|
||||
name: true,
|
||||
color: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
res.json({
|
||||
message: "Notes updated successfully",
|
||||
host: updatedHost,
|
||||
});
|
||||
} catch (error) {
|
||||
console.error("Update notes error:", error);
|
||||
res.status(500).json({ error: "Failed to update notes" });
|
||||
}
|
||||
},
|
||||
);
|
||||
|
||||
module.exports = router;
|
||||
|
||||
Reference in New Issue
Block a user