fix: ora il timer del tempo consuntivato si aggiorna ogni 60 secondi.
This commit is contained in:
1 parent
a36e501596
commit
37c5f0c500
3 files changed
+50
-1
No files matched your search
@@ -236,6 +236,37 @@ router.get('/settings', (req, res) => {
|
||||
}
|
||||
});
|
||||
|
||||
// POST /api/dashboard/settings — Save settings for the agent
|
||||
router.post('/settings', (req, res) => {
|
||||
const activeAgentId = parseInt(req.headers['x-agent-id'], 10) || 1;
|
||||
const { preview_limit, tickets_per_page } = req.body || {};
|
||||
|
||||
try {
|
||||
const existing = db.prepare("SELECT agent_id, preview_limit, tickets_per_page FROM agent_settings WHERE agent_id = ?").get(activeAgentId);
|
||||
|
||||
const newPreviewLimit = preview_limit !== undefined ? parseInt(preview_limit, 10) : (existing ? existing.preview_limit : 10);
|
||||
const newTicketsPerPage = tickets_per_page !== undefined ? parseInt(tickets_per_page, 10) : (existing ? existing.tickets_per_page : 50);
|
||||
|
||||
if (existing) {
|
||||
db.prepare(`
|
||||
UPDATE agent_settings
|
||||
SET preview_limit = ?, tickets_per_page = ?
|
||||
WHERE agent_id = ?
|
||||
`).run(newPreviewLimit, newTicketsPerPage, activeAgentId);
|
||||
} else {
|
||||
db.prepare(`
|
||||
INSERT INTO agent_settings (agent_id, preview_limit, tickets_per_page)
|
||||
VALUES (?, ?, ?)
|
||||
`).run(activeAgentId, newPreviewLimit, newTicketsPerPage);
|
||||
}
|
||||
|
||||
res.json({ success: true, preview_limit: newPreviewLimit, tickets_per_page: newTicketsPerPage });
|
||||
} catch (err) {
|
||||
console.error('Error saving agent settings:', err);
|
||||
res.status(500).json({ error: err.message });
|
||||
}
|
||||
});
|
||||
|
||||
// GET /api/dashboard/chart-lines
|
||||
router.get('/chart-lines', (req, res) => {
|
||||
try {
|
||||
|
||||
Reference in new issue
Block a user