v0.43.1
This commit is contained in:
1 parent
4d1087e357
commit
7514227b3b
40 files changed
+502
-260
No files matched your search
@@ -86,6 +86,7 @@ function translate() {
|
||||
if (envelope) renderConfig(); renderConfigStorage(); if (latestStatus) { renderFooter(latestStatus); renderDiagnostics(latestStatus, false); window.rustProxyVhosts?.renderStatus(latestStatus); window.rustProxyDocker?.renderStatus(latestStatus); window.rustProxyStreams?.renderStatus(latestStatus); window.rustProxyStreamDashboard?.render(latestStatus); window.rustProxyDockerDashboard?.render(latestStatus, null, false); window.rustProxyBackendDashboard?.render(latestStatus, null, false); window.rustProxyExtraOverview?.render(latestStatus, false); window.rustProxyWideOverview?.render(latestStatus, false); window.rustProxyWebOverview?.render(latestStatus, false); } if (lastLogs) renderLogs(lastLogs);
|
||||
syncSettingsDirtyIndicators();
|
||||
window.rustProxyIcons?.refresh?.();
|
||||
rustProxyAutoId.repaintAll();
|
||||
}
|
||||
function toastNode() {
|
||||
let node = document.getElementById("toast");
|
||||
@@ -728,7 +729,7 @@ $("export-config").addEventListener("click", () => { const url = URL.createObjec
|
||||
|
||||
const rustProxyAutoId = (() => {
|
||||
const FOLD = { "ł": "l", "đ": "d", "ø": "o", "ß": "ss", "æ": "ae", "œ": "oe", "þ": "th", "ð": "d" };
|
||||
const states = new WeakMap();
|
||||
const states = new WeakMap(), registry = new Set();
|
||||
function slugify(value, max = 64) {
|
||||
let slug = String(value ?? "").trim().toLowerCase().replace(/^\*\./, "").replace(/[łđøßæœþð]/g, ch => FOLD[ch]).normalize("NFKD").replace(/[̀-ͯ]/g, "");
|
||||
slug = slug.replace(/[^a-z0-9_-]+/g, "-").replace(/-{2,}/g, "-").replace(/^[-_]+/, "").slice(0, max).replace(/[-_]+$/, "");
|
||||
@@ -753,34 +754,63 @@ const rustProxyAutoId = (() => {
|
||||
state.row.hidden = !compact;
|
||||
state.hint.hidden = compact || !state.auto; state.hint.textContent = t("autoIdHint");
|
||||
state.reset.hidden = compact || state.auto || state.resettable === false || !wanted || wanted === value; state.reset.textContent = t("autoIdReset");
|
||||
const reason = typeof state.lockedReason === "function" ? state.lockedReason() : state.lockedReason;
|
||||
state.lock.hidden = !reason; state.lock.textContent = reason || "";
|
||||
state.renameNote.hidden = !state.renameKey || !state.open || isLocked; state.renameNote.textContent = state.renameKey ? t(state.renameKey) : "";
|
||||
}
|
||||
function regenerate(input, state) { if (!state.auto || locked(input)) return; input.value = suggestion(state); input.setCustomValidity?.(""); paint(input, state); }
|
||||
function attach(input, options) {
|
||||
let state = states.get(input);
|
||||
if (!state) {
|
||||
state = { auto: true, open: false, holder: input.closest("label") || input.parentElement, hint: document.createElement("small"), reset: document.createElement("button"), row: document.createElement("div"), value: document.createElement("code"), badge: document.createElement("span"), change: document.createElement("button") };
|
||||
state = { auto: true, open: false, holder: input.closest("label") || input.parentElement, hint: document.createElement("small"), reset: document.createElement("button"), row: document.createElement("div"), value: document.createElement("code"), badge: document.createElement("span"), change: document.createElement("button"), lock: document.createElement("small"), renameNote: document.createElement("small") };
|
||||
state.lock.className = "fine auto-id-lock"; state.renameNote.className = "fine auto-id-rename-note";
|
||||
state.holder.classList.add("auto-id-field");
|
||||
state.hint.className = "fine auto-id-hint"; state.reset.type = "button"; state.reset.className = "quiet auto-id-reset";
|
||||
state.row.className = "auto-id-row"; state.value.className = "auto-id-value"; state.badge.className = "auto-id-badge"; state.change.type = "button"; state.change.className = "quiet auto-id-change";
|
||||
state.row.append(state.value, state.badge, state.change); state.holder.append(state.row, state.hint, state.reset);
|
||||
state.row.append(state.value, state.badge, state.change, state.lock); state.holder.append(state.row, state.hint, state.reset, state.renameNote);
|
||||
input.addEventListener("input", event => { if (!event.isTrusted) return; state.auto = input.value.trim() === ""; if (state.auto) regenerate(input, state); else paint(input, state); });
|
||||
input.addEventListener("invalid", () => { if (!state.open) { state.open = true; paint(input, state); } });
|
||||
input.addEventListener("blur", () => { if (input.value.trim() && input.validity.valid) { state.open = false; paint(input, state); } });
|
||||
state.change.addEventListener("click", () => { state.open = true; paint(input, state); input.focus(); input.select?.(); });
|
||||
state.reset.addEventListener("mousedown", event => event.preventDefault());
|
||||
state.reset.addEventListener("click", () => { state.auto = true; regenerate(input, state); input.dispatchEvent(new Event("input", { bubbles: true })); });
|
||||
states.set(input, state);
|
||||
states.set(input, state); registry.add(new WeakRef(input));
|
||||
for (const source of options.elements || []) source.addEventListener("input", () => { const current = states.get(input); if (current) regenerate(input, current); });
|
||||
}
|
||||
state.text = options.text || (() => (options.elements || []).map(node => node.value).find(value => value.trim()) || "");
|
||||
state.taken = options.taken || (() => []); state.resettable = options.resettable;
|
||||
if (options.original) {
|
||||
const refs = options.inUse ? options.inUse(options.original) : [];
|
||||
if (refs.length) { input.readOnly = true; state.lockedByRefs = true; } else if (state.lockedByRefs) { input.readOnly = false; state.lockedByRefs = false; }
|
||||
state.lockedReason = refs.length ? () => `${t("idRenameLocked")}: ${refs.slice(0, 4).join(", ")}${refs.length > 4 ? ` +${refs.length - 4}` : ""}` : null;
|
||||
state.renameKey = refs.length ? null : (options.renameKey || "idRenameHelp");
|
||||
} else { state.lockedReason = null; state.renameKey = null; if (state.lockedByRefs) { input.readOnly = false; state.lockedByRefs = false; } }
|
||||
state.auto = !locked(input) && input.value.trim() === ""; state.open = false;
|
||||
paint(input, state);
|
||||
return { refresh() { const current = states.get(input); if (current) regenerate(input, current); } };
|
||||
}
|
||||
return { slugify, unique, attach };
|
||||
function repaintAll() { for (const ref of [...registry]) { const input = ref.deref(); if (!input || !input.isConnected) { if (!input) registry.delete(ref); continue; } const state = states.get(input); if (state) paint(input, state); } }
|
||||
return { slugify, unique, attach, repaintAll };
|
||||
})();
|
||||
window.rustProxyAutoId = rustProxyAutoId;
|
||||
function configReferences(id, keys) {
|
||||
const config = envelope?.config || {}, found = [], wanted = new Set(keys);
|
||||
const labelFor = (top, item) => `${t(`refSection_${top}`) === `refSection_${top}` ? top : t(`refSection_${top}`)}: ${item?.id || item?.name || "?"}`;
|
||||
const walk = (node, top, item) => {
|
||||
if (Array.isArray(node)) { for (const child of node) walk(child, top, item); return; }
|
||||
if (!node || typeof node !== "object") return;
|
||||
for (const [key, value] of Object.entries(node)) {
|
||||
if (wanted.has(key) && (value === id || (Array.isArray(value) && value.includes(id)))) { const label = labelFor(top, item); if (!found.includes(label)) found.push(label); }
|
||||
else if (value && typeof value === "object") walk(value, top, item);
|
||||
}
|
||||
};
|
||||
for (const [top, section] of Object.entries(config)) {
|
||||
if (Array.isArray(section)) for (const item of section) walk(item, top, item);
|
||||
else if (section && typeof section === "object") for (const [key, value] of Object.entries(section)) { if (Array.isArray(value)) for (const item of value) walk(item, `${top}.${key}`, item); else if (wanted.has(key) && value === id) found.push(key === "default_certificate" ? t("certificateDefaultSni") : t(`refSection_${top}`) === `refSection_${top}` ? top : t(`refSection_${top}`)); else walk(value, top, null); }
|
||||
}
|
||||
return found;
|
||||
}
|
||||
window.rustProxyConfigReferences = configReferences;
|
||||
|
||||
const rustProxyAutoCertificate = (() => {
|
||||
const states = new WeakMap();
|
||||
|
||||
Reference in new issue
Block a user