catbase/plugins/secrets/secrets.templ

52 lines
1.8 KiB
Plaintext
Raw Permalink Normal View History

2024-02-27 19:29:54 +00:00
package secrets
import "fmt"
templ (s *SecretsPlugin) index() {
<div class="grid-container">
2024-02-27 19:29:54 +00:00
<form hx-post="/secrets/add" hx-target="#data">
<div class="grid-x">
<h2>Secrets</h2>
</div>
<div class="grid-x">
<div class="cell auto">
<div class="input-group">
<span class="input-group-label">Key</span>
<input class="input-group-field" placeholder="Key..." name="key" />
</div>
2024-02-27 19:29:54 +00:00
</div>
<div class="cell auto">
<div class="input-group">
<span class="input-group-label">Value</span>
<input class="input-group-field" placeholder="Value..." name="value" />
<div class="input-group-button">
<button class="button primary" type="submit">Add Secret</button>
</div>
</div>
2024-02-27 19:29:54 +00:00
</div>
</div>
</form>
<div class="grid-x grid-margin-x">
2024-02-27 19:29:54 +00:00
<div id="data">
@s.keysList()
</div>
</div>
</div>
}
templ (s *SecretsPlugin) keysList() {
<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>
}