{{define "apps.html"}}
{{template "partials/header.html" .}}

<div style="display: flex; justify-content: space-between; align-items: center;">
    <h1>Applications</h1>
    {{if .IsSuperAdmin}}
    <a href="/admin/apps/new" role="button">+ Nouvelle App</a>
    {{end}}
</div>

{{if .Apps}}
<div class="apps-list">
    {{range .Apps}}
    <article>
        <header>
            <strong>{{.App}}</strong>
            {{if .Version}}<small>v{{.Version}}</small>{{end}}
        </header>

        <dl>
            <dt>Hosts</dt>
            <dd>
                {{range .Hosts}}
                <code>{{.}}</code><br>
                {{end}}
            </dd>

            <dt>Base Path</dt>
            <dd><code>{{.BasePath}}</code></dd>

            <dt>Database</dt>
            <dd>
                <code>{{.Database.User}}@{{.Database.Host}}:{{.Database.Port}}/{{.Database.Name}}</code>
            </dd>

            {{if .Schema}}
            <dt>Tables (schema)</dt>
            <dd>{{.SchemaTableCount}} tables</dd>
            {{end}}

            {{if .Queries}}
            <dt>Queries</dt>
            <dd>{{.QueriesCount}} fichiers</dd>
            {{end}}
        </dl>

        <footer>
            <a href="/admin/apps/{{.App}}" role="button" class="outline">Détails</a>
        </footer>
    </article>
    {{end}}
</div>
{{else}}
<p>Aucune application configurée.</p>
{{end}}

{{template "partials/footer.html" .}}
{{end}}
