diff --git a/static/setup.js b/static/setup.js index dabacb9..c277b24 100644 --- a/static/setup.js +++ b/static/setup.js @@ -11,6 +11,7 @@ function slot(number) { return { name: form.querySelector(`[name="key_${number}_name"]`), type: form.querySelector(`[name="key_${number}_type"]`), + addressPath: form.querySelector(`[name="key_${number}_address_path"]`), }; } @@ -18,11 +19,12 @@ function fillSlot(number, key) { const fields = slot(number); fields.name.value = key.name; fields.type.value = key.type; + fields.addressPath.value = key.address_path || ""; } function lockForm() { - // The names and the types are locked once the setup is saved, so nothing on - // the page can change them afterwards (section 23.2). + // The setup is written once, so nothing on the page can change it afterwards + // (sections 23.2 and 25.1). for (const field of form.querySelectorAll("input, select, button")) { field.disabled = true; } @@ -36,11 +38,24 @@ function collectSetup() { key_number: number, name: fields.name.value.trim(), type: fields.type.value, + address_path: fields.addressPath.value.trim(), }); } return { keys: entries }; } +function showLockedState() { + // The type and the address path are locked with the setup, while the name is + // only a label that the settings may change (sections 25.1 and 25.2). + const note = document.createElement("span"); + note.textContent = "The key setup is already saved. The type and the address path are locked; the key names can be changed in the settings. "; + const link = document.createElement("a"); + link.className = "back-link"; + link.href = "/settings"; + link.textContent = "Open settings"; + status.replaceChildren(note, link); +} + async function loadSetup() { try { const response = await fetch("/api/setup", { headers: { Accept: "application/json" } }); @@ -55,7 +70,7 @@ async function loadSetup() { // The stored keys arrive in key order, so the slot number is their index. (setup.keys || []).forEach((key, index) => fillSlot(index + 1, key)); lockForm(); - status.textContent = "The key setup is already saved. The names and the types are locked."; + showLockedState(); } catch { lockForm(); status.textContent = "The key setup could not be loaded. Reload the page or contact the service administrator.";