path resolution
This commit is contained in:
+22
-4
@@ -282,7 +282,12 @@ app = FastAPI(title="Scheduler API", version="0.1.0", lifespan=lifespan)
|
||||
|
||||
app.add_middleware(
|
||||
CORSMiddleware,
|
||||
allow_origins=["http://localhost:5173", "http://127.0.0.1:5173"],
|
||||
allow_origins=[
|
||||
"http://localhost:5173",
|
||||
"http://127.0.0.1:5173",
|
||||
"http://localhost:8080",
|
||||
"http://127.0.0.1:8080",
|
||||
],
|
||||
allow_methods=["*"],
|
||||
allow_headers=["*"],
|
||||
)
|
||||
@@ -307,9 +312,22 @@ def get_settings() -> dict[str, Any]:
|
||||
|
||||
@app.post("/api/tests/load")
|
||||
def load_tests(request: LoadTestsRequest) -> dict[str, Any]:
|
||||
csv_path = Path(request.csv_path)
|
||||
if not csv_path.is_absolute():
|
||||
csv_path = APP_ROOT / csv_path
|
||||
received_path = request.csv_path
|
||||
|
||||
# Handle absolute paths (Windows or Unix) by extracting just the filename
|
||||
if "\\" in received_path or ":" in received_path or received_path.startswith("/"):
|
||||
# Absolute path (Windows with backslash or drive letter, or Unix with /)
|
||||
# Extract just the filename from the path
|
||||
filename = received_path.replace("\\", "/").split("/")[-1]
|
||||
|
||||
data_dir_path = APP_ROOT / "data" / filename
|
||||
if data_dir_path.exists():
|
||||
csv_path = data_dir_path
|
||||
else:
|
||||
csv_path = APP_ROOT / filename
|
||||
else:
|
||||
# Relative paths - prepend APP_ROOT
|
||||
csv_path = APP_ROOT / received_path
|
||||
|
||||
settings = db.read_settings(DB_PATH)
|
||||
smb_credentials = _smb_credentials_from_settings(settings)
|
||||
|
||||
@@ -35,14 +35,9 @@ export default function SettingsModal({ isOpen, onClose, settings, onSave }) {
|
||||
onClose()
|
||||
}
|
||||
|
||||
function handleBackdropClick(e) {
|
||||
if (e.target === e.currentTarget) onClose()
|
||||
}
|
||||
|
||||
return (
|
||||
<div
|
||||
className="fixed inset-0 z-50 flex items-center justify-center bg-black/60 backdrop-blur-sm"
|
||||
onClick={handleBackdropClick}
|
||||
>
|
||||
<div className="relative bg-gray-900 border border-gray-700 rounded-xl shadow-2xl w-full max-w-xl max-h-[90vh] flex flex-col">
|
||||
{/* Modal header */}
|
||||
|
||||
Reference in New Issue
Block a user