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;
|
||||
|
||||
@@ -70,6 +70,9 @@
|
||||
<button class="btn btn-secondary btn-sm" id="btn-apply-active" onclick="executeActiveImage()" title="Execute on current image (Ctrl+Enter)">
|
||||
<i class="fa-solid fa-bolt"></i> Apply Active
|
||||
</button>
|
||||
<button class="btn btn-sm btn-cyan" id="btn-download-active" onclick="downloadActiveImage()" style="display: none;" title="Download active processed image (Ctrl+S)">
|
||||
<i class="fa-solid fa-download"></i> Download Image
|
||||
</button>
|
||||
<button class="btn btn-sm btn-cyan" id="btn-batch-all" onclick="executeBatchAll()" style="display: none;" title="Execute active tool on all loaded files">
|
||||
<i class="fa-solid fa-layer-group"></i> Batch All (0)
|
||||
</button>
|
||||
@@ -379,9 +382,12 @@
|
||||
|
||||
<!-- Inspector Action Footer -->
|
||||
<div class="ps-action-footer">
|
||||
<button class="btn" style="width: 100%;" onclick="executeActiveImage()">
|
||||
<button class="btn" style="width: 100%;" onclick="executeActiveImage()" title="Apply transformation to active image (Ctrl+Enter)">
|
||||
<i class="fa-solid fa-bolt"></i> Apply to Active Image
|
||||
</button>
|
||||
<button class="btn btn-cyan btn-sm" id="btn-download-footer" style="width: 100%; display: none;" onclick="downloadActiveImage()" title="Download current processed image (Ctrl+S)">
|
||||
<i class="fa-solid fa-download"></i> Download Image
|
||||
</button>
|
||||
<button class="btn btn-secondary btn-sm" id="btn-batch-footer" style="width: 100%; display: none;" onclick="executeBatchAll()">
|
||||
<i class="fa-solid fa-layer-group"></i> Apply to All (0 Files)
|
||||
</button>
|
||||
|
||||
@@ -98,8 +98,8 @@ func main() {
|
||||
w.Header().Set("Content-Type", "text/css; charset=utf-8")
|
||||
w.Header().Set("Cache-Control", "no-cache, no-store, must-revalidate")
|
||||
for _, p := range []string{
|
||||
"cmd/image-manipulator/styles.css",
|
||||
"web/image-manipulator/styles.css",
|
||||
"cmd/image-manipulator/styles.css",
|
||||
} {
|
||||
if _, err := os.Stat(p); err == nil {
|
||||
http.ServeFile(w, r, p)
|
||||
@@ -112,8 +112,8 @@ func main() {
|
||||
w.Header().Set("Content-Type", "application/javascript; charset=utf-8")
|
||||
w.Header().Set("Cache-Control", "no-cache, no-store, must-revalidate")
|
||||
for _, p := range []string{
|
||||
"cmd/image-manipulator/app.js",
|
||||
"web/image-manipulator/app.js",
|
||||
"cmd/image-manipulator/app.js",
|
||||
} {
|
||||
if _, err := os.Stat(p); err == nil {
|
||||
http.ServeFile(w, r, p)
|
||||
|
||||
@@ -895,6 +895,45 @@ html, body {
|
||||
color: var(--text-3);
|
||||
}
|
||||
|
||||
.ps-thumb-actions {
|
||||
position: absolute;
|
||||
top: 3px;
|
||||
right: 4px;
|
||||
display: none;
|
||||
gap: 3px;
|
||||
z-index: 5;
|
||||
}
|
||||
|
||||
.ps-thumb-card:hover .ps-thumb-actions {
|
||||
display: flex;
|
||||
}
|
||||
|
||||
.ps-thumb-btn {
|
||||
width: 17px;
|
||||
height: 17px;
|
||||
border-radius: 50%;
|
||||
background: rgba(0, 0, 0, 0.75);
|
||||
border: 1px solid var(--border-1);
|
||||
color: var(--text-2);
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
font-size: 8.5px;
|
||||
cursor: pointer;
|
||||
transition: all 0.15s ease;
|
||||
}
|
||||
|
||||
.ps-thumb-btn:hover {
|
||||
background: var(--bg-card-hover);
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
.ps-thumb-dl:hover {
|
||||
background: var(--accent-cyan);
|
||||
color: #000;
|
||||
border-color: var(--accent-cyan);
|
||||
}
|
||||
|
||||
.ps-thumb-close {
|
||||
position: absolute;
|
||||
top: 3px;
|
||||
@@ -912,6 +951,14 @@ html, body {
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.ps-thumb-actions .ps-thumb-close {
|
||||
position: static;
|
||||
display: flex;
|
||||
width: 17px;
|
||||
height: 17px;
|
||||
font-size: 8.5px;
|
||||
}
|
||||
|
||||
.ps-thumb-card:hover .ps-thumb-close {
|
||||
display: flex;
|
||||
}
|
||||
@@ -919,6 +966,7 @@ html, body {
|
||||
.ps-thumb-close:hover {
|
||||
background: #ef4444;
|
||||
color: #fff;
|
||||
border-color: #ef4444;
|
||||
}
|
||||
|
||||
/* ═══════════════════════════════════════════════════════════════════
|
||||
|
||||
Reference in New Issue
Block a user