refactor: remove VM Name/ID from download and SCP forms — moved to configure page
This commit is contained in:
parent
41059b128d
commit
13dc96375d
2 changed files with 10 additions and 43 deletions
|
|
@ -34,24 +34,11 @@
|
||||||
</div>
|
</div>
|
||||||
<div class="pve-panel-body">
|
<div class="pve-panel-body">
|
||||||
<form id="session-form" onsubmit="startSession(event)">
|
<form id="session-form" onsubmit="startSession(event)">
|
||||||
<div class="pve-row">
|
|
||||||
<div class="pve-form-group">
|
|
||||||
<label>VM Name *</label>
|
|
||||||
<input type="text" id="vm-name" name="vm_name" required class="pve-input"
|
|
||||||
placeholder="e.g. debian-test" value="{{ prefill_vmname or '' }}">
|
|
||||||
</div>
|
|
||||||
<div class="pve-form-group">
|
|
||||||
<label>VM ID *</label>
|
|
||||||
<input type="number" id="vmid" name="vmid" required class="pve-input"
|
|
||||||
placeholder="e.g. 21050" min="21000" max="21100">
|
|
||||||
<span class="pve-hint">Range 21000–21100. Must be unique on host.</span>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="pve-form-group" id="url-group">
|
<div class="pve-form-group" id="url-group">
|
||||||
<label>Download URL *</label>
|
<label>Download URL *</label>
|
||||||
<input type="url" id="source-url" name="source_url" required class="pve-input"
|
<input type="url" id="source-url" name="source_url" required class="pve-input"
|
||||||
placeholder="https://example.com/image.7z">
|
placeholder="https://example.com/image.7z">
|
||||||
<span class="pve-hint">Direct URL to a disk image or archive (.vmdk, .7z, .zip, etc.)</span>
|
<span class="pve-hint">Direct URL to a disk image or archive (.vmdk, .7z, .zip, .ova, etc.)</span>
|
||||||
</div>
|
</div>
|
||||||
<button type="submit" id="start-btn" class="pve-btn pve-btn-primary">Download & Analyse</button>
|
<button type="submit" id="start-btn" class="pve-btn pve-btn-primary">Download & Analyse</button>
|
||||||
<button type="button" class="pve-btn" onclick="hideDownload()" style="margin-left:0.5rem;">Cancel</button>
|
<button type="button" class="pve-btn" onclick="hideDownload()" style="margin-left:0.5rem;">Cancel</button>
|
||||||
|
|
@ -124,22 +111,20 @@ function resumeSession(sessionId, firstFile) {
|
||||||
document.getElementById('card-scp').style.display = 'none';
|
document.getElementById('card-scp').style.display = 'none';
|
||||||
document.getElementById('download-section').classList.remove('pve-hidden');
|
document.getElementById('download-section').classList.remove('pve-hidden');
|
||||||
document.getElementById('download-title').textContent = 'Resume Session';
|
document.getElementById('download-title').textContent = 'Resume Session';
|
||||||
document.getElementById('url-group').classList.add('pve-hidden');
|
|
||||||
var btn = document.getElementById('start-btn');
|
var btn = document.getElementById('start-btn');
|
||||||
btn.textContent = 'Resume Analysis';
|
btn.textContent = 'Resume Analysis';
|
||||||
|
var urlGroup = document.getElementById('url-group');
|
||||||
|
if (urlGroup) urlGroup.classList.add('pve-hidden');
|
||||||
|
document.getElementById('source-url').required = false;
|
||||||
btn.onclick = function(e) {
|
btn.onclick = function(e) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
var vmid = document.getElementById('vmid').value;
|
|
||||||
var vmName = document.getElementById('vm-name').value.trim();
|
|
||||||
if (!vmid) { alert('Please enter a VM ID.'); return; }
|
|
||||||
window.RESUMED_SID = sessionId;
|
window.RESUMED_SID = sessionId;
|
||||||
document.getElementById('resume-sessions').classList.add('pve-hidden');
|
document.getElementById('resume-sessions').classList.add('pve-hidden');
|
||||||
var status = document.getElementById('session-status');
|
var status = document.getElementById('session-status');
|
||||||
status.classList.remove('pve-hidden');
|
status.classList.remove('pve-hidden');
|
||||||
setPhase('Analysing source image...', 0, true);
|
setPhase('Analysing source image...', 0, true);
|
||||||
runAnalysis(vmid, firstFile, vmName, sessionId);
|
runAnalysis(0, firstFile, '', sessionId);
|
||||||
};
|
};
|
||||||
document.getElementById('source-url').required = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function cleanupSession(sessionId, btn) {
|
function cleanupSession(sessionId, btn) {
|
||||||
|
|
@ -190,15 +175,11 @@ async function startSession(e) {
|
||||||
polling.innerHTML = '';
|
polling.innerHTML = '';
|
||||||
document.getElementById('session-error').textContent = '';
|
document.getElementById('session-error').textContent = '';
|
||||||
|
|
||||||
const vmid = document.getElementById('vmid').value;
|
|
||||||
const vmName = document.getElementById('vm-name').value.trim();
|
|
||||||
const url = document.getElementById('source-url').value.trim();
|
const url = document.getElementById('source-url').value.trim();
|
||||||
if (!url) { showError('Please enter a download URL.'); btn.disabled = false; return; }
|
if (!url) { showError('Please enter a download URL.'); btn.disabled = false; return; }
|
||||||
|
|
||||||
const sessionId = window.VM_BENCH_SID || '';
|
const sessionId = window.VM_BENCH_SID || '';
|
||||||
const formData = new FormData();
|
const formData = new FormData();
|
||||||
formData.append('vmid', vmid);
|
|
||||||
formData.append('vm_name', vmName);
|
|
||||||
formData.append('source_type', 'url');
|
formData.append('source_type', 'url');
|
||||||
formData.append('source_url', url);
|
formData.append('source_url', url);
|
||||||
formData.append('session_id', sessionId);
|
formData.append('session_id', sessionId);
|
||||||
|
|
@ -232,7 +213,7 @@ async function handleDownload(formData) {
|
||||||
if (pdata.phase === 'complete') {
|
if (pdata.phase === 'complete') {
|
||||||
setPhase('Download complete (' + (pdata.file_size_gb || 0) + ' GiB)', 100, false);
|
setPhase('Download complete (' + (pdata.file_size_gb || 0) + ' GiB)', 100, false);
|
||||||
await sleep(500);
|
await sleep(500);
|
||||||
await runAnalysis(data.vmid, filename, data.vm_name);
|
await runAnalysis(0, filename, '');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (pdata.phase === 'error') { throw new Error(pdata.error); }
|
if (pdata.phase === 'error') { throw new Error(pdata.error); }
|
||||||
|
|
|
||||||
|
|
@ -40,18 +40,6 @@
|
||||||
placeholder="/mnt/vmware/exchange-server.vmdk">
|
placeholder="/mnt/vmware/exchange-server.vmdk">
|
||||||
<span class="pve-hint">Full path to the disk image or archive on the remote server.</span>
|
<span class="pve-hint">Full path to the disk image or archive on the remote server.</span>
|
||||||
</div>
|
</div>
|
||||||
<div class="pve-row">
|
|
||||||
<div class="pve-form-group">
|
|
||||||
<label>VM Name *</label>
|
|
||||||
<input type="text" id="scp-vm-name" name="vm_name" required class="pve-input"
|
|
||||||
placeholder="e.g. exchange-prod">
|
|
||||||
</div>
|
|
||||||
<div class="pve-form-group">
|
|
||||||
<label>VM ID *</label>
|
|
||||||
<input type="number" id="scp-vmid" name="vmid" required class="pve-input"
|
|
||||||
placeholder="e.g. 21050" min="21000" max="21100">
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<button type="submit" id="scp-start-btn" class="pve-btn pve-btn-primary">Start SCP Pull</button>
|
<button type="submit" id="scp-start-btn" class="pve-btn pve-btn-primary">Start SCP Pull</button>
|
||||||
</form>
|
</form>
|
||||||
|
|
@ -107,10 +95,10 @@ async function startScpPull(e) {
|
||||||
await new Promise(r => setTimeout(r, 500));
|
await new Promise(r => setTimeout(r, 500));
|
||||||
setScpPhase('Step 2/2: Analysing source image...', 0, true);
|
setScpPhase('Step 2/2: Analysing source image...', 0, true);
|
||||||
var fd = new FormData();
|
var fd = new FormData();
|
||||||
fd.append('vmid', document.getElementById('scp-vmid').value);
|
|
||||||
fd.append('filename', filename);
|
fd.append('filename', filename);
|
||||||
fd.append('vm_name', document.getElementById('scp-vm-name').value.trim());
|
|
||||||
fd.append('session_id', SESSION_ID);
|
fd.append('session_id', SESSION_ID);
|
||||||
|
fd.append('vmid', '0');
|
||||||
|
fd.append('vm_name', '');
|
||||||
var ar = await fetch('/session/analyze', { method: 'POST', body: fd });
|
var ar = await fetch('/session/analyze', { method: 'POST', body: fd });
|
||||||
var adata = await ar.json();
|
var adata = await ar.json();
|
||||||
if (adata.phase === 'error') {
|
if (adata.phase === 'error') {
|
||||||
|
|
@ -121,11 +109,9 @@ async function startScpPull(e) {
|
||||||
var analysisId = adata.analysis_id;
|
var analysisId = adata.analysis_id;
|
||||||
if (!analysisId) {
|
if (!analysisId) {
|
||||||
setScpPhase('Analysis failed', 0, false);
|
setScpPhase('Analysis failed', 0, false);
|
||||||
showScpError('Backend returned invalid response — may need restart.');
|
showScpError('Backend returned invalid response.');
|
||||||
btn.disabled = false; return;
|
btn.disabled = false; return;
|
||||||
}
|
}
|
||||||
var vmid = document.getElementById('scp-vmid').value;
|
|
||||||
var vmName = document.getElementById('scp-vm-name').value.trim();
|
|
||||||
var astart = Date.now();
|
var astart = Date.now();
|
||||||
var pollErrs = 0;
|
var pollErrs = 0;
|
||||||
for (;;) {
|
for (;;) {
|
||||||
|
|
@ -135,7 +121,7 @@ async function startScpPull(e) {
|
||||||
var elapsed = Math.round((Date.now() - astart) / 1000);
|
var elapsed = Math.round((Date.now() - astart) / 1000);
|
||||||
setScpPhase('Analysing... ' + (sdata.message || '') + ' (' + elapsed + 's)', sdata.status === 'completed' ? 100 : 50, sdata.status !== 'completed');
|
setScpPhase('Analysing... ' + (sdata.message || '') + ' (' + elapsed + 's)', sdata.status === 'completed' ? 100 : 50, sdata.status !== 'completed');
|
||||||
if (sdata.status === 'completed') {
|
if (sdata.status === 'completed') {
|
||||||
window.location.href = '/session/configure/' + analysisId + '?source_filename=' + encodeURIComponent(filename) + '&vm_name=' + encodeURIComponent(vmName) + '&vmid=' + vmid + '&session_id=' + SESSION_ID;
|
window.location.href = '/session/configure/' + analysisId + '?source_filename=' + encodeURIComponent(filename) + '&session_id=' + SESSION_ID;
|
||||||
btn.disabled = false; return;
|
btn.disabled = false; return;
|
||||||
}
|
}
|
||||||
if (sdata.status === 'failed') {
|
if (sdata.status === 'failed') {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue