<div class="pure-u-1-1">
    <p>
        Sections
    </p>

    <div class="pure-button-group" role="group" aria-label="Table Of Contents">
        <a class="pure-button pure-button-small" href="#overview">Info &amp; Status</a>
        <a class="pure-button pure-button-small" href="#requirements">Drupal Status Report</a>
        <a class="pure-button pure-button-small" href="#users">Users (Drupal)</a>
        <a class="pure-button pure-button-small" href="#wisski">WissKI Data</a>
        <a class="pure-button pure-button-small" href="#stats">Statistics</a>
        <a class="pure-button pure-button-small" href="#ssh">SSH Keys</a>
        <a class="pure-button pure-button-small" href="#snapshots">Snapshots</a>
        <a class="pure-button pure-button-small" href="#danger">Dangerous Actions</a>
    </div>
</div>

<div class="pure-u-1-1">
    <h2 id="overview">Info &amp; Status</h2>
</div>
<div class="pure-u-1 pure-u-xl-2-5">
    <div class="padding">
        <div class="overflow">
            <table class="pure-table pure-table-bordered">
                <thead>
                    <tr>
                        <th colspan="2">
                            Overview
                        </th>
                    </tr>
                </thead>
                <tbody>
                    <tr>
                        <td>
                            Slug
                        </td>
                        <td>
                            <code>{{ .Info.Slug }}</code>
                        </td>
                    </tr>
                    <tr>
                        <td>
                            URL
                        </td>
                        <td>
                            <a href="{{ .Info.URL }}" target="_blank" rel="noopener noreferrer">{{ .Info.URL }}</a>
                        </td>
                    </tr>
                    <tr>
                        <td>
                            Running
                        </td>
                        <td>
                            <code>{{ .Info.Running }}</code>
                            <div class="pure-button-group" role="group">
                                <button class="remote-action pure-button pure-button-action" data-action="start" data-param="{{ .Instance.Slug }}" data-buffer="1000" data-force-reload>
                                    (Re)Start
                                </button>
                                <button class="remote-action pure-button pure-button-danger" data-action="stop" data-param="{{ .Instance.Slug }}" data-buffer="1000" data-force-reload>
                                    Stop
                                </button>
                            </div>
                            
                        </td>
                    </tr>
                    <tr>
                        <td>
                            Locked
                        </td>
                        <td>
                            <code>{{ .Info.Locked }}</code>
                        </td>
                    </tr>
                </tbody>
            </table>
        </div>
    </div>
</div>
<div class="pure-u-1 pure-u-xl-2-5">
    <div class="padding">
        <div class="overflow">
            <table class="pure-table pure-table-bordered">
                <thead>
                    <tr>
                        <th colspan="2">
                            System
                            <small>
                                (use <em>Rebuild</em> to edit)
                            </small>
                        </th>
                    </tr>
                </thead>
                <tbody>
                    <tr>
                        <td>
                            Docker Base Image
                        </td>
                        <td>
                            <code>{{ .Instance.System.GetDockerBaseImage }}</code>
                        </td>
                    </tr>
                    <tr>
                        <td>
                            PHP Version
                        </td>
                        <td>
                            <code>{{ .Instance.System.PHP }}</code>
                        </td>
                    </tr>
                    <tr>
                        <td>
                            OPCache Development Config
                        </td>
                        <td>
                            <code>{{ .Instance.System.OpCacheDevelopment }}</code>
                        </td>
                    </tr>
                    <tr>
                        <td>
                            Content Security Policy
                        </td>
                        <td>
                            <code>{{ .Instance.System.ContentSecurityPolicy }}</code>
                        </td>
                    </tr>
                </tbody>
            </table>
        </div>
    </div>
</div>

<div class="pure-u-1 pure-u-xl-2-5">
    <div class="padding">
        <div class="overflow">
            <table class="pure-table pure-table-bordered">
                <thead>
                    <tr>
                        <th colspan="2">
                            Drupal Info
                        </th>
                    </tr>
                </thead>
                <tbody>
                    <tr>
                        <td>
                            Drupal Version
                        </td>
                        <td>
                            <code>{{ .Info.DrupalVersion }}</code>
                        </td>
                    </tr>
                    <tr>
                        <td>
                            Default Theme
                        </td>
                        <td>
                            <code>{{ .Info.Theme }}</code>
                        </td>
                    </tr>
                </tbody>
            </table>
        </div>
    </div>
