mirror of
https://github.com/hansjone/netx.git
synced 2026-10-09 04:20:45 +08:00
feat(ne): batch delete selected managed network elements
Add POST /v1/managed-ne/batch-delete and toolbar button with confirmation on NE management page. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
parent
d3eae3351c
commit
778442dc57
7 changed files with 75 additions and 0 deletions
|
|
@ -328,6 +328,21 @@ def delete_managed_ne(db: Session, ne_id: str) -> dict[str, bool]:
|
|||
return {"ok": True}
|
||||
|
||||
|
||||
def batch_delete_managed_ne(db: Session, ids: list[str]) -> dict[str, Any]:
|
||||
ne_ids = [str(x).strip() for x in ids if str(x).strip()]
|
||||
if not ne_ids:
|
||||
raise HTTPException(status_code=400, detail="ids_required")
|
||||
rows = db.query(ManagedNE).filter(ManagedNE.id.in_(ne_ids)).all()
|
||||
found_ids = {str(r.id) for r in rows}
|
||||
missing = [x for x in ne_ids if x not in found_ids]
|
||||
if missing:
|
||||
raise HTTPException(status_code=404, detail=f"managed_ne_not_found: {','.join(missing[:5])}")
|
||||
for row in rows:
|
||||
db.delete(row)
|
||||
db.commit()
|
||||
return {"ok": True, "deleted": len(rows)}
|
||||
|
||||
|
||||
def build_managed_ne_import_template(fmt: str = "xlsx") -> tuple[str, bytes, str]:
|
||||
"""Return (filename, content, media_type) for bulk-import template."""
|
||||
rows = [
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue