diff --git a/index.js b/index.js index f5d8bd7..c86015a 100644 --- a/index.js +++ b/index.js @@ -105,6 +105,20 @@ app.post('/trig', async (req, res) => { res.status(200).send('Call triggered'); }); +app.post('/stop', async (req, res) => { + console.log('Stopping page for phone:', req.body.phone); + // Logic to stop the page would go here. + // For now we will just log it, as the specific asterisk command to hangup a channel depends on implementation details not provided. + // Typically it might involve 'asterisk -rx "channel request hangup "' or similar via AMI. + // Assuming we might want to run a command similar to originate but for hangup if we knew the channel. + // Since we don't have the channel ID easily available without tracking it, we might need to implement channel tracking or use a broad command. + + // Example placeholder: + // exec(`/usr/sbin/asterisk -rx "channel request hangup all"`, (error, stdout, stderr) => { ... }); + + res.status(200).send('Stop request received'); +}); + app.listen(PORT, HOST, () => { console.log(`Server running on http://${HOST}:${PORT}`); }); \ No newline at end of file diff --git a/views/index.ejs b/views/index.ejs index e280272..b8abbcc 100644 --- a/views/index.ejs +++ b/views/index.ejs @@ -61,6 +61,10 @@

Paging Console

+
@@ -148,6 +152,15 @@ body: JSON.stringify(payload) }); } + + function stopPage() { + const phoneSelect = document.getElementById('phoneSelect'); + const phone = phoneSelect.value; + fetch('/stop', { + method: 'POST', + headers: { 'Content-Type': 'application/json' } + }); + }