</div>

<div class="pure-u-1 pure-u-xl-2-5">
    <div class="padding">
        <div class="overflow">
            <table class="pure-table pure-table-bordered">
                <thead>
                    <tr>
                        <th colspan="2">
                            Component Settings
                        </th>
                    </tr>
                </thead>
                <tbody>
                    <tr>
                        <td>
                            Directory
                        </td>
                        <td>
                            <code class="overflow">{{ .Instance.FilesystemBase }}</code>
                        </td>
                    </tr>
                    <tr>
                        <td>
                            SQL DB
                        </td>
                        <td>
                            <code class="copy">{{ .Instance.SqlDatabase }}</code>
                        </td>
                    </tr>
                    <tr>
                        <td>
                            SQL User
                        </td>
                        <td>
                            <code class="copy">{{ .Instance.SqlUsername }}</code>
                        </td>
                    </tr>
                    <tr>
                        <td>
                            SQL Password
                        </td>
                        <td>
                            <span data-reveal="{{ .Instance.SqlPassword }}"></span>
                        </td>
                    </tr>
                    <tr>
                        <td>
                            TS Repo
                        </td>
                        <td>
                            <code class="copy">{{ .Instance.GraphDBRepository }}</code>
                        </td>
                    </tr>
                    <tr>
                        <td>
                            TS User
                        </td>
                        <td>
                            <code class="copy">{{ .Instance.GraphDBUsername }}</code>
                        </td>
                    </tr>

                    <tr>
                        <td>
                            TS Password
                        </td>
                        <td>
                            <span data-reveal="{{ .Instance.GraphDBPassword }}"></span>
                        </td>
                    </tr>
                </tbody>
            </table>
        </div>
    </div>
</div>

<div class="pure-u-1 pure-u-xl-2-5">
    <div class="padding">
        <div class="overflow">
            <table class="pure-table pure-table-bordered">
                <thead>
                    <tr>
                        <th colspan="2">
                            Build Status
                        </th>
                    </tr>
                </thead>
                <tbody>
                    <tr>
                        <td>
                            Created
                        </td>
                        <td>
                            <code class="date">{{ .Instance.Created.Format "2006-01-02T15:04:05Z07:00" }}</code>
                        </td>
                    </tr>
                    <tr>
                        <td>
                            Last Rebuild <br>
                            <a class="pure-button" href="/admin/rebuild/{{ .Info.Slug }}">Rebuild</button>
                        </td>
                        <td>
                            <code class="date">{{ .Info.LastRebuild.Format "2006-01-02T15:04:05Z07:00" }}</code>
                        </td>
                    </tr>
                    <tr>
                        <td>
                            Last Cron<br>
                            <button class="remote-action pure-button pure-button-action" data-action="cron" data-param="{{ .Instance.Slug }}" data-buffer="1000" data-force-reload>Cron</button>
                        </td>
                        <td>
                            <code class="date">{{ .Info.LastRebuild.Format "2006-01-02T15:04:05Z07:00" }}</code>
                        </td>
                    </tr>
                    <tr>
                        <td>
                            Last Update <br>
                            <button class="remote-action pure-button pure-button-action" data-action="update" data-param="{{ .Instance.Slug }}" data-buffer="1000" data-force-reload>Update</button>
                        </td>
                        <td>
                            <code class="date">{{ .Info.LastUpdate.Format "2006-01-02T15:04:05Z07:00" }}</code><br>
                            (Automatic: <code>{{ .Instance.AutoBlindUpdateEnabled }}</code>)
                        </td>
                    </tr>
                </tbody>
            </table>
        </div>
    </div>
</div>

<div class="pure-u-1-1">
    <h2 id="requirements">Drupal Status Report</h2>
</div>

