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
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<!DOCTYPE html>
|
| 2 |
+
<html lang="bn">
|
| 3 |
+
<head>
|
| 4 |
+
<meta charset="UTF-8">
|
| 5 |
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
| 6 |
+
<title>DevOps Pro Terminal</title>
|
| 7 |
+
<script src="https://cdn.tailwindcss.com"></script>
|
| 8 |
+
<script src="https://unpkg.com/lucide@latest"></script>
|
| 9 |
+
<style>
|
| 10 |
+
@import url('https://fonts.googleapis.com/css2?family=Fira+Code:wght@400;500&display=swap');
|
| 11 |
+
body { font-family: 'Fira Code', monospace; }
|
| 12 |
+
.theme-dracula { --bg: #282a36; --fg: #f8f8f2; --accent: #bd93f9; }
|
| 13 |
+
.theme-monokai { --bg: #272822; --fg: #f8f8f2; --accent: #a6e22e; }
|
| 14 |
+
.theme-ocean { --bg: #0f172a; --fg: #e2e8f0; --accent: #38bdf8; }
|
| 15 |
+
.main-container { background-color: var(--bg); color: var(--fg); }
|
| 16 |
+
</style>
|
| 17 |
+
</head>
|
| 18 |
+
<body class="theme-ocean main-container min-h-screen transition-colors duration-300">
|
| 19 |
+
|
| 20 |
+
<!-- Login Overlay -->
|
| 21 |
+
<div id="loginOverlay" class="fixed inset-0 bg-black/90 z-50 flex items-center justify-center p-4">
|
| 22 |
+
<div class="bg-slate-800 p-8 rounded-2xl border border-slate-700 w-full max-w-md shadow-2xl">
|
| 23 |
+
<h2 class="text-2xl font-bold mb-6 flex items-center gap-2">
|
| 24 |
+
<i data-lucide="lock"></i> Authentication
|
| 25 |
+
</h2>
|
| 26 |
+
<input type="password" id="passInput" placeholder="Enter Secret Password"
|
| 27 |
+
class="w-full bg-slate-900 border border-slate-600 p-3 rounded-lg mb-4 outline-none focus:border-blue-500">
|
| 28 |
+
<button onclick="authenticate()" class="w-full bg-blue-600 hover:bg-blue-500 py-3 rounded-lg font-bold">Access Terminal</button>
|
| 29 |
+
</div>
|
| 30 |
+
</div>
|
| 31 |
+
|
| 32 |
+
<!-- Dashboard Layout -->
|
| 33 |
+
<div class="flex h-screen">
|
| 34 |
+
<!-- Sidebar: File Explorer -->
|
| 35 |
+
<div class="w-64 bg-black/20 border-r border-slate-800 flex flex-col">
|
| 36 |
+
<div class="p-4 border-b border-slate-800 font-bold flex items-center gap-2">
|
| 37 |
+
<i data-lucide="folder-tree"></i> Explorer
|
| 38 |
+
</div>
|
| 39 |
+
<div id="fileList" class="flex-1 overflow-y-auto p-2 text-sm opacity-80">
|
| 40 |
+
Loading files...
|
| 41 |
+
</div>
|
| 42 |
+
</div>
|
| 43 |
+
|
| 44 |
+
<!-- Main Area -->
|
| 45 |
+
<div class="flex-1 flex flex-col">
|
| 46 |
+
<!-- Header/Top Bar -->
|
| 47 |
+
<div class="h-16 bg-black/10 border-b border-slate-800 flex items-center justify-between px-6">
|
| 48 |
+
<div class="flex gap-4 items-center">
|
| 49 |
+
<span class="flex items-center gap-1"><i data-lucide="cpu" class="w-4 h-4"></i> <span id="cpuVal">0%</span></span>
|
| 50 |
+
<span class="flex items-center gap-1"><i data-lucide="database" class="w-4 h-4"></i> <span id="ramVal">0%</span></span>
|
| 51 |
+
</div>
|
| 52 |
+
<div class="flex gap-3">
|
| 53 |
+
<select onchange="changeTheme(this.value)" class="bg-slate-800 text-xs p-1 rounded border border-slate-600">
|
| 54 |
+
<option value="theme-ocean">Ocean Dark</option>
|
| 55 |
+
<option value="theme-dracula">Dracula</option>
|
| 56 |
+
<option value="theme-monokai">Monokai</option>
|
| 57 |
+
</select>
|
| 58 |
+
<button onclick="downloadLogs()" class="p-2 hover:bg-slate-700 rounded"><i data-lucide="download" class="w-4 h-4"></i></button>
|
| 59 |
+
</div>
|
| 60 |
+
</div>
|
| 61 |
+
|
| 62 |
+
<!-- Terminal Area -->
|
| 63 |
+
<div id="terminal" class="flex-1 overflow-y-auto p-6 space-y-2 text-sm">
|
| 64 |
+
<div class="text-blue-400">Welcome to DevOps Pro. System Secure.</div>
|
| 65 |
+
</div>
|
| 66 |
+
|
| 67 |
+
<!-- Input Bar -->
|
| 68 |
+
<div class="p-4 bg-black/30">
|
| 69 |
+
<div class="flex gap-2 bg-slate-900 p-2 rounded-lg border border-slate-700">
|
| 70 |
+
<span class="text-accent font-bold px-2">❯</span>
|
| 71 |
+
<input type="text" id="cmdInput" class="flex-1 bg-transparent border-none outline-none" placeholder="Enter command...">
|
| 72 |
+
</div>
|
| 73 |
+
</div>
|
| 74 |
+
</div>
|
| 75 |
+
</div>
|
| 76 |
+
|
| 77 |
+
<script>
|
| 78 |
+
lucide.createIcons();
|
| 79 |
+
let socket;
|
| 80 |
+
let commandHistory = JSON.parse(localStorage.getItem('history') || '[]');
|
| 81 |
+
let historyIndex = -1;
|
| 82 |
+
|
| 83 |
+
function authenticate() {
|
| 84 |
+
const pass = document.getElementById('passInput').value;
|
| 85 |
+
const protocol = window.location.protocol === 'https:' ? 'wss:' : 'ws:';
|
| 86 |
+
socket = new WebSocket(`${protocol}//${window.location.host}/ws`);
|
| 87 |
+
|
| 88 |
+
socket.onopen = () => socket.send(pass);
|
| 89 |
+
|
| 90 |
+
socket.onmessage = (event) => {
|
| 91 |
+
if (event.data === "AUTH_SUCCESS") {
|
| 92 |
+
document.getElementById('loginOverlay').style.display = 'none';
|
| 93 |
+
initApp();
|
| 94 |
+
} else if (event.data === "AUTH_FAILED") {
|
| 95 |
+
alert("Wrong Password!");
|
| 96 |
+
} else {
|
| 97 |
+
appendOutput(event.data);
|
| 98 |
+
}
|
| 99 |
+
};
|
| 100 |
+
}
|
| 101 |
+
|
| 102 |
+
function initApp() {
|
| 103 |
+
updateMetrics();
|
| 104 |
+
loadFiles();
|
| 105 |
+
setInterval(updateMetrics, 5000);
|
| 106 |
+
}
|
| 107 |
+
|
| 108 |
+
async function updateMetrics() {
|
| 109 |
+
const res = await fetch('/api/metrics');
|
| 110 |
+
const data = await res.json();
|
| 111 |
+
document.getElementById('cpuVal').innerText = data.cpu + '%';
|
| 112 |
+
document.getElementById('ramVal').innerText = data.ram + '%';
|
| 113 |
+
}
|
| 114 |
+
|
| 115 |
+
async function loadFiles() {
|
| 116 |
+
const res = await fetch('/api/files');
|
| 117 |
+
const files = await res.json();
|
| 118 |
+
const container = document.getElementById('fileList');
|
| 119 |
+
container.innerHTML = files.map(f => `
|
| 120 |
+
<div class="flex items-center gap-2 p-1 hover:bg-white/10 rounded cursor-pointer">
|
| 121 |
+
<i data-lucide="${f.is_dir ? 'folder' : 'file-text'}" class="w-4 h-4"></i>
|
| 122 |
+
<span>${f.name}</span>
|
| 123 |
+
</div>
|
| 124 |
+
`).join('');
|
| 125 |
+
lucide.createIcons();
|
| 126 |
+
}
|
| 127 |
+
|
| 128 |
+
function appendOutput(text) {
|
| 129 |
+
const div = document.createElement('pre');
|
| 130 |
+
div.className = "bg-black/20 p-3 rounded text-slate-300 border-l-2 border-indigo-500 whitespace-pre-wrap mt-2";
|
| 131 |
+
div.innerText = text;
|
| 132 |
+
const term = document.getElementById('terminal');
|
| 133 |
+
term.appendChild(div);
|
| 134 |
+
term.scrollTop = term.scrollHeight;
|
| 135 |
+
}
|
| 136 |
+
|
| 137 |
+
document.getElementById('cmdInput').addEventListener('keydown', (e) => {
|
| 138 |
+
if (e.key === 'Enter') {
|
| 139 |
+
const cmd = e.target.value;
|
| 140 |
+
if (!cmd) return;
|
| 141 |
+
appendOutput("➜ " + cmd);
|
| 142 |
+
socket.send(cmd);
|
| 143 |
+
commandHistory.push(cmd);
|
| 144 |
+
localStorage.setItem('history', JSON.stringify(commandHistory));
|
| 145 |
+
e.target.value = "";
|
| 146 |
+
}
|
| 147 |
+
});
|
| 148 |
+
|
| 149 |
+
function changeTheme(theme) {
|
| 150 |
+
document.body.className = `${theme} main-container min-h-screen transition-colors duration-300`;
|
| 151 |
+
}
|
| 152 |
+
|
| 153 |
+
function downloadLogs() {
|
| 154 |
+
const content = document.getElementById('terminal').innerText;
|
| 155 |
+
const blob = new Blob([content], {type: 'text/plain'});
|
| 156 |
+
const a = document.createElement('a');
|
| 157 |
+
a.href = URL.createObjectURL(blob);
|
| 158 |
+
a.download = 'terminal_logs.txt';
|
| 159 |
+
a.click();
|
| 160 |
+
}
|
| 161 |
+
</script>
|
| 162 |
+
</body>
|
| 163 |
+
</html>
|