|
| 1 | +<div class="container mx-auto px-4 py-8"> |
| 2 | + <h1 class="text-3xl font-bold mb-8">File Uploads</h1> |
| 3 | + |
| 4 | + <div id="flash"> |
| 5 | + <% if notice %> |
| 6 | + <div class="bg-green-100 border border-green-400 text-green-700 px-4 py-3 rounded mb-4"> |
| 7 | + <%= notice %> |
| 8 | + </div> |
| 9 | + <% end %> |
| 10 | + </div> |
| 11 | + |
| 12 | + <!-- Upload Form --> |
| 13 | + <div class="bg-white shadow-md rounded px-8 pt-6 pb-8 mb-8"> |
| 14 | + <h2 class="text-xl font-semibold mb-4">Upload a New File</h2> |
| 15 | + |
| 16 | + <%= render "form", upload: Upload.new %> |
| 17 | + </div> |
| 18 | + |
| 19 | + <!-- Uploads Table --> |
| 20 | + <div class="mb-8"> |
| 21 | + <h2 class="text-xl font-semibold mb-4">Uploaded Files</h2> |
| 22 | + <div class="overflow-x-auto"> |
| 23 | + <table class="min-w-full bg-white shadow-md rounded"> |
| 24 | + <thead class="bg-gray-100"> |
| 25 | + <tr> |
| 26 | + <th class="px-4 py-2 text-left">ID</th> |
| 27 | + <th class="px-4 py-2 text-left">Name</th> |
| 28 | + <th class="px-4 py-2 text-left">File</th> |
| 29 | + <th class="px-4 py-2 text-left">Created At</th> |
| 30 | + <th class="px-4 py-2 text-left">Actions</th> |
| 31 | + </tr> |
| 32 | + </thead> |
| 33 | + <tbody id="uploads"> |
| 34 | + <% @uploads.each do |upload| %> |
| 35 | + <tr class="border-t" id="<%= dom_id(upload) %>"> |
| 36 | + <td class="px-4 py-2"><%= upload.id %></td> |
| 37 | + <td class="px-4 py-2"><%= upload.name %></td> |
| 38 | + <td class="px-4 py-2"> |
| 39 | + <% if upload.file.attached? %> |
| 40 | + <%= link_to upload.file.filename, rails_blob_path(upload.file, disposition: "attachment"), class: "text-blue-500 hover:underline" %> |
| 41 | + <% end %> |
| 42 | + </td> |
| 43 | + <td class="px-4 py-2"><%= upload.created_at.strftime("%Y-%m-%d %H:%M") %></td> |
| 44 | + <td class="px-4 py-2"> |
| 45 | + <%= button_to "Delete", upload_path(upload), method: :delete, class: "bg-red-500 hover:bg-red-700 text-white text-sm py-1 px-2 rounded", data: { turbo_confirm: "Are you sure?" } %> |
| 46 | + </td> |
| 47 | + </tr> |
| 48 | + <% end %> |
| 49 | + </tbody> |
| 50 | + </table> |
| 51 | + </div> |
| 52 | + </div> |
| 53 | + |
| 54 | + <!-- Active Storage Attachments Table --> |
| 55 | + <div class="mb-8"> |
| 56 | + <h2 class="text-xl font-semibold mb-4">Active Storage Attachments</h2> |
| 57 | + <div class="overflow-x-auto"> |
| 58 | + <table class="min-w-full bg-white shadow-md rounded"> |
| 59 | + <thead class="bg-gray-100"> |
| 60 | + <tr> |
| 61 | + <th class="px-4 py-2 text-left">ID</th> |
| 62 | + <th class="px-4 py-2 text-left">Name</th> |
| 63 | + <th class="px-4 py-2 text-left">Record Type</th> |
| 64 | + <th class="px-4 py-2 text-left">Record ID</th> |
| 65 | + <th class="px-4 py-2 text-left">Blob ID</th> |
| 66 | + <th class="px-4 py-2 text-left">Created At</th> |
| 67 | + </tr> |
| 68 | + </thead> |
| 69 | + <tbody id="attachments"> |
| 70 | + <% @uploads.each do |upload| %> |
| 71 | + <% if upload.file.attached? %> |
| 72 | + <% attachment = upload.file.attachment %> |
| 73 | + <tr class="border-t" id="attachment_<%= attachment.id %>"> |
| 74 | + <td class="px-4 py-2"><%= attachment.id %></td> |
| 75 | + <td class="px-4 py-2"><%= attachment.name %></td> |
| 76 | + <td class="px-4 py-2"><%= attachment.record_type %></td> |
| 77 | + <td class="px-4 py-2"><%= attachment.record_id %></td> |
| 78 | + <td class="px-4 py-2"><%= attachment.blob_id %></td> |
| 79 | + <td class="px-4 py-2"><%= attachment.created_at.strftime("%Y-%m-%d %H:%M") %></td> |
| 80 | + </tr> |
| 81 | + <% end %> |
| 82 | + <% end %> |
| 83 | + </tbody> |
| 84 | + </table> |
| 85 | + </div> |
| 86 | + </div> |
| 87 | + |
| 88 | + <!-- Active Storage Blobs Table --> |
| 89 | + <div class="mb-8"> |
| 90 | + <h2 class="text-xl font-semibold mb-4">Active Storage Blobs</h2> |
| 91 | + <div class="overflow-x-auto"> |
| 92 | + <table class="min-w-full bg-white shadow-md rounded"> |
| 93 | + <thead class="bg-gray-100"> |
| 94 | + <tr> |
| 95 | + <th class="px-4 py-2 text-left">ID</th> |
| 96 | + <th class="px-4 py-2 text-left">Key</th> |
| 97 | + <th class="px-4 py-2 text-left">Filename</th> |
| 98 | + <th class="px-4 py-2 text-left">Content Type</th> |
| 99 | + <th class="px-4 py-2 text-left">Byte Size</th> |
| 100 | + <th class="px-4 py-2 text-left">Checksum</th> |
| 101 | + <th class="px-4 py-2 text-left">Created At</th> |
| 102 | + </tr> |
| 103 | + </thead> |
| 104 | + <tbody id="blobs"> |
| 105 | + <% @uploads.each do |upload| %> |
| 106 | + <% if upload.file.attached? %> |
| 107 | + <% blob = upload.file.blob %> |
| 108 | + <tr class="border-t" id="blob_<%= blob.id %>"> |
| 109 | + <td class="px-4 py-2"><%= blob.id %></td> |
| 110 | + <td class="px-4 py-2 text-xs font-mono"><%= truncate(blob.key, length: 20) %></td> |
| 111 | + <td class="px-4 py-2"><%= blob.filename %></td> |
| 112 | + <td class="px-4 py-2"><%= blob.content_type %></td> |
| 113 | + <td class="px-4 py-2"><%= number_to_human_size(blob.byte_size) %></td> |
| 114 | + <td class="px-4 py-2 text-xs font-mono"><%= truncate(blob.checksum, length: 15) %></td> |
| 115 | + <td class="px-4 py-2"><%= blob.created_at.strftime("%Y-%m-%d %H:%M") %></td> |
| 116 | + </tr> |
| 117 | + <% end %> |
| 118 | + <% end %> |
| 119 | + </tbody> |
| 120 | + </table> |
| 121 | + </div> |
| 122 | + </div> |
| 123 | +</div> |
0 commit comments