feat(khira): complete remediation, performance optimization, and Cloudflare Turnstile integration
- Backend: - Fix ListTickets parameter order mismatch for assignee filtering - Replicate all 13 PostgreSQL tables and columns during disaster recovery sync and rollback - Implement server-side session store with HttpOnly cookies and Bearer tokens - Add profile update verification requiring current password - Whitelist allowed file uploads and apply strict security headers (nosniff, CSP) - Enforce role check on error deletion (admin/lead/tester only) and authenticate SSE stream - Align foreign key user_id for saved filters and api tokens - Add ReopenTicket endpoint and workflow - Integrate Cloudflare Turnstile verification with testing/production key support - Frontend: - Remove liquid glass displacement filter and lens capsule for high-performance UI - Eliminate recursive backdrop-filters and heavy inset shadows - Add debounced search and optimize SSE re-rendering - Wire Saved Views filter bar with creation, active indicators, and deletion - Add Linked & Related Tickets management UI to sheet - Seed 6 demo personas in PostgreSQL with instant sign-in - Add Cloudflare Turnstile widgets to authentication modals - Add keyboard arrow navigation to Command Palette - Image Manipulator, Docs & Tooling: - Sync image manipulator updates, docs, and test coordinates
This commit is contained in:
@@ -313,10 +313,80 @@ function renderActiveImage() {
|
||||
};
|
||||
}
|
||||
|
||||
// ═══════════════════════════════════════════════════════════════════
|
||||
// DOWNLOAD / EXPORT UTILITIES (Single & Batch)
|
||||
// ═══════════════════════════════════════════════════════════════════
|
||||
async function downloadImageItem(item) {
|
||||
if (!item || (!item.dataUrl && !item.file)) {
|
||||
showToast("No image available to download", "error");
|
||||
return;
|
||||
}
|
||||
try {
|
||||
let blob;
|
||||
if (item.dataUrl) {
|
||||
const res = await fetch(item.dataUrl);
|
||||
blob = await res.blob();
|
||||
} else if (item.file instanceof Blob) {
|
||||
blob = item.file;
|
||||
}
|
||||
|
||||
if (!blob) {
|
||||
showToast("Failed to prepare image blob for download", "error");
|
||||
return;
|
||||
}
|
||||
|
||||
let filename = item.name || "processed_image";
|
||||
if (filename.includes("/")) {
|
||||
filename = filename.substring(filename.lastIndexOf("/") + 1);
|
||||
}
|
||||
const mimeExtMap = {
|
||||
"image/jpeg": ".jpg",
|
||||
"image/png": ".png",
|
||||
"image/webp": ".webp",
|
||||
"image/avif": ".avif",
|
||||
"image/bmp": ".bmp",
|
||||
"image/tiff": ".tiff"
|
||||
};
|
||||
if (blob.type && mimeExtMap[blob.type]) {
|
||||
const expectedExt = mimeExtMap[blob.type];
|
||||
const curExt = filename.substring(filename.lastIndexOf(".")).toLowerCase();
|
||||
if (!curExt || (curExt !== expectedExt && !(expectedExt === ".jpg" && curExt === ".jpeg"))) {
|
||||
filename = filename.replace(/\.[^/.]+$/, "") + expectedExt;
|
||||
}
|
||||
}
|
||||
|
||||
const blobUrl = window.URL.createObjectURL(blob);
|
||||
const a = document.createElement("a");
|
||||
a.href = blobUrl;
|
||||
a.download = filename;
|
||||
document.body.appendChild(a);
|
||||
a.click();
|
||||
a.remove();
|
||||
setTimeout(() => window.URL.revokeObjectURL(blobUrl), 2000);
|
||||
showToast(`Downloaded ${filename}`, "success");
|
||||
} catch (err) {
|
||||
showToast(`Download failed: ${err.message}`, "error");
|
||||
}
|
||||
}
|
||||
window.downloadImageItem = downloadImageItem;
|
||||
|
||||
function downloadActiveImage() {
|
||||
if (!filesList || filesList.length === 0) {
|
||||
showToast("No image open to download", "error");
|
||||
return;
|
||||
}
|
||||
const cur = filesList[activeIndex];
|
||||
if (!cur) return;
|
||||
downloadImageItem(cur);
|
||||
}
|
||||
window.downloadActiveImage = downloadActiveImage;
|
||||
|
||||
function updateQueueUI() {
|
||||
const counterPill = document.getElementById("ps-file-counter");
|
||||
const btnBatchHeader = document.getElementById("btn-batch-all");
|
||||
const btnBatchFooter = document.getElementById("btn-batch-footer");
|
||||
const btnDownloadHeader = document.getElementById("btn-download-active");
|
||||
const btnDownloadFooter = document.getElementById("btn-download-footer");
|
||||
const hubCount = document.getElementById("batch-hub-count");
|
||||
const hubSize = document.getElementById("batch-hub-size");
|
||||
|
||||
@@ -330,6 +400,14 @@ function updateQueueUI() {
|
||||
else counterPill.classList.remove("has-files");
|
||||
}
|
||||
|
||||
// Show Download button whenever there is at least 1 image loaded
|
||||
if (btnDownloadHeader) {
|
||||
btnDownloadHeader.style.display = count > 0 ? "inline-flex" : "none";
|
||||
}
|
||||
if (btnDownloadFooter) {
|
||||
btnDownloadFooter.style.display = count > 0 ? "inline-flex" : "none";
|
||||
}
|
||||
|
||||
if (btnBatchHeader) {
|
||||
if (count > 1) {
|
||||
btnBatchHeader.style.display = "inline-flex";
|
||||
@@ -369,9 +447,14 @@ function renderFilmstrip() {
|
||||
<span class="ps-thumb-name" title="${item.name}">${item.name}</span>
|
||||
<span class="ps-thumb-size">${item.naturalW}×${item.naturalH} · ${sizeKb}KB</span>
|
||||
</div>
|
||||
<button class="ps-thumb-close" onclick="removeImage(${index}, event)" title="Remove image">
|
||||
<i class="fa-solid fa-xmark"></i>
|
||||
</button>
|
||||
<div class="ps-thumb-actions">
|
||||
<button class="ps-thumb-btn ps-thumb-dl" onclick="event.stopPropagation(); downloadImageItem(filesList[${index}]);" title="Download this image">
|
||||
<i class="fa-solid fa-download"></i>
|
||||
</button>
|
||||
<button class="ps-thumb-btn ps-thumb-close" onclick="removeImage(${index}, event)" title="Remove image">
|
||||
<i class="fa-solid fa-xmark"></i>
|
||||
</button>
|
||||
</div>
|
||||
`;
|
||||
tray.appendChild(card);
|
||||
});
|
||||
@@ -1960,13 +2043,20 @@ async function executeEndpointRequest(endpoint, formData) {
|
||||
|
||||
// Re-convert data URI to Blob to update File reference
|
||||
const blob = await (await fetch(resItem.image)).blob();
|
||||
cur.file = new File([blob], resItem.filename || cur.name, { type: blob.type });
|
||||
const finalName = resItem.filename || cur.name;
|
||||
cur.name = finalName;
|
||||
cur.file = new File([blob], finalName, { type: blob.type });
|
||||
cur.size = blob.size;
|
||||
|
||||
pushHistorySnapshot(currentTool.toUpperCase() + " applied", resItem.image, cur.naturalW, cur.naturalH);
|
||||
renderActiveImage();
|
||||
updateSplitImages();
|
||||
showToast("Transformation applied successfully!", "success");
|
||||
renderFilmstrip();
|
||||
updateInspectorInfo(cur);
|
||||
|
||||
// Auto-download single image output directly
|
||||
await downloadImageItem(cur);
|
||||
showToast("Transformation applied & image downloaded!", "success");
|
||||
} else {
|
||||
showToast(data.error || "Transformation failed", "error");
|
||||
}
|
||||
@@ -2372,6 +2462,18 @@ function setupKeyboardShortcuts() {
|
||||
return;
|
||||
}
|
||||
|
||||
if ((e.ctrlKey || e.metaKey) && e.key.toLowerCase() === "s") {
|
||||
e.preventDefault();
|
||||
downloadActiveImage();
|
||||
return;
|
||||
}
|
||||
|
||||
// Do NOT intercept any browser or OS modifier shortcuts (Ctrl, Meta/Cmd, Alt)
|
||||
// This allows Ctrl+R, Ctrl+Shift+R, Ctrl+F, Ctrl+Z, Ctrl+C, etc. to work natively!
|
||||
if (e.ctrlKey || e.metaKey || e.altKey) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (e.key === "Escape") {
|
||||
closeBatchModal();
|
||||
return;
|
||||
|
||||
Reference in New Issue
Block a user