mirror of
https://github.com/jokob-sk/NetAlertX.git
synced 2026-07-29 17:08:45 -04:00
feat: Implement DevicesHistory feature with triggers and history tracking
- Added db_history.py to manage DevicesHistory table and triggers for INSERT and UPDATE operations. - Created device_history_instance.py for querying and grouping DevicesHistory records. - Developed change_history.php for displaying device change history with filtering and pagination. - Introduced skel_device_details_tab_history.php for skeleton loading state in device details tab. - Added unit tests in test_device_history.py to validate trigger functionality and history management. - Implemented filter population and pagination in the change history UI.
This commit is contained in:
@@ -6,6 +6,7 @@ import os
|
||||
|
||||
from flask import Flask, redirect, request, jsonify, url_for, Response
|
||||
from models.device_instance import DeviceInstance # noqa: E402
|
||||
from models.device_history_instance import DevicesHistoryInstance # noqa: E402
|
||||
from flask_cors import CORS
|
||||
from werkzeug.exceptions import HTTPException
|
||||
|
||||
@@ -772,6 +773,20 @@ def api_devices_totals(payload=None):
|
||||
return jsonify(device_handler.getTotals())
|
||||
|
||||
|
||||
@app.route("/devices/history/filters", methods=["GET"])
|
||||
@validate_request(
|
||||
operation_id="get_device_history_filters",
|
||||
summary="Get Device History Filter Values",
|
||||
description="Return distinct changedBy and changedColumn values available in DevicesHistory. Optionally scope to a single device with ?devGuid=<guid>.",
|
||||
tags=["devices"],
|
||||
auth_callable=is_authorized
|
||||
)
|
||||
def api_devices_history_filters(payload=None):
|
||||
dev_guid = request.args.get("devGuid") or None
|
||||
filters = DevicesHistoryInstance().get_available_filter_values(devGUID=dev_guid)
|
||||
return jsonify({"success": True, "data": filters})
|
||||
|
||||
|
||||
@app.route("/devices/totals/named", methods=["GET"])
|
||||
@validate_request(
|
||||
operation_id="get_device_totals_named",
|
||||
|
||||
Reference in New Issue
Block a user