Netzwerkanalyse-Zugang: network_access Toggle im User-Management
- network_access Spalte in UserResponse Model
- PUT /api/users/{id}/network-access Toggle-Endpoint
- Dashboard: Netzwerk-Spalte mit An/Aus-Button in User-Tabelle
Dieser Commit ist enthalten in:
@@ -34,6 +34,7 @@ class OrgResponse(BaseModel):
|
|||||||
license_type: str = ""
|
license_type: str = ""
|
||||||
created_at: str
|
created_at: str
|
||||||
globe_access: bool = False
|
globe_access: bool = False
|
||||||
|
network_access: bool = False
|
||||||
|
|
||||||
|
|
||||||
class LicenseCreate(BaseModel):
|
class LicenseCreate(BaseModel):
|
||||||
@@ -63,6 +64,7 @@ class LicenseResponse(BaseModel):
|
|||||||
budget_warning_percent: Optional[int] = None
|
budget_warning_percent: Optional[int] = None
|
||||||
created_at: str
|
created_at: str
|
||||||
globe_access: bool = False
|
globe_access: bool = False
|
||||||
|
network_access: bool = False
|
||||||
|
|
||||||
|
|
||||||
class UserCreate(BaseModel):
|
class UserCreate(BaseModel):
|
||||||
@@ -81,3 +83,4 @@ class UserResponse(BaseModel):
|
|||||||
last_login_at: Optional[str]
|
last_login_at: Optional[str]
|
||||||
created_at: str
|
created_at: str
|
||||||
globe_access: bool = False
|
globe_access: bool = False
|
||||||
|
network_access: bool = False
|
||||||
|
|||||||
@@ -180,3 +180,20 @@ async def delete_user(
|
|||||||
|
|
||||||
await db.execute("DELETE FROM users WHERE id = ?", (user_id,))
|
await db.execute("DELETE FROM users WHERE id = ?", (user_id,))
|
||||||
await db.commit()
|
await db.commit()
|
||||||
|
|
||||||
|
|
||||||
|
@router.put("/{user_id}/network-access")
|
||||||
|
async def toggle_network_access(
|
||||||
|
user_id: int,
|
||||||
|
admin: dict = Depends(get_current_admin),
|
||||||
|
db: aiosqlite.Connection = Depends(db_dependency),
|
||||||
|
):
|
||||||
|
cursor = await db.execute("SELECT id, network_access FROM users WHERE id = ?", (user_id,))
|
||||||
|
row = await cursor.fetchone()
|
||||||
|
if not row:
|
||||||
|
raise HTTPException(status_code=404, detail="Nutzer nicht gefunden")
|
||||||
|
|
||||||
|
new_val = 0 if row[1] else 1
|
||||||
|
await db.execute("UPDATE users SET network_access = ? WHERE id = ?", (new_val, user_id))
|
||||||
|
await db.commit()
|
||||||
|
return {"ok": True, "network_access": bool(new_val)}
|
||||||
|
|||||||
@@ -108,6 +108,7 @@
|
|||||||
<th>Rolle</th>
|
<th>Rolle</th>
|
||||||
<th>Status</th>
|
<th>Status</th>
|
||||||
<th>Globe</th>
|
<th>Globe</th>
|
||||||
|
<th>Netzwerk</th>
|
||||||
<th>Aktionen</th>
|
<th>Aktionen</th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
|
|||||||
@@ -248,6 +248,7 @@ async function loadOrgUsers(orgId) {
|
|||||||
</td>
|
</td>
|
||||||
<td><span class="badge badge-${u.is_active ? 'active' : 'inactive'}">${u.is_active ? "Aktiv" : "Inaktiv"}</span></td>
|
<td><span class="badge badge-${u.is_active ? 'active' : 'inactive'}">${u.is_active ? "Aktiv" : "Inaktiv"}</span></td>
|
||||||
<td style="text-align:center">${u.globe_access ? '<button class="btn btn-small" style="background:#00cc66;color:#fff;border:none;min-width:50px" onclick="toggleGlobeAccess(' + u.id + ')">An</button>' : '<button class="btn btn-secondary btn-small" style="min-width:50px" onclick="toggleGlobeAccess(' + u.id + ')">Aus</button>'}</td>
|
<td style="text-align:center">${u.globe_access ? '<button class="btn btn-small" style="background:#00cc66;color:#fff;border:none;min-width:50px" onclick="toggleGlobeAccess(' + u.id + ')">An</button>' : '<button class="btn btn-secondary btn-small" style="min-width:50px" onclick="toggleGlobeAccess(' + u.id + ')">Aus</button>'}</td>
|
||||||
|
<td style="text-align:center">${u.network_access ? '<button class="btn btn-small" style="background:#f0b429;color:#0f172a;border:none;min-width:50px" onclick="toggleNetworkAccess(' + u.id + ')">An</button>' : '<button class="btn btn-secondary btn-small" style="min-width:50px" onclick="toggleNetworkAccess(' + u.id + ')">Aus</button>'}</td>
|
||||||
<td>
|
<td>
|
||||||
${u.is_active
|
${u.is_active
|
||||||
? `<button class="btn btn-secondary btn-small" onclick="toggleUser(${u.id}, false)">Deaktivieren</button>`
|
? `<button class="btn btn-secondary btn-small" onclick="toggleUser(${u.id}, false)">Deaktivieren</button>`
|
||||||
@@ -290,6 +291,16 @@ async function toggleGlobeAccess(userId) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function toggleNetworkAccess(userId) {
|
||||||
|
try {
|
||||||
|
await API.put("/api/users/" + userId + "/network-access");
|
||||||
|
if (currentOrgId) loadOrgUsers(currentOrgId);
|
||||||
|
} catch (err) {
|
||||||
|
alert(err.message);
|
||||||
|
if (currentOrgId) loadOrgUsers(currentOrgId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function confirmDeleteUser(userId, email) {
|
function confirmDeleteUser(userId, email) {
|
||||||
showConfirm(
|
showConfirm(
|
||||||
"Nutzer löschen",
|
"Nutzer löschen",
|
||||||
|
|||||||
In neuem Issue referenzieren
Einen Benutzer sperren