Globe-Zugang: Checkbox im User-Management
Neue Spalte "Globe" in der Nutzertabelle mit Toggle-Checkbox.
API-Endpoint PUT /api/users/{id}/globe-access.
Steuert das globe_access Feld in der geteilten DB.
Dieser Commit ist enthalten in:
@@ -131,6 +131,24 @@ async def activate_user(
|
|||||||
return {"ok": True}
|
return {"ok": True}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@router.put("/{user_id}/globe-access")
|
||||||
|
async def toggle_globe_access(
|
||||||
|
user_id: int,
|
||||||
|
admin: dict = Depends(get_current_admin),
|
||||||
|
db: aiosqlite.Connection = Depends(db_dependency),
|
||||||
|
):
|
||||||
|
cursor = await db.execute("SELECT id, globe_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 globe_access = ? WHERE id = ?", (new_val, user_id))
|
||||||
|
await db.commit()
|
||||||
|
return {"ok": True, "globe_access": bool(new_val)}
|
||||||
|
|
||||||
@router.put("/{user_id}/role")
|
@router.put("/{user_id}/role")
|
||||||
async def change_role(
|
async def change_role(
|
||||||
user_id: int,
|
user_id: int,
|
||||||
|
|||||||
@@ -105,6 +105,7 @@
|
|||||||
<th>E-Mail</th>
|
<th>E-Mail</th>
|
||||||
<th>Rolle</th>
|
<th>Rolle</th>
|
||||||
<th>Status</th>
|
<th>Status</th>
|
||||||
|
<th>Globe</th>
|
||||||
<th>Aktionen</th>
|
<th>Aktionen</th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
|
|||||||
@@ -234,7 +234,7 @@ async function loadOrgUsers(orgId) {
|
|||||||
|
|
||||||
const tbody = document.getElementById("userTable");
|
const tbody = document.getElementById("userTable");
|
||||||
if (users.length === 0) {
|
if (users.length === 0) {
|
||||||
tbody.innerHTML = '<tr><td colspan="4" class="text-muted">Keine Nutzer</td></tr>';
|
tbody.innerHTML = '<tr><td colspan="5" class="text-muted">Keine Nutzer</td></tr>';
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
tbody.innerHTML = users.map(u => `
|
tbody.innerHTML = users.map(u => `
|
||||||
@@ -247,6 +247,7 @@ async function loadOrgUsers(orgId) {
|
|||||||
</select>
|
</select>
|
||||||
</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"><input type="checkbox" ${u.globe_access ? "checked" : ""} onchange="toggleGlobeAccess(${u.id})" title="Globe-Zugang"></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>`
|
||||||
@@ -279,6 +280,15 @@ async function toggleUser(userId, activate) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function toggleGlobeAccess(userId) {
|
||||||
|
try {
|
||||||
|
await API.put("/api/users/" + userId + "/globe-access");
|
||||||
|
} 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