document-processor/app/templates/ingest/index.html

182 lines
8.2 KiB
HTML

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Ingest</title>
<link rel="stylesheet" href="/static/app.css">
</head>
<body>
<div class="app-shell" id="app-shell">
{% include "partials/sidebar.html" %}
<main class="main">
<div class="topbar">
<div>
<h1 class="page-title">Ingest</h1>
<p class="page-subtitle">Upload files, ingest from server-side paths, or use the current default ingest root.</p>
</div>
</div>
<div class="card">
<h2 class="card-title">Default ingest root</h2>
<form method="post" action="/ingest/set-default-root">
<div class="form-grid">
<div class="form-field full">
<label for="default_ingest_root">Default ingest root</label>
<input id="default_ingest_root" type="text" name="directory_path" value="{{ default_ingest_root }}" placeholder="/mnt/data/shared/scans/processed">
</div>
</div>
<div class="button-row" style="margin-top: 1rem;">
<button class="primary" type="submit">Save default</button>
</div>
</form>
<div class="button-row" style="margin-top: 1rem;">
<form method="post" action="/ingest/reset-default-root">
<button type="submit">Revert to /mnt/data/shared/scans/processed</button>
</form>
<form method="get" action="/ingest/">
<input type="hidden" name="browse_path" value="{{ default_ingest_root }}">
<button type="submit">Browse current default</button>
</form>
<form method="post" action="/ingest/inbox">
<button type="submit">Ingest current default root</button>
</form>
</div>
</div>
<div class="card">
<h2 class="card-title">Browse directories</h2>
<form method="get" action="/ingest/">
<div class="form-grid">
<div class="form-field full">
<label for="browse_path">Browse path</label>
<input id="browse_path" type="text" name="browse_path" value="{{ current_browse_path }}" placeholder="/mnt/data/shared/scans/processed">
</div>
</div>
<div class="button-row" style="margin-top: 1rem;">
<button class="primary" type="submit">Browse</button>
{% if browser.parent %}
<a class="button-link" href="/ingest/?browse_path={{ browser.parent }}">Up one level</a>
{% endif %}
</div>
</form>
{% if browser.error %}
<p class="empty-state">{{ browser.error }}</p>
<p class="page-subtitle">This app can only browse directories that exist on svr-02 or are mounted there.</p>
{% else %}
<p class="page-subtitle">Current path: {{ browser.path }}</p>
{% if browser.entries %}
<div class="table-wrap">
<table>
<thead>
<tr>
<th>Name</th>
<th>Kind</th>
<th>Actions</th>
</tr>
</thead>
<tbody>
{% for entry in browser.entries %}
<tr>
<td>{{ entry.name }}</td>
<td>{% if entry.is_dir %}Directory{% else %}File{% endif %}</td>
<td>
<div class="button-row">
{% if entry.is_dir %}
<a class="button-link" href="/ingest/?browse_path={{ entry.path }}">Open</a>
<form method="post" action="/ingest/set-default-root">
<input type="hidden" name="directory_path" value="{{ entry.path }}">
<button type="submit">Set default</button>
</form>
<form method="post" action="/ingest/server-directory">
<input type="hidden" name="directory_path" value="{{ entry.path }}">
<input type="hidden" name="recursive" value="1">
<button type="submit">Ingest directory</button>
</form>
{% else %}
<form method="post" action="/ingest/server-file">
<input type="hidden" name="file_path" value="{{ entry.path }}">
<button type="submit">Ingest file</button>
</form>
{% endif %}
</div>
</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
{% else %}
<p class="empty-state">No entries found in this directory.</p>
{% endif %}
{% endif %}
</div>
<div class="card">
<h2 class="card-title">Upload files</h2>
<form method="post" action="/ingest/upload-files" enctype="multipart/form-data">
<div class="form-field full">
<label>Select file(s)</label>
<input type="file" name="uploaded_files" multiple required>
</div>
<div class="button-row" style="margin-top: 1rem;">
<button class="primary" type="submit">Upload and ingest</button>
</div>
</form>
</div>
<div class="card">
<h2 class="card-title">Server-side ingest</h2>
<form method="post" action="/ingest/server-file" style="margin-bottom: 1.25rem;">
<div class="form-field full">
<label>Ingest one server file</label>
<input type="text" name="file_path" placeholder="/mnt/data/.../file.pdf" required>
</div>
<div class="button-row" style="margin-top: 1rem;">
<button type="submit">Ingest file</button>
</div>
</form>
<form method="post" action="/ingest/server-directory" style="margin-bottom: 1.25rem;">
<div class="form-field full">
<label>Ingest one server directory</label>
<input type="text" name="directory_path" placeholder="/mnt/data/.../incoming" required>
</div>
<div class="form-field">
<label><input type="checkbox" name="recursive" value="1"> Recursive</label>
</div>
<div class="button-row" style="margin-top: 1rem;">
<button type="submit">Ingest directory</button>
</div>
</form>
</div>
</main>
</div>
<script>
(function () {
const appShell = document.getElementById("app-shell");
const menuToggle = document.getElementById("menu-toggle");
if (!appShell || !menuToggle) return;
menuToggle.addEventListener("click", function () {
appShell.classList.toggle("nav-open");
});
menuToggle.addEventListener("keydown", function (e) {
if (e.key === "Enter" || e.key === " ") {
e.preventDefault();
appShell.classList.toggle("nav-open");
}
});
})();
</script>
</body>
</html>