This commit is contained in:
Mateusz Gruszczyński committed 2026-10-06 15:12:59 +02:00
1 parent 464ff42cfd
commit f07429c267
53 files changed
+1049 -283

No files matched your search

+16 -4
View File
@@ -1,6 +1,6 @@
"use strict";
(() => {
let job = null, pending = false, loading = false, renewalLogs = {};
let job = null, pending = false, loading = false, renewalLogs = {}, resetIssueFormJob = null;
const picker = $("certificate-provider");
const secrets = ["acme-secret", "acme-cf-token", "acme-ovh-application-key", "acme-ovh-application-secret", "acme-ovh-consumer-key"];
const tabs = [...document.querySelectorAll("[data-certificate-tab]")];
@@ -37,6 +37,13 @@
}
const clearSecrets = () => { for (const id of secrets) $(id).value = ""; };
function resetIssueForm() {
$("acme-form").reset();
$("acme-environment").value = "production";
$("acme-confirm-production").required = true;
clearSecrets();
syncProvider();
}
function syncProvider() {
const provider = picker.value, acme = !["import", "existing"].includes(provider);
$("certificate-acme-editor").hidden = !acme;
@@ -71,7 +78,12 @@
log.textContent = showLog ? `${t("certbotLogs")}: ${value.log_directory}` : "";
}
function render(value) {
job = value; $("acme-submit").disabled = pending || value?.status === "running";
job = value;
if (resetIssueFormJob && value?.kind === "issue" && value.id === resetIssueFormJob) {
if (value.status === "ready") { resetIssueForm(); resetIssueFormJob = null; }
else if (value.status === "failed") resetIssueFormJob = null;
}
$("acme-submit").disabled = pending || value?.status === "running";
const issue = value?.kind === "issue" ? value : null;
const renewal = value?.kind?.startsWith("renewal") ? value : null;
renderOperation("acme-issue-status-card", "acme-job", "acme-issue-state", "acme-log-path", issue, "acmeIdle");
@@ -152,7 +164,7 @@
pending = true; $("acme-submit").disabled = true; const epoch = authEpoch;
try {
const value = await api("/api/acme/issue", { method: "POST", body: JSON.stringify(input) });
if (epoch === authEpoch && authenticated) { render(value.job); selectTab("generate"); toast(t("acme.working")); }
if (epoch === authEpoch && authenticated) { resetIssueFormJob = value.job?.id || null; render(value.job); selectTab("generate"); toast(t("acme.working")); }
} catch (error) { if (epoch === authEpoch) toast(error.message, true); }
finally {
for (const key of ["key_secret", "api_token", "application_key", "application_secret", "consumer_key"]) delete input[key];
@@ -175,7 +187,7 @@
syncLocation,
current: () => activeTab,
reset() {
job = null; renewalLogs = {}; $("renewal-list").replaceChildren(); $("acme-form").reset(); $("acme-environment").value = "production"; $("acme-confirm-production").required = true;
job = null; renewalLogs = {}; resetIssueFormJob = null; $("renewal-list").replaceChildren(); resetIssueForm();
render(null); selectTab("installed", false, false);
}
};