<h1 class="my-3">Sideload directory tree</h1>

<div class="my-3 p-3 border bg-light">
This will sideload documents from a directory tree.  See the <a href="https://docs.marginalia.nu">docs</a>
for more information on how to set this up.
</div>
<form method="post" action="actions/sideload-dirtree" onsubmit="return confirm('Confirm sideloading')">
    <div class="my-3 py-3">
        <table class="table">
            <th></th><th>Filename</th><th>Size</th><th>Last Modified</th>
            {{#each uploadDirContents.items}}
                <tr>
                    <td><input {{#if directory}}disabled{{/if}} class="form-check-input" type="radio" name="source" id="{{name}}" value="{{name}}"></td>
                    <td {{#if directory}}class="text-muted"{{/if}}>
                        <label class="form-check-label" for="{{name}}">{{name}}{{#if directory}}/{{/if}}</label>
                    </td>
                    <td>{{#unless directory}}{{size}}{{/unless}}</td>
                    <td title={{lastModifiedTime}}>{{shortTimestamp lastModifiedTime}}</td>
                </tr>
            {{/each}}
            {{#unless uploadDirContents.items}}
                <tr>
                    <td colspan="3">Nothing found in upload directory</td>
                </tr>
            {{/unless}}
        </table>

        <p>
            <small class="text-muted">
                The upload directory is typically mounted to /uploads on the server.  The external
                directory is typically something like index-{{node.id}}/uploads.
            </small>
        </p>

        <button type="submit" {{#unless uploadDirContents.items}}disabled{{/unless}} class="btn btn-primary">Sideload Dirtree</button>
    </div>
</form>