catbase/plugins/admin/admin.templ

91 lines
2.9 KiB
Plaintext
Raw Permalink Normal View History

2024-02-27 17:02:16 +00:00
package admin
import "fmt"
templ (a *AdminPlugin) page() {
<div class="grid-container">
2024-02-27 17:02:16 +00:00
<form>
<div class="grid-x grid-margin-x align-bottom">
<h2>App Pass</h2>
</div>
<div class="grid-x grid-margin-x align-bottom">
<div class="cell auto">
2024-02-27 17:02:16 +00:00
<label for="password">Password:
<input type="text" name="password"></input>
</label>
</div>
<div class="cell auto">
2024-02-27 17:02:16 +00:00
<label for="secret">Secret:
<input type="text" name="secret"></input>
</label>
</div>
<div class="cell auto">
<button hx-post="/apppass/api" hx-target="#data" class="button">List</button>
<button hx-put="/apppass/api" hx-target="#data" class="submit success button">New</button>
2024-02-27 17:02:16 +00:00
</div>
</div>
<div class="grid-x">
<div class="cell" id="data"></div>
2024-02-27 17:02:16 +00:00
</div>
2024-03-13 16:15:38 +00:00
</form>
2024-02-27 17:02:16 +00:00
</div>
}
templ (a *AdminPlugin) showPassword(entry PassEntry) {
2024-03-13 16:15:38 +00:00
<div><span style="margin-right: 2em">ID</span><span>{ fmt.Sprintf(" %d", entry.ID) }</span></div>
<div><span style="margin-right: 2em">Password</span><span> { entry.Secret }:{ entry.Pass }</span></div>
2024-02-27 17:02:16 +00:00
}
templ (a *AdminPlugin) entries(items []PassEntry) {
<div>
if len(items) == 0 {
<span>No items</span>
}
<ul>
for _, entry := range items {
<li>
<button href="#"
class="button alert tiny"
style="vertical-align: baseline"
2024-02-27 17:02:16 +00:00
hx-delete="/apppass/api"
hx-confirm={ fmt.Sprintf("Are you sure you want to delete %d?", entry.ID) }
hx-target="#data"
name="id" value={ fmt.Sprintf("%d", entry.ID) }>X</button>
{ fmt.Sprintf("%d", entry.ID) }
</li>
}
</ul>
</div>
}
templ renderError(err error) {
<div>{ err.Error() }</div>
2024-02-27 19:29:54 +00:00
}
templ vars(items []configEntry) {
<div class="container">
<h2>Variables</h2>
<table class="hover striped">
2024-02-27 19:29:54 +00:00
<thead>
<tr>
<th>Key</th>
<th>Value</th>
</tr>
</thead>
<tbody>
for _, item := range items {
<tr>
<td>{ item.Key }</td><td>{ item.Value }</td>
</tr>
}
if len(items) == 0 {
<tr>
<td colspan="2">No data</td>
</tr>
}
</tbody>
</table>
</div>
}