mirror of
https://github.com/retspen/webvirtcloud
synced 2026-11-10 04:06:47 +00:00
feat(instances): a clone takes the size asked and starts if asked
A VM made from a template came out at the template's size and shut off, and was then resized and started by hand. The Clone tab now asks for the clone's vCPUs and memory, filled in with the VM's, and whether to start it. After the copy, before the clone is recorded, it is resized with the Resize tab's own functions and started; a step that fails is a warning of the job, and the clone stays. The quota counts the larger of the size asked and the VM's, so a resize that fails leaves the clone at a size it allowed. When the job ends the page opens the clone's, not the cloned VM's again: a template's page, shut off, read as a clone that had not started. An outcome kept for a warning links to it.
This commit is contained in:
parent
9aedb5b4d1
commit
8a809443a4
9 changed files with 423 additions and 233 deletions
|
|
@ -74,7 +74,8 @@ function jobPanel(element, urls, csrfToken, initialIds) {
|
|||
var note = job.result && job.result.warning ? '<div class="small mt-2">' + esc(job.result.warning) + "</div>" : "";
|
||||
var warn = note + (left.length ? '<div class="small mt-2">Files not removed:</div><ul class="list-unstyled small mb-0">'
|
||||
+ left.map(function (path) { return '<li class="text-break"><code>' + esc(path) + "</code></li>"; }).join("") + "</ul>" : "");
|
||||
var buttons = '<button type="button" class="btn btn-sm btn-primary" data-refresh="1">Refresh</button>'
|
||||
var buttons = (opens(job) ? '<a class="btn btn-sm btn-primary" href="' + esc(job.result.open) + '">Open</a>' : "")
|
||||
+ '<button type="button" class="btn btn-sm btn-primary" data-refresh="1">Refresh</button>'
|
||||
+ '<button type="button" class="btn btn-sm btn-outline-secondary" data-dismiss="' + esc(job.id)
|
||||
+ '">Dismiss</button>';
|
||||
return alertHtml(job.state, header(job.label, job.state, "", buttons) + errorHtml(job) + warn);
|
||||
|
|
@ -114,6 +115,11 @@ function jobPanel(element, urls, csrfToken, initialIds) {
|
|||
holding = busy;
|
||||
}
|
||||
|
||||
// the page of what the job made, a path of this site
|
||||
function opens(job) {
|
||||
return !!(job.result && /^\/[^\/]/.test(job.result.open || ""));
|
||||
}
|
||||
|
||||
// a job that did what it was asked, with nothing more to read: the page shows its effect
|
||||
function quiet(job) {
|
||||
var result = job.result || {};
|
||||
|
|
@ -134,7 +140,13 @@ function jobPanel(element, urls, csrfToken, initialIds) {
|
|||
var others = Object.keys(outcomes).length + Object.keys(pending).length + Object.keys(shown).length;
|
||||
// the page in use (poll.js): its outcome waits in the panel, with Refresh
|
||||
if (quiet(job) && !pageInUse() && !others) {
|
||||
window.location.reload(); // the job is not remembered again: no loop
|
||||
// a job that made a VM opens its page (result.open); another reloads this one,
|
||||
// where the job is not remembered again: no loop
|
||||
if (opens(job)) {
|
||||
window.location.assign(job.result.open);
|
||||
} else {
|
||||
window.location.reload();
|
||||
}
|
||||
return;
|
||||
}
|
||||
outcomes[id] = job;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue