feat: add software stack versions modal and quick terminal button, expose stack API
This commit is contained in:
parent
1632acb14c
commit
68721e79ec
@ -626,6 +626,7 @@
|
||||
<div class="terminal-quick-actions-bar" aria-label="Comandos rápidos del sistema">
|
||||
<span class="quick-actions-label">Comandos Rápidos:</span>
|
||||
<div class="quick-buttons-wrapper">
|
||||
<button type="button" class="btn-quick-cmd" data-cmd="echo '=== VERSIONES DEL STACK ===' && echo 'Node.js: '$(node -v) && echo 'TypeScript: '$(tsc -v) && echo 'Python: '$(python3 --version) && echo 'PHP: '$(php -v | head -n 1) && echo 'MySQL: '$(mysql -V) && echo 'PostgreSQL: '$(psql -V) && echo 'SQLite3: '$(sqlite3 --version) && echo 'Apache2: '$(apache2 -v | head -n 1) && echo 'PM2: 'v$(pm2 -v)" style="border-color: var(--accent-lime); color: var(--accent-lime); font-weight: 700;">📦 Ver Versiones del Stack</button>
|
||||
<button type="button" class="btn-quick-cmd" data-cmd="apache2ctl -S">apache2ctl -S</button>
|
||||
<button type="button" class="btn-quick-cmd" data-cmd="pm2 list">pm2 list</button>
|
||||
<button type="button" class="btn-quick-cmd" data-cmd="free -m">free -m</button>
|
||||
@ -963,6 +964,30 @@
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Tarjeta 4: Stack de Software y Versiones -->
|
||||
<div class="maintenance-card">
|
||||
<div class="maintenance-card-header">
|
||||
<div class="maintenance-icon-badge" style="background: rgba(132, 204, 22, 0.15); color: var(--accent-lime);">
|
||||
<svg viewBox="0 0 20 20" width="20" height="20" fill="none" stroke="currentColor" stroke-width="2">
|
||||
<path stroke-linecap="round" stroke-linejoin="round" d="M4 6l6-3 6 3-6 3-6-3zm0 4l6 3 6-3m-12 4l6 3 6-3"></path>
|
||||
</svg>
|
||||
</div>
|
||||
<div>
|
||||
<h4 class="maintenance-card-title">📦 Stack de Desarrollo y Versiones</h4>
|
||||
<p class="maintenance-card-desc">Verifica las versiones de Node, TypeScript, Python, PHP, MySQL, PostgreSQL, SQLite y Apache.</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="maintenance-card-actions">
|
||||
<button type="button" id="btn-view-stack-versions" class="btn btn-secondary btn-maintenance">
|
||||
<svg viewBox="0 0 16 16" width="14" height="14" fill="none" stroke="currentColor" stroke-width="2">
|
||||
<circle cx="8" cy="8" r="7"></circle>
|
||||
<path d="M8 5v6M5 8h6"></path>
|
||||
</svg>
|
||||
<span>Ver Versiones del Software</span>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@ -2097,6 +2122,51 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- =======================================================================
|
||||
Modal: Stack de Software y Versiones Instaladas
|
||||
======================================================================= -->
|
||||
<div id="modal-stack-versions" class="modal-backdrop" role="dialog" aria-modal="true" aria-labelledby="modal-stack-title">
|
||||
<div class="modal-dialog modal-dialog-lg">
|
||||
<div class="modal-header">
|
||||
<div class="modal-title-wrap">
|
||||
<div class="modal-icon-badge" style="background: rgba(132, 204, 22, 0.15); color: var(--accent-lime); border-color: rgba(132, 204, 22, 0.3);">
|
||||
<svg viewBox="0 0 20 20" width="18" height="18" fill="none" stroke="currentColor" stroke-width="2">
|
||||
<path stroke-linecap="round" stroke-linejoin="round" d="M4 6l6-3 6 3-6 3-6-3zm0 4l6 3 6-3m-12 4l6 3 6-3"></path>
|
||||
</svg>
|
||||
</div>
|
||||
<h2 id="modal-stack-title" class="modal-title">Stack de Desarrollo y Versiones Instaladas</h2>
|
||||
</div>
|
||||
<button type="button" class="modal-close-btn" aria-label="Cerrar modal">×</button>
|
||||
</div>
|
||||
|
||||
<div class="modal-body">
|
||||
<p style="font-size: 0.88rem; color: var(--text-secondary); margin-bottom: 1rem; line-height: 1.5;">
|
||||
Estas herramientas se encuentran instaladas en el sistema operativo del VPS y están disponibles para ser utilizadas en tus proyectos:
|
||||
</p>
|
||||
|
||||
<div class="table-responsive">
|
||||
<table class="data-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Herramienta / Software</th>
|
||||
<th>Categoría</th>
|
||||
<th>Versión Detectada</th>
|
||||
<th style="text-align: right;">Estado</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody id="stack-versions-table-body">
|
||||
<!-- Se llena dinámicamente -->
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-secondary btn-modal-cancel">Cerrar</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- =======================================================================
|
||||
Modal: Confirmación de Finalizar Proceso (Kill PID)
|
||||
======================================================================= -->
|
||||
|
||||
@ -375,6 +375,10 @@ class ApiClient {
|
||||
return this.request('/system/firewall', { method: 'GET' });
|
||||
}
|
||||
|
||||
async getSoftwareStack() {
|
||||
return this.request('/system/stack', { method: 'GET' });
|
||||
}
|
||||
|
||||
// --- Users Endpoints ---
|
||||
async getUsers() {
|
||||
return this.request('/users', { method: 'GET' });
|
||||
|
||||
@ -2142,7 +2142,36 @@ function setupMonitor() {
|
||||
navigator.clipboard.writeText(codeBlock.textContent).then(() => {
|
||||
toast.info('Comandos Copiados', 'Reglas UFW copiadas al portapapeles.');
|
||||
}).catch(() => {
|
||||
toast.info('Comandos seleccionados');
|
||||
toast.error('No se pudo copiar', 'Copia manualmente el texto de la caja.');
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// Ver Versiones del Stack Tecnológico
|
||||
const btnViewStack = document.getElementById('btn-view-stack-versions');
|
||||
if (btnViewStack) {
|
||||
btnViewStack.addEventListener('click', async () => {
|
||||
openModal('modal-stack-versions');
|
||||
const tbody = document.getElementById('stack-versions-table-body');
|
||||
if (tbody) tbody.innerHTML = `<tr><td colspan="4" style="text-align: center; color: var(--text-muted); padding: 1.5rem;">Detectando versiones del software en el servidor...</td></tr>`;
|
||||
|
||||
try {
|
||||
const res = await api.getSoftwareStack();
|
||||
const items = res.data || res;
|
||||
if (tbody && Array.isArray(items)) {
|
||||
tbody.innerHTML = items.map(item => `
|
||||
<tr>
|
||||
<td><strong style="color: var(--text-primary);">${escapeHtml(item.name)}</strong></td>
|
||||
<td><span class="text-xs text-muted">${escapeHtml(item.category)}</span></td>
|
||||
<td><code class="credential-value" style="font-size: 0.82rem; color: var(--accent-lime);">${escapeHtml(item.version)}</code></td>
|
||||
<td style="text-align: right;"><span class="badge ${item.installed ? 'badge-status-active' : 'badge-status-disabled'}">${item.installed ? 'Instalado · Listo' : 'No detectado'}</span></td>
|
||||
</tr>
|
||||
`).join('');
|
||||
}
|
||||
} catch (err) {
|
||||
if (tbody) tbody.innerHTML = `<tr><td colspan="4" style="text-align: center; color: var(--status-danger); padding: 1.5rem;">Error al detectar versiones: ${escapeHtml(err.message)}</td></tr>`;
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
@ -79,6 +79,15 @@ export class SystemController {
|
||||
next(err);
|
||||
}
|
||||
};
|
||||
|
||||
stack = async (req, res, next) => {
|
||||
try {
|
||||
const items = await this.systemService.getSoftwareStack();
|
||||
return res.json(items);
|
||||
} catch (err) {
|
||||
next(err);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
export const defaultSystemController = new SystemController();
|
||||
|
||||
@ -11,6 +11,7 @@ export function createSystemRoutes(controller = defaultSystemController) {
|
||||
router.get('/processes', controller.processes);
|
||||
router.get('/disk-breakdown', controller.diskBreakdown);
|
||||
router.get('/firewall', controller.firewall);
|
||||
router.get('/stack', controller.stack);
|
||||
|
||||
// Acciones administrativas de mantenimiento y control
|
||||
router.post('/clean-ram', requireRole('admin'), controller.cleanRam);
|
||||
|
||||
@ -551,6 +551,70 @@ export class SystemService {
|
||||
}
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Detecta y retorna las versiones de todo el stack de software instalado.
|
||||
* @returns {Promise<Array<object>>}
|
||||
*/
|
||||
async getSoftwareStack() {
|
||||
const isMock = config.mockApache || process.env.NODE_ENV === 'test';
|
||||
if (isMock) {
|
||||
return [
|
||||
{ name: 'Node.js', category: 'Runtime', version: process.version, installed: true, icon: 'node' },
|
||||
{ name: 'TypeScript', category: 'Compiler', version: 'Version 7.0.2', installed: true, icon: 'ts' },
|
||||
{ name: 'Python 3', category: 'Language', version: 'Python 3.10.12', installed: true, icon: 'python' },
|
||||
{ name: 'PIP (Python)', category: 'Package Manager', version: 'pip 22.0.2', installed: true, icon: 'python' },
|
||||
{ name: 'PHP', category: 'Web Language', version: 'PHP 8.1.2', installed: true, icon: 'php' },
|
||||
{ name: 'MySQL / MariaDB', category: 'Database', version: 'MySQL 8.0.46', installed: true, icon: 'db' },
|
||||
{ name: 'PostgreSQL', category: 'Database', version: 'PostgreSQL 14.24', installed: true, icon: 'db' },
|
||||
{ name: 'SQLite', category: 'Embedded DB', version: 'SQLite 3.37.2', installed: true, icon: 'db' },
|
||||
{ name: 'Apache2', category: 'Web Server', version: 'Apache/2.4.52', installed: true, icon: 'server' },
|
||||
{ name: 'PM2', category: 'Process Manager', version: 'v7.1.2', installed: true, icon: 'server' },
|
||||
{ name: 'vsFTPd', category: 'FTP Server', version: 'v3.0.5', installed: true, icon: 'ftp' },
|
||||
{ name: 'Git', category: 'Version Control', version: '2.34.1', installed: true, icon: 'git' }
|
||||
];
|
||||
}
|
||||
|
||||
const checkCmd = async (cmd, parseFn) => {
|
||||
try {
|
||||
const { stdout, stderr } = await execFileAsync('/bin/bash', ['-c', cmd], { timeout: 3000 });
|
||||
const out = (stdout || stderr || '').trim();
|
||||
return out ? parseFn(out) : { version: 'No instalado', installed: false };
|
||||
} catch {
|
||||
return { version: 'No instalado', installed: false };
|
||||
}
|
||||
};
|
||||
|
||||
const [nodeV, tsV, pyV, pipV, phpV, mysqlV, pgV, sqliteV, apacheV, pm2V, ftpV, gitV] = await Promise.all([
|
||||
checkCmd('node -v', (s) => ({ version: s.split('\n')[0], installed: true })),
|
||||
checkCmd('tsc -v', (s) => ({ version: s.split('\n')[0], installed: true })),
|
||||
checkCmd('python3 --version', (s) => ({ version: s.split('\n')[0], installed: true })),
|
||||
checkCmd('pip3 --version', (s) => ({ version: s.split(' ')[0] + ' ' + s.split(' ')[1], installed: true })),
|
||||
checkCmd('php -v', (s) => ({ version: s.split('\n')[0].split(' ')[0] + ' ' + s.split('\n')[0].split(' ')[1], installed: true })),
|
||||
checkCmd('mysql -V', (s) => ({ version: s.split('\n')[0].split(',')[0], installed: true })),
|
||||
checkCmd('psql -V', (s) => ({ version: s.split('\n')[0], installed: true })),
|
||||
checkCmd('sqlite3 --version', (s) => ({ version: s.split(' ')[0], installed: true })),
|
||||
checkCmd('apache2 -v', (s) => ({ version: s.split('\n')[0].split(':')[1]?.trim() || s, installed: true })),
|
||||
checkCmd('pm2 -v', (s) => ({ version: 'v' + s.split('\n')[0].trim(), installed: true })),
|
||||
checkCmd('dpkg -l vsftpd 2>/dev/null | awk \'/vsftpd/ {print $3}\'', (s) => ({ version: s ? 'v' + s : 'v3.0.5', installed: Boolean(s) })),
|
||||
checkCmd('git --version', (s) => ({ version: s.split('\n')[0], installed: true }))
|
||||
]);
|
||||
|
||||
return [
|
||||
{ name: 'Node.js', category: 'Runtime', version: nodeV.version, installed: nodeV.installed, icon: 'node' },
|
||||
{ name: 'TypeScript', category: 'Compiler', version: tsV.version, installed: tsV.installed, icon: 'ts' },
|
||||
{ name: 'Python 3', category: 'Language', version: pyV.version, installed: pyV.installed, icon: 'python' },
|
||||
{ name: 'PIP (Python)', category: 'Package Manager', version: pipV.version, installed: pipV.installed, icon: 'python' },
|
||||
{ name: 'PHP', category: 'Web Language', version: phpV.version, installed: phpV.installed, icon: 'php' },
|
||||
{ name: 'MySQL / MariaDB', category: 'Database', version: mysqlV.version, installed: mysqlV.installed, icon: 'db' },
|
||||
{ name: 'PostgreSQL', category: 'Database', version: pgV.version, installed: pgV.installed, icon: 'db' },
|
||||
{ name: 'SQLite', category: 'Embedded DB', version: sqliteV.version, installed: sqliteV.installed, icon: 'db' },
|
||||
{ name: 'Apache2', category: 'Web Server', version: apacheV.version, installed: apacheV.installed, icon: 'server' },
|
||||
{ name: 'PM2', category: 'Process Manager', version: pm2V.version, installed: pm2V.installed, icon: 'server' },
|
||||
{ name: 'vsFTPd', category: 'FTP Server', version: ftpV.version, installed: ftpV.installed, icon: 'ftp' },
|
||||
{ name: 'Git', category: 'Version Control', version: gitV.version, installed: gitV.installed, icon: 'git' }
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
function formatBytes(bytes) {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user