Skip to content

Commit

Permalink
Merge pull request #1102 from PRX/feat/display_media_timeout_errors
Browse files Browse the repository at this point in the history
Render processing view for stalled uploads
  • Loading branch information
radical-ube authored Oct 9, 2024
2 parents 1fcc8dd + c772143 commit d39a96c
Show file tree
Hide file tree
Showing 7 changed files with 36 additions and 8 deletions.
2 changes: 0 additions & 2 deletions app/views/episode_media/media/_media.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
<% if policy(media).create? %>
<%= render "episode_media/media/new", form: form, episode: episode, media: media %>
<% end %>
<% elsif upload_stalled?(media) %>
<%= render "episode_media/media/error", form: form, episode: episode, media: media, retryable: true %>
<% elsif upload_processing?(media) %>
<%= render "episode_media/media/processing", form: form, episode: episode, media: media %>
<% elsif upload_complete?(media) %>
Expand Down
9 changes: 9 additions & 0 deletions app/views/episode_media/media/_processing.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@
<% if media.file_size.present? %>
<small class="text-muted">(<%= number_to_human_size(media.file_size) %>)</small>
<% end %>
<% if upload_stalled?(media) %>
<%= link_to episode_media_path(media.episode, uploads_retry_params(form)), method: :put, class: "btn btn-sm btn-warning ms-2" do %>
<span class="material-icons">restart_alt</span> Retry
<% end %>
<% end %>
</div>

<% if policy(media).destroy? %>
Expand All @@ -22,6 +27,10 @@
<label><%= episode_media_label(episode, media) %></label>
</div>

<% if upload_stalled?(media) %>
<small class="text-muted"><%= t(".still_processing") %></small>
<% end %>
<%# just keep polling until the file finishes processing %>
<%= link_to "", request.fullpath, class: "d-none", data: {controller: "polling"} %>
</div>
4 changes: 1 addition & 3 deletions app/views/episode_transcripts/transcripts/_form.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,8 @@
<% if policy(transcript).create? %>
<%= render "episode_transcripts/transcripts/new", form: form, transcript: transcript %>
<% end %>
<% elsif upload_stalled?(transcript) %>
<%= render "episode_transcripts/transcripts/error", form: form, transcript: transcript, delete_path: delete_path, retry_path: retry_path %>
<% elsif upload_processing?(transcript) %>
<%= render "episode_transcripts/transcripts/processing", form: form, transcript: transcript, delete_path: delete_path %>
<%= render "episode_transcripts/transcripts/processing", form: form, transcript: transcript, delete_path: delete_path, retry_path: retry_path %>
<% elsif upload_complete?(transcript) %>
<%= render "episode_transcripts/transcripts/complete", form: form, transcript: transcript, delete_path: delete_path %>
<% else %>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@
<% if transcript.file_size.present? %>
<small class="text-muted">(<%= number_to_human_size(transcript.file_size) %>)</small>
<% end %>
<% if upload_stalled?(transcript) %>
<%= link_to retry_path, method: :put, class: "btn btn-sm btn-warning ms-2" do %>
<span class="material-icons">restart_alt</span> <%= t(".retry") %>
<% end %>
<% end %>
</div>

<% if policy(transcript).destroy? %>
Expand All @@ -22,6 +27,10 @@
<label><%= t(".transcript_file") %></label>
</div>

<% if upload_stalled?(transcript) %>
<small class="text-muted"><%= t(".still_processing") %></small>
<% end %>
<%# just keep polling until the file finishes processing %>
<%= link_to "", request.fullpath, class: "d-none", data: {controller: "polling"} %>
</div>
4 changes: 1 addition & 3 deletions app/views/images/_form.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,8 @@
<% if policy(image).create? %>
<%= render "images/new", form: form, image: image %>
<% end %>
<% elsif upload_stalled?(image) %>
<%= render "images/error", form: form, image: image, delete_path: delete_path, retry_path: retry_path %>
<% elsif upload_processing?(image) %>
<%= render "images/processing", form: form, image: image, delete_path: delete_path %>
<%= render "images/processing", form: form, image: image, delete_path: delete_path, retry_path: retry_path %>
<% elsif upload_complete?(image) %>
<%= render "images/complete", form: form, image: image, delete_path: delete_path %>
<% else %>
Expand Down
10 changes: 10 additions & 0 deletions app/views/images/_processing.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,21 @@
<% if image.size.present? %>
<small class="text-muted">(<%= number_to_human_size(image.size) %>)</small>
<% end %>
<% if upload_stalled?(image) %>
<%= link_to retry_path, method: :put, class: "btn btn-sm btn-warning ms-2" do %>
<span class="material-icons">restart_alt</span> <%= t("images.label.retry") %>
<% end %>
<% end %>
</div>

<label><%= t("images.label.image_file") %></label>
</div>

<% if upload_stalled?(image) %>
<small class="text-muted"><%= t(".still_processing") %></small>
<% end %>
<%# just keep polling until the file finishes processing %>
<%= link_to "", request.fullpath, class: "d-none", data: {controller: "polling"} %>
Expand Down
6 changes: 6 additions & 0 deletions config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ defaults:
destroy: &destroy
success: "%{model} deleted successfully."
failure: "There was a problem deleting the %{model}."
uploads:
still_processing: &still_processing Processing is taking longer than expected. Thank you for your patience. You can continue waiting or retry.

en:
# general config
Expand Down Expand Up @@ -649,6 +651,7 @@ en:
title: MP3 Not Provided
processing:
hint: Processing
still_processing: *still_processing
segmenter:
modal:
label:
Expand Down Expand Up @@ -731,6 +734,7 @@ en:
<<: *transcript_labels
loading: Loading...
processing: Processing
still_processing: *still_processing
complete:
<<: *transcript_labels
error:
Expand Down Expand Up @@ -881,6 +885,8 @@ en:
size: Size
status: Status
upload: Upload a file or drag it here
processing:
still_processing: *still_processing
title:
episode_image: Cover Image
feed_image: Thumbnail Image
Expand Down

0 comments on commit d39a96c

Please sign in to comment.