0.2.0: job engine, VM actions, theme-aware styling
This commit is contained in:
1 parent
c62de24cc0
commit
485a267ffe
14 files changed
+901
-71
No files matched your search
+75
-30
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
/*
|
||||
* vmmngr.php - VM Manager dashboard (read-only preview 0.1.0)
|
||||
* vmmngr.php - VM Manager dashboard (0.2.0: actions via job engine)
|
||||
*/
|
||||
|
||||
require_once 'vmmngr-boot.inc';
|
||||
@@ -11,6 +11,7 @@ $vmprov = vmm_resolve('vm');
|
||||
$vms = $vmprov['available'] ? vmm_list() : [];
|
||||
$ver = $vmprov['available'] ? vmm_vm_version() : ['version' => '', 'rev' => ''];
|
||||
$vm_dir = $vmprov['available'] ? vmm_vm_dir() : '';
|
||||
$budget = vmm_ram_budget();
|
||||
|
||||
$running = array_values(array_filter($vms, static fn(array $v): bool => ($v['state'] ?? '') === 'running'));
|
||||
$mem_used = 0;
|
||||
@@ -19,27 +20,17 @@ foreach ($running as $v) {
|
||||
$mem_used += vmm_size_to_bytes((string)($v['memory'] ?? '0'));
|
||||
$cpus += (int)($v['cpu'] ?? 0);
|
||||
}
|
||||
vmm_job_recover();
|
||||
$jobs = vmm_job_list(5);
|
||||
|
||||
include 'fbegin.inc';
|
||||
vmm_css();
|
||||
?>
|
||||
<style>
|
||||
.vmm-badge{display:inline-block;padding:1px 8px;border-radius:10px;font-size:11px;font-weight:600;letter-spacing:.02em}
|
||||
.vmm-running{background:#153e2b;color:#5ee79b;border:1px solid #2f7d54}
|
||||
.vmm-stopped{background:#3a2c2c;color:#e0a0a0;border:1px solid #7d4a4a}
|
||||
.vmm-suspended,.vmm-starting{background:#3a3320;color:#e8cf7a;border:1px solid #7d6a2f}
|
||||
.vmm-unknown,.vmm-locked{background:#2c2c3a;color:#a9a9d0;border:1px solid #4a4a7d}
|
||||
.vmm-grid{display:flex;flex-wrap:wrap;gap:10px;margin:10px 0 14px}
|
||||
.vmm-card{flex:1 1 150px;min-width:150px;padding:10px 12px;border:1px solid #3a3f46;border-radius:6px;background:#23272c}
|
||||
.vmm-card .k{font-size:11px;text-transform:uppercase;letter-spacing:.05em;opacity:.65}
|
||||
.vmm-card .v{font-size:20px;font-weight:600;margin-top:2px}
|
||||
.vmm-card .s{font-size:11px;opacity:.7;margin-top:2px}
|
||||
.vmm-mono{font-family:monospace;font-size:12px}
|
||||
</style>
|
||||
|
||||
<form action="vmmngr.php" method="post" name="iform" id="iform"><table id="area_data"><tbody><tr><td id="area_data_frame">
|
||||
|
||||
<?php if (!$vmprov['available']): ?>
|
||||
<?php print_info_box(sprintf(gettext('vm-bhyve was not found. Neither %s nor the bundled copy exists.'), '/usr/local/sbin/vm') . '<br />' . gettext('Install vm-bhyve or run the installer with a bundled vendor tree.')); ?>
|
||||
<?php print_info_box(sprintf(gettext('vm-bhyve was not found. Neither %s nor the bundled copy exists.'), '/usr/local/sbin/vm')); ?>
|
||||
<?php endif; ?>
|
||||
|
||||
<div class="vmm-grid">
|
||||
@@ -51,7 +42,7 @@ include 'fbegin.inc';
|
||||
<div class="vmm-card">
|
||||
<div class="k"><?=gettext('Assigned Memory');?></div>
|
||||
<div class="v"><?=vmm_human_bytes($mem_used);?></div>
|
||||
<div class="s"><?=$cpus;?> vCPU</div>
|
||||
<div class="s"><?=$cpus;?> vCPU · <?=gettext('budget');?> <?=vmm_human_bytes($budget['limit']);?> (<?=$budget['pct'];?>%)</div>
|
||||
</div>
|
||||
<div class="vmm-card">
|
||||
<div class="k"><?=gettext('vm-bhyve');?></div>
|
||||
@@ -65,16 +56,18 @@ include 'fbegin.inc';
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="vmm-job" class="vmm-job"></div>
|
||||
|
||||
<table class="area_data_selection" style="width:100%;table-layout:fixed;border-collapse:collapse;">
|
||||
<colgroup>
|
||||
<col style="width:20%">
|
||||
<col style="width:16%">
|
||||
<col style="width:11%">
|
||||
<col style="width:8%">
|
||||
<col style="width:6%">
|
||||
<col style="width:8%">
|
||||
<col style="width:12%">
|
||||
<col style="width:9%">
|
||||
<col style="width:7%">
|
||||
<col style="width:9%">
|
||||
<col style="width:18%">
|
||||
<col style="width:7%">
|
||||
<col style="width:18%">
|
||||
<col style="width:6%">
|
||||
<col style="width:33%">
|
||||
</colgroup>
|
||||
<thead>
|
||||
<?php
|
||||
@@ -88,8 +81,8 @@ include 'fbegin.inc';
|
||||
<th class="lhell"><?=gettext('vCPU');?></th>
|
||||
<th class="lhell"><?=gettext('Memory');?></th>
|
||||
<th class="lhell"><?=gettext('Datastore');?></th>
|
||||
<th class="lhell"><?=gettext('Autostart');?></th>
|
||||
<th class="lhebl"><?=gettext('Details');?></th>
|
||||
<th class="lhell"><?=gettext('Auto');?></th>
|
||||
<th class="lhebl"><?=gettext('Actions');?></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@@ -97,8 +90,13 @@ include 'fbegin.inc';
|
||||
<tr><td class="lcell" colspan="8"><?=gettext('No virtual machines found.');?></td></tr>
|
||||
<?php else: ?>
|
||||
<?php foreach ($vms as $v): ?>
|
||||
<?php
|
||||
$n = (string)$v['name'];
|
||||
$isRunning = ($v['state'] ?? '') === 'running';
|
||||
$jsName = htmlspecialchars(json_encode($n), ENT_QUOTES);
|
||||
?>
|
||||
<tr>
|
||||
<td class="lcell"><strong><?=vmm_h((string)$v['name']);?></strong></td>
|
||||
<td class="lcell"><strong><?=vmm_h($n);?></strong></td>
|
||||
<td class="lcell"><?=vmm_badge((string)$v['state']);?></td>
|
||||
<td class="lcell"><?=vmm_h((string)$v['loader']);?></td>
|
||||
<td class="lcell"><?=vmm_h((string)$v['cpu']);?></td>
|
||||
@@ -106,7 +104,15 @@ include 'fbegin.inc';
|
||||
<td class="lcell"><?=vmm_h((string)$v['datastore']);?></td>
|
||||
<td class="lcell"><?=!empty($v['auto']) ? gettext('yes') : gettext('no');?></td>
|
||||
<td class="lcebl">
|
||||
<a class="formbtn" href="vmmngr_vm.php?name=<?=urlencode((string)$v['name']);?>"><?=gettext('Open');?></a>
|
||||
<span class="vmm-actions">
|
||||
<?php if ($isRunning): ?>
|
||||
<input type="button" class="formbtn" value="<?=gettext('Stop');?>" onclick='vmmConfirmRun("stop", <?=$jsName;?>, "Stop <?=vmm_h($n);?>?")'/>
|
||||
<input type="button" class="formbtn" value="<?=gettext('Restart');?>" onclick='vmmConfirmRun("restart", <?=$jsName;?>, "Restart <?=vmm_h($n);?>?")'/>
|
||||
<?php else: ?>
|
||||
<input type="button" class="formbtn" value="<?=gettext('Start');?>" onclick='vmmRun("start", <?=$jsName;?>)'/>
|
||||
<?php endif; ?>
|
||||
<a class="formbtn" href="vmmngr_vm.php?name=<?=urlencode($n);?>"><?=gettext('Details');?></a>
|
||||
</span>
|
||||
</td>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
@@ -114,12 +120,51 @@ include 'fbegin.inc';
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<br />
|
||||
|
||||
<table class="area_data_selection" style="width:100%;border-collapse:collapse;">
|
||||
<colgroup>
|
||||
<col style="width:26%">
|
||||
<col style="width:10%">
|
||||
<col style="width:14%">
|
||||
<col style="width:10%">
|
||||
<col style="width:40%">
|
||||
</colgroup>
|
||||
<thead>
|
||||
<?php html_separator2(); html_titleline2(gettext('Recent jobs'), 5); ?>
|
||||
<tr>
|
||||
<th class="lhell"><?=gettext('Job');?></th>
|
||||
<th class="lhell"><?=gettext('Action');?></th>
|
||||
<th class="lhell"><?=gettext('VM');?></th>
|
||||
<th class="lhell"><?=gettext('State');?></th>
|
||||
<th class="lhebl"><?=gettext('Started');?></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php if ($jobs === []): ?>
|
||||
<tr><td class="lcell" colspan="5"><?=gettext('No jobs yet.');?></td></tr>
|
||||
<?php else: ?>
|
||||
<?php foreach ($jobs as $j): ?>
|
||||
<tr>
|
||||
<td class="lcell vmm-mono"><a href="vmmngr_jobs.php?id=<?=urlencode((string)$j['id']);?>"><?=vmm_h((string)$j['id']);?></a></td>
|
||||
<td class="lcell"><?=vmm_h((string)$j['verb']);?></td>
|
||||
<td class="lcell"><?=vmm_h((string)$j['vm']);?></td>
|
||||
<td class="lcell">
|
||||
<span class="<?=($j['state'] ?? '') === 'failed' ? 'vmm-err' : 'vmm-ok';?>"><?=vmm_h((string)$j['state']);?></span>
|
||||
</td>
|
||||
<td class="lcebl vmm-mono"><?=!empty($j['started']) ? date('Y-m-d H:i:s', (int)$j['started']) : '—';?></td>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
<?php endif; ?>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<div id="remarks">
|
||||
<?php
|
||||
html_remark2(
|
||||
'preview',
|
||||
gettext('Preview build'),
|
||||
gettext('This build is read-only on purpose: it lists and inspects the existing machines but does not start, stop or change anything. Actions, creation wizard, images and templates follow in the next milestone.')
|
||||
'status',
|
||||
gettext('Status'),
|
||||
gettext('0.2.0: start/stop/restart/reset/poweroff/destroy run as jobs. Every action is locked per VM and logged; long operations continue if you close the browser.')
|
||||
);
|
||||
?>
|
||||
</div>
|
||||
|
||||
Reference in new issue
Block a user