{{define "body"}}
<div class="page-header">
    <div class="row">
        <h2>{{.BodyTitle}}</h2>
    </div>
</div>
{{if .Admin}}
<div class="row mb-3">
    <div class="col-xs-5">
        <a class="btn btn-sm btn-primary" href="/user/new"><b>New User</b></a>
    </div>
</div>
{{end}}
<div class="row">
    <div class="col">
    {{if .Data}}
    <table class="table table-hover">
    <thead>
        <tr>
            <th>Username</th>
            <th>Flags</th>
            <th>Options</th>
        </tr>
    </thead>
    <tbody>
        {{$user := .User}}
        {{$admin := .Admin}}
        {{range $item := .Data}}
        <tr>
            <td>{{$item.Username}}</td>
            <td>
            {{if $item.Secret}}<span class="badge badge-success">TOTP</span>{{end}}
            {{if eq $item.Locked 3}}<span class="badge badge-warning">Locked</span>{{end}}
            {{if $item.Admin}}<span class="badge badge-danger">Admin</span>{{end}}
            </td>
            <td>
                <div class="btn-group">
                    {{if $admin}}
                    <a class="btn btn-sm btn-primary" href="/user/edit/{{$item.Username}}">Edit</a>
                    <a class="btn btn-sm btn-danger" href="/user/del/{{$item.Username}}">Delete</a>
                    {{else}}
                    {{if eq $item.Username $user}}
                    <a class="btn btn-sm btn-primary" href="/user/edit/{{$item.Username}}">Edit</a>
                    {{end}}
                    {{end}}
                </div>
            </td>
        </tr>
        {{end}}
    </tbody>
    </table>
    {{end}}
    </div>
</div>
{{end}}
