2024-02-27 17:02:16 +00:00
|
|
|
package admin
|
|
|
|
|
|
|
|
import "fmt"
|
|
|
|
|
|
|
|
templ (a *AdminPlugin) page() {
|
2024-02-28 14:39:38 +00:00
|
|
|
<div class="grid-container">
|
2024-02-27 17:02:16 +00:00
|
|
|
<form>
|
2024-02-28 14:39:38 +00:00
|
|
|
<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>
|
2024-02-28 14:39:38 +00:00
|
|
|
<div class="cell auto">
|
2024-02-27 17:02:16 +00:00
|
|
|
<label for="secret">Secret:
|
|
|
|
<input type="text" name="secret"></input>
|
|
|
|
</label>
|
|
|
|
</div>
|
2024-02-28 14:39:38 +00:00
|
|
|
<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>
|
|
|
|
</form>
|
|
|
|
|
2024-02-28 14:39:38 +00:00
|
|
|
<div class="grid-x">
|
|
|
|
<div class="cell" id="data"></div>
|
2024-02-27 17:02:16 +00:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
}
|
|
|
|
|
|
|
|
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="#"
|
2024-02-28 14:39:38 +00:00
|
|
|
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"
|
|
|
|
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>
|
2024-02-27 19:29:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
templ vars(items []configEntry) {
|
|
|
|
<div class="container">
|
2024-02-28 14:39:38 +00:00
|
|
|
<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>
|
|
|
|
}
|