<div class="pure-u-1">
    <div class="padding">
        <div class="overflow">
            <table class="pure-table pure-table-bordered">
                <thead>
                    <tr>
                        <th>
                            ID
                        </th>
                        <th>
                            Severity
                        </th>
                        <th>
                            Title
                        </th>
                        <th>
                            Value
                        </th>
                        <th>
                            Description
                        </th>
                    </tr>
                </thead>

                <tbody>
                    {{ range $name, $req := .Info.Requirements }}
                    <tr>
                        <td>
                            <code>{{ $req.ID }}</code>
                        </td>
                        <td>
                            {{ $req.Level }}
                        </td>
                        <td>
                            {{ $req.Title }}
                        </td>
                        <td>
                            {{ $req.Value }}
                        </td>
                        <td>
                            {{ $req.Description }}
                        </td>
                    </tr>
                    {{ end }}
                </tbody>
            </table>
        </div>
    </div>
</div>

<div class="pure-u-1-1">
    <h2 id="users">Users (Drupal)</h2>
    <a class="pure-button" href="/admin/grants/{{ .Info.Slug }}">Manage Grants</a>
</div>

<div class="pure-u-1">
    <div class="padding">
        <div class="overflow">
            <table class="pure-table pure-table-bordered">
                <thead>
                    <tr>
                        <th>
                            ID
                        </th>
                        <th>
                            Active
                        </th>
                        <th>
                            Name
                        </th>
                        
                        <th>
                            Email
                        </th>
                        <th>
                            Roles
                        </th>
                        <th>
                            Created
                        </th>
                        <th>
                            Last Login
                        </th>
                        <th>
                            Action
                        </th>
                    </tr>
                </thead>
                <tbody>
                    {{ $slug := .Instance.Slug }}
                    {{ $csrf := .CSRF }}
                    {{ range $index, $user := .Info.Users }}
                    <tr {{ if not $user.Status }}class="disabled" aria-disabled="true"{{ end }}>
                        <td>
                            <code>{{ $user.UID }}</code>
                        </td>
                        <td>
                            <code>{{ $user.Status }}</code>
                        </td>
                        <td>
                            <code>{{ $user.Name }}</code>
                        </td>

                        <td>
                            {{ if $user.Mail }}
                                <a href="mailto:{{ $user.Mail }}">{{ $user.Mail }}</a>
                            {{ end }}
                        </td>
                        <td>
                            {{ range $role, $unuused := $user.Roles }}
                                <code>
                                    {{ $role }}
                                </code>
                            {{ end }}
                        </td>
                        <td>
                            <code class="date">{{ $user.Created.Time.Format "2006-01-02T15:04:05Z07:00" }}</code>
                        </td>
                        <td>
                            <code class="date">{{ $user.Login.Time.Format "2006-01-02T15:04:05Z07:00" }}</code>
                        </td>
                        <td>
                            <form action="/admin/login" method="POST" target="_blank">
                                <input type="hidden" name="slug" value="{{ $slug }}">
                                <input type="hidden" name="user" value="{{ $user.Name }}">
                                <input type="submit" class="pure-button pure-button-action" value="Login in new window">
                                {{ $csrf }}
                            </form>
                        </td>
                    </tr>
                    {{ end }}
                </tbody>
            </table>
        </div>
    </div>
</div>

<div class="pure-u-1-1">
    <h2 id="wisski">WissKI Data</h2>
</div>

<div class="pure-u-1 pure-u-xl-1-2">
    <div class="padding">
        <div class="overflow">
            <table class="pure-table pure-table-bordered">
                <thead>
                    <tr>
                        <th colspan="2">
                            Pathbuilders
                        </th>
                    </tr>
                </thead>

                <tbody>
                    {{ range $name, $xml := .Info.Pathbuilders }}
                    <tr>
                        <td>
                            <code>{{ $name }}</code>
                        </td>
                        <td>
                            <code class="pathbuilder" data-name="{{ $name }}">{{ $xml }}</code>
                        </td>
                    </tr>
                    {{ end }}
                </tbody>
            </table>
        </div>
    </div>
</div>
<div class="pure-u-1 pure-u-xl-1-2">
    <div class="padding">
        <div class="overflow">
            <table class="pure-table pure-table-bordered">
                <thead>
                    <tr>
                        <th>
                            URI Prefixes

                            {{ if .Info.NoPrefixes }}
                            (excluded from resolver)
                            {{ end }}
                        </th>
                    </tr>
                </thead>
                <tbody>
                    {{ range $index, $prefix := .Info.Prefixes }}
                    <tr>
                        <td>
                            <code>{{ $prefix }}</code>
                        </td>
                    </tr>
                    {{ end }}
                </tbody>
            </table>
        </div>
    </div>
