Ordering
This commit is contained in:
32
server.cjs
32
server.cjs
@@ -199,7 +199,7 @@ app.get("/trigger/api/links", async (req, res) => {
|
|||||||
|
|
||||||
app.post("/trigger/api/links", async (req, res) => {
|
app.post("/trigger/api/links", async (req, res) => {
|
||||||
const conn = await pool.getConnection();
|
const conn = await pool.getConnection();
|
||||||
const query = `INSERT INTO trigger_database.links (name, url, category) VALUES ('${sqlEscape(req.body.name)}', '${sqlEscape(req.body.url)}', '${sqlEscape(req.body.category)}')`;
|
const query = `INSERT INTO trigger_database.links (name, url, category, \`index\`) VALUES ('${sqlEscape(req.body.name)}', '${sqlEscape(req.body.url)}', '${sqlEscape(req.body.category)}', ${req.body.index});`;
|
||||||
conn
|
conn
|
||||||
.query(query)
|
.query(query)
|
||||||
.then((rows) => {
|
.then((rows) => {
|
||||||
@@ -416,7 +416,7 @@ app.post("/trigger/api/categories", async (req, res) => {
|
|||||||
});
|
});
|
||||||
conn.end();
|
conn.end();
|
||||||
conn = await pool.getConnection();
|
conn = await pool.getConnection();
|
||||||
query = `INSERT INTO trigger_database.linkCategories (categoryName, categoryIndex, filterName) VALUES ('${sqlEscape(req.body.categoryName)}','${categoryIndex || 0}','${sqlEscape(req.body.filterName)}')`;
|
query = `INSERT INTO trigger_database.linkCategories (categoryName, categoryIndex, filterName) VALUES ('${sqlEscape(req.body.categoryName)}','${req.body.categoryIndex || 0}','${sqlEscape(req.body.filterName)}')`;
|
||||||
conn.query(query).then((rows) => {
|
conn.query(query).then((rows) => {
|
||||||
categoryIndex = rows.length;
|
categoryIndex = rows.length;
|
||||||
res.status(200).send({ status: "success" });
|
res.status(200).send({ status: "success" });
|
||||||
@@ -452,6 +452,34 @@ app.delete("/trigger/api/categories", async (req, res) => {
|
|||||||
conn.end();
|
conn.end();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
app.patch("/trigger/api/categoryOrder", async (req, res) => {
|
||||||
|
const conn = await pool.getConnection();
|
||||||
|
req.body.map((category) => {
|
||||||
|
conn
|
||||||
|
.query("UPDATE trigger_database.linkCategories SET categoryIndex = ? where id IN (?)", [category.index, category.id])
|
||||||
|
.then((rows) => {
|
||||||
|
res.status(200);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
res.send({ status: "success" });
|
||||||
|
conn.end();
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
app.patch("/trigger/api/linkOrder", async (req, res) => {
|
||||||
|
const conn = await pool.getConnection();
|
||||||
|
req.body.map((link) => {
|
||||||
|
conn
|
||||||
|
.query("UPDATE trigger_database.links SET \`index\` = ? where id IN (?)", [link.index, link.id])
|
||||||
|
.then((rows) => {
|
||||||
|
res.status(200);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
res.send({ status: "success" });
|
||||||
|
conn.end();
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
app.get("/trigger/api/wolClients", async (req, res) => {
|
app.get("/trigger/api/wolClients", async (req, res) => {
|
||||||
const conn = await pool.getConnection();
|
const conn = await pool.getConnection();
|
||||||
const query = "SELECT * from trigger_database.wolClients;";
|
const query = "SELECT * from trigger_database.wolClients;";
|
||||||
|
|||||||
Reference in New Issue
Block a user