Nuevo menú por defecto en el cliente, organizando la información por discos
testing/ogcore-api/pipeline/head This commit looks good Details
testing/ogcore-api/pipeline/pr-main Build started... Details

pull/71/head
Juan Manuel Bardallo 2026-02-27 09:53:40 +01:00
parent 9a49154cbb
commit c1090936ab
3 changed files with 169 additions and 48 deletions

View File

@ -1,4 +1,9 @@
# Changelog
## [1.2.2] - 2026-02-27
### Improved
- Nuevo menú por defecto en el cliente, organizando la información por discos
---
## [1.2.1] - 2025-10-22
### Fixed
- Se ha corregido un error en el commando que se encarga de ejecutar tareas pendientes.

View File

@ -29,9 +29,42 @@ class MenuBrowserController extends AbstractController
$partitions = [];
$client = $this->entityManager->getRepository(Client::class)->findOneBy(['ip' => $host]);
$disks = []; // Array nuevo estructurado
if ($client) {
$partitions = $client->getPartitions();
$rawPartitions = $client->getPartitions()->toArray();
foreach ($rawPartitions as $part) {
$diskNum = $part->getDiskNumber();
$partNum = $part->getPartitionNumber();
// Inicializamos el array del disco si no existe
if (!isset($disks[$diskNum])) {
$disks[$diskNum] = [
'info' => null, // Aquí guardaremos la partición 0 (tamaño total)
'parts' => [] // Aquí las particiones reales
];
}
if ($partNum == 0) {
// Es la info del disco completo
$disks[$diskNum]['info'] = $part;
} else {
// Es una partición normal
$disks[$diskNum]['parts'][] = $part;
}
}
// Ordenamos los discos (1, 2, 3...)
ksort($disks);
// Ordenamos las particiones dentro de cada disco (1, 2, 3...)
foreach ($disks as &$diskData) {
usort($diskData['parts'], function($a, $b) {
return $a->getPartitionNumber() <=> $b->getPartitionNumber();
});
}
}
$menuName = $client->getMenu()->getPublicUrl();
@ -39,7 +72,7 @@ class MenuBrowserController extends AbstractController
return $this->render('browser/' . $menuName . '.html.twig', [
'ip' => $host,
'mac' => $client ? $client->getMac() : null,
'partitions' => $partitions,
'disks' => $disks,
]);
}
@ -54,7 +87,7 @@ class MenuBrowserController extends AbstractController
return $this->render($templatePath, [
'ip' => 'invitado',
'partitions' => [],
'disks' => [],
]);
}
}

View File

