uploads: add column for error messages.
Change it so uploads store errors in an `error` column instead of in the `status` field.
This commit is contained in:
@@ -115,12 +115,12 @@ export default class FileUploadComponent {
|
||||
} else {
|
||||
window.location.assign(url);
|
||||
}
|
||||
} else {
|
||||
} else if (upload.status === "error") {
|
||||
this.$dropzone.removeClass("success");
|
||||
this.$component.find("progress").addClass("hidden");
|
||||
this.$component.find("input").removeAttr("disabled");
|
||||
|
||||
Utility.error(upload.status);
|
||||
Utility.error(`Upload failed: ${upload.error}.`);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -20,6 +20,7 @@ class Upload < ApplicationRecord
|
||||
scope :pending, -> { where(status: "pending") }
|
||||
scope :preprocessed, -> { where(status: "preprocessed") }
|
||||
scope :completed, -> { where(status: "completed") }
|
||||
scope :failed, -> { where(status: "error") }
|
||||
|
||||
def self.visible(user)
|
||||
if user.is_admin?
|
||||
@@ -43,7 +44,7 @@ class Upload < ApplicationRecord
|
||||
end
|
||||
|
||||
def is_errored?
|
||||
status.match?(/error:/)
|
||||
status == "error"
|
||||
end
|
||||
end
|
||||
|
||||
@@ -102,7 +103,7 @@ class Upload < ApplicationRecord
|
||||
media_asset = MediaAsset.upload!(media_file)
|
||||
update!(media_assets: [media_asset], status: "completed")
|
||||
rescue Exception => e
|
||||
update!(status: "error: #{e.message}")
|
||||
update!(status: "error", error: e.message)
|
||||
end
|
||||
|
||||
def self.available_includes
|
||||
|
||||
@@ -59,7 +59,7 @@
|
||||
<div>
|
||||
<strong>Error</strong>
|
||||
<span>
|
||||
<%= upload.status.delete_prefix("error: ") %>
|
||||
<%= upload.error %>
|
||||
</span>
|
||||
</div>
|
||||
<% end %>
|
||||
@@ -72,11 +72,7 @@
|
||||
<% end %>
|
||||
|
||||
<% t.column :status do |upload| %>
|
||||
<% if upload.is_errored? %>
|
||||
error
|
||||
<% elsif !upload.is_completed? %>
|
||||
<%= upload.status %>
|
||||
<% end %>
|
||||
<%= upload.status %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
<% end %>
|
||||
|
||||
<% if @upload.is_errored? %>
|
||||
<p><%= @upload.status %></p>
|
||||
<p>Error: <%= @upload.error %>.</p>
|
||||
<% elsif @upload.is_pending? && @upload.source.present? %>
|
||||
<p>Preparing to upload <%= external_link_to @upload.source %>...</p>
|
||||
<% elsif @upload.is_processing? && @upload.source.present? %>
|
||||
|
||||
Reference in New Issue
Block a user