catbase/plugins/secrets/secrets.templ

40 lines
1.1 KiB
Plaintext
Raw Permalink Normal View History

2024-02-27 19:29:54 +00:00
package secrets
import "fmt"
templ (s *SecretsPlugin) index() {
<h2>Secrets</h2>
<form hx-post="/secrets/add" hx-target="#data">
<fieldset>
<label>Key
<input class="input-group-field" placeholder="Key..." name="key" />
</label>
<label>Value
<input class="input-group-field" placeholder="Value..." name="value" />
</label>
</fieldset>
<button class="button primary" type="submit">Add Secret</button>
</form>
<div id="data" style="margin-top: 2em">
@s.keysList()
2024-02-27 19:29:54 +00:00
</div>
}
templ (s *SecretsPlugin) keysList() {
<h2>Keys List</h2>
<ul class="no-bullet">
2024-02-27 19:29:54 +00:00
for _, key := range s.keys() {
<li>
<button
class="button tiny alert middle"
style="vertical-align: baseline"
2024-02-27 19:29:54 +00:00
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>
}