diff --git a/app/main.py b/app/main.py index cee4638..83268ef 100644 --- a/app/main.py +++ b/app/main.py @@ -196,7 +196,13 @@ async def _origins_delete(request: Request): return Response(status_code=201) -@app.delete('/-/origins/{origin_ref}', summary='* Origins') +@app.delete('/-/origins/expired', summary='* Delete all Origins without active Lease') +async def _origins_delete_expired(request: Request): + Origin.delete_expired(db) + return Response(status_code=201) + + +@app.delete('/-/origins/{origin_ref}', summary='* Delete specific Origin') async def _origins_delete_origin_ref(request: Request, origin_ref: str): if Origin.delete(db, [origin_ref]) == 1: return Response(status_code=201) @@ -219,13 +225,13 @@ async def _leases(request: Request, origin: bool = False): return JSONr(response) -@app.delete('/-/leases/expired', summary='* Leases') +@app.delete('/-/leases/expired', summary='* Delete all expired Leases') async def _lease_delete_expired(request: Request): Lease.delete_expired(db) return Response(status_code=201) -@app.delete('/-/lease/{lease_ref}', summary='* Lease') +@app.delete('/-/lease/{lease_ref}', summary='* Delete specific Lease') async def _lease_delete(request: Request, lease_ref: str): if Lease.delete(db, lease_ref) == 1: return Response(status_code=201) diff --git a/app/static/assets/js/helper.js b/app/static/assets/js/helper.js index 2f40de4..b7ab7ee 100644 --- a/app/static/assets/js/helper.js +++ b/app/static/assets/js/helper.js @@ -116,6 +116,12 @@ async function deleteOrigin(origin_ref) { xhr.send(); } +async function deleteExpiredOrigins() { + let xhr = new XMLHttpRequest(); + xhr.open("DELETE", `/-/origins/expired`, true); + xhr.send(); +} + async function deleteLease(lease_ref) { if (lease_ref === undefined) lease_ref = window.prompt("Please enter 'lease_ref' which should be deleted"); diff --git a/app/templates/views/dashboard_origins.html b/app/templates/views/dashboard_origins.html index be53086..e165720 100644 --- a/app/templates/views/dashboard_origins.html +++ b/app/templates/views/dashboard_origins.html @@ -13,6 +13,9 @@ +