feat: ora è possibile scorrere gli allegati e modificare i pdf, aggiunte personalizzazioni di immagini e forme per poterle richiamare più rapidamente.
This commit is contained in:
1 parent
ec1fb25d4e
commit
719fc09c66
8 files changed
+2168
-71
No files matched your search
+178
-2
@@ -146,8 +146,8 @@ router.post('/env/restore/:history_id', async (req, res) => {
|
||||
}
|
||||
});
|
||||
|
||||
// DELETE /api/config/env/history/:id — Delete a specific .env history entry
|
||||
router.delete('/env/history/:id', async (req, res) => {
|
||||
// Helper handler for deleting a specific .env history entry
|
||||
async function handleDeleteHistory(req, res) {
|
||||
try {
|
||||
const { id } = req.params;
|
||||
const operatorId = parseInt(req.headers['x-agent-id'] || '1', 10);
|
||||
@@ -181,6 +181,182 @@ router.delete('/env/history/:id', async (req, res) => {
|
||||
console.error('Error deleting .env history entry:', err);
|
||||
res.status(500).json({ error: 'Errore durante l\'eliminazione della versione dello storico', message: err.message });
|
||||
}
|
||||
}
|
||||
|
||||
// DELETE & POST /api/config/env/history/:id — Delete a specific .env history entry
|
||||
router.delete('/env/history/:id', handleDeleteHistory);
|
||||
router.post('/env/history/:id/delete', handleDeleteHistory);
|
||||
|
||||
// GET /api/config/user-signatures — Fetch all user signature images
|
||||
router.get('/user-signatures', (req, res) => {
|
||||
try {
|
||||
const operatorId = parseInt(req.headers['x-agent-id'] || '1', 10);
|
||||
const signatures = db.prepare(`
|
||||
SELECT * FROM user_signatures WHERE agent_id = ? ORDER BY id DESC
|
||||
`).all(operatorId);
|
||||
res.json(signatures);
|
||||
} catch (err) {
|
||||
console.error('Error fetching user signatures:', err);
|
||||
res.status(500).json({ error: 'Errore durante il recupero delle firme utente', message: err.message });
|
||||
}
|
||||
});
|
||||
|
||||
// POST /api/config/user-signatures — Add new user signature image
|
||||
router.post('/user-signatures', (req, res) => {
|
||||
try {
|
||||
const operatorId = parseInt(req.headers['x-agent-id'] || '1', 10);
|
||||
const { name, image_data } = req.body;
|
||||
|
||||
if (!name || !image_data) {
|
||||
return res.status(400).json({ error: 'Nome e dati immagine sono obbligatori' });
|
||||
}
|
||||
|
||||
const info = db.prepare(`
|
||||
INSERT INTO user_signatures (agent_id, name, image_data)
|
||||
VALUES (?, ?, ?)
|
||||
`).run(operatorId, name.trim(), image_data);
|
||||
|
||||
const signatures = db.prepare(`
|
||||
SELECT * FROM user_signatures WHERE agent_id = ? ORDER BY id DESC
|
||||
`).all(operatorId);
|
||||
|
||||
res.json({
|
||||
success: true,
|
||||
message: 'Immagine/Firma salvata nel database con successo!',
|
||||
id: info.lastInsertRowid,
|
||||
signatures
|
||||
});
|
||||
} catch (err) {
|
||||
console.error('Error saving user signature:', err);
|
||||
res.status(500).json({ error: 'Errore durante il salvataggio della firma', message: err.message });
|
||||
}
|
||||
});
|
||||
|
||||
// DELETE /api/config/user-signatures/:id — Delete user signature image
|
||||
router.delete('/user-signatures/:id', (req, res) => {
|
||||
try {
|
||||
const operatorId = parseInt(req.headers['x-agent-id'] || '1', 10);
|
||||
const { id } = req.params;
|
||||
|
||||
db.prepare(`DELETE FROM user_signatures WHERE id = ? AND agent_id = ?`).run(id, operatorId);
|
||||
|
||||
const signatures = db.prepare(`
|
||||
SELECT * FROM user_signatures WHERE agent_id = ? ORDER BY id DESC
|
||||
`).all(operatorId);
|
||||
|
||||
res.json({
|
||||
success: true,
|
||||
message: 'Firma eliminata con successo!',
|
||||
signatures
|
||||
});
|
||||
} catch (err) {
|
||||
console.error('Error deleting user signature:', err);
|
||||
res.status(500).json({ error: 'Errore durante l\'eliminazione della firma', message: err.message });
|
||||
}
|
||||
});
|
||||
|
||||
// GET /api/config/user-shapes — List custom user shapes
|
||||
router.get('/user-shapes', (req, res) => {
|
||||
try {
|
||||
const operatorId = parseInt(req.headers['x-agent-id'] || '1', 10);
|
||||
const shapes = db.prepare(`
|
||||
SELECT * FROM user_shapes WHERE agent_id = ? ORDER BY id DESC
|
||||
`).all(operatorId);
|
||||
res.json(shapes);
|
||||
} catch (err) {
|
||||
console.error('Error fetching user shapes:', err);
|
||||
res.status(500).json({ error: 'Errore durante il recupero delle forme utente', message: err.message });
|
||||
}
|
||||
});
|
||||
|
||||
// POST /api/config/user-shapes — Create a new custom shape
|
||||
router.post('/user-shapes', (req, res) => {
|
||||
try {
|
||||
const operatorId = parseInt(req.headers['x-agent-id'] || '1', 10);
|
||||
const { name, shape_type, fill_color, border_color, border_width, is_favorite } = req.body;
|
||||
|
||||
if (!name) {
|
||||
return res.status(400).json({ error: 'Il nome della forma è obbligatorio' });
|
||||
}
|
||||
|
||||
const info = db.prepare(`
|
||||
INSERT INTO user_shapes (agent_id, name, shape_type, fill_color, border_color, border_width, is_favorite)
|
||||
VALUES (?, ?, ?, ?, ?, ?, ?)
|
||||
`).run(
|
||||
operatorId,
|
||||
name.trim(),
|
||||
shape_type || 'rectangle',
|
||||
fill_color || '#3b82f6',
|
||||
border_color || '#1e3a8a',
|
||||
parseInt(border_width || 3, 10),
|
||||
is_favorite !== undefined ? (is_favorite ? 1 : 0) : 1
|
||||
);
|
||||
|
||||
const shapes = db.prepare(`
|
||||
SELECT * FROM user_shapes WHERE agent_id = ? ORDER BY id DESC
|
||||
`).all(operatorId);
|
||||
|
||||
res.json({
|
||||
success: true,
|
||||
message: 'Forma salvata nei preferiti con successo!',
|
||||
id: info.lastInsertRowid,
|
||||
shapes
|
||||
});
|
||||
} catch (err) {
|
||||
console.error('Error saving user shape:', err);
|
||||
res.status(500).json({ error: 'Errore durante il salvataggio della forma', message: err.message });
|
||||
}
|
||||
});
|
||||
|
||||
// PUT /api/config/user-shapes/:id/toggle-favorite — Toggle favorite status
|
||||
router.put('/user-shapes/:id/toggle-favorite', (req, res) => {
|
||||
try {
|
||||
const operatorId = parseInt(req.headers['x-agent-id'] || '1', 10);
|
||||
const { id } = req.params;
|
||||
|
||||
const shape = db.prepare(`SELECT * FROM user_shapes WHERE id = ? AND agent_id = ?`).get(id, operatorId);
|
||||
if (!shape) {
|
||||
return res.status(404).json({ error: 'Forma non trovata' });
|
||||
}
|
||||
|
||||
const newFav = shape.is_favorite ? 0 : 1;
|
||||
db.prepare(`UPDATE user_shapes SET is_favorite = ? WHERE id = ? AND agent_id = ?`).run(newFav, id, operatorId);
|
||||
|
||||
const shapes = db.prepare(`
|
||||
SELECT * FROM user_shapes WHERE agent_id = ? ORDER BY id DESC
|
||||
`).all(operatorId);
|
||||
|
||||
res.json({
|
||||
success: true,
|
||||
shapes
|
||||
});
|
||||
} catch (err) {
|
||||
console.error('Error toggling shape favorite status:', err);
|
||||
res.status(500).json({ error: 'Errore durante l\'aggiornamento dei preferiti', message: err.message });
|
||||
}
|
||||
});
|
||||
|
||||
// DELETE /api/config/user-shapes/:id — Delete a custom shape
|
||||
router.delete('/user-shapes/:id', (req, res) => {
|
||||
try {
|
||||
const operatorId = parseInt(req.headers['x-agent-id'] || '1', 10);
|
||||
const { id } = req.params;
|
||||
|
||||
db.prepare(`DELETE FROM user_shapes WHERE id = ? AND agent_id = ?`).run(id, operatorId);
|
||||
|
||||
const shapes = db.prepare(`
|
||||
SELECT * FROM user_shapes WHERE agent_id = ? ORDER BY id DESC
|
||||
`).all(operatorId);
|
||||
|
||||
res.json({
|
||||
success: true,
|
||||
message: 'Forma eliminata con successo!',
|
||||
shapes
|
||||
});
|
||||
} catch (err) {
|
||||
console.error('Error deleting user shape:', err);
|
||||
res.status(500).json({ error: 'Errore durante l\'eliminazione della forma', message: err.message });
|
||||
}
|
||||
});
|
||||
|
||||
module.exports = router;
|
||||
Reference in new issue
Block a user