This commit is contained in:
Mateusz Gruszczyński committed 2026-10-23 13:07:11 +02:00
1 parent 66ff9dfaa2
commit ee54aa6875
30 files changed
+939 -68

No files matched your search

+10 -3
View File
@@ -2,6 +2,9 @@
(() => {
let editing = null, dirty = false;
const form = $("web-service-form"), dialog = $("web-service-dialog");
function syncRootPermissions() {
window.rustProxyPermissions?.render($("web-service-permissions"), { kind: "web", paths: [$("web-service-root").value] });
}
const lines = value => value.split(/[\n,]+/).map(item => item.trim()).filter(Boolean);
const strictLines = value => value.split(/\n+/).map(item => item.trim()).filter(Boolean);
const mimeLines = value => Object.entries(value || {}).map(([extension, mime]) => `${extension} = ${mime}`).join("\n");
@@ -276,6 +279,7 @@
syncCompression();
syncPrecompressed();
syncHtaccess();
syncRootPermissions();
}
function updatePresetSummary() {
@@ -335,22 +339,23 @@
dialog.showModal();
}
function clearEditor() { editing = null; dirty = false; form.reset(); if (dialog.open) dialog.close(); }
function clearEditor() { editing = null; dirty = false; form.reset(); syncRootPermissions(); if (dialog.open) dialog.close(); }
function suspendDraft() {
const activeTab = $("web-service-tabs").querySelector("button.active")?.dataset.tab || "general";
const state = { editing, activeTab, label: $("web-service-editing").textContent, controls: window.rustProxyDrafts.captureControls(form) };
const title = $("web-service-id").value.trim() || $("web-service-name").value.trim() || editing || t("draftUntitled");
editing = null; dirty = false; form.reset(); dialog.close(); return { title, state };
editing = null; dirty = false; form.reset(); syncRootPermissions(); dialog.close(); return { title, state };
}
function restoreDraft(state) {
const saved = state.editing ? (envelope?.config.web_services || []).find(item => item.id === state.editing) : null;
open(saved ? structuredClone(saved) : (state.editing ? { id: state.editing } : null));
window.rustProxyDrafts.restoreControls(form, state.controls); editing = state.editing; $("web-service-editing").textContent = state.label;
syncPhp(); syncPrecompressed(); syncHtaccess(); updatePresetSummary(); activateTab(state.activeTab || "general"); dirty = true;
syncPhp(); syncPrecompressed(); syncHtaccess(); syncRootPermissions(); updatePresetSummary(); activateTab(state.activeTab || "general"); dirty = true;
}
function closeEditor() { if (dirty) return window.rustProxyDrafts.dock("web-server"); clearEditor(); return true; }
function render() {
syncRootPermissions();
if (!envelope) return;
const query = ($("web-service-search")?.value || "").trim().toLowerCase();
const services = (envelope.config.web_services || []).filter(service => !query || [service.id, service.name, service.document_root].join(" ").toLowerCase().includes(query));
@@ -530,6 +535,8 @@
initTabs();
form.addEventListener("input", () => { dirty = true; });
form.addEventListener("change", () => { dirty = true; });
$("web-service-root").addEventListener("input", syncRootPermissions);
$("web-service-root").addEventListener("change", syncRootPermissions);
$("web-service-php-enabled").addEventListener("change", syncPhp);
$("web-service-php-profile").addEventListener("change", syncPhp);
$("web-service-php-profiles").addEventListener("click", openProfiles);