navid/veinsforge / ef416676a5229183a60f68e8c363c22320dbe1dc6685ac81eae37db4df83c6bf / internal/web/templates/admin.html

admin.html

← internal/web/templates · 5652 bytes · raw · download

{{define "content"}}
<h1>Administration</h1>
<p class="small"><a href="/admin">overview</a> · <a href="/admin/users">users</a> · <a href="/admin/repos">repositories</a> · <a href="/admin/audit">audit log</a></p>

{{if .Data.Stats}}
<p class="muted">{{.Data.Stats.Users}} users · {{.Data.Stats.Repos}} repositories · {{.Data.Stats.PublicRepos}} public · {{.Data.Stats.Issues}} open issues · {{.Data.Stats.Stars}} stars</p>

<h2>Native server</h2>
<dl class="facts">
  <dt>state</dt><dd>{{if .Data.NativeState}}{{.Data.NativeState}}{{else}}disabled{{end}}</dd>
  <dt>address</dt><dd><code>{{.Data.NativeAddress}}</code></dd>
  <dt>TLS pin</dt><dd><code class="break">{{.Data.NativePin}}</code></dd>
  {{if .Data.NativeError}}<dt>last error</dt><dd>{{.Data.NativeError}}</dd>{{end}}
</dl>

<h2>Site settings</h2>
<form method="post" action="/admin/settings" class="form-narrow">
  <input type="hidden" name="csrf" value="{{.CSRF}}">
  <label>Site name <input name="site_name" value="{{.SiteName}}" maxlength="60"></label>
  <label>Description <input name="site_description" value="{{.SiteDesc}}" maxlength="240"></label>
  <label class="checkbox"><input type="checkbox" name="registration_open" {{if .Data.RegistrationOpen}}checked{{end}}> open registration</label>
  <button class="btn" type="submit">Save</button>
</form>

<h2>Audit log</h2>
<table class="table">
  <thead><tr><th>Time</th><th>User</th><th>IP</th><th>Action</th><th>Detail</th></tr></thead>
  <tbody>
  {{range .Data.Audit}}
    <tr>
      <td class="nowrap">{{date .CreatedAt}}</td>
      <td>{{if .Username}}{{.Username}}{{else}}—{{end}}</td>
      <td><code>{{.IP}}</code></td>
      <td><code>{{.Action}}</code></td>
      <td class="break">{{.Detail}}</td>
    </tr>
  {{end}}
  </tbody>
</table>
{{end}}

{{if .Data.Users}}
<h2>Users</h2>
<p class="muted">{{.Data.Count}} total</p>
<table class="table">
  <thead><tr><th>User</th><th>Email</th><th>Flags</th><th>Last IP</th><th>Created</th><th>Actions</th></tr></thead>
  <tbody>
  {{range .Data.Users}}
    <tr>
      <td><a href="/u/{{.Username}}">{{.Username}}</a><br><span class="muted small">{{.DisplayName}}</span></td>
      <td>{{if .Email}}{{.Email}}{{else}}—{{end}}</td>
      <td>{{if .IsAdmin}}admin {{end}}{{if .IsActive}}active{{else}}disabled{{end}}</td>
      <td><code>{{.LastIP}}</code></td>
      <td>{{date .CreatedAt}}</td>
      <td class="actions-cell">
        <form method="post" action="/admin/users/{{.ID}}/active" class="inline"><input type="hidden" name="csrf" value="{{$.CSRF}}"><button class="link" type="submit">{{if .IsActive}}disable{{else}}enable{{end}}</button></form>
        <form method="post" action="/admin/users/{{.ID}}/admin" class="inline"><input type="hidden" name="csrf" value="{{$.CSRF}}"><button class="link" type="submit">{{if .IsAdmin}}demote{{else}}promote{{end}}</button></form>
        <form method="post" action="/admin/users/{{.ID}}/password" class="inline"><input type="hidden" name="csrf" value="{{$.CSRF}}"><input type="password" name="password" placeholder="new password" required minlength="10"><button class="link" type="submit">reset</button></form>
      </td>
    </tr>
  {{end}}
  </tbody>
</table>
<p class="pager">
  {{if gt .Data.Page 1}}<a href="/admin/users?page={{sub .Data.Page 1}}">← previous</a>{{end}}
  <span class="muted">page {{.Data.Page}}</span>
  {{if .Data.HasNext}}<a href="/admin/users?page={{add .Data.Page 1}}">next →</a>{{end}}
</p>
<h2>Create user</h2>
<form method="post" action="/admin/users" class="inline-form">
  <input type="hidden" name="csrf" value="{{.CSRF}}">
  <input name="username" placeholder="username" required maxlength="32">
  <input name="display_name" placeholder="display name" maxlength="80">
  <input type="email" name="email" placeholder="email" maxlength="254">
  <input type="password" name="password" placeholder="password" required minlength="10">
  <label class="checkbox"><input type="checkbox" name="is_admin"> admin</label>
  <button class="btn" type="submit">Create</button>
</form>
{{end}}

{{if .Data.Repos}}
<h2>Repositories</h2>
<p class="muted">{{.Data.Count}} total</p>
<table class="table">
  <thead><tr><th>Repository</th><th>Visibility</th><th>Default</th><th>Updated</th></tr></thead>
  <tbody>
  {{range .Data.Repos}}
    <tr>
      <td><a href="{{repoURL .}}">{{.OwnerName}}/{{.Name}}</a><br><span class="muted small">{{.Description}}</span></td>
      <td>{{.Visibility}}</td>
      <td><code>{{.DefaultBranch}}</code></td>
      <td>{{timeago .UpdatedAt}}</td>
    </tr>
  {{end}}
  </tbody>
</table>
<p class="pager">
  {{if gt .Data.Page 1}}<a href="/admin/repos?page={{sub .Data.Page 1}}">← previous</a>{{end}}
  <span class="muted">page {{.Data.Page}}</span>
  {{if .Data.HasNext}}<a href="/admin/repos?page={{add .Data.Page 1}}">next →</a>{{end}}
</p>
{{end}}

{{if and .Data.Audit (not .Data.Stats)}}
<h2>Audit log</h2>
<p class="muted">{{.Data.Count}} entries</p>
<table class="table">
  <thead><tr><th>Time</th><th>User</th><th>IP</th><th>Action</th><th>Detail</th></tr></thead>
  <tbody>
  {{range .Data.Audit}}
    <tr>
      <td class="nowrap">{{date .CreatedAt}}</td>
      <td>{{if .Username}}{{.Username}}{{else}}—{{end}}</td>
      <td><code>{{.IP}}</code></td>
      <td><code>{{.Action}}</code></td>
      <td class="break">{{.Detail}}</td>
    </tr>
  {{end}}
  </tbody>
</table>
<p class="pager">
  {{if gt .Data.Page 1}}<a href="/admin/audit?page={{sub .Data.Page 1}}">← previous</a>{{end}}
  <span class="muted">page {{.Data.Page}}</span>
  {{if .Data.HasNext}}<a href="/admin/audit?page={{add .Data.Page 1}}">next →</a>{{end}}
</p>
{{end}}
{{end}}