From cc4bdafa0b148a2a35d8ed8adf42fac1f0e6e504 Mon Sep 17 00:00:00 2001 From: Yaro Kasear Date: Fri, 12 Sep 2025 12:58:37 -0500 Subject: [PATCH] API improvements and maybe some "eh" reporting style improvements. --- crudkit/api/flask_api.py | 25 ++++++++++++++++++++----- inventory/templates/index.html | 20 +++++++++++++++----- 2 files changed, 35 insertions(+), 10 deletions(-) diff --git a/crudkit/api/flask_api.py b/crudkit/api/flask_api.py index 46832c2..d238678 100644 --- a/crudkit/api/flask_api.py +++ b/crudkit/api/flask_api.py @@ -6,26 +6,41 @@ def generate_crud_blueprint(model, service): @bp.get('/') def list_items(): items = service.list(request.args) - return jsonify([item.as_dict() for item in items]) + try: + return jsonify([item.as_dict() for item in items]) + except Exception as e: + return jsonify({"status": "error", "error": str(e)}) @bp.get('/') def get_item(id): item = service.get(id, request.args) - return jsonify(item.as_dict()) + try: + return jsonify(item.as_dict()) + except Exception as e: + return jsonify({"status": "error", "error": str(e)}) @bp.post('/') def create_item(): obj = service.create(request.json) - return jsonify(obj.as_dict()) + try: + return jsonify(obj.as_dict()) + except Exception as e: + return jsonify({"status": "error", "error": str(e)}) @bp.patch('/') def update_item(id): obj = service.update(id, request.json) - return jsonify(obj.as_dict()) + try: + return jsonify(obj.as_dict()) + except Exception as e: + return jsonify({"status": "error", "error": str(e)}) @bp.delete('/') def delete_item(id): service.delete(id) - return '', 204 + try: + return jsonify({"status": "success"}), 204 + except Exception as e: + return jsonify({"status": "error", "error": str(e)}) return bp diff --git a/inventory/templates/index.html b/inventory/templates/index.html index cfd0dce..c3bc9fc 100644 --- a/inventory/templates/index.html +++ b/inventory/templates/index.html @@ -1,17 +1,27 @@ {% extends 'base.html' %} +{% block style %} + .chart-container { height: 420px; } + + .pivot-cell { min-width: 0; min-height: 0; } + + .table-responsive { max-height: 420px; overflow: auto; } + + #pivot thead th { position: sticky; top: 0; z-index: 1; background: var(--bs-body-bg); } +{% endblock %} + {% block main %}

{{ title or "Inventory Manager" }}

Find out about all of your assets.

-
+

Active Worklogs

{{ logs | safe }}
-
-

Inventory PivotTable

+
+

Inventory Report

@@ -52,11 +62,11 @@
-
+
-
+