79 lines
3.6 KiB
HTML
79 lines
3.6 KiB
HTML
{{template "base" .}}
|
|
|
|
{{define "content"}}
|
|
<h1 class="mb-4"><i class="bi bi-people me-2" aria-hidden="true"></i>ユーザー管理</h1>
|
|
|
|
{{if .error}}<div class="alert alert-danger" role="alert">{{.error}}</div>{{end}}
|
|
|
|
{{if .users}}
|
|
<div class="table-responsive">
|
|
<table class="table table-hover custom-table" aria-label="ユーザー一覧">
|
|
<thead class="table-light">
|
|
<tr>
|
|
<th scope="col">ID</th>
|
|
<th scope="col">名前</th>
|
|
<th scope="col">メールアドレス</th>
|
|
<th scope="col">ロール</th>
|
|
<th scope="col">登録日</th>
|
|
<th scope="col" style="width: 200px">操作</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
{{range .users}}
|
|
<tr class="user-row {{if eq .ID $.currentUserID}}table-primary{{end}}">
|
|
<td>{{.ID}}</td>
|
|
<td>{{.Name}}{{if eq .ID $.currentUserID}}<span class="badge bg-info ms-2">自分</span>{{end}}</td>
|
|
<td>{{.Email}}</td>
|
|
<td>
|
|
{{if eq .Role "admin"}}
|
|
<span class="badge bg-danger">管理者</span>
|
|
{{else}}
|
|
<span class="badge bg-secondary">ユーザー</span>
|
|
{{end}}
|
|
</td>
|
|
<td>{{formatDate .CreatedAt}}</td>
|
|
<td>
|
|
{{if ne .ID $.currentUserID}}
|
|
{{if eq .Role "admin"}}
|
|
<form action="/admin/users/{{.ID}}/role" method="POST" class="d-inline"
|
|
data-confirm="このユーザーを一般ユーザーに降格しますか?">
|
|
<input type="hidden" name="_csrf" value="{{$.csrfToken}}">
|
|
<input type="hidden" name="role" value="user">
|
|
<button type="submit" class="btn btn-sm btn-outline-secondary" aria-label="{{.Name}}をユーザーに降格">
|
|
<i class="bi bi-arrow-down" aria-hidden="true"></i>
|
|
</button>
|
|
</form>
|
|
{{else}}
|
|
<form action="/admin/users/{{.ID}}/role" method="POST" class="d-inline"
|
|
data-confirm="このユーザーを管理者に昇格しますか?">
|
|
<input type="hidden" name="_csrf" value="{{$.csrfToken}}">
|
|
<input type="hidden" name="role" value="admin">
|
|
<button type="submit" class="btn btn-sm btn-outline-warning" aria-label="{{.Name}}を管理者に昇格">
|
|
<i class="bi bi-arrow-up" aria-hidden="true"></i>
|
|
</button>
|
|
</form>
|
|
{{end}}
|
|
<form action="/admin/users/{{.ID}}/delete" method="POST" class="d-inline"
|
|
data-confirm="このユーザーを削除しますか?">
|
|
<input type="hidden" name="_csrf" value="{{$.csrfToken}}">
|
|
<button type="submit" class="btn btn-sm btn-outline-danger" aria-label="{{.Name}}を削除">
|
|
<i class="bi bi-trash" aria-hidden="true"></i>
|
|
</button>
|
|
</form>
|
|
{{else}}
|
|
<span class="text-muted">-</span>
|
|
{{end}}
|
|
</td>
|
|
</tr>
|
|
{{end}}
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
{{else}}
|
|
<div class="text-center py-5">
|
|
<i class="bi bi-people display-1 text-muted" aria-hidden="true"></i>
|
|
<h3 class="mt-3">ユーザーがいません</h3>
|
|
</div>
|
|
{{end}}
|
|
{{end}}
|