Files
sms-otp-gateway/public/index.html
Vassiliy Yegorov d71d83a044
All checks were successful
Build SMS Gateway / Build image (push) Successful in 16s
fix front
2026-02-02 07:20:37 +07:00

212 lines
5.6 KiB
HTML

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