mirror of
https://github.com/retspen/webvirtcloud
synced 2026-11-11 12:46:49 +00:00
fix(instances): the VM page opens the tab a redirect points to, and host links are for administrators
Redirects to #access (root password, SSH key) and other top-level panes opened nothing, and some sub-tab ids did not exist. static/js/instance_tabs.js opens the pane and the tab that holds it from the page structure, and opens Settings on its first section, without leaving the current tab; guest OS info is loaded whenever it is the section opened. The bottom bar linked to host pages, which only administrators may open, and showed host names to everyone. A stray </li> is removed; the page's inline scripts and the tab logic are checked with Node.
This commit is contained in:
parent
70bed79c60
commit
44b3b6569a
7 changed files with 181 additions and 31 deletions
40
static/js/instance_tabs.js
Normal file
40
static/js/instance_tabs.js
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
// The tab the VM page opens on.
|
||||
//
|
||||
// A redirect points at a pane (#access, #resize, #options, ...): open the tab
|
||||
// that holds it first, then the pane itself; the page structure tells which
|
||||
// tab holds which pane. Settings opens on its first section the user has;
|
||||
// guest OS info is loaded whenever it is the section opened.
|
||||
//
|
||||
// show(target) opens the tab whose control targets "#id"; loadInfo() fetches
|
||||
// the guest OS info.
|
||||
function restoreInstanceTab(doc, hash, show, loadInfo) {
|
||||
var pane = hash && hash.length > 1 ? doc.getElementById(hash.slice(1)) : null;
|
||||
if (pane && pane.classList.contains("tab-pane")) {
|
||||
var holder = pane.parentElement;
|
||||
while (holder && !holder.classList.contains("tab-pane")) {
|
||||
holder = holder.parentElement;
|
||||
}
|
||||
if (holder) {
|
||||
show("#" + holder.id);
|
||||
}
|
||||
show(hash);
|
||||
if (hash === "#osinfo") {
|
||||
loadInfo();
|
||||
}
|
||||
}
|
||||
var settings = doc.getElementById("settings");
|
||||
var tabs = settings ? settings.querySelector(".nav-tabs") : null;
|
||||
if (tabs && !tabs.querySelector(".nav-link.active")) {
|
||||
var first = tabs.querySelector(".nav-link:not(#osinfo-tab)");
|
||||
if (first) {
|
||||
show(first.getAttribute("data-bs-target"));
|
||||
} else if (tabs.querySelector("#osinfo-tab")) {
|
||||
show("#osinfo");
|
||||
loadInfo();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (typeof module !== "undefined") {
|
||||
module.exports = {restoreInstanceTab: restoreInstanceTab};
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue