blob: ac4ba944957d7143ae72eea97b976fbce7d07404 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
|
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Admin Dashboard</title>
<link rel="stylesheet" href="{{.Paths.Assets}}/css/style.css">
<link rel="stylesheet" href="{{.Paths.Assets}}/css/admin.css">
</head>
<body class="admin-page">
<div class="container admin-container">
<h1>User Management</h1>
<a href="{{.Paths.Account}}">My Account</a> | <a href="{{.Paths.Logout}}">Logout</a>
<div class="table-container">
<table>
<thead>
<tr>
<th>ID</th>
<th>Username</th>
<th>Role</th>
<th>Is Active</th>
<th>Failed Logins</th>
<th>Last Login</th>
<th>Actions</th>
</tr>
</thead>
<tbody id="user-list">
{{range .Users}}
<tr>
<td>{{.ID}}</td>
<td>{{.Username}}</td>
<td>
<select id="role-{{.ID}}">
<option value="user" {{if eq .Role "user"}}selected{{end}}>user</option>
<option value="admin" {{if eq .Role "admin"}}selected{{end}}>admin</option>
</select>
</td>
<td>{{if .IsActive}}Yes{{else}}No{{end}}</td>
<td>{{.FailedLogins}}</td>
<td>{{if .LastLoginAt.Valid}}{{.LastLoginAt.Time.Format "2006-01-02 15:04"}}{{else}}Never{{end}}</td>
<td>
<button onclick="updateRole({{.ID}})">Save Role</button>
<button onclick="toggleActive({{.ID}}, {{not .IsActive}})">{{if .IsActive}}Deactivate{{else}}Activate{{end}}</button>
<button class="delete" onclick="deleteUser({{.ID}})">Delete</button>
</td>
</tr>
{{end}}
</tbody>
</table>
</div>
</div>
<script>
const API_BASE_PATH = "{{.Paths.AdminUsersAPI}}";
const LOGIN_PATH = "{{.Paths.Login}}";
</script>
<script src="{{.Paths.Assets}}/js/auth.js"></script>
<script src="{{.Paths.Assets}}/js/admin.js"></script>
</body>
</html>
|