mirror of
https://github.com/retspen/webvirtcloud
synced 2026-11-08 11:16:47 +00:00
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.
40 lines
1.5 KiB
JavaScript
40 lines
1.5 KiB
JavaScript
// 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};
|
|
}
|