Fix six buttons sending GET instead of POST, causing 404s

The api() helper only sends POST when a body argument is passed;
Browse Folder, Pause, Stop, Retry Failed (x2), Undo All, and Scan for
Duplicates were all called with no body, so they defaulted to GET
against POST-only server routes and 404'd. Verified live via the actual
browser: Pause/Stop now correctly transition server status
(running -> paused -> idle) instead of silently failing.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
drjones
2026-07-23 03:55:10 -07:00
parent 52442d6a6d
commit 7fc81daaa0

View File

@@ -1012,7 +1012,7 @@ if($("btnBrowseFolder")){
$("btnBrowseFolder").onclick = async ()=>{ $("btnBrowseFolder").onclick = async ()=>{
$("btnBrowseFolder").disabled = true; $("btnBrowseFolder").disabled = true;
showToast("Opening folder chooser…", "info"); showToast("Opening folder chooser…", "info");
const j = await api("/api/choose_folder"); const j = await api("/api/choose_folder", {});
$("btnBrowseFolder").disabled = false; $("btnBrowseFolder").disabled = false;
if(j.ok && j.folder){ if(j.ok && j.folder){
$("folder").value = j.folder; $("folder").value = j.folder;
@@ -1052,18 +1052,18 @@ $("btnStart").onclick = ()=>{
}); });
}; };
$("btnPause").onclick = ()=>api("/api/pause"); $("btnPause").onclick = ()=>api("/api/pause", {});
$("btnStop").onclick = ()=>api("/api/stop"); $("btnStop").onclick = ()=>api("/api/stop", {});
$("btnRetryFailed").onclick = async ()=>{ $("btnRetryFailed").onclick = async ()=>{
const j = await api("/api/retry_failed"); const j = await api("/api/retry_failed", {});
if(j.ok) addLog({level:"info",msg:"Retrying failures...",ts:new Date().toTimeString().slice(0,8)}); if(j.ok) addLog({level:"info",msg:"Retrying failures...",ts:new Date().toTimeString().slice(0,8)});
}; };
$("btnUndoAll").onclick = async ()=>{ $("btnUndoAll").onclick = async ()=>{
if(confirm("☣ WARNING ☣\nThis will remove all PHOTON embedded descriptions/categories/keywords from ALL files in the scanned folder. It will also clear organized symlinks, reset the database and delete the failures log.\n\nTHIS ACTION CANNOT BE UNDONE.\n\nDo you want to proceed?")){ if(confirm("☣ WARNING ☣\nThis will remove all PHOTON embedded descriptions/categories/keywords from ALL files in the scanned folder. It will also clear organized symlinks, reset the database and delete the failures log.\n\nTHIS ACTION CANNOT BE UNDONE.\n\nDo you want to proceed?")){
$("btnUndoAll").disabled = true; $("btnUndoAll").disabled = true;
const j = await api("/api/undo_all"); const j = await api("/api/undo_all", {});
$("btnUndoAll").disabled = false; $("btnUndoAll").disabled = false;
if(j.ok){ if(j.ok){
recentFiles = []; recentFiles = [];
@@ -1753,7 +1753,7 @@ async function loadFailed(){
} }
$("btnRetryAllFailed").onclick = async ()=>{ $("btnRetryAllFailed").onclick = async ()=>{
$("btnRetryAllFailed").disabled = true; $("btnRetryAllFailed").disabled = true;
const j = await api("/api/retry_failed"); const j = await api("/api/retry_failed", {});
if(j.ok) addLog({level:"info", msg:"Retrying all failed photos…", ts:new Date().toTimeString().slice(0,8)}); if(j.ok) addLog({level:"info", msg:"Retrying all failed photos…", ts:new Date().toTimeString().slice(0,8)});
}; };
@@ -1904,7 +1904,7 @@ async function loadDupeGroups(){
}); });
} }
$("btnScanDupes").onclick = async ()=>{ $("btnScanDupes").onclick = async ()=>{
const j = await api("/api/dedupe/build"); const j = await api("/api/dedupe/build", {});
if(j.ok){ if(j.ok){
addLog({level:"info", msg:"Duplicate scan started in the background…", ts:new Date().toTimeString().slice(0,8)}); addLog({level:"info", msg:"Duplicate scan started in the background…", ts:new Date().toTimeString().slice(0,8)});
loadDupeGroups(); loadDupeGroups();