aceberg/miniboard

View on GitHub
internal/web/templates/tabs.html

Summary

Maintainability
Test Coverage
{{ define "tabs" }}

<body>
    <div class="container">
        <br>
        <div class="row">
        <div class="col-8">
            <h4>Edit Tabs</h4>
            <table class="table table-striped">
                <thead>
                    <th style="width: 1em;">Edit</th>
                    <th style="width: 2em;">ID</th>
                    <th style="width: 1em;">Up</th>
                    <th>Name</th>
                    <th style="width: 1em;">Horiz</th>
                    <th style="width: 4em;" title="Refresh (seconds). Leave blank for system-wide config:WebRefresh to work"><i class="bi bi-question-circle"></i></th>
                    <th>Panels</th>
                    <th style="width: 1em;"></th>
                </thead>
                {{ range $id, $tab := .Links.Tabs }}
                <tr>
                    <td><a href="/tab_edit/?tab={{ $id }}">
                        <button type="submit" class="btn btn-outline-warning"><i class="bi bi-pencil"></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="/tabs/?up={{ $id }}">
                            <button type="submit" class="btn btn-outline-warning"><i class="bi bi-arrow-up"></i></button>
                        </a>
                        {{ end }}
                    </td>
                <form action="/tabs/" method="post">
                    <input name="id" type="hidden" value="{{ $id }}">
                    <input name="panels" type="hidden" value="{{ .Panels }}">
                    <td><input name="name" type="text" class="form-control" value="{{ .Name }}"></td>
                    <td>
                        <div class="form-check">
                            {{ if .Horiz }}
                            <input class="form-check-input" type="checkbox" name="horiz" checked>
                            {{ else }}
                            <input class="form-check-input" type="checkbox" name="horiz">
                            {{ end }}
                        </div>
                    </td>
                    <td><input name="refresh" type="text" class="form-control" value="{{ .Refresh }}"></td>
                    <td>{{ range .Panels }}
                        <a href="/panel_edit/?edit={{ . }}">{{ . }}</a>&nbsp;
                        {{ end }}</td>
                    <td><button type="submit" class="btn btn-outline-success"><i class="bi bi-check2"></i></button></td>
                </form>
                </tr>
                {{ end }}
            </table>
        </div>
        <div class="col-4">
            <h4>New Tab</h4>
            <table class="table">
            <form action="/tabs/" method="post">
                <tr>
                    <td>Name</td>
                    <td><input name="name" type="text" class="form-control"></td>
                </tr>
                <tr>
                    <td>Panels</td>
                    <td><select name="panels" class="form-select" multiple size="10em">
                        {{ range $id, $panel := $.Links.Panels }}
                        <option value="{{ $id }}">{{ $id }}</option>
                        {{ end }}
                    </select></td>
                </tr>
                <tr>
                    <td></td>
                    <td><button type="submit" class="btn btn-outline-success">Save</button></td>
                </tr>
            </form>
            </table>
        </div>
        </div>
    </div>

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