Update IP fixed

This commit is contained in:
ecki
2026-03-28 15:04:30 +01:00
parent 013be5c201
commit 162253c753
3 changed files with 26 additions and 18 deletions
+25
View File
@@ -1,4 +1,6 @@
const pool = require("../db");
const db = require("../db");
/* LIST IPs for resource */
exports.getByResource = async (req, res) => {
@@ -31,3 +33,26 @@ exports.remove = async (req, res) => {
res.json({ message: "IP deleted" });
};
exports.update = async (req, res) => {
try{
const {ip, type, comment} = req.body;
await db.query(
"UPDATE resource_ips SET ip=?, type=?, comment=? WHERE id=?",
[ip, type, comment, req.params.id]
);
res.json({success:true});
}catch(e){
console.error("UPDATE IP error:", e);
res.status(500).json({error:"DB error"});
}
};
-1
View File
@@ -63,7 +63,6 @@ window.loadResources = async function(){
${ips}
<br>
<button type="button" onclick="openIPManager(${r.id})">IPs</button>
<button onclick="openIPManager(${r.id})">IPs</button>
</td>
<td>
+1 -17
View File
@@ -11,27 +11,11 @@ router.post("/resources/:id/ips", controller.create);
/* delete IP */
router.delete("/ips/:id", controller.remove);
router.put("/ips/:id", async (req, res) => {
try{
router.put("/ips/:id", controller.update);
const {ip, type, comment} = req.body
await db.query(
"UPDATE resource_ips SET ip=?, type=?, comment=? WHERE id=?",
[ip, type, comment, req.params.id]
)
res.json({success:true})
}catch(e){
console.error("UPDATE IP error:", e)
res.status(500).json({error:"DB error"})
}
})
module.exports = router;