Kunden & Lizenzen + Ressourcen - Nicht so zufrieden
Dieser Commit ist enthalten in:
@@ -2322,6 +2322,37 @@ def api_customer_licenses(customer_id):
|
||||
|
||||
licenses = []
|
||||
for row in cur.fetchall():
|
||||
license_id = row[0]
|
||||
|
||||
# Hole die konkreten zugewiesenen Ressourcen für diese Lizenz
|
||||
cur.execute("""
|
||||
SELECT rp.id, rp.resource_type, rp.resource_value, lr.assigned_at
|
||||
FROM resource_pools rp
|
||||
JOIN license_resources lr ON rp.id = lr.resource_id
|
||||
WHERE lr.license_id = %s AND lr.is_active = true
|
||||
ORDER BY rp.resource_type, rp.resource_value
|
||||
""", (license_id,))
|
||||
|
||||
resources = {
|
||||
'domains': [],
|
||||
'ipv4s': [],
|
||||
'phones': []
|
||||
}
|
||||
|
||||
for res_row in cur.fetchall():
|
||||
resource_info = {
|
||||
'id': res_row[0],
|
||||
'value': res_row[2],
|
||||
'assigned_at': res_row[3].strftime('%d.%m.%Y') if res_row[3] else ''
|
||||
}
|
||||
|
||||
if res_row[1] == 'domain':
|
||||
resources['domains'].append(resource_info)
|
||||
elif res_row[1] == 'ipv4':
|
||||
resources['ipv4s'].append(resource_info)
|
||||
elif res_row[1] == 'phone':
|
||||
resources['phones'].append(resource_info)
|
||||
|
||||
licenses.append({
|
||||
'id': row[0],
|
||||
'license_key': row[1],
|
||||
@@ -2332,7 +2363,8 @@ def api_customer_licenses(customer_id):
|
||||
'status': row[6],
|
||||
'domain_count': row[7],
|
||||
'ipv4_count': row[8],
|
||||
'phone_count': row[9]
|
||||
'phone_count': row[9],
|
||||
'resources': resources
|
||||
})
|
||||
|
||||
cur.close()
|
||||
@@ -2447,6 +2479,56 @@ def api_license_quick_edit(license_id):
|
||||
conn.close()
|
||||
return jsonify({'success': False, 'error': str(e)}), 500
|
||||
|
||||
@app.route("/api/license/<int:license_id>/resources")
|
||||
@login_required
|
||||
def api_license_resources(license_id):
|
||||
"""API-Endpoint für detaillierte Ressourcen-Informationen einer Lizenz"""
|
||||
conn = get_connection()
|
||||
cur = conn.cursor()
|
||||
|
||||
try:
|
||||
# Hole die konkreten zugewiesenen Ressourcen für diese Lizenz
|
||||
cur.execute("""
|
||||
SELECT rp.id, rp.resource_type, rp.resource_value, lr.assigned_at
|
||||
FROM resource_pools rp
|
||||
JOIN license_resources lr ON rp.id = lr.resource_id
|
||||
WHERE lr.license_id = %s AND lr.is_active = true
|
||||
ORDER BY rp.resource_type, rp.resource_value
|
||||
""", (license_id,))
|
||||
|
||||
resources = {
|
||||
'domains': [],
|
||||
'ipv4s': [],
|
||||
'phones': []
|
||||
}
|
||||
|
||||
for row in cur.fetchall():
|
||||
resource_info = {
|
||||
'id': row[0],
|
||||
'value': row[2],
|
||||
'assigned_at': row[3].strftime('%d.%m.%Y') if row[3] else ''
|
||||
}
|
||||
|
||||
if row[1] == 'domain':
|
||||
resources['domains'].append(resource_info)
|
||||
elif row[1] == 'ipv4':
|
||||
resources['ipv4s'].append(resource_info)
|
||||
elif row[1] == 'phone':
|
||||
resources['phones'].append(resource_info)
|
||||
|
||||
cur.close()
|
||||
conn.close()
|
||||
|
||||
return jsonify({
|
||||
'success': True,
|
||||
'resources': resources
|
||||
})
|
||||
|
||||
except Exception as e:
|
||||
cur.close()
|
||||
conn.close()
|
||||
return jsonify({'success': False, 'error': str(e)}), 500
|
||||
|
||||
@app.route("/sessions")
|
||||
@login_required
|
||||
def sessions():
|
||||
@@ -3228,7 +3310,8 @@ def resources():
|
||||
c.name as customer_name,
|
||||
rp.status_changed_at,
|
||||
rp.quarantine_reason,
|
||||
rp.quarantine_until
|
||||
rp.quarantine_until,
|
||||
c.id as customer_id
|
||||
FROM resource_pools rp
|
||||
LEFT JOIN licenses l ON rp.allocated_to_license = l.id
|
||||
LEFT JOIN customers c ON l.customer_id = c.id
|
||||
|
||||
In neuem Issue referenzieren
Einen Benutzer sperren