mirror of
https://github.com/jokob-sk/NetAlertX.git
synced 2026-03-31 15:22:26 -07:00
refactor UI backend calls to python endpoints
This commit is contained in:
@@ -275,7 +275,8 @@ def api_update_device_column(mac):
|
||||
column_name = data.get("columnName")
|
||||
column_value = data.get("columnValue")
|
||||
|
||||
if not column_name or not column_value:
|
||||
# columnName is required, but columnValue can be empty string (e.g., for unassigning)
|
||||
if not column_name or "columnValue" not in data:
|
||||
return jsonify({"success": False, "message": "ERROR: Missing parameters", "error": "columnName and columnValue are required"}), 400
|
||||
|
||||
device_handler = DeviceInstance()
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
import os
|
||||
import base64
|
||||
import sys
|
||||
from urllib.parse import unquote
|
||||
from flask import jsonify
|
||||
|
||||
# Register NetAlertX directories
|
||||
@@ -15,7 +16,8 @@ from database import get_temp_db_connection # noqa: E402 [flake8 lint suppressi
|
||||
def read_query(raw_sql_b64):
|
||||
"""Execute a read-only query (SELECT)."""
|
||||
try:
|
||||
raw_sql = base64.b64decode(raw_sql_b64).decode("utf-8")
|
||||
# Decode: base64 -> URL decode (matches JS: btoa(unescape(encodeURIComponent())))
|
||||
raw_sql = unquote(base64.b64decode(raw_sql_b64).decode("utf-8"))
|
||||
|
||||
conn = get_temp_db_connection()
|
||||
cur = conn.cursor()
|
||||
@@ -35,7 +37,8 @@ def read_query(raw_sql_b64):
|
||||
def write_query(raw_sql_b64):
|
||||
"""Execute a write query (INSERT/UPDATE/DELETE)."""
|
||||
try:
|
||||
raw_sql = base64.b64decode(raw_sql_b64).decode("utf-8")
|
||||
# Decode: base64 -> URL decode (matches JS: btoa(unescape(encodeURIComponent())))
|
||||
raw_sql = unquote(base64.b64decode(raw_sql_b64).decode("utf-8"))
|
||||
|
||||
conn = get_temp_db_connection()
|
||||
cur = conn.cursor()
|
||||
|
||||
Reference in New Issue
Block a user