Implement full system directory browser modal for temp directories

- Add GET /api/system/browse-dir and POST /api/system/create-dir endpoints
- Add Folder Browser Modal overlay in index.html
- Add browse buttons to both job-specific and default setting temp dir inputs
- Add JS helpers and event handlers for directory list loading, parent navigation, directory selection, and new folder creation
This commit is contained in:
2026-06-29 10:02:58 -04:00
parent 006eece417
commit c7b637e70a
3 changed files with 319 additions and 2 deletions
+59
View File
@@ -1113,6 +1113,65 @@ def update_settings(req: UpdateSettingsRequest):
save_settings(settings)
return {"status": "saved", "settings": settings}
class CreateDirRequest(BaseModel):
parent_path: str
name: str
@app.get("/api/system/browse-dir")
def browse_dir(path: str = ""):
"""Browse directories on the system"""
if not path:
path = os.path.expanduser("~")
path = os.path.abspath(path)
if not os.path.exists(path):
raise HTTPException(status_code=404, detail="Path does not exist")
if not os.path.isdir(path):
raise HTTPException(status_code=400, detail="Path is not a directory")
try:
entries = []
# Add parent directory entry if not at root
parent = os.path.dirname(path)
if parent != path:
entries.append({
"name": "..",
"path": parent,
"is_dir": True
})
for name in sorted(os.listdir(path)):
full_path = os.path.join(path, name)
try:
if os.path.isdir(full_path):
entries.append({
"name": name,
"path": full_path,
"is_dir": True
})
except PermissionError:
continue
return {
"current_path": path,
"entries": entries
}
except Exception as e:
raise HTTPException(status_code=500, detail=str(e))
@app.post("/api/system/create-dir")
def create_dir(req: CreateDirRequest):
"""Create a new directory"""
full_path = os.path.abspath(os.path.join(req.parent_path, req.name))
try:
os.makedirs(full_path, exist_ok=True)
return {"status": "ok", "path": full_path}
except Exception as e:
raise HTTPException(status_code=400, detail=str(e))
@app.get("/api/uploads/{filename}")
def get_upload_file(filename: str):
file_path = os.path.join(upscaler.UPLOAD_DIR, filename)