mirror of
https://codeberg.org/PostERG/xamxam.git
synced 2026-06-25 16:19:19 +02:00
Add SQLite indexes for contenus page language/tag queries + WIP: Peertube orphans, dialogs, contact decoupling, context note, finality types
This commit is contained in:
@@ -948,4 +948,110 @@
|
||||
bodyEl.innerHTML = '<p class="file-browser-error">Erreur réseau.</p>';
|
||||
});
|
||||
};
|
||||
|
||||
// PeerTube video relink (edit page — binds a channel-orphan video to the thesis)
|
||||
window.XamxamRelinkPeerTube = (el) => {
|
||||
var li = el.closest(".file-browser-entry");
|
||||
if (!li) return;
|
||||
|
||||
var uuid = li.dataset.ptUuid;
|
||||
var name = li.dataset.ptName;
|
||||
if (!uuid) return;
|
||||
|
||||
var ctx = window.__xamxamPeertubeRelinkCtx || {};
|
||||
var thesisId = ctx.thesisId;
|
||||
if (!thesisId) return;
|
||||
|
||||
var bodyEl = document.getElementById("peertube-relink-modal-body");
|
||||
if (bodyEl)
|
||||
bodyEl.innerHTML =
|
||||
'<p class="file-browser-loading">Reliage en cours…</p>';
|
||||
|
||||
var csrfToken =
|
||||
document
|
||||
.querySelector('meta[name="csrf-token"]')
|
||||
?.getAttribute("content") || "";
|
||||
|
||||
fetch("/admin/actions/peertube-relink.php", {
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
"X-CSRF-Token": csrfToken,
|
||||
},
|
||||
body: JSON.stringify({
|
||||
thesis_id: parseInt(thesisId, 10),
|
||||
uuid: uuid,
|
||||
}),
|
||||
})
|
||||
.then((r) =>
|
||||
r.json().then((data) => ({ ok: r.ok, status: r.status, data })),
|
||||
)
|
||||
.then(({ ok, status, data }) => {
|
||||
if (!ok || (data && data.ok === false)) {
|
||||
var msg = data?.error
|
||||
? data.error
|
||||
: typeof data === "string"
|
||||
? data
|
||||
: "Erreur " + status;
|
||||
if (bodyEl)
|
||||
bodyEl.innerHTML = '<p class="file-browser-error">Erreur : ' + msg + '</p>';
|
||||
return;
|
||||
}
|
||||
console.log("[pt-relink] success | new_id=" + data.id);
|
||||
|
||||
var input = document.querySelector(
|
||||
'.tfe-file-picker[data-queue-type="tfe"]',
|
||||
);
|
||||
var closeAndRefresh = () => {
|
||||
var modal = document.getElementById("peertube-relink-modal");
|
||||
if (modal) modal.close();
|
||||
var block = document.getElementById("format-fichiers-block");
|
||||
if (block && window.htmx) {
|
||||
var url = "/admin/fragments/fichiers.php";
|
||||
if (thesisId)
|
||||
url += "?_thesis_id=" + encodeURIComponent(thesisId);
|
||||
htmx.ajax("GET", url, {
|
||||
target: "#format-fichiers-block",
|
||||
swap: "outerHTML",
|
||||
});
|
||||
}
|
||||
};
|
||||
if (input) {
|
||||
var pond = FilePond.find(input);
|
||||
if (pond) {
|
||||
pond
|
||||
.addFile(String(data.id), {
|
||||
type: "limbo",
|
||||
file: {
|
||||
name: name,
|
||||
size: 0,
|
||||
type: "video/mp4",
|
||||
},
|
||||
})
|
||||
.then(() => {
|
||||
console.log("[pt-relink] addFile resolved");
|
||||
closeAndRefresh();
|
||||
})
|
||||
.catch((err) => {
|
||||
console.error("[pt-relink] addFile rejected", err);
|
||||
closeAndRefresh();
|
||||
});
|
||||
} else {
|
||||
console.error("[pt-relink] FilePond.find returned null");
|
||||
closeAndRefresh();
|
||||
}
|
||||
} else {
|
||||
console.warn("[pt-relink] input not found");
|
||||
closeAndRefresh();
|
||||
}
|
||||
|
||||
window.__xamxamDirty = true;
|
||||
})
|
||||
.catch((err) => {
|
||||
console.error("[pt-relink] fetch error", err);
|
||||
if (bodyEl)
|
||||
bodyEl.innerHTML =
|
||||
'<p class="file-browser-error">Erreur réseau.</p>';
|
||||
});
|
||||
};
|
||||
})();
|
||||
|
||||
Reference in New Issue
Block a user