feat(exports): turbo poll for pending exports

This commit is contained in:
Colin Darie 2023-09-20 13:03:11 +02:00
parent ed057737a5
commit 3af93735a3
No known key found for this signature in database
GPG key ID: 8C76CADD40253590
4 changed files with 12 additions and 2 deletions

View file

@ -1,4 +1,4 @@
%ul.fr-raw-list %ul#exports-list.fr-raw-list
- @exports.each do |export| - @exports.each do |export|
%li.fr-mb-3w %li.fr-mb-3w
.flex .flex

View file

@ -231,6 +231,11 @@ module Instructeurs
value: DateTime.current, value: DateTime.current,
expires: Export::MAX_DUREE_GENERATION + Export::MAX_DUREE_CONSERVATION_EXPORT expires: Export::MAX_DUREE_GENERATION + Export::MAX_DUREE_CONSERVATION_EXPORT
} }
respond_to do |format|
format.turbo_stream
format.html
end
end end
def email_usagers def email_usagers

View file

@ -10,8 +10,10 @@
= render Dsfr::CalloutComponent.new(title: nil) do |c| = render Dsfr::CalloutComponent.new(title: nil) do |c|
- c.with_body do - c.with_body do
%p= t('.export_description') %p= t('.export_description')
- if @exports.present? - if @exports.present?
= render Dossiers::ExportLinkComponent.new(procedure: @procedure, exports: @exports, statut: @statut, count: @dossiers_count, class_btn: 'fr-btn--tertiary', export_url: method(:download_export_instructeur_procedure_path)) %div{ data: @exports.any?(&:pending?) ? { controller: "turbo-poll", turbo_poll_url_value: "", turbo_poll_interval_value: 10_000, turbo_poll_max_checks_value: 6 } : {} }
= render Dossiers::ExportLinkComponent.new(procedure: @procedure, exports: @exports, statut: @statut, count: @dossiers_count, class_btn: 'fr-btn--tertiary', export_url: method(:download_export_instructeur_procedure_path))
- else - else
= t('.no_export_html', expiration_time: Export::MAX_DUREE_CONSERVATION_EXPORT.in_hours.to_i ) = t('.no_export_html', expiration_time: Export::MAX_DUREE_CONSERVATION_EXPORT.in_hours.to_i )

View file

@ -0,0 +1,3 @@
= turbo_stream.replace "exports-list" do
- if @exports.present?
= render Dossiers::ExportLinkComponent.new(procedure: @procedure, exports: @exports, statut: @statut, count: @dossiers_count, class_btn: 'fr-btn--tertiary', export_url: method(:download_export_instructeur_procedure_path))