more admin stuff 2
This commit is contained in:
@ -10,6 +10,30 @@
|
||||
return res.json();
|
||||
}
|
||||
|
||||
async function showCredentials(host) {
|
||||
const box = document.getElementById("credentials-box");
|
||||
box.className = "reveal-box";
|
||||
box.textContent = `Lade Zugangsdaten fuer ${host.hostname} ...`;
|
||||
try {
|
||||
const info = await getJson(`/admin/hosts/${host.id}/credentials`);
|
||||
const lines = [`Zugangsdaten fuer ${host.hostname}:`];
|
||||
lines.push(
|
||||
info.ssh_keys.length
|
||||
? `SSH-Keys: ${info.ssh_keys.map((k) => k.label).join(", ")}`
|
||||
: "SSH-Keys: keine zugeordnet"
|
||||
);
|
||||
lines.push(
|
||||
info.rdp_credentials_set
|
||||
? `RDP-Passwort gesetzt (zuletzt aktualisiert: ${info.rdp_credentials_updated_at}).`
|
||||
: "RDP-Passwort: nicht gesetzt."
|
||||
);
|
||||
box.textContent = lines.join("\n");
|
||||
} catch (err) {
|
||||
box.className = "banner error";
|
||||
box.textContent = `Zugangsdaten konnten nicht geladen werden: ${err.message}`;
|
||||
}
|
||||
}
|
||||
|
||||
function hostCard(host) {
|
||||
const div = document.createElement("div");
|
||||
div.className = "host-card";
|
||||
@ -32,6 +56,17 @@
|
||||
connect.textContent = "Verbinden";
|
||||
actions.appendChild(connect);
|
||||
|
||||
if (host.can_view_credentials) {
|
||||
const credBtn = document.createElement("button");
|
||||
credBtn.type = "button";
|
||||
credBtn.textContent = "Zugangsdaten";
|
||||
credBtn.addEventListener("click", () => {
|
||||
document.getElementById("credentials-box").classList.remove("hidden");
|
||||
showCredentials(host);
|
||||
});
|
||||
actions.appendChild(credBtn);
|
||||
}
|
||||
|
||||
div.appendChild(actions);
|
||||
return div;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user