object store users
This commit is contained in:
@@ -52,10 +52,10 @@ templ ObjectStoreUsers(data dash.ObjectStoreUsersData) {
|
||||
<div class="row no-gutters align-items-center">
|
||||
<div class="col mr-2">
|
||||
<div class="text-xs font-weight-bold text-success text-uppercase mb-1">
|
||||
Active Users
|
||||
Total Users
|
||||
</div>
|
||||
<div class="h5 mb-0 font-weight-bold text-gray-800">
|
||||
{fmt.Sprintf("%d", countActiveUsers(data.Users))}
|
||||
{fmt.Sprintf("%d", len(data.Users))}
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-auto">
|
||||
@@ -115,9 +115,6 @@ templ ObjectStoreUsers(data dash.ObjectStoreUsersData) {
|
||||
<th>Username</th>
|
||||
<th>Email</th>
|
||||
<th>Access Key</th>
|
||||
<th>Status</th>
|
||||
<th>Created</th>
|
||||
<th>Last Login</th>
|
||||
<th>Actions</th>
|
||||
</tr>
|
||||
</thead>
|
||||
@@ -134,23 +131,30 @@ templ ObjectStoreUsers(data dash.ObjectStoreUsersData) {
|
||||
<td>
|
||||
<code class="text-muted">{user.AccessKey}</code>
|
||||
</td>
|
||||
<td>
|
||||
<span class={fmt.Sprintf("badge bg-%s", getUserStatusColor(user.Status))}>
|
||||
{user.Status}
|
||||
</span>
|
||||
</td>
|
||||
<td>{user.CreatedAt.Format("2006-01-02")}</td>
|
||||
<td>{user.LastLogin.Format("2006-01-02")}</td>
|
||||
<td>
|
||||
<div class="btn-group btn-group-sm" role="group">
|
||||
<button type="button"
|
||||
class="btn btn-outline-info btn-sm"
|
||||
title="View Details"
|
||||
onclick={ templ.ComponentScript{Call: fmt.Sprintf("showUserDetails('%s')", user.Username)} }>
|
||||
<i class="fas fa-eye"></i>
|
||||
</button>
|
||||
<button type="button"
|
||||
class="btn btn-outline-primary btn-sm"
|
||||
title="Edit User">
|
||||
title="Edit User"
|
||||
onclick={ templ.ComponentScript{Call: fmt.Sprintf("editUser('%s')", user.Username)} }>
|
||||
<i class="fas fa-edit"></i>
|
||||
</button>
|
||||
<button type="button"
|
||||
class="btn btn-outline-warning btn-sm"
|
||||
title="Manage Keys"
|
||||
onclick={ templ.ComponentScript{Call: fmt.Sprintf("manageAccessKeys('%s')", user.Username)} }>
|
||||
<i class="fas fa-key"></i>
|
||||
</button>
|
||||
<button type="button"
|
||||
class="btn btn-outline-danger btn-sm"
|
||||
title="Delete User">
|
||||
title="Delete User"
|
||||
onclick={ templ.ComponentScript{Call: fmt.Sprintf("deleteUser('%s')", user.Username)} }>
|
||||
<i class="fas fa-trash"></i>
|
||||
</button>
|
||||
</div>
|
||||
@@ -159,7 +163,7 @@ templ ObjectStoreUsers(data dash.ObjectStoreUsersData) {
|
||||
}
|
||||
if len(data.Users) == 0 {
|
||||
<tr>
|
||||
<td colspan="7" class="text-center text-muted py-4">
|
||||
<td colspan="4" class="text-center text-muted py-4">
|
||||
<i class="fas fa-users fa-3x mb-3 text-muted"></i>
|
||||
<div>
|
||||
<h5>No users found</h5>
|
||||
@@ -186,29 +190,144 @@ templ ObjectStoreUsers(data dash.ObjectStoreUsersData) {
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Create User Modal -->
|
||||
<div class="modal fade" id="createUserModal" tabindex="-1" role="dialog">
|
||||
<div class="modal-dialog" role="document">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h5 class="modal-title">
|
||||
<i class="fas fa-user-plus me-2"></i>Create New User
|
||||
</h5>
|
||||
<button type="button" class="btn-close" data-bs-dismiss="modal"></button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<form id="createUserForm">
|
||||
<div class="mb-3">
|
||||
<label for="username" class="form-label">Username *</label>
|
||||
<input type="text" class="form-control" id="username" name="username" required>
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label for="email" class="form-label">Email</label>
|
||||
<input type="email" class="form-control" id="email" name="email">
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label for="actions" class="form-label">Permissions</label>
|
||||
<select multiple class="form-control" id="actions" name="actions">
|
||||
<option value="Admin">Admin (Full Access)</option>
|
||||
<option value="Read">Read</option>
|
||||
<option value="Write">Write</option>
|
||||
<option value="List">List</option>
|
||||
<option value="Tagging">Tagging</option>
|
||||
</select>
|
||||
<small class="form-text text-muted">Hold Ctrl/Cmd to select multiple permissions</small>
|
||||
</div>
|
||||
<div class="mb-3 form-check">
|
||||
<input type="checkbox" class="form-check-input" id="generateKey" name="generateKey" checked>
|
||||
<label class="form-check-label" for="generateKey">
|
||||
Generate access key automatically
|
||||
</label>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Cancel</button>
|
||||
<button type="button" class="btn btn-primary" onclick="handleCreateUser()">Create User</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Edit User Modal -->
|
||||
<div class="modal fade" id="editUserModal" tabindex="-1" role="dialog">
|
||||
<div class="modal-dialog" role="document">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h5 class="modal-title">
|
||||
<i class="fas fa-user-edit me-2"></i>Edit User
|
||||
</h5>
|
||||
<button type="button" class="btn-close" data-bs-dismiss="modal"></button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<form id="editUserForm">
|
||||
<input type="hidden" id="editUsername" name="username">
|
||||
<div class="mb-3">
|
||||
<label for="editEmail" class="form-label">Email</label>
|
||||
<input type="email" class="form-control" id="editEmail" name="email">
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label for="editActions" class="form-label">Permissions</label>
|
||||
<select multiple class="form-control" id="editActions" name="actions">
|
||||
<option value="Admin">Admin (Full Access)</option>
|
||||
<option value="Read">Read</option>
|
||||
<option value="Write">Write</option>
|
||||
<option value="List">List</option>
|
||||
<option value="Tagging">Tagging</option>
|
||||
</select>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Cancel</button>
|
||||
<button type="button" class="btn btn-primary" onclick="handleUpdateUser()">Update User</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- User Details Modal -->
|
||||
<div class="modal fade" id="userDetailsModal" tabindex="-1" role="dialog">
|
||||
<div class="modal-dialog modal-lg" role="document">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h5 class="modal-title">
|
||||
<i class="fas fa-user me-2"></i>User Details
|
||||
</h5>
|
||||
<button type="button" class="btn-close" data-bs-dismiss="modal"></button>
|
||||
</div>
|
||||
<div class="modal-body" id="userDetailsContent">
|
||||
<!-- Content will be loaded dynamically -->
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Close</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Access Keys Management Modal -->
|
||||
<div class="modal fade" id="accessKeysModal" tabindex="-1" role="dialog">
|
||||
<div class="modal-dialog modal-lg" role="document">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h5 class="modal-title">
|
||||
<i class="fas fa-key me-2"></i>Manage Access Keys
|
||||
</h5>
|
||||
<button type="button" class="btn-close" data-bs-dismiss="modal"></button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<div class="d-flex justify-content-between align-items-center mb-3">
|
||||
<h6>Access Keys for <span id="accessKeysUsername"></span></h6>
|
||||
<button type="button" class="btn btn-primary btn-sm" onclick="createAccessKey()">
|
||||
<i class="fas fa-plus me-1"></i>Create New Key
|
||||
</button>
|
||||
</div>
|
||||
<div id="accessKeysContent">
|
||||
<!-- Content will be loaded dynamically -->
|
||||
</div>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Close</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- JavaScript for user management -->
|
||||
<script>
|
||||
// User management functions will be included in admin.js
|
||||
</script>
|
||||
}
|
||||
|
||||
// Helper functions for template
|
||||
func getUserStatusColor(status string) string {
|
||||
switch status {
|
||||
case "active":
|
||||
return "success"
|
||||
case "inactive":
|
||||
return "warning"
|
||||
case "suspended":
|
||||
return "danger"
|
||||
default:
|
||||
return "secondary"
|
||||
}
|
||||
}
|
||||
|
||||
func countActiveUsers(users []dash.ObjectStoreUser) int {
|
||||
count := 0
|
||||
for _, user := range users {
|
||||
if user.Status == "active" {
|
||||
count++
|
||||
}
|
||||
}
|
||||
return count
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user