aceberg/miniboard

View on GitHub
internal/web/templates/uptime-edit.html

Summary

Maintainability
Test Coverage
{{ define "uptime-edit" }}

<body>
    <div class="container">
        <br>
        <div class="row">
            <div class="col">
                {{ if .Links.Uptime.Enabled }}
                <a href="/uptime_edit/?edit=yes&enable=no">
                    <button type="submit" class="btn btn-outline-success">Uptime enabled. Disable</button>
                </a>
                {{ else }}
                <a href="/uptime_edit/?edit=yes&enable=yes">
                    <button type="submit" class="btn btn-outline-danger">Uptime disabled. Enable</button>
                </a>
                {{ end }}
                <br>
                <br>
                <table class="table">
                    <form action="/uptime_edit/" method="post">
                        <tr>
                            <td>Show lines on Uptime page (Default: 20)</td>
                            <td><input name="show" type="text" class="form-control" value="{{ .Links.Uptime.Show }}"></td>
                        </tr>
                        <input name="edit" type="hidden" value="yes">
                        <tr>
                            <td>Needs auth to view</td>
                            <td><select name="auth" class="form-select">
                                {{ if .Links.Uptime.Auth }}
                                    <option selected>yes</option>
                                {{ else }}
                                    <option selected>no</option>
                                {{ end }}
                                <option value="yes">yes</option>
                                <option value="no">no</option>
                            </select></td>
                        </tr>
                        <tr>
                            <td><button type="submit" class="btn btn-outline-success">Save</button></td>
                            <td></td>
                        </tr>
                    </form>
                </table>
                <br>
                <br>
                <h4>Notifications (<a href="https://containrrr.dev/shoutrrr/0.7/services/overview/" target="_blank">Shoutrrr docs</a>)</h4>
                <form action="/uptime_edit/" method="post" class="input-group">
                    <input name="edit" type="hidden" value="yes">
                    <input name="nname" type="text" placeholder="Name" class="form-control">
                    <input name="link" type="text" placeholder="Link" class="form-control" style="width: 60%;">
                    <button type="submit" class="btn btn-outline-success"><i class="bi bi-check2"></i></button>
                </form>
                <br>
                <table class="table table-striped">
                    <thead>
                        <th>Del</th>
                        <th>Name</th>
                        <th>Link</th>
                        <th>Test</th>
                    </thead>
                    {{ range $name, $value := .Links.Uptime.Notify }}
                    <tr>
                        <td>
                            <a href="/uptime_edit/?edit=yes&delnotify={{ $name }}">
                                <button type="submit" class="btn btn-outline-danger"><i class="bi bi-x-lg"></i></button>
                            </a>
                        </td>
                        <td>{{ $name }}</td>
                        <td>{{ $value }}</td>
                        <td>
                            <a href="/uptime_edit/?testnotify={{ $name }}">
                                <button type="submit" class="btn btn-outline-success">Test</button>
                            </a>
                        </td>
                    </tr>
                    {{ end }}
                </table>
            </div>
            <div class="col">
                <table class="table table-striped">
                    <thead>
                        <th style="width: 0em;">Del</th>
                        <th>Name</th>
                        <th style="width: 3em;">Retries</th>
                        <th>Notify</th>
                        <th style="width: 0em;"><a href="/panels/">Timeout</a></th>
                    </thead>
                    {{ range $key, $val := .Links.Uptime.Panels }}
                    <tr>
                        <td>
                            <a href="/uptime_edit/?edit=yes&delpanel={{ $key }}">
                                <button type="submit" class="btn btn-outline-danger"><i class="bi bi-x-lg"></i></button>
                            </a>
                        </td>
                        <td><a href="/panel_edit/?edit={{ $key }}">{{ $key }}</a></td>
                        <td>{{ .Retries }}</td>
                        <td>{{ range .Notify }}{{ . }}<br>{{ end }}</td>
                        <td>{{ range $.Links.Panels }}{{ if eq .Name $key }}{{ .Timeout }}{{ end }}{{ end }}</td>
                    </tr>
                    {{ end }}
                    <tr>
                        <td></td>
                        <form action="/uptime_edit/" method="post" class="input-group">
                            <input name="edit" type="hidden" value="yes">
                            <td>
                                <select name="newpanel" class="form-select">
                                    {{ range $id, $panel := $.Links.Panels }}
                                    <option value="{{ $id }}">{{ $id }}</option>
                                    {{ end }}
                                </select>
                            </td>
                            <td>
                                <input name="retries" type="text" class="form-control">
                            </td>
                            <td>
                                {{ range $id, $notif := $.Links.Uptime.Notify }}
                                <div class="form-check">
                                    <input class="form-check-input" type="checkbox" name="notify" value="{{ $id }}">{{ $id }}
                                </div>
                                {{ end }}
                            </td>
                            <td>
                                <button type="submit" class="btn btn-outline-success"><i class="bi bi-check2"></i></button>
                            </td>
                        </form>
                    </tr>
                </table>
            </div>
        </div>
    </div>

{{ template "footer" }}
{{ end }}