catbase/plugins/admin/apppass.templ

77 lines
2.5 KiB
Plaintext
Raw Normal View History

2024-02-27 17:02:16 +00:00
package admin
import "fmt"
templ (a *AdminPlugin) page() {
<!DOCTYPE html />
<html lang="en">
<head>
<!-- Load required Bootstrap and BootstrapVue CSS -->
<link type="text/css" rel="stylesheet" href="//unpkg.com/bootstrap/dist/css/bootstrap.min.css"/>
<meta charset="UTF-8" />
<title>Vars</title>
</head>
<body>
<div hx-get="/navHTML/Variables" hx-trigger="load" hx-swap="outerHTML"></div>
<div class="container">
<form>
<div class="row">
<div class="col">
<label for="password">Password:
<input type="text" name="password"></input>
</label>
</div>
<div class="col">
<label for="secret">Secret:
<input type="text" name="secret"></input>
</label>
</div>
<div class="col">
<button hx-post="/apppass/api" hx-target="#data" class="btn btn-primary">List</button>
<button hx-put="/apppass/api" hx-target="#data" class="btn btn-secondary">New</button>
</div>
</div>
</form>
<div class="row">
<div id="data"></div>
</div>
</div>
<script src="//unpkg.com/htmx.org@1.9.10" integrity="sha384-D1Kt99CQMDuVetoL1lrYwg5t+9QdHe7NLX/SoJYkXDFfX37iInKRy5xLSi8nO7UC" crossorigin="anonymous"></script>
</body>
</html>
}
templ (a *AdminPlugin) showPassword(entry PassEntry) {
<div><span>ID</span><span>{ fmt.Sprintf("%d", entry.ID) }</span></div>
<div><span>Password</span><span>{ entry.Secret }:{ entry.Pass }</span></div>
}
templ (a *AdminPlugin) entries(items []PassEntry) {
<div>
if len(items) == 0 {
<span>No items</span>
}
<ul>
for _, entry := range items {
<li>
<button href="#"
class="btn btn-danger"
hx-delete="/apppass/api"
hx-confirm={ fmt.Sprintf("Are you sure you want to delete %d?", entry.ID) }
hx-target="#data"
hx-include="this,[name='password'],[name='secret']"
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>
}