mirror of
https://github.com/rickbarrette/simple-aircraft-manager-rails.git
synced 2026-11-17 15:50:36 -05:00
Bulk document upload and deduplicated file storage
- Bulk Upload page: pick many files or a folder; each file becomes a document named after it, and files sharing a name become one multi-page document. Files go up as direct uploads with per-file progress. - Direct uploads require a signed-in user and check type/size up front; only fresh, unattached blobs can be attached; abandoned uploads are purged nightly. - DedupDisk storage service: each distinct file is stored once under its SHA-256 and blobs hard-link to it; nightly sweep (and storage:dedupe) links pre-existing duplicates and drops unused objects. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
230a569b77
commit
2bfcb845ca
15 files changed
+735
-5
No files matched your search
@@ -19,6 +19,9 @@
|
||||
<% end %>
|
||||
</div>
|
||||
<% end %>
|
||||
<% unless document.persisted? %>
|
||||
<p class="text-sm text-slate-500">Lots of files? <%= link_to "Bulk upload", new_bulk_aircraft_documents_path(aircraft, collection_id: document.document_collection_id), class: "link" %> makes a document from each one.</p>
|
||||
<% end %>
|
||||
<div class="flex gap-2"><%= f.submit "Save Document" %><%= link_to "Cancel", aircraft_documents_path(aircraft), class: "btn-secondary" %></div>
|
||||
<% end %>
|
||||
<% if document.persisted? %><div class="mt-4"><%= delete_button "Delete document", aircraft_document_path(aircraft, document) %></div><% end %>
|
||||
@@ -0,0 +1,68 @@
|
||||
<% content_for :title, "#{@aircraft.tail_number} Bulk Upload" %>
|
||||
<%= render "shared/aircraft_header", aircraft: @aircraft %>
|
||||
<% file_classes = "block w-full text-sm text-slate-600 file:mr-3 file:rounded-md file:border-0 file:bg-slate-100 file:px-3 file:py-1.5 file:text-sm file:font-medium hover:file:bg-slate-200" %>
|
||||
<%= form_with url: bulk_aircraft_documents_path(@aircraft), multipart: true, class: "card card-body max-w-3xl space-y-4",
|
||||
data: { controller: "bulk-upload", bulk_upload_url_value: rails_direct_uploads_path,
|
||||
bulk_upload_max_bytes_value: UploadValidation::MAX_SIZE, action: "submit->bulk-upload#submit" } do %>
|
||||
<div>
|
||||
<h2 class="card-title">Bulk upload</h2>
|
||||
<p class="text-sm text-slate-500">Each file becomes its own document, named after the file. Give files the same name to combine them, in order, as the pages of one document.</p>
|
||||
</div>
|
||||
<% if @bulk_error %>
|
||||
<div class="rounded-md bg-red-50 p-3 text-sm text-red-700 ring-1 ring-red-200" role="alert"><%= @bulk_error %></div>
|
||||
<% end %>
|
||||
|
||||
<div class="grid gap-4 sm:grid-cols-2">
|
||||
<div>
|
||||
<%= label_tag :doc_type, "Type", class: "label" %>
|
||||
<%= select_tag :doc_type, options_for_select(Document::TYPES.invert, @bulk[:doc_type]), class: "input" %>
|
||||
</div>
|
||||
<div>
|
||||
<%= label_tag :visibility, "Share-link visibility", class: "label" %>
|
||||
<%= select_tag :visibility, options_for_select([ [ "Inherit from collection", "" ] ] + DocumentCollection::VISIBILITIES.invert.to_a, @bulk[:visibility]), class: "input" %>
|
||||
</div>
|
||||
<div>
|
||||
<%= label_tag :document_collection_id, "Collection", class: "label" %>
|
||||
<%= select_tag :document_collection_id,
|
||||
options_for_select([ [ "— None —", "" ] ] + @aircraft.document_collections.ordered.map { [ _1.name, _1.id ] }, @bulk[:document_collection_id]), class: "input" %>
|
||||
</div>
|
||||
<div>
|
||||
<%= label_tag :new_collection, "…or a new collection", class: "label" %>
|
||||
<%= text_field_tag :new_collection, @bulk[:new_collection], class: "input", placeholder: "e.g. 2025 Annual" %>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="grid gap-4 sm:grid-cols-2">
|
||||
<div>
|
||||
<%= label_tag :files, "Files", class: "label" %>
|
||||
<%= file_field_tag "files[]", id: "files", multiple: true, class: file_classes,
|
||||
data: { bulk_upload_target: "input", action: "change->bulk-upload#add" } %>
|
||||
</div>
|
||||
<div data-bulk-upload-target="folderField" hidden>
|
||||
<%= label_tag :folder, "…or a whole folder", class: "label" %>
|
||||
<input type="file" id="folder" webkitdirectory multiple class="<%= file_classes %>"
|
||||
data-bulk-upload-target="folder" data-action="change->bulk-upload#add">
|
||||
</div>
|
||||
</div>
|
||||
<p class="hint !mt-1">Images, PDFs or text, up to <%= UploadValidation::MAX_SIZE / 1.megabyte %> MB each and <%= DocumentsController::MAX_BULK_FILES %> at a time.</p>
|
||||
|
||||
<div data-bulk-upload-target="panel" hidden class="space-y-2">
|
||||
<div class="flex flex-wrap items-center justify-between gap-2">
|
||||
<p class="text-sm font-medium text-slate-700" data-bulk-upload-target="summary"></p>
|
||||
<div class="flex flex-wrap items-center gap-3">
|
||||
<label class="flex items-center gap-2 text-sm text-slate-700" data-bulk-upload-target="groupField" hidden>
|
||||
<input type="checkbox" class="h-4 w-4 rounded border-slate-300" data-bulk-upload-target="group" data-action="bulk-upload#regroup">
|
||||
One document per folder
|
||||
</label>
|
||||
<button type="button" class="btn-secondary btn-sm" data-action="bulk-upload#clear">Clear</button>
|
||||
</div>
|
||||
</div>
|
||||
<ul class="divide-y divide-slate-100 rounded-md ring-1 ring-slate-200" data-bulk-upload-target="list"></ul>
|
||||
</div>
|
||||
|
||||
<div class="flex flex-wrap items-center gap-2">
|
||||
<button type="submit" class="btn-primary" data-bulk-upload-target="submit">Upload</button>
|
||||
<%= link_to "Cancel", aircraft_documents_path(@aircraft), class: "btn-secondary" %>
|
||||
<p class="text-sm text-slate-500" data-bulk-upload-target="status" role="status"></p>
|
||||
</div>
|
||||
<% end %>
|
||||
@@ -1,8 +1,9 @@
|
||||
<% content_for :title, "#{@aircraft.tail_number} Documents" %>
|
||||
<%= render "shared/aircraft_header", aircraft: @aircraft %>
|
||||
<div class="mb-4 flex justify-end gap-2">
|
||||
<div class="mb-4 flex flex-wrap justify-end gap-2">
|
||||
<% if owner? %>
|
||||
<%= link_to "+ Collection", new_aircraft_document_collection_path(@aircraft), class: "btn-secondary" %>
|
||||
<%= link_to "Bulk Upload", new_bulk_aircraft_documents_path(@aircraft), class: "btn-secondary" %>
|
||||
<%= link_to "+ Upload Document", new_aircraft_document_path(@aircraft), class: "btn-primary" %>
|
||||
<% end %>
|
||||
</div>
|
||||
|
||||
Reference in new issue
Block a user