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
+56
-16
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
/*
|
||||
* vmmngr_vm.php - VM detail view (read-only preview 0.1.0)
|
||||
* vmmngr_vm.php - VM detail view with actions (0.2.0)
|
||||
*/
|
||||
|
||||
require_once 'vmmngr-boot.inc';
|
||||
@@ -13,18 +13,11 @@ if ($name === '' || !vmm_valid_name($name)) {
|
||||
|
||||
$info = vmm_info($name);
|
||||
$pgtitle = [gettext('Extensions'), gettext('VM Manager'), $name];
|
||||
$jobs = vmm_job_list(10, $name);
|
||||
|
||||
include 'fbegin.inc';
|
||||
vmm_css();
|
||||
?>
|
||||
<style>
|
||||
.vmm-badge{display:inline-block;padding:1px 8px;border-radius:10px;font-size:11px;font-weight:600}
|
||||
.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-mono{font-family:monospace;font-size:12px}
|
||||
.vmm-raw{background:#1b1f23;border:1px solid #333a41;border-radius:4px;padding:10px;overflow:auto;max-height:420px}
|
||||
</style>
|
||||
|
||||
<form action="vmmngr_vm.php" method="post" name="iform" id="iform"><table id="area_data"><tbody><tr><td id="area_data_frame">
|
||||
|
||||
@@ -34,6 +27,8 @@ include 'fbegin.inc';
|
||||
<?php
|
||||
$g = $info['general'] ?? [];
|
||||
$state = vmm_state_from_string((string)($g['state'] ?? ''));
|
||||
$isRunning = $state['state'] === 'running';
|
||||
$jsName = htmlspecialchars(json_encode($name), ENT_QUOTES);
|
||||
?>
|
||||
|
||||
<table class="area_data_settings" style="width:100%;border-collapse:collapse;">
|
||||
@@ -53,10 +48,27 @@ include 'fbegin.inc';
|
||||
<tr><td class="celltag"><?=gettext('vCPU / Memory');?></td><td class="celldata"><?=vmm_h((string)($g['cpu'] ?? ''));?> vCPU · <?=vmm_h((string)($g['memory'] ?? ''));?><?php if (!empty($g['memory-resident'])): ?> <span class="vmm-mono">(<?=vmm_h((string)$g['memory-resident']);?>)</span><?php endif; ?></td></tr>
|
||||
<tr><td class="celltag"><?=gettext('Datastore');?></td><td class="celldata"><?=vmm_h((string)($g['datastore'] ?? ''));?></td></tr>
|
||||
<tr><td class="celltag">UUID</td><td class="celldata vmm-mono"><?=vmm_h((string)($g['uuid'] ?? ''));?></td></tr>
|
||||
<tr>
|
||||
<td class="celltag"><?=gettext('Actions');?></td>
|
||||
<td class="celldata">
|
||||
<span class="vmm-actions">
|
||||
<?php if ($isRunning): ?>
|
||||
<input type="button" class="formbtn" value="<?=gettext('Stop');?>" onclick='vmmConfirmRun("stop", <?=$jsName;?>, "Stop <?=vmm_h($name);?>?")'/>
|
||||
<input type="button" class="formbtn" value="<?=gettext('Restart');?>" onclick='vmmConfirmRun("restart", <?=$jsName;?>, "Restart <?=vmm_h($name);?>?")'/>
|
||||
<input type="button" class="formbtn" value="<?=gettext('Power off');?>" onclick='vmmConfirmRun("poweroff", <?=$jsName;?>, "Force power off <?=vmm_h($name);?>? Unsaved data in the guest may be lost.")'/>
|
||||
<input type="button" class="formbtn" value="<?=gettext('Reset');?>" onclick='vmmConfirmRun("reset", <?=$jsName;?>, "Hard reset <?=vmm_h($name);?>?")'/>
|
||||
<?php else: ?>
|
||||
<input type="button" class="formbtn" value="<?=gettext('Start');?>" onclick='vmmRun("start", <?=$jsName;?>)'/>
|
||||
<input type="button" class="formbtn" value="<?=gettext('Destroy');?>" onclick='vmmDestroy(<?=$jsName;?>)'/>
|
||||
<?php endif; ?>
|
||||
<a class="formbtn" href="vmmngr.php"><?=gettext('Back');?></a>
|
||||
</span>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<br />
|
||||
<div id="vmm-job" class="vmm-job"></div>
|
||||
|
||||
<?php foreach (($info['sections'] ?? []) as $type => $blocks): ?>
|
||||
<table class="area_data_settings" style="width:100%;border-collapse:collapse;">
|
||||
@@ -90,15 +102,43 @@ include 'fbegin.inc';
|
||||
<br />
|
||||
<?php endforeach; ?>
|
||||
|
||||
<details>
|
||||
<table class="area_data_selection" style="width:100%;border-collapse:collapse;">
|
||||
<colgroup>
|
||||
<col style="width:30%">
|
||||
<col style="width:12%">
|
||||
<col style="width:12%">
|
||||
<col style="width:46%">
|
||||
</colgroup>
|
||||
<thead>
|
||||
<?php html_separator2(); html_titleline2(gettext('Jobs for this VM'), 4); ?>
|
||||
<tr>
|
||||
<th class="lhell"><?=gettext('Job');?></th>
|
||||
<th class="lhell"><?=gettext('Action');?></th>
|
||||
<th class="lhell"><?=gettext('State');?></th>
|
||||
<th class="lhebl"><?=gettext('Started');?></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php if ($jobs === []): ?>
|
||||
<tr><td class="lcell" colspan="4"><?=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"><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>
|
||||
|
||||
<details style="margin-top:12px;">
|
||||
<summary style="cursor:pointer;padding:6px 0;"><?=gettext('Raw vm-bhyve output');?></summary>
|
||||
<pre class="vmm-raw vmm-mono"><?=vmm_h((string)($info['raw'] ?? ''));?></pre>
|
||||
</details>
|
||||
<?php endif; ?>
|
||||
|
||||
<div id="remarks">
|
||||
<?php html_remark2('preview', gettext('Read-only'), gettext('Actions are intentionally not wired yet. This page shows exactly what vm-bhyve reports.')); ?>
|
||||
</div>
|
||||
|
||||
</td></tr></tbody></table></form>
|
||||
<?php include 'fend.inc'; ?>
|
||||
Reference in new issue
Block a user