| Server IP : 3.111.61.48 / Your IP : 216.73.216.67 Web Server : Apache System : Linux ip-10-0-5-176 6.8.0-1057-aws #60~22.04.1-Ubuntu SMP Wed May 27 08:16:59 UTC 2026 x86_64 User : ubuntu ( 1000) PHP Version : 8.2.31 Disable Function : exec,passthru,shell_exec,system MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : ON Directory : /var/www/vhost/itmtrsrv.arukustech.com/public/ |
Upload File : |
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Admin Panel - Server Monitor</title>
<link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0/css/all.min.css" rel="stylesheet">
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap" rel="stylesheet">
<style>
:root {
--primary: #2563eb; /* Bright blue from Inventory system */
--primary-hover: #1d4ed8;
--danger: #ef4444;
--bg: #f1f5f9;
--sidebar: #0f172a;
--header-bg: #1e293b;
--card: #ffffff;
--text-main: #1e293b;
--text-muted: #94a3b8;
--border: #e2e8f0;
--success: #10b981;
}
body {
font-family: 'Inter', system-ui, sans-serif;
background-color: var(--bg);
color: var(--text-main);
margin: 0;
display: flex;
min-height: 100vh;
overflow-x: hidden;
}
/* --- FIXED HEADER --- */
header {
position: fixed;
top: 0;
left: 0;
right: 0;
height: 60px;
background: var(--header-bg);
color: white;
padding: 0 2.5rem;
display: flex;
justify-content: space-between;
align-items: center;
z-index: 1100;
box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}
header h2 { margin: 0; font-size: 1.1rem; font-weight: 600; display: flex; align-items: center; gap: 10px; }
/* --- CATEGORIZED SIDEBAR --- */
.sidebar {
width: 260px;
height: 100vh;
background: linear-gradient(180deg,#111827,#1f2937);
color: white;
display: flex;
flex-direction: column;
justify-content: space-between;
position: fixed;
top: 0;
left: 0;
overflow-y: auto;
z-index: 1000;
padding-top: 0;
transition: transform 0.3s ease;
box-shadow: 3px 5px 4px rgba(0,0,0,.2);
}
.nav-category {
padding: 24px 24px 8px;
font-size: 0.7rem;
text-transform: uppercase;
letter-spacing: 0.1em;
color: var(--text-muted);
font-weight: 700;
}
.nav-menu { flex-grow: 1; }
.nav-item {
padding: 12px 20px;
margin: 4px 16px;
display: flex;
align-items: center;
gap: 12px;
color: #94a3b8;
text-decoration: none;
border-radius: 8px;
transition: all 0.2s;
font-weight: 500;
font-size: 0.95rem;
cursor: pointer;
}
.nav-item i { width: 20px; text-align: center; font-size: 1.1rem; }
.nav-item:hover { background: rgba(255,255,255,0.05); color: white; }
.nav-item.active {
background: var(--primary);
color: white;
box-shadow: 0 4px 12px rgba(37, 99, 235, 0.3);
}
/* --- MAIN CONTENT --- */
.main-content {
margin-left: 260px;
margin-top: 60px; /* Offset for Header */
flex-grow: 1;
padding: 40px;
padding-bottom: 80px;
width: calc(100% - 260px);
box-sizing: border-box;
}
/* --- FIXED FOOTER --- */
footer {
position: fixed;
bottom: 0;
left: 260px; /* for sidebar width */
right: 0;
height: 45px;
background: white;
border-top: 1px solid var(--border);
display: flex;
align-items: center;
justify-content: flex-end; /* ?? key change */
padding: 0 40px;
font-size: 0.8rem;
color: #64748b;
z-index: 1050;
}
.card {
background: var(--card);
border-radius: 12px;
padding: 24px;
box-shadow: 0 1px 3px rgba(0,0,0,0.05);
margin-bottom: 30px;
border: 1px solid var(--border);
}
.card h3 {
margin-top: 0;
margin-bottom: 20px;
font-size: 0.8rem;
color: var(--text-muted);
text-transform: uppercase;
letter-spacing: 0.05em;
}
/* --- UI COMPONENTS --- */
.form-group { display: flex; gap: 12px; flex-wrap: wrap; }
input {
padding: 12px 16px;
border: 1px solid var(--border);
border-radius: 8px;
outline: none;
flex: 1;
min-width: 200px;
font-size: 0.9rem;
}
button {
padding: 12px 20px;
border-radius: 8px;
border: none;
font-weight: 600;
cursor: pointer;
display: flex;
align-items: center;
gap: 8px;
transition: 0.2s;
}
.btn-add { background: var(--primary); color: white; }
.btn-add:hover { background: var(--primary-hover); }
.btn-delete { background: #fee2e2; color: var(--danger); font-size: 0.85rem; padding: 8px 12px; }
.btn-delete:hover { background: #fecaca; }
.table-container { overflow: hidden; border-radius: 12px; border: 1px solid var(--border); }
table { width: 100%; border-collapse: collapse; background: white; }
th { background: #f8fafc; padding: 16px; text-align: left; font-size: 0.75rem; color: var(--text-muted); text-transform: uppercase; }
td { padding: 16px; border-bottom: 1px solid var(--border); font-size: 0.9rem; }
.status-pill {
padding: 4px 10px;
border-radius: 6px;
font-size: 0.75rem;
font-weight: 700;
}
.status-active { background: #fef2f2; color: var(--danger); }
.status-resolved { background: #ecfdf5; color: var(--success); }
#section-alerts { display: none; }
@media (max-width: 768px) {
header {
padding: 0 12px;
height: 60px;
}
header h2 {
font-size: 1rem;
display: flex;
align-items: center;
}
.sidebar {
width: 250px !important;
height: 100vh;
transform: translateX(-100%);
transition: transform 0.3s ease;
z-index: 1200;
top: 0;
left: 0;
}
.sidebar.active {
transform: translateX(0);
}
.nav-item {
display: flex;
align-items: center;
justify-content: flex-start;
padding: 12px 18px;
margin: 6px 12px;
}
.nav-item i {
width: 20px;
margin-right: 10px;
}
.nav-item span {
display: inline !important;
}
.nav-category {
display: block !important;
}
.main-content {
margin-left: 0 !important;
width: 100% !important;
padding: 80px 15px 80px;
}
.form-group {
flex-direction: column;
}
input,
button {
width: 100%;
box-sizing: border-box;
}
.table-container {
overflow-x: auto;
}
table {
min-width: 850px;
}
footer {
left: 0 !important;
justify-content: center;
padding: 0 10px;
font-size: 0.75rem;
}
}
</style>
</head>
<body>
<header>
<h2>
<i class="fas fa-bars menu-toggle" onclick="toggleSidebar()" style="cursor:pointer;margin-right:10px;"></i>
<i class="fas fa-microchip"></i>
Server Admin Panel
</h2>
<div style="font-size: 0.85rem; color: #cbd5e1;"><i class="fas fa-user-shield"></i> Administrator Mode</div>
</header>
<nav class="sidebar">
<!-- Top Section -->
<div>
<!-- Logo / Brand -->
<div style="padding:28px 24px;border-bottom:1px solid rgba(255,255,255,0.08);">
<h2 style="margin:0;font-size:24px;font-weight:700;color:#ffffff;letter-spacing:0.5px;">
<i class="fas fa-network-wired" style="color:#60a5fa;"></i>
InfraPanel
</h2>
<p style="margin:8px 0 0;color:#9ca3af;font-size:13px;">
Infrastructure Monitoring
</p>
</div>
<!-- Navigation -->
<div style="padding:20px 14px;">
<!-- Main -->
<div style="margin-bottom:10px;padding:0 12px;color:#6b7280;font-size:11px;font-weight:700;text-transform:uppercase;letter-spacing:1px;">
Main
</div>
<a href="index.html"
style="display:flex;align-items:center;gap:14px;padding:14px 16px;margin-bottom:8px;border-radius:14px;background:linear-gradient(135deg,#2563eb,#3b82f6);color:#fff;text-decoration:none;font-weight:600;box-shadow:0 6px 18px rgba(37,99,235,0.35);">
<i class="fas fa-th-large" style="font-size:18px;"></i>
<span>Dashboard</span>
</a>
<!-- Operations -->
<div style="margin:22px 0 10px;padding:0 12px;color:#6b7280;font-size:11px;font-weight:700;text-transform:uppercase;letter-spacing:1px;">
Operations
</div>
<a href="admin.html"
class="admin-only"
style="display:flex;align-items:center;gap:14px;padding:13px 16px;margin-bottom:8px;border-radius:14px;color:#d1d5db;text-decoration:none;font-weight:500;transition:0.3s;background:rgba(255,255,255,0.03);">
<i class="fas fa-server" style="font-size:17px;color:#60a5fa;"></i>
<span>Manage Servers</span>
</a>
<a href="user.html"
class="admin-only"
style="display:flex;align-items:center;gap:14px;padding:13px 16px;margin-bottom:8px;border-radius:14px;color:#d1d5db;text-decoration:none;font-weight:500;transition:0.3s;background:rgba(255,255,255,0.03);">
<i class="fas fa-users-cog" style="font-size:17px;color:#34d399;"></i>
<span>User Management</span>
</a>
<!-- Reports -->
<div style="margin:22px 0 10px;padding:0 12px;color:#6b7280;font-size:11px;font-weight:700;text-transform:uppercase;letter-spacing:1px;">
Reports
</div>
<a href="alerts.html"
class="admin-only"
style="display:flex;align-items:center;gap:14px;padding:13px 16px;margin-bottom:8px;border-radius:14px;color:#d1d5db;text-decoration:none;font-weight:500;background:rgba(255,255,255,0.03);">
<i class="fas fa-history" style="font-size:17px;color:#fbbf24;"></i>
<span>Alert History</span>
</a>
<a href="reports.html"
class="admin-only"
style="display:flex;align-items:center;gap:14px;padding:13px 16px;margin-bottom:8px;border-radius:14px;color:#d1d5db;text-decoration:none;font-weight:500;background:rgba(255,255,255,0.03);">
<i class="fas fa-chart-line" style="font-size:17px;color:#c084fc;"></i>
<span>Reports</span>
</a>
</div>
</div>
<!-- Bottom Logout -->
<div style="padding:18px;border-top:1px solid rgba(255,255,255,0.08);">
<a href="#"
onclick="logout()"
style="display:flex;align-items:center;gap:14px;padding:14px 16px;border-radius:14px;background:rgba(239,68,68,0.12);color:#f87171;text-decoration:none;font-weight:600;">
<i class="fas fa-sign-out-alt"></i>
<span>Logout</span>
</a>
</div>
</nav>
<div class="main-content">
<div id="section-servers">
<h2 style="margin-top:0; margin-bottom: 25px;">Infrastructure Management</h2>
<div class="card">
<h3>Register New Instance</h3>
<div class="form-group">
<input type="text" id="server_name" placeholder="Server Name">
<input type="text" id="project" placeholder="Project Name">
<input type="text" id="environment" placeholder="Environment (e.g. Prod)">
<button class="btn-add" onclick="addServer()">
<i class="fas fa-plus"></i> Add Server
</button>
</div>
<div id="newKey" style="margin-top:15px; display:none; padding:15px; background:#f0f9ff; border: 1px solid #bae6fd; border-radius:8px; color:#0369a1;"></div>
</div>
<div class="card">
<h3>Active Server Inventory</h3>
<div class="table-container">
<table>
<thead>
<tr>
<th>ID</th>
<th>Instance Name</th>
<th>Project</th>
<th>Environment</th>
<th style="text-align: right;">Action</th>
</tr>
</thead>
<tbody id="serverTable"></tbody>
</table>
</div>
</div>
</div>
<div id="section-alerts">
<h2 style="margin-top:0; margin-bottom: 25px;">Alert History Logs</h2>
<div class="card">
<h3>System Incident Reports</h3>
<div class="table-container">
<table>
<thead>
<tr>
<th>Server</th>
<th>Type</th>
<th>Message</th>
<th>Status</th>
<th>Last Notified</th>
</tr>
</thead>
<tbody id="alertTable"></tbody>
</table>
</div>
</div>
</div>
</div>
<footer>
© 2026 | Designed by <strong>Company Pvt. Ltd.</strong>
</footer>
<script>
// --- 1. STRICT ROLE CHECK ---
const token = localStorage.getItem("token");
if (!token) {
window.location.href = "login.html";
} else {
try {
const payload = JSON.parse(atob(token.split('.')[1]));
if (payload.role !== "Admin") {
alert("Access Denied: You do not have administrator privileges.");
window.location.href = "index.html";
}
} catch (e) {
console.error("Auth Error", e);
window.location.href = "login.html";
}
}
function toggleSidebar() {
document.querySelector(".sidebar").classList.toggle("active");
}
function logout() {
localStorage.removeItem("token");
window.location.href = "login.html";
}
// Toggle between Sidebar sections
function showSection(section) {
document.getElementById('section-servers').style.display = section === 'servers' ? 'block' : 'none';
document.getElementById('section-alerts').style.display = section === 'alerts' ? 'block' : 'none';
document.getElementById('nav-servers').classList.toggle('active', section === 'servers');
document.getElementById('nav-alerts').classList.toggle('active', section === 'alerts');
if(section === 'alerts') loadAlerts();
}
async function loadServers() {
try {
const response = await fetch('/api/v1/servers', {
headers: { 'Authorization': 'Bearer ' + token }
});
const data = await response.json();
const table = document.getElementById("serverTable");
table.innerHTML = "";
data.forEach(server => {
table.innerHTML += `
<tr>
<td><span style="color:#94a3b8">#${server.id}</span></td>
<td><strong>${server.server_name}</strong></td>
<td>${server.project ?? '�'}</td>
<td><span class="status-pill" style="background:#f1f5f9; color:#475569">${server.environment ?? 'N/A'}</span></td>
<td style="text-align: right;">
<button class="btn-delete" onclick="deleteServer(${server.id})"><i class="fas fa-trash-alt"></i></button>
</td>
</tr>`;
});
} catch (e) { console.error("Load servers failed", e); }
}
async function loadAlerts() {
try {
const response = await fetch('/api/v1/admin/alerts', {
headers: { 'Authorization': 'Bearer ' + token }
});
if (response.status === 401) return logout();
const alerts = await response.json();
const table = document.getElementById("alertTable");
table.innerHTML = "";
alerts.forEach(a => {
table.innerHTML += `
<tr>
<td><strong>${a.server_name}</strong></td>
<td><span style="font-weight:600; color:#4338ca">${a.alert_type}</span></td>
<td style="color:#64748b">${a.message}</td>
<td>
<span class="status-pill ${a.is_active ? 'status-active' : 'status-resolved'}">
${a.is_active ? '? ACTIVE' : '? RESOLVED'}
</span>
</td>
<td style="font-size:0.8rem; color:#94a3b8">${a.last_notified_at ?? '-'}</td>
</tr>`;
});
} catch (e) { console.error("Load alerts failed", e); }
}
async function addServer() {
const server_name = document.getElementById("server_name").value;
const project = document.getElementById("project").value;
const environment = document.getElementById("environment").value;
if(!server_name) return alert("Server name is required");
const response = await fetch('/api/v1/admin/add-server', {
method: 'POST',
headers: { 'Content-Type': 'application/json', 'Authorization': 'Bearer ' + token },
body: JSON.stringify({ server_name, project, environment })
});
if (response.status === 401) return logout();
const data = await response.json();
if(data.api_key) {
const keyEl = document.getElementById("newKey");
keyEl.style.display = "block";
keyEl.innerHTML = `<strong><i class="fas fa-check-circle"></i> Success!</strong> <br> API Key: <code style="background:#fff; padding:2px 5px; border-radius:4px; font-weight:700;">${data.api_key}</code> <br><small>Copy this key immediately. It will not be shown again.</small>`;
loadServers();
// Clear inputs
document.getElementById("server_name").value = "";
document.getElementById("project").value = "";
document.getElementById("environment").value = "";
} else {
alert(data.error || "Failed to add server");
}
}
async function deleteServer(id) {
if(!confirm("Are you sure you want to delete this server? All historical metric data will be permanently removed.")) return;
const response = await fetch('/api/v1/admin/delete-server/' + id, {
method: 'DELETE',
headers: { 'Authorization': 'Bearer ' + token }
});
if (response.status === 401) return logout();
loadServers();
}
// --- SECURITY: DISABLE INSPECT ---
document.addEventListener('contextmenu', event => event.preventDefault());
document.onkeydown = function(e) {
if (e.keyCode == 123 ||
(e.ctrlKey && e.shiftKey && (e.keyCode == 'I'.charCodeAt(0) || e.keyCode == 'J'.charCodeAt(0))) ||
(e.ctrlKey && e.keyCode == 'U'.charCodeAt(0))) {
return false;
}
};
// Initial Load
loadServers();
</script>
</body>
</html>