Compare commits
2
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
306ebcc871 | ||
|
|
3486f3b2cb |
No files matched your search
@@ -29,6 +29,8 @@ chmod +x start.sh
|
|||||||
- **Chat Logs** with channel filtering and auto-refresh
|
- **Chat Logs** with channel filtering and auto-refresh
|
||||||
- **Director Tools** (battlegroups, world state, transfers)
|
- **Director Tools** (battlegroups, world state, transfers)
|
||||||
- **SSH File Browser** + **in-browser shell**
|
- **SSH File Browser** + **in-browser shell**
|
||||||
|
- **Pod Management** (list, logs, describe, delete with safe-mode for DB backup pods)
|
||||||
|
- **Nav Layout** — switch between horizontal and vertical sidebar; persists preference; auto-enables sidebar on mobile
|
||||||
- **Firewall Hardening** via iptables
|
- **Firewall Hardening** via iptables
|
||||||
- **Auto‑Update** with safe file replacement
|
- **Auto‑Update** with safe file replacement
|
||||||
- **HTTPS + Remote Access** (self‑signed or Let’s Encrypt)
|
- **HTTPS + Remote Access** (self‑signed or Let’s Encrypt)
|
||||||
|
|||||||
@@ -1115,6 +1115,79 @@ def register_api_routes(app, services, settings):
|
|||||||
except Exception as e:
|
except Exception as e:
|
||||||
return jsonify({'success': False, 'error': str(e)}), 500
|
return jsonify({'success': False, 'error': str(e)}), 500
|
||||||
|
|
||||||
|
# Pod actions (list, logs, delete, describe)
|
||||||
|
@app.route('/api/pods')
|
||||||
|
@auth_req
|
||||||
|
def api_pods_list():
|
||||||
|
try:
|
||||||
|
ns = settings['kubernetes']['namespace']
|
||||||
|
out, err, rc = ssh.run(
|
||||||
|
f'sudo kubectl get pods -n {ns} -o custom-columns=NAME:.metadata.name,ROLE:.metadata.labels.role,STATUS:.status.phase')
|
||||||
|
if rc != 0:
|
||||||
|
return jsonify({'success': False, 'error': err or 'Failed to list pods'})
|
||||||
|
pods = []
|
||||||
|
for line in (out or '').strip().split('\n')[1:]:
|
||||||
|
parts = line.split(None, 2)
|
||||||
|
if len(parts) >= 3:
|
||||||
|
pods.append({
|
||||||
|
'name': parts[0],
|
||||||
|
'role': parts[1] if parts[1] != '<none>' else '',
|
||||||
|
'status': parts[2],
|
||||||
|
})
|
||||||
|
return jsonify({'success': True, 'pods': pods})
|
||||||
|
except Exception as e:
|
||||||
|
return jsonify({'success': False, 'error': str(e)}), 500
|
||||||
|
|
||||||
|
@app.route('/api/pod/logs', methods=['POST'])
|
||||||
|
@auth_req
|
||||||
|
def api_pod_logs():
|
||||||
|
try:
|
||||||
|
data = request.get_json(force=True) or {}
|
||||||
|
pod = data.get('pod', '').strip()
|
||||||
|
if not pod:
|
||||||
|
return jsonify({'success': False, 'error': 'pod name required'})
|
||||||
|
ns = settings['kubernetes']['namespace']
|
||||||
|
out, err, rc = ssh.run(
|
||||||
|
f'sudo kubectl logs -n {ns} {pod} --tail=300 2>/dev/null || echo "NO_LOGS"', timeout=15)
|
||||||
|
if rc != 0 and 'NO_LOGS' not in (out or ''):
|
||||||
|
return jsonify({'success': False, 'error': err or 'Failed to get logs'})
|
||||||
|
logs = (out or '').replace('NO_LOGS\n', '').replace('NO_LOGS', '')
|
||||||
|
return jsonify({'success': True, 'logs': logs, 'pod': pod})
|
||||||
|
except Exception as e:
|
||||||
|
return jsonify({'success': False, 'error': str(e)}), 500
|
||||||
|
|
||||||
|
@app.route('/api/pod/delete', methods=['POST'])
|
||||||
|
@auth_req
|
||||||
|
def api_pod_delete():
|
||||||
|
try:
|
||||||
|
data = request.get_json(force=True) or {}
|
||||||
|
pod = data.get('pod', '').strip()
|
||||||
|
if not pod:
|
||||||
|
return jsonify({'success': False, 'error': 'pod name required'})
|
||||||
|
ns = settings['kubernetes']['namespace']
|
||||||
|
out, err, rc = ssh.run(f'sudo kubectl delete pod -n {ns} {pod} --wait=false', timeout=30)
|
||||||
|
if rc != 0:
|
||||||
|
return jsonify({'success': False, 'error': err or 'Failed to delete pod'})
|
||||||
|
return jsonify({'success': True, 'message': f'Pod {pod} deleted (will be recreated by its controller)'})
|
||||||
|
except Exception as e:
|
||||||
|
return jsonify({'success': False, 'error': str(e)}), 500
|
||||||
|
|
||||||
|
@app.route('/api/pod/describe', methods=['POST'])
|
||||||
|
@auth_req
|
||||||
|
def api_pod_describe():
|
||||||
|
try:
|
||||||
|
data = request.get_json(force=True) or {}
|
||||||
|
pod = data.get('pod', '').strip()
|
||||||
|
if not pod:
|
||||||
|
return jsonify({'success': False, 'error': 'pod name required'})
|
||||||
|
ns = settings['kubernetes']['namespace']
|
||||||
|
out, err, rc = ssh.run(f'sudo kubectl describe pod -n {ns} {pod}', timeout=30)
|
||||||
|
if rc != 0:
|
||||||
|
return jsonify({'success': False, 'error': err or 'Failed to describe pod'})
|
||||||
|
return jsonify({'success': True, 'describe': out or '', 'pod': pod})
|
||||||
|
except Exception as e:
|
||||||
|
return jsonify({'success': False, 'error': str(e)}), 500
|
||||||
|
|
||||||
# Update management
|
# Update management
|
||||||
@app.route('/api/update/status')
|
@app.route('/api/update/status')
|
||||||
@auth_req
|
@auth_req
|
||||||
|
|||||||
+2
-1
@@ -4,7 +4,7 @@ import json
|
|||||||
import logging
|
import logging
|
||||||
from flask import Blueprint, render_template, request, jsonify
|
from flask import Blueprint, render_template, request, jsonify
|
||||||
from flask_login import login_required, current_user
|
from flask_login import login_required, current_user
|
||||||
from app.utils.constants import NAV_PAGES, GUILD_ROLES
|
from app.utils.constants import NAV_PAGES, NAV_GROUPS, GUILD_ROLES
|
||||||
from app.utils.debug_logging import sanitize_for_log
|
from app.utils.debug_logging import sanitize_for_log
|
||||||
from app.services.player import LIKE_PC
|
from app.services.player import LIKE_PC
|
||||||
|
|
||||||
@@ -49,6 +49,7 @@ def register_routes(app, services, settings):
|
|||||||
)
|
)
|
||||||
return dict(
|
return dict(
|
||||||
nav_pages=NAV_PAGES,
|
nav_pages=NAV_PAGES,
|
||||||
|
nav_groups=NAV_GROUPS,
|
||||||
current_path=request.path if request else '/',
|
current_path=request.path if request else '/',
|
||||||
fmt_role=fmt_role,
|
fmt_role=fmt_role,
|
||||||
conn_ok=conn_ok,
|
conn_ok=conn_ok,
|
||||||
|
|||||||
@@ -84,3 +84,28 @@ NAV_PAGES = [
|
|||||||
('/admin-experimental', 'Experimental'),
|
('/admin-experimental', 'Experimental'),
|
||||||
('/backup', 'Backup'),
|
('/backup', 'Backup'),
|
||||||
]
|
]
|
||||||
|
|
||||||
|
NAV_GROUPS = [
|
||||||
|
('/', 'Overview'),
|
||||||
|
('Server', [
|
||||||
|
('/server', 'Server'),
|
||||||
|
('/director', 'Director'),
|
||||||
|
('/shell', 'Shell'),
|
||||||
|
('/files', 'Files'),
|
||||||
|
]),
|
||||||
|
('Players', [
|
||||||
|
('/players', 'Players'),
|
||||||
|
('/vehicles', 'Vehicles'),
|
||||||
|
('/guilds', 'Guilds'),
|
||||||
|
('/buildings', 'Buildings'),
|
||||||
|
]),
|
||||||
|
('World', [
|
||||||
|
('/events', 'Events'),
|
||||||
|
('/chat', 'Chat'),
|
||||||
|
('/map', 'Map'),
|
||||||
|
]),
|
||||||
|
('System', [
|
||||||
|
('/admin-experimental', 'Experimental'),
|
||||||
|
('/backup', 'Backup'),
|
||||||
|
]),
|
||||||
|
]
|
||||||
@@ -71,6 +71,50 @@ nav a.active {
|
|||||||
|
|
||||||
nav .spacer { flex: 1; }
|
nav .spacer { flex: 1; }
|
||||||
|
|
||||||
|
/* Horizontal vs vertical nav link visibility */
|
||||||
|
.nav-links-h { display: flex; align-items: center; gap: 2px; }
|
||||||
|
.nav-links-v { display: none; }
|
||||||
|
|
||||||
|
body[data-nav-layout="vertical"] .nav-links-h { display: none; }
|
||||||
|
body[data-nav-layout="vertical"] .nav-links-v { display: flex; flex-direction: column; width: 100%; flex: 1; overflow-y: auto; }
|
||||||
|
|
||||||
|
/* Horizontal nav dropdowns */
|
||||||
|
.nav-dropdown {
|
||||||
|
position: relative;
|
||||||
|
display: inline-block;
|
||||||
|
}
|
||||||
|
.nav-dropdown-toggle {
|
||||||
|
cursor: default;
|
||||||
|
padding: 0 10px;
|
||||||
|
}
|
||||||
|
.nav-dropdown-content {
|
||||||
|
display: none;
|
||||||
|
position: absolute;
|
||||||
|
top: 100%;
|
||||||
|
left: 0;
|
||||||
|
background: var(--nav-bg);
|
||||||
|
min-width: 140px;
|
||||||
|
box-shadow: 0 4px 16px rgba(0,0,0,0.4);
|
||||||
|
border-radius: 6px;
|
||||||
|
z-index: 1000;
|
||||||
|
padding: 4px 0;
|
||||||
|
border: 1px solid rgba(255,255,255,0.1);
|
||||||
|
}
|
||||||
|
.nav-dropdown-content a {
|
||||||
|
color: var(--nav-text);
|
||||||
|
padding: 8px 16px;
|
||||||
|
height: auto;
|
||||||
|
border-bottom: none;
|
||||||
|
font-size: 12px;
|
||||||
|
display: block;
|
||||||
|
}
|
||||||
|
.nav-dropdown-content a:hover { color: #fff; background: rgba(255,255,255,0.06); }
|
||||||
|
.nav-dropdown-content a.active {
|
||||||
|
color: var(--nav-active);
|
||||||
|
border-left: 3px solid var(--nav-active);
|
||||||
|
}
|
||||||
|
.nav-dropdown:hover .nav-dropdown-content { display: block; }
|
||||||
|
|
||||||
.conn-dot {
|
.conn-dot {
|
||||||
width: 8px;
|
width: 8px;
|
||||||
height: 8px;
|
height: 8px;
|
||||||
@@ -1170,3 +1214,130 @@ td a:hover { text-decoration: underline; }
|
|||||||
font-family: monospace;
|
font-family: monospace;
|
||||||
white-space: nowrap;
|
white-space: nowrap;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Nav Layout Toggle */
|
||||||
|
.nav-toggle {
|
||||||
|
position: fixed;
|
||||||
|
top: 56px;
|
||||||
|
left: 6px;
|
||||||
|
z-index: 101;
|
||||||
|
background: var(--nav-bg);
|
||||||
|
color: var(--nav-text);
|
||||||
|
border: 1px solid rgba(255,255,255,0.15);
|
||||||
|
border-radius: 4px;
|
||||||
|
padding: 3px 7px;
|
||||||
|
font-size: 15px;
|
||||||
|
cursor: pointer;
|
||||||
|
line-height: 1;
|
||||||
|
opacity: 0.5;
|
||||||
|
transition: opacity 0.15s;
|
||||||
|
}
|
||||||
|
.nav-toggle:hover { opacity: 1; color: #fff; }
|
||||||
|
|
||||||
|
/* Vertical sidebar layout */
|
||||||
|
body[data-nav-layout="vertical"] {
|
||||||
|
padding-left: 216px;
|
||||||
|
}
|
||||||
|
|
||||||
|
body[data-nav-layout="vertical"] .nav-toggle {
|
||||||
|
left: 204px;
|
||||||
|
top: 6px;
|
||||||
|
}
|
||||||
|
|
||||||
|
body[data-nav-layout="vertical"] nav {
|
||||||
|
position: fixed;
|
||||||
|
left: 0;
|
||||||
|
top: 0;
|
||||||
|
bottom: 0;
|
||||||
|
width: 200px;
|
||||||
|
flex-direction: column;
|
||||||
|
height: 100vh;
|
||||||
|
padding: 0;
|
||||||
|
align-items: stretch;
|
||||||
|
box-shadow: 1px 0 4px rgba(0,0,0,0.2);
|
||||||
|
}
|
||||||
|
|
||||||
|
body[data-nav-layout="vertical"] nav .brand {
|
||||||
|
padding: 20px 16px 12px;
|
||||||
|
margin-right: 0;
|
||||||
|
font-size: 13px;
|
||||||
|
text-align: center;
|
||||||
|
border-bottom: 1px solid rgba(255,255,255,0.08);
|
||||||
|
}
|
||||||
|
|
||||||
|
body[data-nav-layout="vertical"] nav a {
|
||||||
|
padding: 10px 16px;
|
||||||
|
height: auto;
|
||||||
|
border-bottom: none;
|
||||||
|
border-left: 3px solid transparent;
|
||||||
|
font-size: 12px;
|
||||||
|
}
|
||||||
|
|
||||||
|
body[data-nav-layout="vertical"] nav a:hover {
|
||||||
|
background: rgba(255,255,255,0.05);
|
||||||
|
}
|
||||||
|
|
||||||
|
body[data-nav-layout="vertical"] nav a.active {
|
||||||
|
border-bottom-color: transparent;
|
||||||
|
border-left-color: var(--nav-active);
|
||||||
|
}
|
||||||
|
|
||||||
|
body[data-nav-layout="vertical"] nav .spacer {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
body[data-nav-layout="vertical"] nav .theme-dropdown {
|
||||||
|
padding: 8px 16px;
|
||||||
|
border-top: 1px solid rgba(255,255,255,0.08);
|
||||||
|
}
|
||||||
|
|
||||||
|
body[data-nav-layout="vertical"] nav .theme-dropdown .theme-dropdown-content {
|
||||||
|
bottom: 100%;
|
||||||
|
top: auto;
|
||||||
|
left: 0;
|
||||||
|
right: auto;
|
||||||
|
margin-bottom: 4px;
|
||||||
|
}
|
||||||
|
|
||||||
|
body[data-nav-layout="vertical"] nav .theme-dropdown .theme-btn {
|
||||||
|
width: 100%;
|
||||||
|
justify-content: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
body[data-nav-layout="vertical"] nav .nav-conn,
|
||||||
|
body[data-nav-layout="vertical"] nav .nav-logout {
|
||||||
|
padding: 10px 16px;
|
||||||
|
justify-content: center;
|
||||||
|
border-top: 1px solid rgba(255,255,255,0.08);
|
||||||
|
}
|
||||||
|
|
||||||
|
body[data-nav-layout="vertical"] .container {
|
||||||
|
max-width: none;
|
||||||
|
padding: 24px;
|
||||||
|
}
|
||||||
|
|
||||||
|
body[data-nav-layout="vertical"] .site-footer {
|
||||||
|
margin-left: 216px;
|
||||||
|
}
|
||||||
|
|
||||||
|
@media (max-width: 768px) {
|
||||||
|
body[data-nav-layout="vertical"] {
|
||||||
|
padding-left: 0;
|
||||||
|
}
|
||||||
|
body[data-nav-layout="vertical"] .nav-toggle {
|
||||||
|
top: 8px;
|
||||||
|
left: 8px;
|
||||||
|
}
|
||||||
|
body[data-nav-layout="vertical"] nav {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
body[data-nav-layout="vertical"] nav.nav-open {
|
||||||
|
display: flex;
|
||||||
|
}
|
||||||
|
body[data-nav-layout="vertical"] .container {
|
||||||
|
padding: 24px;
|
||||||
|
}
|
||||||
|
body[data-nav-layout="vertical"] .site-footer {
|
||||||
|
margin-left: 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
+2
-2
@@ -367,7 +367,7 @@
|
|||||||
display: none;
|
display: none;
|
||||||
position: absolute;
|
position: absolute;
|
||||||
right: 0;
|
right: 0;
|
||||||
background: #252530;
|
background: var(--nav-bg);
|
||||||
min-width: 290px;
|
min-width: 290px;
|
||||||
max-height: 80vh;
|
max-height: 80vh;
|
||||||
overflow-y: auto;
|
overflow-y: auto;
|
||||||
@@ -375,7 +375,7 @@
|
|||||||
border-radius: 8px;
|
border-radius: 8px;
|
||||||
z-index: 1000;
|
z-index: 1000;
|
||||||
padding: 12px;
|
padding: 12px;
|
||||||
border: 1px solid #404050;
|
border: 1px solid rgba(255,255,255,0.1);
|
||||||
}
|
}
|
||||||
|
|
||||||
.theme-grid {
|
.theme-grid {
|
||||||
|
|||||||
+59
-2
@@ -18,11 +18,34 @@
|
|||||||
{% block head_extra %}{% endblock %}
|
{% block head_extra %}{% endblock %}
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
|
<button class="nav-toggle" id="navToggle" title="Toggle nav layout" onclick="toggleNavLayout()">☰</button>
|
||||||
<nav>
|
<nav>
|
||||||
<div class="brand">DUNE DASHBOARD</div>
|
<div class="brand">DUNE DASHBOARD</div>
|
||||||
|
<!-- Horizontal: use grouped nav -->
|
||||||
|
<div class="nav-links-h">
|
||||||
|
{% for item in nav_groups %}
|
||||||
|
{% if item|length == 2 and item[1] is string %}
|
||||||
|
{# Simple link #}
|
||||||
|
<a href="{{ item[0] }}" class="{% if current_path == item[0] %}active{% endif %}">{{ item[1] }}</a>
|
||||||
|
{% else %}
|
||||||
|
{# Dropdown group: item[0] is label, item[1] is list of (href, label) #}
|
||||||
|
<div class="nav-dropdown">
|
||||||
|
<a class="nav-dropdown-toggle {% for ih, il in item[1] %}{% if current_path == ih %}active{% endif %}{% endfor %}">{{ item[0] }} ▾</a>
|
||||||
|
<div class="nav-dropdown-content">
|
||||||
|
{% for ih, il in item[1] %}
|
||||||
|
<a href="{{ ih }}" class="{% if current_path == ih %}active{% endif %}">{{ il }}</a>
|
||||||
|
{% endfor %}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{% endif %}
|
||||||
|
{% endfor %}
|
||||||
|
</div>
|
||||||
|
<!-- Vertical nav links (flat list) -->
|
||||||
|
<div class="nav-links-v">
|
||||||
{% for href, label in nav_pages %}
|
{% for href, label in nav_pages %}
|
||||||
<a href="{{ href }}" class="{% if current_path == href %}active{% endif %}">{{ label }}</a>
|
<a href="{{ href }}" class="{% if current_path == href %}active{% endif %}">{{ label }}</a>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
</div>
|
||||||
<div class="spacer"></div>
|
<div class="spacer"></div>
|
||||||
<div class="theme-dropdown">
|
<div class="theme-dropdown">
|
||||||
<button class="theme-btn" title="Theme">🎨</button>
|
<button class="theme-btn" title="Theme">🎨</button>
|
||||||
@@ -101,12 +124,12 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<span style="font-size:12px;color:var(--nav-text);display:flex;align-items:center;">
|
<span class="nav-conn">
|
||||||
<span class="conn-dot {% if conn_ok %}online{% else %}offline{% endif %}"></span>
|
<span class="conn-dot {% if conn_ok %}online{% else %}offline{% endif %}"></span>
|
||||||
{{ 'Connected' if conn_ok else 'Disconnected' }}
|
{{ 'Connected' if conn_ok else 'Disconnected' }}
|
||||||
</span>
|
</span>
|
||||||
{% if current_user and current_user.is_authenticated %}
|
{% if current_user and current_user.is_authenticated %}
|
||||||
<a href="/logout" style="font-size:12px;color:var(--nav-text);">Logout</a>
|
<a href="/logout" class="nav-logout">Logout</a>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</nav>
|
</nav>
|
||||||
<main class="container">
|
<main class="container">
|
||||||
@@ -135,7 +158,41 @@
|
|||||||
updateThemeUI(savedTheme);
|
updateThemeUI(savedTheme);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Nav Layout System (experimental vertical toggle)
|
||||||
|
function toggleNavLayout() {
|
||||||
|
const body = document.body;
|
||||||
|
const isMobile = window.innerWidth <= 768;
|
||||||
|
if (isMobile) {
|
||||||
|
document.querySelector('nav').classList.toggle('nav-open');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const current = body.getAttribute('data-nav-layout') || 'horizontal';
|
||||||
|
const next = current === 'horizontal' ? 'vertical' : 'horizontal';
|
||||||
|
body.setAttribute('data-nav-layout', next);
|
||||||
|
localStorage.setItem('dune-nav-layout', next);
|
||||||
|
}
|
||||||
|
|
||||||
|
function initNavLayout() {
|
||||||
|
const isMobile = window.innerWidth <= 768;
|
||||||
|
if (isMobile) {
|
||||||
|
document.body.setAttribute('data-nav-layout', 'vertical');
|
||||||
|
localStorage.removeItem('dune-nav-layout');
|
||||||
|
} else {
|
||||||
|
const saved = localStorage.getItem('dune-nav-layout') || 'horizontal';
|
||||||
|
document.body.setAttribute('data-nav-layout', saved);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
window.addEventListener('resize', function() {
|
||||||
|
const isMobile = window.innerWidth <= 768;
|
||||||
|
const current = document.body.getAttribute('data-nav-layout');
|
||||||
|
if (isMobile && current !== 'vertical') {
|
||||||
|
document.body.setAttribute('data-nav-layout', 'vertical');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
initTheme();
|
initTheme();
|
||||||
|
initNavLayout();
|
||||||
</script>
|
</script>
|
||||||
{% block scripts %}{% endblock %}
|
{% block scripts %}{% endblock %}
|
||||||
<style>
|
<style>
|
||||||
|
|||||||
+257
-6
@@ -35,27 +35,79 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="card">
|
<div class="card">
|
||||||
<div class="card-header">Pods ({{ pods|length }})</div>
|
<div class="card-header" style="display:flex;justify-content:space-between;align-items:center;">
|
||||||
|
<span>Pods (<span id="pod-count">{{ pods|length }}</span>)</span>
|
||||||
|
<button onclick="refreshPodList()" style="padding:4px 12px;background:var(--primary);color:#fff;border:none;border-radius:4px;cursor:pointer;font-size:12px;">↻ Refresh</button>
|
||||||
|
</div>
|
||||||
<div class="table-wrap">
|
<div class="table-wrap">
|
||||||
<table>
|
<table id="pods-table">
|
||||||
<thead>
|
<thead>
|
||||||
<tr><th>Name</th><th>Role</th><th>Status</th></tr>
|
<tr><th>Name</th><th>Role</th><th>Status</th><th>Actions</th></tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
{% for pod in pods %}
|
{% for pod in pods %}
|
||||||
<tr>
|
<tr data-pod="{{ pod.name }}" data-role="{{ pod.role }}">
|
||||||
<td style="font-family:monospace;font-size:12px;">{{ pod.name }}</td>
|
<td style="font-family:monospace;font-size:12px;">{{ pod.name }}</td>
|
||||||
<td><span class="badge badge-{{ pod.role.lower() if pod.role else 'default' }}">{{ pod.role or 'default' }}</span></td>
|
<td><span class="badge badge-{{ (pod.role or 'default').lower() }}">{{ pod.role or 'default' }}</span></td>
|
||||||
<td><span class="badge badge-{{ pod.status.lower() }}">{{ pod.status }}</span></td>
|
<td><span class="badge badge-{{ pod.status.lower() }}">{{ pod.status }}</span></td>
|
||||||
|
<td style="white-space:nowrap;">
|
||||||
|
<button class="pod-btn shell-btn" onclick="shellPod('{{ pod.name }}')" title="Open shell">[>_]</button>
|
||||||
|
<button class="pod-btn logs-btn" onclick="fetchPodLogs('{{ pod.name }}')" title="View logs">[📄]</button>
|
||||||
|
<button class="pod-btn desc-btn" onclick="fetchPodDescribe('{{ pod.name }}')" title="Describe pod">[i]</button>
|
||||||
|
{% if pod.role == 'igw-database-operation' %}
|
||||||
|
<button class="pod-btn del-btn-safe" onclick="promptDeletePod('{{ pod.name }}', true)" title="Delete DB backup pod">[🗑 DB backup]</button>
|
||||||
|
{% else %}
|
||||||
|
<button class="pod-btn del-btn" onclick="promptDeletePod('{{ pod.name }}', false)" title="Delete pod">[🗑]</button>
|
||||||
|
{% endif %}
|
||||||
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
{% else %}
|
{% else %}
|
||||||
<tr><td colspan="3" class="empty">No pods found</td></tr>
|
<tr><td colspan="4" class="empty">No pods found</td></tr>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<!-- Pod Logs Modal -->
|
||||||
|
<div id="logs-modal" class="modal-overlay" style="display:none;" onclick="if(event.target===this)closeModal('logs-modal')">
|
||||||
|
<div class="modal" style="max-width:900px;">
|
||||||
|
<div class="modal-header"><h3>Pod Logs — <span id="logs-pod-name"></span></h3></div>
|
||||||
|
<div id="logs-loading" style="padding:20px;text-align:center;color:var(--text-muted);">Loading logs...</div>
|
||||||
|
<pre id="logs-content" style="max-height:500px;overflow:auto;white-space:pre-wrap;display:none;margin:0;padding:16px;font-size:12px;background:var(--bg-card);color:var(--text);border-top:1px solid var(--border);"></pre>
|
||||||
|
<div class="modal-actions" style="padding:12px 16px;border-top:1px solid var(--border);">
|
||||||
|
<button onclick="closeModal('logs-modal')" class="btn-cancel">Close</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Pod Describe Modal -->
|
||||||
|
<div id="describe-modal" class="modal-overlay" style="display:none;" onclick="if(event.target===this)closeModal('describe-modal')">
|
||||||
|
<div class="modal" style="max-width:900px;">
|
||||||
|
<div class="modal-header"><h3>Describe Pod — <span id="describe-pod-name"></span></h3></div>
|
||||||
|
<div id="describe-loading" style="padding:20px;text-align:center;color:var(--text-muted);">Loading...</div>
|
||||||
|
<pre id="describe-content" style="max-height:500px;overflow:auto;white-space:pre-wrap;display:none;margin:0;padding:16px;font-size:12px;background:var(--bg-card);color:var(--text);border-top:1px solid var(--border);"></pre>
|
||||||
|
<div class="modal-actions" style="padding:12px 16px;border-top:1px solid var(--border);">
|
||||||
|
<button onclick="closeModal('describe-modal')" class="btn-cancel">Close</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Delete Confirmation Modal -->
|
||||||
|
<div id="delete-modal" class="modal-overlay" style="display:none;">
|
||||||
|
<div class="modal" style="max-width:450px;">
|
||||||
|
<div class="modal-header"><h3 id="delete-modal-title">Delete Pod</h3></div>
|
||||||
|
<div class="modal-body" style="padding:20px;">
|
||||||
|
<p id="delete-modal-message">Are you sure you want to delete this pod?</p>
|
||||||
|
<p style="font-family:monospace;font-size:14px;padding:8px 12px;background:var(--bg-card);border-radius:4px;margin:12px 0 0;" id="delete-pod-name-display"></p>
|
||||||
|
</div>
|
||||||
|
<div class="modal-actions" style="padding:12px 16px;border-top:1px solid var(--border);">
|
||||||
|
<button onclick="closeModal('delete-modal')" class="btn-cancel">Cancel</button>
|
||||||
|
<button id="delete-confirm-btn" onclick="confirmDeletePod()" class="btn-danger" style="margin-left:8px;">Delete Pod</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
@@ -178,9 +230,208 @@ function setupTerminalInput(term, type) {
|
|||||||
socket.emit('shell_input', {data: data, type: type});
|
socket.emit('shell_input', {data: data, type: type});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ── Pod action functions ──────────────────────────────────────────
|
||||||
|
|
||||||
|
let _pendingDeletePod = null;
|
||||||
|
|
||||||
|
function openModal(id) {
|
||||||
|
document.getElementById(id).style.display = '';
|
||||||
|
}
|
||||||
|
|
||||||
|
function closeModal(id) {
|
||||||
|
document.getElementById(id).style.display = 'none';
|
||||||
|
}
|
||||||
|
|
||||||
|
function shellPod(name) {
|
||||||
|
const sel = document.getElementById('pod-select');
|
||||||
|
for (let i = 0; i < sel.options.length; i++) {
|
||||||
|
if (sel.options[i].value === name) {
|
||||||
|
sel.selectedIndex = i;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!connectedPod) {
|
||||||
|
toggleShell('pod');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function fetchPodLogs(name) {
|
||||||
|
document.getElementById('logs-pod-name').textContent = name;
|
||||||
|
document.getElementById('logs-content').style.display = 'none';
|
||||||
|
document.getElementById('logs-loading').style.display = '';
|
||||||
|
document.getElementById('logs-content').textContent = '';
|
||||||
|
openModal('logs-modal');
|
||||||
|
csrfFetch('/api/pod/logs', {
|
||||||
|
method: 'POST',
|
||||||
|
headers: {'Content-Type': 'application/json'},
|
||||||
|
body: JSON.stringify({pod: name}),
|
||||||
|
})
|
||||||
|
.then(r => r.json())
|
||||||
|
.then(data => {
|
||||||
|
document.getElementById('logs-loading').style.display = 'none';
|
||||||
|
if (data.success) {
|
||||||
|
const el = document.getElementById('logs-content');
|
||||||
|
el.textContent = data.logs || '(empty logs)';
|
||||||
|
el.style.display = '';
|
||||||
|
} else {
|
||||||
|
document.getElementById('logs-content').textContent = 'Error: ' + (data.error || 'Unknown');
|
||||||
|
document.getElementById('logs-content').style.display = '';
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.catch(err => {
|
||||||
|
document.getElementById('logs-loading').style.display = 'none';
|
||||||
|
document.getElementById('logs-content').textContent = 'Request failed: ' + err;
|
||||||
|
document.getElementById('logs-content').style.display = '';
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function fetchPodDescribe(name) {
|
||||||
|
document.getElementById('describe-pod-name').textContent = name;
|
||||||
|
document.getElementById('describe-content').style.display = 'none';
|
||||||
|
document.getElementById('describe-loading').style.display = '';
|
||||||
|
document.getElementById('describe-content').textContent = '';
|
||||||
|
openModal('describe-modal');
|
||||||
|
csrfFetch('/api/pod/describe', {
|
||||||
|
method: 'POST',
|
||||||
|
headers: {'Content-Type': 'application/json'},
|
||||||
|
body: JSON.stringify({pod: name}),
|
||||||
|
})
|
||||||
|
.then(r => r.json())
|
||||||
|
.then(data => {
|
||||||
|
document.getElementById('describe-loading').style.display = 'none';
|
||||||
|
if (data.success) {
|
||||||
|
const el = document.getElementById('describe-content');
|
||||||
|
el.textContent = data.describe || '(empty)';
|
||||||
|
el.style.display = '';
|
||||||
|
} else {
|
||||||
|
document.getElementById('describe-content').textContent = 'Error: ' + (data.error || 'Unknown');
|
||||||
|
document.getElementById('describe-content').style.display = '';
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.catch(err => {
|
||||||
|
document.getElementById('describe-loading').style.display = 'none';
|
||||||
|
document.getElementById('describe-content').textContent = 'Request failed: ' + err;
|
||||||
|
document.getElementById('describe-content').style.display = '';
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function promptDeletePod(name, safe) {
|
||||||
|
_pendingDeletePod = name;
|
||||||
|
document.getElementById('delete-pod-name-display').textContent = name;
|
||||||
|
const title = document.getElementById('delete-modal-title');
|
||||||
|
const msg = document.getElementById('delete-modal-message');
|
||||||
|
const btn = document.getElementById('delete-confirm-btn');
|
||||||
|
if (safe) {
|
||||||
|
title.textContent = 'Delete DB Backup Pod';
|
||||||
|
msg.innerHTML = 'This pod stores database backups. It is <strong>safe to delete</strong> — Kubernetes will recreate it automatically. Continue?';
|
||||||
|
btn.className = 'btn-edit';
|
||||||
|
btn.textContent = 'Delete Backup Pod';
|
||||||
|
} else {
|
||||||
|
title.textContent = 'Delete Pod?';
|
||||||
|
msg.innerHTML = 'Deleting a pod will restart it. Depending on the pod role, this may cause a brief service interruption. Proceed?';
|
||||||
|
btn.className = 'btn-danger';
|
||||||
|
btn.textContent = 'Delete Pod';
|
||||||
|
}
|
||||||
|
openModal('delete-modal');
|
||||||
|
}
|
||||||
|
|
||||||
|
function confirmDeletePod() {
|
||||||
|
const name = _pendingDeletePod;
|
||||||
|
if (!name) return;
|
||||||
|
closeModal('delete-modal');
|
||||||
|
const btn = document.querySelector(`[data-pod="${name}"] .del-btn, [data-pod="${name}"] .del-btn-safe`);
|
||||||
|
if (btn) { btn.textContent = '...'; btn.disabled = true; }
|
||||||
|
csrfFetch('/api/pod/delete', {
|
||||||
|
method: 'POST',
|
||||||
|
headers: {'Content-Type': 'application/json'},
|
||||||
|
body: JSON.stringify({pod: name}),
|
||||||
|
})
|
||||||
|
.then(r => r.json())
|
||||||
|
.then(data => {
|
||||||
|
if (data.success) {
|
||||||
|
setTimeout(refreshPodList, 3000);
|
||||||
|
} else {
|
||||||
|
alert('Delete failed: ' + (data.error || 'Unknown'));
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.catch(err => {
|
||||||
|
alert('Delete request failed: ' + err);
|
||||||
|
})
|
||||||
|
.finally(() => {
|
||||||
|
_pendingDeletePod = null;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function refreshPodList() {
|
||||||
|
csrfFetch('/api/pods')
|
||||||
|
.then(r => r.json())
|
||||||
|
.then(data => {
|
||||||
|
if (!data.success) return;
|
||||||
|
const tbody = document.querySelector('#pods-table tbody');
|
||||||
|
const countEl = document.getElementById('pod-count');
|
||||||
|
if (!tbody) return;
|
||||||
|
tbody.innerHTML = '';
|
||||||
|
if (!data.pods || data.pods.length === 0) {
|
||||||
|
tbody.innerHTML = '<tr><td colspan="4" class="empty">No pods found</td></tr>';
|
||||||
|
if (countEl) countEl.textContent = '0';
|
||||||
|
// Also update pod select
|
||||||
|
const sel = document.getElementById('pod-select');
|
||||||
|
sel.innerHTML = '';
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (countEl) countEl.textContent = data.pods.length;
|
||||||
|
// Rebuild pod select
|
||||||
|
const sel = document.getElementById('pod-select');
|
||||||
|
sel.innerHTML = '';
|
||||||
|
data.pods.forEach(p => {
|
||||||
|
const opt = document.createElement('option');
|
||||||
|
opt.value = p.name;
|
||||||
|
opt.textContent = p.name;
|
||||||
|
sel.appendChild(opt);
|
||||||
|
// Build table row
|
||||||
|
const tr = document.createElement('tr');
|
||||||
|
tr.dataset.pod = p.name;
|
||||||
|
tr.dataset.role = p.role || '';
|
||||||
|
const role = p.role || 'default';
|
||||||
|
const roleLower = role.toLowerCase();
|
||||||
|
tr.innerHTML = `
|
||||||
|
<td style="font-family:monospace;font-size:12px;">${p.name}</td>
|
||||||
|
<td><span class="badge badge-${roleLower}">${role}</span></td>
|
||||||
|
<td><span class="badge badge-${p.status.toLowerCase()}">${p.status}</span></td>
|
||||||
|
<td style="white-space:nowrap;">
|
||||||
|
<button class="pod-btn shell-btn" onclick="shellPod('${p.name}')" title="Open shell">[>_]</button>
|
||||||
|
<button class="pod-btn logs-btn" onclick="fetchPodLogs('${p.name}')" title="View logs">[📄]</button>
|
||||||
|
<button class="pod-btn desc-btn" onclick="fetchPodDescribe('${p.name}')" title="Describe pod">[i]</button>
|
||||||
|
${p.role === 'igw-database-operation'
|
||||||
|
? `<button class="pod-btn del-btn-safe" onclick="promptDeletePod('${p.name}', true)" title="Delete DB backup pod">[🗑 DB backup]</button>`
|
||||||
|
: `<button class="pod-btn del-btn" onclick="promptDeletePod('${p.name}', false)" title="Delete pod">[🗑]</button>`
|
||||||
|
}
|
||||||
|
</td>`;
|
||||||
|
tbody.appendChild(tr);
|
||||||
|
});
|
||||||
|
})
|
||||||
|
.catch(() => {});
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
<style>
|
<style>
|
||||||
.xterm { height: 100%; }
|
.xterm { height: 100%; }
|
||||||
.xterm-viewport { overflow-y: auto !important; }
|
.xterm-viewport { overflow-y: auto !important; }
|
||||||
|
.pod-btn {
|
||||||
|
padding: 2px 6px; border: none; border-radius: 3px;
|
||||||
|
cursor: pointer; font-size: 11px; font-family: monospace;
|
||||||
|
margin: 0 2px; line-height: 1.6;
|
||||||
|
}
|
||||||
|
.shell-btn { background: var(--primary); color: #fff; }
|
||||||
|
.shell-btn:hover { opacity: .85; }
|
||||||
|
.logs-btn { background: #5a6c7d; color: #fff; }
|
||||||
|
.logs-btn:hover { opacity: .85; }
|
||||||
|
.desc-btn { background: #6c5a7d; color: #fff; }
|
||||||
|
.desc-btn:hover { opacity: .85; }
|
||||||
|
.del-btn { background: #c0392b; color: #fff; }
|
||||||
|
.del-btn:hover { opacity: .85; }
|
||||||
|
.del-btn-safe { background: #27ae60; color: #fff; padding: 2px 8px; }
|
||||||
|
.del-btn-safe:hover { opacity: .85; }
|
||||||
|
.pod-btn:disabled { opacity: .5; cursor: not-allowed; }
|
||||||
</style>
|
</style>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
Reference in new issue
Block a user