catbase/plugins/secrets/secrets.templ

42 lines
1.3 KiB
Plaintext
Raw Normal View History

2024-02-27 19:29:54 +00:00
package secrets
import "fmt"
templ (s *SecretsPlugin) index() {
<div class="container">
<form hx-post="/secrets/add" hx-target="#data">
<div class="row">
<div class="col-3">
<input placeholder="Key..." name="key" />
</div>
<div class="col-3">
<input placeholder="Value..." name="value" />
</div>
<div class="col-3">
<button class="btn btn-primary" type="submit">Add Secret</button>
</div>
</div>
</form>
<div class="row" style="padding-top: 2em;">
<div id="data">
@s.keysList()
</div>
</div>
</div>
}
templ (s *SecretsPlugin) keysList() {
<ul>
for _, key := range s.keys() {
<li>
<button
class="btn btn-danger"
hx-delete="/secrets/remove"
hx-confirm={ fmt.Sprintf("Are you sure you want to delete %s?", key) }
hx-target="#data"
hx-include="this"
name="key" value={ key }>X</button>
{ key }</li>
}
</ul>
}