UI- Verbesserung
Dieser Commit ist enthalten in:
@@ -3820,6 +3820,69 @@ def check_resource_availability():
|
||||
|
||||
return jsonify(availability)
|
||||
|
||||
@app.route('/api/global-search', methods=['GET'])
|
||||
@login_required
|
||||
def global_search():
|
||||
"""Global search API endpoint for searching customers and licenses"""
|
||||
query = request.args.get('q', '').strip()
|
||||
|
||||
if not query or len(query) < 2:
|
||||
return jsonify({'customers': [], 'licenses': []})
|
||||
|
||||
conn = get_connection()
|
||||
cur = conn.cursor()
|
||||
|
||||
# Search pattern with wildcards
|
||||
search_pattern = f'%{query}%'
|
||||
|
||||
# Search customers
|
||||
cur.execute("""
|
||||
SELECT id, name, email, company_name
|
||||
FROM customers
|
||||
WHERE (LOWER(name) LIKE LOWER(%s)
|
||||
OR LOWER(email) LIKE LOWER(%s)
|
||||
OR LOWER(company_name) LIKE LOWER(%s))
|
||||
AND is_test = FALSE
|
||||
ORDER BY name
|
||||
LIMIT 5
|
||||
""", (search_pattern, search_pattern, search_pattern))
|
||||
|
||||
customers = []
|
||||
for row in cur.fetchall():
|
||||
customers.append({
|
||||
'id': row[0],
|
||||
'name': row[1],
|
||||
'email': row[2],
|
||||
'company_name': row[3]
|
||||
})
|
||||
|
||||
# Search licenses
|
||||
cur.execute("""
|
||||
SELECT l.id, l.license_key, c.name as customer_name
|
||||
FROM licenses l
|
||||
JOIN customers c ON l.customer_id = c.id
|
||||
WHERE LOWER(l.license_key) LIKE LOWER(%s)
|
||||
AND l.is_test = FALSE
|
||||
ORDER BY l.created_at DESC
|
||||
LIMIT 5
|
||||
""", (search_pattern,))
|
||||
|
||||
licenses = []
|
||||
for row in cur.fetchall():
|
||||
licenses.append({
|
||||
'id': row[0],
|
||||
'license_key': row[1],
|
||||
'customer_name': row[2]
|
||||
})
|
||||
|
||||
cur.close()
|
||||
conn.close()
|
||||
|
||||
return jsonify({
|
||||
'customers': customers,
|
||||
'licenses': licenses
|
||||
})
|
||||
|
||||
@app.route('/resources/history/<int:resource_id>')
|
||||
@login_required
|
||||
def resource_history(resource_id):
|
||||
|
||||
In neuem Issue referenzieren
Einen Benutzer sperren