mirror of
https://github.com/rickbarrette/simple-aircraft-manager-rails.git
synced 2026-11-17 15:50:36 -05:00
Admin setting for the maximum upload size
- Admin -> Settings: maximum upload size per file (1-1024 MB, default 50), stored in a new settings table and read on each use, so a change applies to every process at once - Enforced by attachment validation and the direct-upload endpoint; upload forms, bulk upload and Admin -> About show the current limit - .sam.zip import accepts files up to 1 GB to match Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
4f548f3874
commit
ef7cd2efba
16 files changed
+186
-13
No files matched your search
@@ -0,0 +1,26 @@
|
||||
<% content_for :title, "Settings" %>
|
||||
<h1 class="mb-4 text-2xl font-bold">Settings</h1>
|
||||
<%= form_with url: admin_settings_path, method: :patch, class: "card card-body max-w-xl space-y-4" do |f| %>
|
||||
<% if @errors.present? %>
|
||||
<div class="rounded-md bg-red-50 p-3 text-sm text-red-700 ring-1 ring-red-200" role="alert">
|
||||
<ul class="list-disc pl-5"><% @errors.each do |e| %><li><%= e %></li><% end %></ul>
|
||||
</div>
|
||||
<% end %>
|
||||
|
||||
<h2 class="card-title">Uploads</h2>
|
||||
<% upload = Setting::INTEGERS["max_upload_mb"] %>
|
||||
<div>
|
||||
<%= label_tag "settings[max_upload_mb]", upload[:label], class: "label" %>
|
||||
<%= number_field_tag "settings[max_upload_mb]", @values["max_upload_mb"], id: "settings_max_upload_mb",
|
||||
min: upload[:in].min, max: upload[:in].max, step: 1, required: true, class: "input w-32" %>
|
||||
<p class="hint">
|
||||
The largest single file anyone can upload: documents, squawk photos and bulk uploads. Default <%= upload[:default] %> MB, up to <%= upload[:in].max %> MB.
|
||||
</p>
|
||||
<p class="hint">
|
||||
A proxy in front of the app can have its own, smaller limit. Cloudflare's proxy stops at 100 MB on its free plan; nginx needs <code>client_max_body_size</code>.
|
||||
Logbook transcription with Claude reads PDFs up to <%= LogbookTranscriber::MAX_PDF_BYTES / 1.megabyte %> MB and images up to <%= LogbookTranscriber::MAX_IMAGE_BYTES / 1.megabyte %> MB, whatever this is set to.
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div class="flex gap-2"><%= f.submit "Save Settings", class: "btn-primary" %><%= link_to "Cancel", admin_about_path, class: "btn-secondary" %></div>
|
||||
<% end %>
|
||||
@@ -10,7 +10,7 @@
|
||||
</div>
|
||||
<%= f.field :description, as: :textarea, rows: 2 %>
|
||||
<%= f.field :pages, as: :file, multiple: true, label: document.persisted? ? "Add files" : "Files",
|
||||
hint: "Images, PDFs or text. Each file is a page in the viewer, in upload order." %>
|
||||
hint: "Images, PDFs or text, up to #{Setting.max_upload_mb} MB each. Each file is a page in the viewer, in upload order." %>
|
||||
<% if document.persisted? && document.pages.any? %>
|
||||
<div>
|
||||
<p class="label">Remove existing files</p>
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<% 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 %>
|
||||
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>
|
||||
@@ -44,7 +44,7 @@
|
||||
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>
|
||||
<p class="hint !mt-1">Images, PDFs or text, up to <%= Setting.max_upload_mb %> 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">
|
||||
|
||||
@@ -37,7 +37,7 @@
|
||||
<%= link_to "Profile", edit_profile_path, class: "block px-4 py-2.5 hover:bg-slate-100" %>
|
||||
<% if current_user.admin? %>
|
||||
<p class="border-t border-slate-100 px-4 pt-2 pb-1 text-xs font-semibold text-slate-500">Admin</p>
|
||||
<% [ [ "Users", admin_users_path ], [ "Component Types", admin_component_types_path ], [ "Airports", admin_airports_path ], [ "About", admin_about_path ] ].each do |label, path| %>
|
||||
<% [ [ "Users", admin_users_path ], [ "Component Types", admin_component_types_path ], [ "Airports", admin_airports_path ], [ "Settings", edit_admin_settings_path ], [ "About", admin_about_path ] ].each do |label, path| %>
|
||||
<%= link_to label, path, class: "block px-4 py-2.5 hover:bg-slate-100" %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
@@ -53,7 +53,7 @@
|
||||
Admin <span aria-hidden="true" class="text-xs">▾</span>
|
||||
</summary>
|
||||
<div class="absolute right-0 z-30 mt-2 w-48 rounded-md bg-surface py-1 text-slate-700 shadow-lg ring-1 ring-slate-200">
|
||||
<% [ [ "Users", admin_users_path ], [ "Component Types", admin_component_types_path ], [ "Airports", admin_airports_path ], [ "About", admin_about_path ] ].each do |label, path| %>
|
||||
<% [ [ "Users", admin_users_path ], [ "Component Types", admin_component_types_path ], [ "Airports", admin_airports_path ], [ "Settings", edit_admin_settings_path ], [ "About", admin_about_path ] ].each do |label, path| %>
|
||||
<%= link_to label, path, class: [ "block px-4 py-2 text-sm hover:bg-slate-100", ("font-semibold text-sky-700" if current_page?(path)) ] %>
|
||||
<% end %>
|
||||
</div>
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
<%= f.field :issue_reported, as: :textarea, label: "Issue", required: true, autofocus: true %>
|
||||
<%= f.field :component_id, as: :select, label: "Component (optional)", collection: component_options(aircraft) %>
|
||||
<%= f.field :attachments, as: :file, multiple: true, label: squawk.attachments.attached? ? "Add photos / files" : "Photos / files",
|
||||
hint: "Select several at once. Images, PDFs or text, up to 50 MB each." %>
|
||||
hint: "Select several at once. Images, PDFs or text, up to #{Setting.max_upload_mb} MB each." %>
|
||||
<% if squawk.persisted? && squawk.attachments.attached? %>
|
||||
<div>
|
||||
<p class="label">Remove attached files</p>
|
||||
|
||||
Reference in new issue
Block a user