mirror of
https://github.com/retspen/webvirtcloud
synced 2026-11-09 03:36:48 +00:00
The console settings form lost its password, keymap and listen address
fields long ago (47009d4), but its scripts stayed: show_console(), which
nothing calls, change handlers for #console_passwd_gen, #console_passwd_clear
and #console_keymap_clear, and two blocks that preselected
#console_select_keymap and #console_select_listener_address. No template
defines any of these ids, so the code matched nothing. The instance list
drops a commented-out line that read #compute_select.
94 lines
4.1 KiB
HTML
94 lines
4.1 KiB
HTML
{% extends "base.html" %}
|
|
{% load i18n %}
|
|
{% load static %}
|
|
{% block title %}{% trans "Instances" %}{% endblock %}
|
|
{% block style %}
|
|
<link rel="stylesheet" href="{% static 'css/sortable-theme-bootstrap.css' %}" />
|
|
{% endblock %}
|
|
{% block page_heading %}{% trans "Instances" %}{% endblock page_heading %}
|
|
|
|
{% block page_heading_extra %}
|
|
{% if request.user.is_superuser %}
|
|
{% include 'create_inst_block.html' %}
|
|
{% endif %}
|
|
{% include 'search_block.html' %}
|
|
{% endblock page_heading_extra %}
|
|
|
|
{% block content %}
|
|
{% if show_hosts %}
|
|
{% for compute in computes %}
|
|
{% if compute.status is not True %}
|
|
<div class="alert alert-danger alert-dismissible fade show" role="alert">
|
|
{% trans 'Problem occurred with host' %} {{ compute.name }}: {{ compute.connection_error }}
|
|
<button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
|
|
</div>
|
|
{% endif %}
|
|
{% endfor %}
|
|
{% elif own_hosts_down %}
|
|
<div class="alert alert-warning alert-dismissible fade show" role="alert">
|
|
{% trans 'A host of some of your virtual machines cannot be reached right now.' %}
|
|
<button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
|
|
</div>
|
|
{% endif %}
|
|
<div class="col-lg-12">
|
|
{% if app_settings.VIEW_INSTANCES_LIST_STYLE == 'grouped' and request.user.is_superuser %}
|
|
{% include 'allinstances_index_grouped.html' %}
|
|
{% else %}
|
|
{% include 'allinstances_index_nongrouped.html' %}
|
|
{% endif %}
|
|
</div>
|
|
{% endblock content %}
|
|
{% block script %}
|
|
<script src="{% static 'js/sortable.min.js' %}"></script>
|
|
<script src="{% static 'js/filter-table.js' %}"></script>
|
|
{% if request.user.is_superuser %}
|
|
<script>
|
|
function goto_compute(compute) {
|
|
window.location.href = "{% url 'instances:create_instance_select_type' 1 %}".replace(1, compute);
|
|
}
|
|
|
|
// The new-VM dialog's CPU bars: each compute's load over one second,
|
|
// read when the dialog opens, two computes at a time (each read holds
|
|
// a worker for that second). Answers of an earlier opening are ignored.
|
|
const addInstance = document.getElementById("AddInstance");
|
|
let cpuOpening = 0, cpuQueue = [], cpuReading = 0;
|
|
|
|
function setCpuUsage(cell, percent, text) {
|
|
const bar = cell.querySelector(".progress-bar");
|
|
bar.style.width = (percent || 0) + "%";
|
|
if (percent === null) {
|
|
bar.removeAttribute("aria-valuenow");
|
|
} else {
|
|
bar.setAttribute("aria-valuenow", percent);
|
|
}
|
|
cell.querySelector(".cpu-usage-value").textContent = text;
|
|
}
|
|
|
|
function readCpuUsage() {
|
|
while (cpuReading < 2 && cpuQueue.length) {
|
|
const cell = cpuQueue.shift(), opening = cpuOpening;
|
|
const show = (percent, text) => { if (opening === cpuOpening) setCpuUsage(cell, percent, text); };
|
|
cpuReading++;
|
|
$.getJSON(cell.dataset.url)
|
|
.done((data) => {
|
|
const usage = typeof data.cpudata === "number" ? Math.round(data.cpudata) : null;
|
|
show(usage, usage === null ? "—" : usage + "%");
|
|
})
|
|
.fail(() => show(null, "—"))
|
|
.always(() => { cpuReading--; readCpuUsage(); });
|
|
}
|
|
}
|
|
|
|
addInstance.addEventListener("show.bs.modal", function () {
|
|
cpuOpening++;
|
|
cpuQueue = Array.from(addInstance.querySelectorAll(".cpu-usage"));
|
|
cpuQueue.forEach((cell) => setCpuUsage(cell, null, "…"));
|
|
readCpuUsage();
|
|
});
|
|
addInstance.addEventListener("hide.bs.modal", function () {
|
|
cpuOpening++;
|
|
cpuQueue = [];
|
|
});
|
|
</script>
|
|
{% endif %}
|
|
{% endblock script %}
|