@ -34,7 +34,7 @@
background-color: var(--background-color);
color: var(--text-color);
line-height: 1.5;
background-image:
background-image:
radial-gradient(at 0% 0%, rgba(37, 99, 235, 0.1) 0px, transparent 50%),
radial-gradient(at 100% 100%, rgba(5, 150, 105, 0.1) 0px, transparent 50%);
min-height: 100vh;
@ -210,15 +210,15 @@
.linux i { color: var(--success-color); }
.apagar i { color: var(--danger-color); }
.windows a:hover {
.windows a:hover {
background-color: rgba(37, 99, 235, 0.1);
color: var(--primary-color);
}
.linux a:hover {
.linux a:hover {
background-color: rgba(5, 150, 105, 0.1);
color: var(--success-color);
}
.apagar a:hover {
.apagar a:hover {
background-color: rgba(220, 38, 38, 0.1);
color: var(--danger-color);
}
@ -393,7 +393,6 @@
border: 2px dashed #cbd5e1;
}
/* Estados especiales para diferentes tipos de particiones */
.partition-os {
font-weight: 600;
color: var(--success-color);
@ -444,6 +443,57 @@
font-size: 0.8rem;
}
}
/* --- NUEVOS ESTILOS PARA LA AGRUPACIÓN POR DISCOS --- */
.disk-container {
margin-bottom: 2.5rem;
border: 1px solid #e2e8f0;
border-radius: var(--border-radius);
overflow: hidden;
background: white;
box-shadow: 0 4px 6px rgba(0, 0, 0, 0.02);
}
.disk-header {
background: #f8fafc;
padding: 1rem 1.5rem;
border-bottom: 1px solid #e2e8f0;
display: flex;
justify-content: space-between;
align-items: center;
}
.disk-header h3 {
margin: 0;
font-size: 1.1rem;
color: var(--text-color);
display: flex;
align-items: center;
gap: 0.5rem;
}
.disk-total-badge {
background: linear-gradient(135deg, var(--primary-color), var(--primary-light));
color: white;
padding: 0.35rem 0.85rem;
border-radius: 20px;
font-size: 0.85rem;
font-weight: 600;
box-shadow: 0 2px 4px rgba(37, 99, 235, 0.2);
}
.empty-disk {
text-align: center;
padding: 2rem;
color: #64748b;
font-style: italic;
}
.partition-number {
font-weight: bold;
font-size: 1.1rem;
color: var(--text-color);
}
</style>
</head>
<body>
@ -475,48 +525,81 @@
</section>
<section class="partitions-section">
<h2><i class="fas fa-hdd"></i> Particiones del sistema</h2>
{% if partitions|length > 0 %}
<div class="partitions-table">
<table>
<thead>
<tr>
<th>Disco</th>
<th>Partición</th>
<th>Tamaño</th>
<th>Tipo</th>
<th>SO</th>
<th>Acciones</th>
</tr>
</thead>
<tbody>
{% for partition in partitions %}
<tr>
<td><strong>{{ partition.diskNumber }}</strong></td>
<td><span class="partition-type">{{ partition.partitionNumber }}</span></td>
<td class="partition-size">{{ (partition.size / 1024)|number_format(2) }} MB</td>
<td><span class="partition-type">{{ partition.filesystem }}</span></td>
<td class="partition-os">{{ partition.operativeSystem ? partition.operativeSystem.name : '-' }}</td>
<td>
{% if partition.operativeSystem %}
<a href="command+output:/opt/opengnsys/scripts/bootOs {{ partition.diskNumber }} {{ partition.partitionNumber }}"
class="partition-boot-btn"
role="button">
<i class="fas fa-play"></i>
Arrancar {{ partition.operativeSystem.name }}
</a>
{% endif %}
</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
<h2><i class="fas fa-hdd"></i> Almacenamiento del sistema</h2>
{% if disks is defined and disks|length > 0 %}
{% for diskNum, data in disks %}
<div class="disk-container">
<div class="disk-header">
<h3>
<i class="fas fa-server"></i> Disco {{ diskNum }}
</h3>
{% if data.info %}
<span class="disk-total-badge">
Total: {{ (data.info.size / 1024 / 1024)|number_format(2) }} GB
</span>
{% endif %}
</div>
<div class="partitions-table" style="box-shadow: none; border: none; border-radius: 0;">
<table>
<thead>
<tr>
<th style="width: 15%;">Partición</th>
<th style="width: 20%;">Tamaño</th>
<th style="width: 15%;">Tipo</th>
<th style="width: 30%;">Sistema Operativo</th>
<th style="width: 20%;">Acciones</th>
</tr>
</thead>
<tbody>
{% for partition in data.parts %}
<tr>
<td style="text-align: center;">
<span class="partition-number">{{ partition.partitionNumber }}</span>
</td>
<td class="partition-size">
{{ (partition.size / 1024)|number_format(0) }} MB
</td>
<td>
<span class="partition-type">{{ partition.filesystem|default('-') }}</span>
</td>
<td class="partition-os">
{{ partition.operativeSystem ? partition.operativeSystem.name : '-' }}
</td>
<td>
{% if partition.operativeSystem %}
<a href="command+output:/opt/opengnsys/scripts/bootOs {{ partition.diskNumber }} {{ partition.partitionNumber }}"
class="partition-boot-btn"
role="button">
<i class="fas fa-play"></i> Arrancar {{ partition.operativeSystem.name }}
</a>
{% endif %}
</td>
</tr>
{% else %}
<tr>
<td colspan="5" class="empty-disk">
No hay particiones utilizables en este disco.
</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
</div>
{% endfor %}
{% else %}
<p class="no-partitions">No hay particiones disponibles.</p>
<p class="no-partitions">No hay discos detectados en el sistema.</p>
{% endif %}
</section>
</main>
</body>
</html>
</html>