aceberg/miniboard

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

Summary

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

<body>
    <div class="container">
        <br>
        <div class="row">
            <div class="col">
                {{ range $key, $value := .Links.Panels }}
                <div class="row">
                    <div class="col">
                        <h4>Edit panel {{ $key }}</h4>
                    </div>
                    <div class="col">
                        <form action="/panels/" class="input-group">
                            <span class="input-group-text">Scan</span>&nbsp;&nbsp;
                            <input name="oldkey" type="hidden" value="{{ $key }}">
                            <input name="key" type="hidden" value="{{ $key }}">
                            <div class="form-check">
                                {{ if .Scan }}
                                <input class="form-check-input" type="checkbox" name="scan" checked>
                                {{ else }}
                                <input class="form-check-input" type="checkbox" name="scan">
                                {{ end }}
                            </div>
                            <span class="input-group-text">Timeout</span>
                            <input name="timeout" type="text" class="form-control" value="{{ .Timeout }}" placeholder="Minutes">
                            <button type="submit" class="btn btn-outline-success"><i class="bi bi-check2"></i></button>
                        </form>
                    </div>
                    <div class="col">
                        <div class="d-flex justify-content-end">
                            <a href="/panel_edit/?del={{ $key }}">
                                <button type="submit" class="btn btn-outline-danger">Delete panel</button>
                            </a>
                        </div>
                    </div>
                </div>
                <br>
                <table class="table table-striped">
                    <thead>
                        <th style="width: 1em;">Del</th>
                        <th style="width: 3em;">ID</th>
                        <th style="width: 1em;">Up</th>
                        <th style="width: 12em;">Name</th>
                        <th style="width: 12em;">IP Address</th>
                        <th style="width: 6em;">Port</th>
                        <th>URL</th>
                        <th>Icon</th>
                        <th style="width: 1em;"></th>
                    </thead>
                    {{ range $id, $host := .Hosts }}
                    <tr>
                        <td><a href="/host/?panel={{ $key }}&del={{ $id }}">
                            <button type="submit" class="btn btn-outline-danger"><i class="bi bi-x-lg"></i></button>
                        </a></td>
                        <td>{{ $id }}</td>
                        <td>{{ if eq $id 0 }}
                            <button type="submit" class="btn btn-outline-warning" disabled><i class="bi bi-arrow-up"></i></button>
                            {{ else }}
                            <a href="/host/?panel={{ $key }}&up={{ $id }}">
                                <button type="submit" class="btn btn-outline-warning"><i class="bi bi-arrow-up"></i></button>
                            </a>
                            {{ end }}
                        </td>
                    <form action="/host/" method="post">
                        <input name="id" type="hidden" value="{{ $id }}">
                        <input name="panel" type="hidden" value="{{ $key }}">
                        <td><input name="name" type="text" class="form-control" value="{{ .Name }}"></td>
                        <td><input name="addr" type="text" class="form-control" value="{{ .Addr }}"></td>
                        <td><input name="port" type="text" class="form-control" value="{{ .Port }}"></td>
                        <td><input name="url" type="text" class="form-control" value="{{ .URL }}"></td>
                        <td><input name="icon" type="text" class="form-control" value="{{ .Icon }}"></td>
                        <td><button type="submit" class="btn btn-outline-success"><i class="bi bi-check2"></i></button></td>
                    </form>
                    </tr>
                    {{ end }}
                    <tr>
                        <td colspan="3">New:</td>
                    <form action="/host/" method="post">
                        <input name="panel" type="hidden" value="{{ $key }}">
                        <td><input name="name" type="text" class="form-control" placeholder="Name"></td>
                        <td><input name="addr" type="text" class="form-control" placeholder="IP or DNS-name"></td>
                        <td><input name="port" type="text" class="form-control" placeholder="Port"></td>
                        <td><input name="url" type="text" class="form-control" placeholder="Starts with http(s)://"></td>
                        <td><input name="icon" type="text" class="form-control" placeholder="Link to icon"></td>
                        <td><button type="submit" class="btn btn-outline-success"><i class="bi bi-check2"></i></button></td>
                    </form>
                    </tr>
                </table>
                {{ end }}
            </div>
        </div>
    </div>

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