active_storage_dashboard 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,203 @@
1
+ <h1 class="page-title">Blob Details</h1>
2
+
3
+ <% if previewable_blob?(@blob) %>
4
+ <div class="card">
5
+ <div class="card-header">Media Preview</div>
6
+ <div class="card-body media-preview">
7
+ <% if @blob.content_type&.start_with?('image/') %>
8
+ <div class="image-preview">
9
+ <img src="<%= download_blob_path(@blob, disposition: 'inline') %>" alt="<%= @blob.filename %>" />
10
+ </div>
11
+ <% elsif @blob.content_type&.start_with?('video/') %>
12
+ <div class="video-preview">
13
+ <video controls width="100%">
14
+ <source src="<%= download_blob_path(@blob, disposition: 'inline') %>" type="<%= @blob.content_type %>">
15
+ Your browser does not support the video tag.
16
+ </video>
17
+ </div>
18
+ <% elsif @blob.content_type&.start_with?('audio/') %>
19
+ <div class="audio-preview">
20
+ <audio controls>
21
+ <source src="<%= download_blob_path(@blob, disposition: 'inline') %>" type="<%= @blob.content_type %>">
22
+ Your browser does not support the audio tag.
23
+ </audio>
24
+ </div>
25
+ <% elsif @blob.content_type == 'application/pdf' %>
26
+ <div class="pdf-preview">
27
+ <object data="<%= download_blob_path(@blob, disposition: 'inline') %>" type="application/pdf" width="100%" height="600px">
28
+ <p>It appears your browser doesn't support embedded PDFs.
29
+ <a href="<%= download_blob_path(@blob, disposition: 'inline') %>">Click here to download the PDF</a>.</p>
30
+ </object>
31
+ </div>
32
+ <% elsif @blob.respond_to?(:preview) && @blob.previewable? %>
33
+ <div class="preview-image">
34
+ <% if Rails.gem_version >= Gem::Version.new('6.1') %>
35
+ <%= blob_preview(@blob) %>
36
+ <% else %>
37
+ <p>Preview not available. <a href="<%= download_blob_path(@blob, disposition: 'inline') %>">Download to view</a>.</p>
38
+ <% end %>
39
+ </div>
40
+ <% end %>
41
+ </div>
42
+ </div>
43
+ <% end %>
44
+
45
+ <div class="card">
46
+ <div class="card-header">Blob Information</div>
47
+ <div class="card-body">
48
+ <table>
49
+ <tr>
50
+ <th>ID</th>
51
+ <td><%= @blob.id %></td>
52
+ </tr>
53
+ <tr>
54
+ <th>Key</th>
55
+ <td><%= @blob.key %></td>
56
+ </tr>
57
+ <tr>
58
+ <th>Filename</th>
59
+ <td><%= @blob.filename %></td>
60
+ </tr>
61
+ <tr>
62
+ <th>Content Type</th>
63
+ <td><%= @blob.content_type || 'Unknown' %></td>
64
+ </tr>
65
+ <tr>
66
+ <th>Byte Size</th>
67
+ <td><%= format_bytes(@blob.byte_size) %></td>
68
+ </tr>
69
+ <tr>
70
+ <th>Service Name</th>
71
+ <td><%= @blob.service_name %></td>
72
+ </tr>
73
+ <tr>
74
+ <th>Checksum</th>
75
+ <td><%= @blob.checksum || 'N/A' %></td>
76
+ </tr>
77
+ <tr>
78
+ <th>Created At</th>
79
+ <td><%= @blob.created_at.strftime('%Y-%m-%d %H:%M:%S') %></td>
80
+ </tr>
81
+ </table>
82
+ </div>
83
+ </div>
84
+
85
+ <% if @blob.metadata.present? %>
86
+ <div class="card">
87
+ <div class="card-header">Metadata</div>
88
+ <div class="card-body">
89
+ <pre><%= JSON.pretty_generate(JSON.parse(@blob.metadata)) rescue @blob.metadata %></pre>
90
+ </div>
91
+ </div>
92
+ <% end %>
93
+
94
+ <div class="card">
95
+ <div class="card-header">Attachments (<%= @attachments.size %>)</div>
96
+ <div class="card-body">
97
+ <% if @attachments.any? %>
98
+ <table>
99
+ <thead>
100
+ <tr>
101
+ <th>ID</th>
102
+ <th>Name</th>
103
+ <th>Record Type</th>
104
+ <th>Record ID</th>
105
+ <th>Created At</th>
106
+ <th>Actions</th>
107
+ </tr>
108
+ </thead>
109
+ <tbody>
110
+ <% @attachments.each do |attachment| %>
111
+ <tr>
112
+ <td><%= attachment.id %></td>
113
+ <td><%= attachment.name %></td>
114
+ <td><%= attachment.record_type %></td>
115
+ <td><%= attachment.record_id %></td>
116
+ <td><%= attachment.created_at.strftime('%Y-%m-%d %H:%M') %></td>
117
+ <td>
118
+ <a href="<%= attachment_path(attachment) %>">View</a>
119
+ </td>
120
+ </tr>
121
+ <% end %>
122
+ </tbody>
123
+ </table>
124
+ <% else %>
125
+ <p>No attachments found for this blob.</p>
126
+ <% end %>
127
+ </div>
128
+ </div>
129
+
130
+ <% if defined?(ActiveStorage::VariantRecord) && @variant_records.any? %>
131
+ <div class="card">
132
+ <div class="card-header">Variant Records (<%= @variant_records.size %>)</div>
133
+ <div class="card-body">
134
+ <table>
135
+ <thead>
136
+ <tr>
137
+ <th>ID</th>
138
+ <th>Variation Digest</th>
139
+ <th>Actions</th>
140
+ </tr>
141
+ </thead>
142
+ <tbody>
143
+ <% @variant_records.each do |variant_record| %>
144
+ <tr>
145
+ <td><%= variant_record.id %></td>
146
+ <td><%= variant_record.variation_digest %></td>
147
+ <td>
148
+ <a href="<%= variant_record_path(variant_record) %>">View</a>
149
+ </td>
150
+ </tr>
151
+ <% end %>
152
+ </tbody>
153
+ </table>
154
+ </div>
155
+ </div>
156
+ <% end %>
157
+
158
+ <div class="card-body">
159
+ <a href="<%= blobs_path %>" class="back-link">← Back to Blobs</a>
160
+ <a href="<%= download_blob_path(@blob) %>" class="download-btn">Download File</a>
161
+ </div>
162
+
163
+ <style>
164
+ .media-preview {
165
+ display: flex;
166
+ justify-content: center;
167
+ align-items: center;
168
+ padding: 20px;
169
+ background: #f8f9fa;
170
+ border-radius: 4px;
171
+ overflow: hidden;
172
+ }
173
+
174
+ .image-preview {
175
+ max-width: 100%;
176
+ text-align: center;
177
+ }
178
+
179
+ .image-preview img {
180
+ max-width: 100%;
181
+ max-height: 600px;
182
+ border-radius: 4px;
183
+ box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
184
+ }
185
+
186
+ .video-preview, .audio-preview, .pdf-preview {
187
+ width: 100%;
188
+ }
189
+
190
+ .audio-preview {
191
+ padding: 20px 0;
192
+ }
193
+
194
+ audio {
195
+ width: 100%;
196
+ }
197
+
198
+ .preview-image img {
199
+ max-width: 100%;
200
+ max-height: 600px;
201
+ border-radius: 4px;
202
+ }
203
+ </style>