754 lines
26 KiB
HTML
754 lines
26 KiB
HTML
<!doctype html>
|
|
<html>
|
|
|
|
<head>
|
|
<meta charset="utf-8" />
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
<title>Admin Panel :: DokkuStatus</title>
|
|
<link rel="icon"
|
|
href="data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100'><text y='0.9em' font-size='90'>⚡</text></svg>" />
|
|
<link rel="preconnect" href="https://fonts.googleapis.com">
|
|
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
|
|
<link href="https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@400;500;600;700&display=swap"
|
|
rel="stylesheet">
|
|
<style>
|
|
* {
|
|
box-sizing: border-box;
|
|
scroll-behavior: smooth;
|
|
}
|
|
|
|
@keyframes scanline {
|
|
0% {
|
|
transform: translateY(-100%);
|
|
}
|
|
|
|
100% {
|
|
transform: translateY(100vh);
|
|
}
|
|
}
|
|
|
|
@keyframes flicker {
|
|
|
|
0%,
|
|
100% {
|
|
opacity: 1;
|
|
}
|
|
|
|
50% {
|
|
opacity: 0.97;
|
|
}
|
|
}
|
|
|
|
@keyframes glow {
|
|
|
|
0%,
|
|
100% {
|
|
text-shadow: 0 0 10px rgba(0, 217, 255, 0.5);
|
|
}
|
|
|
|
50% {
|
|
text-shadow: 0 0 20px rgba(0, 217, 255, 0.8);
|
|
}
|
|
}
|
|
|
|
body {
|
|
font-family: 'JetBrains Mono', 'Fira Code', 'Courier New', monospace;
|
|
margin: 0;
|
|
padding: 0;
|
|
background: #0a0e17;
|
|
background-image:
|
|
linear-gradient(rgba(0, 217, 255, 0.03) 1px, transparent 1px),
|
|
linear-gradient(90deg, rgba(0, 217, 255, 0.03) 1px, transparent 1px);
|
|
background-size: 50px 50px;
|
|
min-height: 100vh;
|
|
color: #c9d1d9;
|
|
position: relative;
|
|
}
|
|
|
|
body::before {
|
|
content: '';
|
|
position: fixed;
|
|
top: 0;
|
|
left: 0;
|
|
width: 100%;
|
|
height: 100vh;
|
|
background: linear-gradient(transparent 50%, rgba(0, 217, 255, 0.02) 50%);
|
|
background-size: 100% 4px;
|
|
pointer-events: none;
|
|
z-index: 999;
|
|
animation: flicker 0.15s infinite;
|
|
}
|
|
|
|
body::after {
|
|
content: '';
|
|
position: fixed;
|
|
top: 0;
|
|
left: 0;
|
|
width: 100%;
|
|
height: 3px;
|
|
background: linear-gradient(transparent, rgba(0, 217, 255, 0.4), transparent);
|
|
pointer-events: none;
|
|
z-index: 1000;
|
|
animation: scanline 8s linear infinite;
|
|
}
|
|
|
|
.container {
|
|
max-width: 1600px;
|
|
margin: 0 auto;
|
|
padding: 20px;
|
|
position: relative;
|
|
z-index: 1;
|
|
}
|
|
|
|
.header-terminal {
|
|
background: #161b22;
|
|
border: 2px solid #00d9ff;
|
|
box-shadow: 0 0 20px rgba(0, 217, 255, 0.3);
|
|
padding: 20px 24px;
|
|
margin-bottom: 20px;
|
|
display: flex;
|
|
justify-content: space-between;
|
|
align-items: center;
|
|
}
|
|
|
|
.terminal-title {
|
|
display: flex;
|
|
align-items: center;
|
|
gap: 12px;
|
|
}
|
|
|
|
.terminal-prompt {
|
|
color: #00ff88;
|
|
font-weight: 700;
|
|
font-size: 18px;
|
|
animation: glow 2s ease-in-out infinite;
|
|
}
|
|
|
|
h1 {
|
|
margin: 0;
|
|
font-size: 24px;
|
|
font-weight: 700;
|
|
letter-spacing: 1px;
|
|
color: #00d9ff;
|
|
text-transform: uppercase;
|
|
}
|
|
|
|
.meta-info {
|
|
display: flex;
|
|
align-items: center;
|
|
gap: 16px;
|
|
}
|
|
|
|
.meta-info a,
|
|
.meta-info button {
|
|
color: #00d9ff;
|
|
text-decoration: none;
|
|
padding: 6px 12px;
|
|
background: rgba(0, 217, 255, 0.1);
|
|
border: 1px solid rgba(0, 217, 255, 0.3);
|
|
font-family: inherit;
|
|
font-size: 12px;
|
|
font-weight: 700;
|
|
cursor: pointer;
|
|
text-transform: uppercase;
|
|
transition: all 0.2s ease;
|
|
}
|
|
|
|
.meta-info a:hover,
|
|
.meta-info button:hover {
|
|
background: rgba(0, 217, 255, 0.2);
|
|
border-color: #00d9ff;
|
|
box-shadow: 0 0 10px rgba(0, 217, 255, 0.4);
|
|
}
|
|
|
|
.btn-red {
|
|
color: #ff5555 !important;
|
|
background: rgba(255, 85, 85, 0.1) !important;
|
|
border-color: rgba(255, 85, 85, 0.3) !important;
|
|
}
|
|
|
|
.btn-red:hover {
|
|
background: rgba(255, 85, 85, 0.2) !important;
|
|
border-color: #ff5555 !important;
|
|
box-shadow: 0 0 10px rgba(255, 85, 85, 0.4) !important;
|
|
}
|
|
|
|
/* Navigation Grid */
|
|
.nav-grid-container {
|
|
background: #161b22;
|
|
border: 2px solid #30363d;
|
|
padding: 20px;
|
|
margin-bottom: 40px;
|
|
position: relative;
|
|
}
|
|
|
|
.nav-grid-container::before {
|
|
content: '[ NAVIGATION_CONTROL_CENTER ]';
|
|
position: absolute;
|
|
top: -12px;
|
|
left: 20px;
|
|
background: #161b22;
|
|
padding: 0 10px;
|
|
color: #00d9ff;
|
|
font-size: 11px;
|
|
font-weight: 700;
|
|
letter-spacing: 2px;
|
|
}
|
|
|
|
.nav-grid {
|
|
display: grid;
|
|
grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
|
|
gap: 10px;
|
|
}
|
|
|
|
.nav-tile {
|
|
background: #0d1117;
|
|
border: 1px solid #30363d;
|
|
padding: 10px;
|
|
display: flex;
|
|
align-items: center;
|
|
gap: 10px;
|
|
text-decoration: none;
|
|
color: inherit;
|
|
transition: all 0.2s ease;
|
|
position: relative;
|
|
overflow: hidden;
|
|
}
|
|
|
|
.nav-tile:hover {
|
|
border-color: #00d9ff;
|
|
background: rgba(0, 217, 255, 0.05);
|
|
transform: translateY(-2px);
|
|
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
|
|
}
|
|
|
|
.led {
|
|
width: 8px;
|
|
height: 8px;
|
|
border-radius: 50%;
|
|
flex-shrink: 0;
|
|
}
|
|
|
|
.led-on {
|
|
background: #00ff88;
|
|
box-shadow: 0 0 8px #00ff88;
|
|
}
|
|
|
|
.led-off {
|
|
background: #ff5555;
|
|
box-shadow: 0 0 8px #ff5555;
|
|
}
|
|
|
|
.nav-tile-name {
|
|
font-size: 11px;
|
|
font-weight: 600;
|
|
white-space: nowrap;
|
|
overflow: hidden;
|
|
text-overflow: ellipsis;
|
|
text-transform: uppercase;
|
|
}
|
|
|
|
/* App Stations */
|
|
.station {
|
|
background: #161b22;
|
|
border: 2px solid #30363d;
|
|
margin-bottom: 60px;
|
|
position: relative;
|
|
padding: 24px;
|
|
scroll-margin-top: 40px;
|
|
}
|
|
|
|
.station::before {
|
|
content: attr(data-label);
|
|
position: absolute;
|
|
top: -12px;
|
|
left: 20px;
|
|
background: #161b22;
|
|
padding: 0 10px;
|
|
color: #00d9ff;
|
|
font-size: 11px;
|
|
font-weight: 700;
|
|
letter-spacing: 2px;
|
|
}
|
|
|
|
.station-header {
|
|
display: flex;
|
|
justify-content: space-between;
|
|
align-items: flex-start;
|
|
margin-bottom: 20px;
|
|
}
|
|
|
|
h2 {
|
|
font-size: 18px;
|
|
color: #00ff88;
|
|
margin: 0;
|
|
text-transform: uppercase;
|
|
letter-spacing: 1px;
|
|
}
|
|
|
|
.back-to-top {
|
|
font-size: 10px;
|
|
color: #8b949e;
|
|
text-decoration: none;
|
|
border: 1px solid #30363d;
|
|
padding: 4px 8px;
|
|
text-transform: uppercase;
|
|
}
|
|
|
|
.back-to-top:hover {
|
|
color: #00d9ff;
|
|
border-color: #00d9ff;
|
|
}
|
|
|
|
.grid {
|
|
display: grid;
|
|
grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
|
|
gap: 20px;
|
|
margin-bottom: 24px;
|
|
}
|
|
|
|
.panel {
|
|
background: #0d1117;
|
|
border: 1px solid #30363d;
|
|
padding: 16px;
|
|
}
|
|
|
|
.panel-title {
|
|
color: #8b949e;
|
|
font-size: 10px;
|
|
font-weight: 700;
|
|
text-transform: uppercase;
|
|
margin-bottom: 12px;
|
|
border-bottom: 1px solid #30363d;
|
|
padding-bottom: 4px;
|
|
}
|
|
|
|
.info-row {
|
|
display: flex;
|
|
justify-content: space-between;
|
|
font-size: 12px;
|
|
margin-bottom: 8px;
|
|
}
|
|
|
|
.info-label {
|
|
color: #8b949e;
|
|
}
|
|
|
|
.info-value {
|
|
color: #c9d1d9;
|
|
font-weight: 500;
|
|
word-break: break-all;
|
|
text-align: right;
|
|
margin-left: 10px;
|
|
}
|
|
|
|
.env-box {
|
|
background: #000;
|
|
border: 1px solid #30363d;
|
|
height: 150px;
|
|
overflow-y: auto;
|
|
padding: 10px;
|
|
font-size: 11px;
|
|
color: #dcdccc;
|
|
}
|
|
|
|
.env-var {
|
|
margin-bottom: 4px;
|
|
font-family: 'JetBrains Mono', monospace;
|
|
}
|
|
|
|
.env-key {
|
|
color: #00d9ff;
|
|
}
|
|
|
|
.terminal-box {
|
|
background: #000;
|
|
border: 1px solid #00d9ff66;
|
|
margin-top: 20px;
|
|
}
|
|
|
|
.terminal-header {
|
|
background: #161b22;
|
|
padding: 6px 12px;
|
|
display: flex;
|
|
justify-content: space-between;
|
|
align-items: center;
|
|
border-bottom: 1px solid #30363d;
|
|
}
|
|
|
|
.terminal-label {
|
|
color: #ffb86c;
|
|
font-size: 10px;
|
|
font-weight: 700;
|
|
}
|
|
|
|
.terminal-body {
|
|
padding: 12px;
|
|
height: 350px;
|
|
overflow-y: auto;
|
|
font-size: 12px;
|
|
line-height: 1.5;
|
|
color: #dcdccc;
|
|
scrollbar-width: thin;
|
|
}
|
|
|
|
.log-line {
|
|
margin: 2px 0;
|
|
}
|
|
|
|
.log-error {
|
|
color: #ff5555;
|
|
}
|
|
|
|
.log-warn {
|
|
color: #ffb86c;
|
|
}
|
|
|
|
.log-info {
|
|
color: #8b949e;
|
|
}
|
|
|
|
.copy-btn {
|
|
background: transparent;
|
|
border: 1px solid #00ff8866;
|
|
color: #00ff88;
|
|
padding: 2px 8px;
|
|
font-size: 9px;
|
|
cursor: pointer;
|
|
text-transform: uppercase;
|
|
}
|
|
|
|
.copy-btn:hover {
|
|
background: rgba(0, 255, 136, 0.1);
|
|
}
|
|
|
|
::-webkit-scrollbar {
|
|
width: 4px;
|
|
}
|
|
|
|
::-webkit-scrollbar-track {
|
|
background: transparent;
|
|
}
|
|
|
|
::-webkit-scrollbar-thumb {
|
|
background: #30363d;
|
|
}
|
|
|
|
::-webkit-scrollbar-thumb:hover {
|
|
background: #00d9ff;
|
|
}
|
|
</style>
|
|
</head>
|
|
|
|
<body id="top">
|
|
<div class="container">
|
|
<div class="header-terminal">
|
|
<div class="terminal-title">
|
|
<span class="terminal-prompt">root@dokku:~$</span>
|
|
<h1>Admin Control Center</h1>
|
|
</div>
|
|
<div class="meta-info">
|
|
<a href="/">DASHBOARD</a>
|
|
<button onclick="location.reload()">REFRESH</button>
|
|
<a href="/logout" class="btn-red">DISCONNECT</a>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Navigation Grid -->
|
|
<div class="nav-grid-container">
|
|
<div class="nav-grid">
|
|
{% for r in data.apps %}
|
|
<a href="#station-{{ loop.index }}" class="nav-tile">
|
|
<div class="led {% if r.detail.state.running %}led-on{% else %}led-off{% endif %}"></div>
|
|
<span class="nav-tile-name">{{ r.app }}</span>
|
|
</a>
|
|
{% endfor %}
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Root Terminal -->
|
|
<section id="root-terminal" class="station" data-label="[ STATION: ROOT_TERMINAL ]">
|
|
<div class="station-header">
|
|
<h2>Server Shell Access</h2>
|
|
<a href="#top" class="back-to-top">[^ BACK_TO_TOP]</a>
|
|
</div>
|
|
|
|
<div class="panel terminal-box" style="margin-top: 0; border-color: #ff555566;">
|
|
<div class="terminal-header" style="border-bottom-color: #ff555566;">
|
|
<div class="terminal-label" style="color: #ff5555;">ROOT@DOKKU:~$</div>
|
|
<button class="copy-btn" onclick="copyLogs('terminal-output')"
|
|
style="border-color: #ff555566; color: #ff5555;">COPY BUFFER</button>
|
|
</div>
|
|
<div id="terminal-output" class="terminal-body"
|
|
style="height: 400px; font-size: 13px; background: #000;">
|
|
<div class="log-line log-info">Dokku Terminal initialized. Ready for commands.</div>
|
|
</div>
|
|
<div style="display: flex; background: #000; padding: 10px; border-top: 1px solid #ff555566;">
|
|
<span style="color: #00ff88; font-weight: 700; margin-right: 10px;">$</span>
|
|
<input type="text" id="terminal-input" placeholder="Enter command..." spellcheck="false"
|
|
autocomplete="off"
|
|
style="background: transparent; color: #c9d1d9; border: none; outline: none; flex: 1; font-family: inherit; font-size: 13px;"
|
|
onkeydown="if(event.key === 'Enter') runCommand()">
|
|
</div>
|
|
</div>
|
|
</section>
|
|
|
|
<!-- SQL Command Center -->
|
|
<section id="sql-center" class="station" data-label="[ STATION: SQL_COMMAND_CENTER ]">
|
|
<div class="station-header">
|
|
<h2>SQL Query Interface</h2>
|
|
<a href="#top" class="back-to-top">[^ BACK_TO_TOP]</a>
|
|
</div>
|
|
|
|
<div class="grid" style="grid-template-columns: 1fr;">
|
|
<div class="panel">
|
|
<div class="panel-title">Query Console</div>
|
|
<div style="display: flex; gap: 10px; margin-bottom: 15px;">
|
|
<select id="sql-db-select"
|
|
style="background: #000; color: #00ff88; border: 1px solid #30363d; padding: 8px; font-family: inherit; font-size: 12px; flex: 1;">
|
|
<option value="">-- SELECT DATABASE CONTAINER --</option>
|
|
{% for db in data.databases %}
|
|
<option value="{{ db.name }}">{{ db.name }} [{{ db.type|upper }}]</option>
|
|
{% endfor %}
|
|
</select>
|
|
<button onclick="runQuery()"
|
|
style="background: #00ff8822; color: #00ff88; border: 1px solid #00ff88; padding: 0 20px; font-family: inherit; font-size: 11px; font-weight: 700; cursor: pointer;">EXECUTE_QUERY</button>
|
|
</div>
|
|
<textarea id="sql-editor" spellcheck="false" placeholder="SELECT * FROM table_name LIMIT 10;"
|
|
style="width: 100%; height: 120px; background: #000; color: #c9d1d9; border: 1px solid #30363d; padding: 12px; font-family: 'JetBrains Mono', monospace; font-size: 13px; resize: vertical;"></textarea>
|
|
</div>
|
|
|
|
<div id="sql-results-panel" class="panel" style="display: none;">
|
|
<div class="panel-title">Query Results</div>
|
|
<div id="sql-status" style="font-size: 11px; margin-bottom: 10px; color: #8b949e;"></div>
|
|
<div style="overflow-x: auto; max-height: 500px;">
|
|
<table id="sql-results-table" style="width: 100%; border-collapse: collapse; font-size: 11px;">
|
|
<thead id="sql-thead"></thead>
|
|
<tbody id="sql-tbody"></tbody>
|
|
</table>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</section>
|
|
|
|
{% for r in data.apps %}
|
|
<section id="station-{{ loop.index }}" class="station" data-label="[ STATION: {{ " %02d"|format(loop.index) }}
|
|
]">
|
|
<div class="station-header">
|
|
<h2>{{ r.app }}</h2>
|
|
<a href="#top" class="back-to-top">[^ BACK_TO_TOP]</a>
|
|
</div>
|
|
|
|
<div class="grid">
|
|
<!-- Metadata Panel -->
|
|
<div class="panel">
|
|
<div class="panel-title">Container Metadata</div>
|
|
<div class="info-row">
|
|
<span class="info-label">ID</span>
|
|
<span class="info-value">{{ r.detail.id or '—' }}</span>
|
|
</div>
|
|
<div class="info-row">
|
|
<span class="info-label">Name</span>
|
|
<span class="info-value">{{ r.container }}</span>
|
|
</div>
|
|
<div class="info-row">
|
|
<span class="info-label">Image</span>
|
|
<span class="info-value">{{ r.detail.image or '—' }}</span>
|
|
</div>
|
|
<div class="info-row">
|
|
<span class="info-label">Status</span>
|
|
<span class="info-value"
|
|
style="color: {% if r.detail.state.running %}#00ff88{% else %}#ff5555{% endif %};">
|
|
{{ (r.detail.state.status or 'unknown') | upper }}
|
|
</span>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Networking Panel -->
|
|
<div class="panel">
|
|
<div class="panel-title">Networking & Ports</div>
|
|
<div class="info-row">
|
|
<span class="info-label">IP Address</span>
|
|
<span class="info-value">{{ r.detail.ip_address or '—' }}</span>
|
|
</div>
|
|
<div class="info-row">
|
|
<span class="info-label">Networks</span>
|
|
<span class="info-value">{{ (r.detail.networks or []) | join(', ') }}</span>
|
|
</div>
|
|
<div class="info-row">
|
|
<span class="info-label">Port Mappings</span>
|
|
<span class="info-value">
|
|
{% for port, mappings in (r.detail.ports or {}).items() %}
|
|
<span style="color: #00ff88;">{{ port }}</span>{% if mappings %} → {{ mappings[0].HostPort
|
|
}}{% endif %}<br>
|
|
{% endfor %}
|
|
</span>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Environment Panel -->
|
|
<div class="panel">
|
|
<div class="panel-title">Environment Variables</div>
|
|
<div class="env-box">
|
|
{% for env in (r.detail.env or []) %}
|
|
{% set parts = env.split('=', 1) %}
|
|
<div class="env-var">
|
|
<span class="env-key">{{ parts[0] }}=</span>{{ parts[1] }}
|
|
</div>
|
|
{% endfor %}
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Terminal Output -->
|
|
<div class="terminal-box">
|
|
<div class="terminal-header">
|
|
<div class="terminal-label">[ STDOUT / STDERR ]</div>
|
|
<button class="copy-btn" onclick="copyLogs('logs-{{ loop.index }}')">Copy Buffer</button>
|
|
</div>
|
|
<div id="logs-{{ loop.index }}" class="terminal-body" data-autoscroll="true">
|
|
{% if r.logs %}
|
|
{% for log in r.logs %}
|
|
<div class="log-line log-{{ log.level }}">{{ log.text }}</div>
|
|
{% endfor %}
|
|
{% else %}
|
|
<div class="log-info">[ NO LOG DATA IN BUFFER ]</div>
|
|
{% endif %}
|
|
</div>
|
|
</div>
|
|
</section>
|
|
{% endfor %}
|
|
|
|
</div>
|
|
|
|
<script>
|
|
function copyLogs(id) {
|
|
const el = document.getElementById(id);
|
|
const text = el.innerText;
|
|
navigator.clipboard.writeText(text).then(() => {
|
|
const btn = event.currentTarget || event.target;
|
|
const orig = btn.innerText;
|
|
btn.innerText = 'COPIED';
|
|
setTimeout(() => { btn.innerText = orig; }, 2000);
|
|
});
|
|
}
|
|
|
|
async function runQuery() {
|
|
const container = document.getElementById('sql-db-select').value;
|
|
const query = document.getElementById('sql-editor').value;
|
|
const resultsPanel = document.getElementById('sql-results-panel');
|
|
const status = document.getElementById('sql-status');
|
|
const thead = document.getElementById('sql-thead');
|
|
const tbody = document.getElementById('sql-tbody');
|
|
|
|
if (!container || !query) {
|
|
alert('Please select a database and enter a query.');
|
|
return;
|
|
}
|
|
|
|
resultsPanel.style.display = 'block';
|
|
status.innerHTML = '<span style="color: #00d9ff;">EXECUTING...</span>';
|
|
thead.innerHTML = '';
|
|
tbody.innerHTML = '';
|
|
|
|
try {
|
|
const response = await fetch('/api/sql/query', {
|
|
method: 'POST',
|
|
headers: { 'Content-Type': 'application/json' },
|
|
body: JSON.stringify({ container, query })
|
|
});
|
|
|
|
const result = await response.json();
|
|
|
|
if (result.error) {
|
|
status.innerHTML = `<span style="color: #ff5555;">ERROR: ${result.error}</span>`;
|
|
return;
|
|
}
|
|
|
|
status.innerHTML = `<span style="color: #00ff88;">SUCCESS: ${result.count || 0} rows found.</span>`;
|
|
|
|
if (result.columns && result.columns.length > 0) {
|
|
const headerRow = document.createElement('tr');
|
|
result.columns.forEach(col => {
|
|
const th = document.createElement('th');
|
|
th.style.padding = '8px';
|
|
th.style.textAlign = 'left';
|
|
th.style.border = '1px solid #30363d';
|
|
th.style.background = 'rgba(0, 217, 255, 0.1)';
|
|
th.style.color = '#00d9ff';
|
|
th.innerText = col;
|
|
headerRow.appendChild(th);
|
|
});
|
|
thead.appendChild(headerRow);
|
|
}
|
|
|
|
if (result.rows && result.rows.length > 0) {
|
|
result.rows.forEach(row => {
|
|
const tr = document.createElement('tr');
|
|
row.forEach(cell => {
|
|
const td = document.createElement('td');
|
|
td.style.padding = '8px';
|
|
td.style.border = '1px solid #30363d';
|
|
td.innerText = cell;
|
|
tr.appendChild(td);
|
|
});
|
|
tbody.appendChild(tr);
|
|
});
|
|
} else if (result.message) {
|
|
status.innerHTML = `<span style="color: #00ff88;">${result.message}</span>`;
|
|
}
|
|
|
|
} catch (err) {
|
|
status.innerHTML = `<span style="color: #ff5555;">CONNECTION ERROR: ${err.message}</span>`;
|
|
}
|
|
}
|
|
|
|
async function runCommand() {
|
|
const input = document.getElementById('terminal-input');
|
|
const output = document.getElementById('terminal-output');
|
|
const command = input.value.trim();
|
|
|
|
if (!command) return;
|
|
|
|
// Add command to terminal
|
|
const cmdLine = document.createElement('div');
|
|
cmdLine.className = 'log-line';
|
|
cmdLine.innerHTML = `<span style="color: #00ff88;">$ ${command}</span>`;
|
|
output.appendChild(cmdLine);
|
|
|
|
input.value = '';
|
|
output.scrollTop = output.scrollHeight;
|
|
|
|
try {
|
|
const response = await fetch('/api/terminal/exec', {
|
|
method: 'POST',
|
|
headers: { 'Content-Type': 'application/json' },
|
|
body: JSON.stringify({ command })
|
|
});
|
|
|
|
const result = await response.json();
|
|
|
|
const resultLine = document.createElement('div');
|
|
resultLine.className = result.error ? 'log-line log-error' : 'log-line';
|
|
resultLine.style.whiteSpace = 'pre-wrap';
|
|
resultLine.innerText = result.output;
|
|
output.appendChild(resultLine);
|
|
|
|
output.scrollTop = output.scrollHeight;
|
|
} catch (err) {
|
|
const errLine = document.createElement('div');
|
|
errLine.className = 'log-line log-error';
|
|
errLine.innerText = `FATAL ERROR: ${err.message}`;
|
|
output.appendChild(errLine);
|
|
output.scrollTop = output.scrollHeight;
|
|
}
|
|
}
|
|
|
|
// Auto-scroll logic
|
|
document.querySelectorAll('.terminal-body').forEach(el => {
|
|
el.scrollTop = el.scrollHeight;
|
|
});
|
|
</script>
|
|
</body>
|
|
|
|
</html> |