mirror of
https://git.collinwebdesigns.de/oscar.krause/fastapi-dls.git
synced 2024-11-23 15:31:00 +03:00
implemented delete origin endpoint for frontend
This commit is contained in:
parent
c8df32375a
commit
dcbcba88cb
@ -196,6 +196,13 @@ async def _origins_delete(request: Request):
|
||||
return Response(status_code=201)
|
||||
|
||||
|
||||
@app.delete('/-/origins/{origin_ref}', summary='* Origins')
|
||||
async def _origins_delete_origin_ref(request: Request, origin_ref: str):
|
||||
if Origin.delete(db, origin_ref) == 1:
|
||||
return Response(status_code=201)
|
||||
raise JSONResponse(status_code=404, content={'status': 404, 'detail': 'lease not found'})
|
||||
|
||||
|
||||
@app.get('/-/leases', summary='* Leases')
|
||||
async def _leases(request: Request, origin: bool = False):
|
||||
session = sessionmaker(bind=db)()
|
||||
|
@ -105,6 +105,16 @@ async function deleteOrigins() {
|
||||
await fetchOriginsWithLeases()
|
||||
}
|
||||
|
||||
async function deleteOrigin(origin_ref) {
|
||||
if (origin_ref === undefined)
|
||||
origin_ref = window.prompt("Please enter 'origin_ref' which should be deleted");
|
||||
if (origin_ref === null || origin_ref === "")
|
||||
return
|
||||
let xhr = new XMLHttpRequest();
|
||||
xhr.open("DELETE", `/-/origins/${origin_ref}`, true);
|
||||
xhr.send();
|
||||
}
|
||||
|
||||
async function deleteLease(lease_ref) {
|
||||
if (lease_ref === undefined)
|
||||
lease_ref = window.prompt("Please enter 'lease_ref' which should be deleted");
|
||||
|
Loading…
Reference in New Issue
Block a user