fix table with handling, icons implemented

This commit is contained in:
root
2026-08-09 08:50:13 +02:00
parent 5e32be7d0c
commit 3ff0794cfc
43 changed files with 1027 additions and 95 deletions
+4 -4
View File
@@ -739,7 +739,7 @@ def _custom_value(row: AssetFieldValue | None, definition: FieldDefinition) -> A
def _coerce_system_value(target: str, value: Any) -> Any:
# Most asset columns are text fields. Integer and foreign-key fields
# are written with the appropriate type so dynamic mappings remain safe there as well.
if target in {"mesh_mtype", "parent_asset_id", "category_id"}:
if target in {"mesh_mtype", "mesh_icon", "parent_asset_id", "category_id"}:
try:
return int(value) if value not in (None, "") else None
except (TypeError, ValueError):
@@ -1165,8 +1165,8 @@ def synchronize(db: Session, log: Callable[[str, str], None] | None = None, *, d
if asset is None:
if not cfg.get("create_missing_assets", True):
continue
device_type = str(mapped.get("mesh_mtype") or 0)
mapped_category_id = category_mapping.get(device_type)
device_icon = str(mapped.get("mesh_icon") or 0)
mapped_category_id = category_mapping.get(device_icon)
try:
mapped_category_id = int(mapped_category_id) if mapped_category_id not in (None, "") else None
except (TypeError, ValueError):
@@ -1174,7 +1174,7 @@ def synchronize(db: Session, log: Callable[[str, str], None] | None = None, *, d
category = db.query(Category).filter(Category.id == mapped_category_id).first() if mapped_category_id else None
if category is None:
category = fallback_category
log("warning", f"{mapped.get('name', node_id)}: keine gültige Kategorie für MeshCentral-Typ {device_type}; Fallback '{category.name}' (ID {category.id}) verwendet.")
log("warning", f"{mapped.get('name', node_id)}: keine gültige Kategorie für MeshCentral-Icon {device_icon}; Fallback '{category.name}' (ID {category.id}) verwendet.")
asset = Asset(category_id=category.id, name=mapped.get("name", node_id), mesh_node_id=node_id)
db.add(asset)
run.created_count += 1