</div>

<div class="pure-u-1-1">
    <h2 id="stats">Statistics</h2>
</div>

<div class="pure-u-1 pure-u-xl-1-2">
    <div class="padding">
        <div class="overflow">
            <table class="pure-table pure-table-bordered">
                <thead>
                    <tr>
                        <th colspan="5">
                            Bundles
                        </th>
                    </tr>
                    <tr>
                        <th>
                            Label
                        </th>
                        <th>
                            Machine Name
                        </th>
                        <th>
                            Count
                        </th>
                        <th>
                            LastEdit
                        </th>
                        <th>
                            MainBundle
                        </th>
                    </tr>
                </thead>
                <tbody>
                    {{ range .Info.Statistics.Bundles.Bundles }}
                    <tr>
                        <td>
                            <code>{{ .Label }}</code>
                        </td>
                        <td>
                            <code>{{ .MachineName }}</code>
                        </td>
                        <td>
                            <code>{{ .Count }}</code>
                        </td>
                        <td>
                            <code class="date">{{ .LastEdit.Time.Format "2006-01-02T15:04:05Z07:00" }}</code>
                        </td>
                        <td>
                            <code>{{ .MainBundle }}</code>
                        </td>
                    </tr>
                    {{ end }}
                </tbody>
            </table>
        </div>
    </div>
</div>


<div class="pure-u-1 pure-u-xl-1-2">
    <div class="padding">
        <div class="overflow">
            <table class="pure-table pure-table-bordered">
                <thead>
                    <tr>
                        <th colspan="2">
                            Triplestore
                        </th>
                    </tr>
                    <tr>
                        <th>
                            URI
                        </th>
                        <th>
                            Count
                        </th>
                    </tr>
                </thead>
                <tbody>
                    {{ range .Info.Statistics.Triplestore.Graphs }}
                    <tr>
                        <td>
                            <code>{{ .URI }}</code>
                        </td>
                        <td>
                            <code>{{ .Count }}</code>
                        </td>
                    </tr>
                    {{ end }}
                </tbody>
            </table>
        </div>
    </div>
</div>

<div class="pure-u-1-1">
    <h2 id="ssh">SSH Keys</h2>
    <table class="pure-table pure-table-bordered padding">
        <tbody>
            {{ range .Info.SSHKeys }}
            <tr>
                <td>
                    <code>{{ . }}</code>
                </td>
            </tr>
            {{ end }}
        </tbody>
    </table>
</div>

<div class="pure-u-1-1">
    <h2 id="snapshots">Snapshots</h2>
    <p>
        <button class="remote-action pure-button pure-button-action" data-action="snapshot" data-param="{{ .Instance.Slug }}" data-buffer="1000" data-force-reload>Take a snapshot</button>
    </p>
</div>

<div class="pure-u-1">
    <table class="pure-table pure-table-bordered padding">
        <thead>
            <tr>
                <th>Path</th>
                <th>Created</th>
                <th>Packed</th>
            </tr>
        </thead>
        <tbody>
            {{ range .Info.Snapshots }}
            <tr>
                <td>
                    <code class="path">{{ .Path }}</code>
                </td>
                <td>
                    <code class="date">{{ .Created.Format "2006-01-02T15:04:05Z07:00" }}</code>
                </td>
                <td>
                    {{ .Packed }}
                </td>
            </tr>
            {{ end}}
        </tbody>
    </table>
</div>

<div class="pure-u-1-1">
    <h2 id="danger">Dangerous Actions</h2>
</div>

<div class="pure-u-1 pure-u-xl-2-5">
    <p>
        Purging this instance completely removes it from the distillery.
        Backups containing the instance will remain, but it will not be possible to restore it directly.
        You must enter the slug <code>{{ .Instance.Slug }}</code> to confirm purging.
    </p>
    <form class="pure-form">
        <fieldset>
            <input type="text" id="purge-confirm-slug" placeholder="{{ .Instance.Slug }}" />
            <button class="remote-action pure-button pure-button-danger" data-action="purge" data-param="{{ .Instance.Slug }}" data-confirm-param="#purge-confirm-slug" data-buffer="1000" data-force-reload="/admin/">Purge Instance</button>
        </fieldset>
    </form>
</div>