fix
All checks were successful
Build SMS Gateway / Build image (push) Successful in 11s

This commit is contained in:
2026-01-19 21:25:48 +07:00
parent 535ea8356f
commit 6062b037b7
2 changed files with 146 additions and 138 deletions

View File

@@ -1 +1 @@
0.2.1 0.2.2

View File

@@ -1,153 +1,161 @@
<!DOCTYPE html> <!doctype html>
<html lang="en"> <html lang="en">
<head> <head>
<meta charset="UTF-8"> <meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>SMS OTP Gateway</title> <title>SMS OTP Gateway</title>
<style> <style>
* { * {
margin: 0; margin: 0;
padding: 0; padding: 0;
box-sizing: border-box; box-sizing: border-box;
} }
body { body {
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
background: #0a1628; background: #0a1628;
color: #e0e6ed; color: #e0e6ed;
min-height: 100vh; min-height: 100vh;
padding: 20px; padding: 20px;
} }
.container { .container {
max-width: 900px; max-width: 900px;
margin: 0 auto; margin: 0 auto;
} }
h1 { h1 {
color: #4a9eff; color: #4a9eff;
margin-bottom: 20px; margin-bottom: 20px;
font-weight: 300; font-weight: 300;
border-bottom: 1px solid #1e3a5f; border-bottom: 1px solid #1e3a5f;
padding-bottom: 10px; padding-bottom: 10px;
} }
.controls { .controls {
margin-bottom: 20px; margin-bottom: 20px;
display: flex; display: flex;
gap: 10px; gap: 10px;
} }
button { button {
background: #1e3a5f; background: #1e3a5f;
color: #4a9eff; color: #4a9eff;
border: 1px solid #2d4a6f; border: 1px solid #2d4a6f;
padding: 10px 20px; padding: 10px 20px;
cursor: pointer; cursor: pointer;
font-size: 14px; font-size: 14px;
transition: all 0.2s; transition: all 0.2s;
} }
button:hover { button:hover {
background: #2d4a6f; background: #2d4a6f;
border-color: #4a9eff; border-color: #4a9eff;
} }
button.danger { button.danger {
color: #ff6b6b; color: #ff6b6b;
border-color: #5f1e1e; border-color: #5f1e1e;
} }
button.danger:hover { button.danger:hover {
background: #3f1e1e; background: #3f1e1e;
border-color: #ff6b6b; border-color: #ff6b6b;
} }
.messages { .messages {
background: #0d1f35; background: #0d1f35;
border: 1px solid #1e3a5f; border: 1px solid #1e3a5f;
padding: 15px; padding: 15px;
min-height: 400px; min-height: 400px;
max-height: 600px; max-height: 600px;
overflow-y: auto; overflow-y: auto;
} }
.message { .message {
padding: 10px; padding: 10px;
border-bottom: 1px solid #1e3a5f; border-bottom: 1px solid #1e3a5f;
font-family: monospace; font-family: monospace;
font-size: 13px; font-size: 13px;
} }
.message:last-child { .message:last-child {
border-bottom: none; border-bottom: none;
} }
.message .time { .message .time {
color: #6b8aaa; color: #6b8aaa;
} }
.message .phone { .message .phone {
color: #4a9eff; color: #4a9eff;
} }
.message .text { .message .text {
color: #7dcea0; color: #7dcea0;
} }
.empty { .empty {
color: #4a6a8a; color: #4a6a8a;
text-align: center; text-align: center;
padding: 40px; padding: 40px;
} }
.status { .status {
margin-top: 10px; margin-top: 10px;
padding: 10px; padding: 10px;
font-size: 12px; font-size: 12px;
color: #6b8aaa; color: #6b8aaa;
} }
</style> </style>
</head> </head>
<body> <body>
<div class="container"> <div class="container">
<h1>SMS OTP Gateway</h1> <h1>SMS OTP Gateway</h1>
<div class="controls"> <div class="controls">
<button onclick="loadMessages()">Refresh</button> <button onclick="loadMessages()">Refresh</button>
<button class="danger" onclick="clearMessages()">Clear All</button> <button class="danger" onclick="clearMessages()">Clear All</button>
</div>
<div class="messages" id="messages">
<div class="empty">Loading...</div>
</div>
<div class="status" id="status"></div>
</div> </div>
<div class="messages" id="messages">
<div class="empty">Loading...</div>
</div>
<div class="status" id="status"></div>
</div>
<script> <script>
async function loadMessages() { // Get base path from current URL
try { const basePath = window.location.pathname.replace(/\/$/, "");
const res = await fetch('/view-all-sms');
const data = await res.json();
const container = document.getElementById('messages');
if (data.messages.length === 0) { async function loadMessages() {
container.innerHTML = '<div class="empty">No messages yet</div>'; try {
} else { const res = await fetch(basePath + "/view-all-sms");
container.innerHTML = data.messages.map(m => ` const data = await res.json();
const container = document.getElementById("messages");
if (data.messages.length === 0) {
container.innerHTML = '<div class="empty">No messages yet</div>';
} else {
container.innerHTML = data.messages
.map(
(m) => `
<div class="message"> <div class="message">
<span class="time">[${m.timestamp}]</span> <span class="time">[${m.timestamp}]</span>
<span class="phone">${m.phone}</span>: <span class="phone">${m.phone}</span>:
<span class="text">${escapeHtml(m.message)}</span> <span class="text">${escapeHtml(m.message)}</span>
</div> </div>
`).join(''); `,
)
.join("");
}
document.getElementById("status").textContent =
`Last updated: ${new Date().toLocaleTimeString()} | Total: ${data.messages.length} messages`;
} catch (err) {
document.getElementById("messages").innerHTML = '<div class="empty">Error loading messages</div>';
} }
document.getElementById('status').textContent = `Last updated: ${new Date().toLocaleTimeString()} | Total: ${data.messages.length} messages`;
} catch (err) {
document.getElementById('messages').innerHTML = '<div class="empty">Error loading messages</div>';
} }
}
async function clearMessages() { async function clearMessages() {
try { try {
await fetch('/clear-all-sms', { method: 'POST' }); await fetch(basePath + "/clear-all-sms", { method: "POST" });
loadMessages(); loadMessages();
} catch (err) { } catch (err) {
alert('Error clearing messages'); alert("Error clearing messages");
}
} }
}
function escapeHtml(text) { function escapeHtml(text) {
const div = document.createElement('div'); const div = document.createElement("div");
div.textContent = text; div.textContent = text;
return div.innerHTML; return div.innerHTML;
} }
loadMessages(); loadMessages();
setInterval(loadMessages, 5000); setInterval(loadMessages, 5000);
</script> </script>
</body> </body>
</html> </html>