Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add feature so a user knows their download is coming and they should not to hit the button more than once #172

Open
cristinamullin opened this issue Nov 21, 2024 · 2 comments
Assignees

Comments

@cristinamullin
Copy link
Collaborator

Is your feature request related to a problem? Please describe.

When a user clicks "Download Working Dataset" or "Download Final Dataset" the application does not do anything right away. It can take over a minute for the file to download.

Describe the solution you'd like

It would be helpful if there was a pop up to let the user know it is running and that they should not hit the button again. It could be the same as the pop up we use for the flag page to let a user know they are running:

image

Additional context

image
@JamesBisese JamesBisese self-assigned this Dec 4, 2024
@JamesBisese
Copy link
Collaborator

JamesBisese commented Dec 26, 2024

Additionally - the download buttons are active by default. They should be inactive or hidden until there is data loaded.

I think the TADA_summary panel maybe should be hidden until there is data. But instead it is displayed always. It has something to do with setting tadat$raw = NULL - which makes req(tadat$raw) == TRUE

I added a variable tadat$ready_for_download that is created in the mod_query_data.initializeTable(). This toggles the visibility of the download buttons

    # Download ... Dataset button - only appears if there data exists in the app already
    output$dwn_working <- shiny::renderUI({
      shiny::req(tadat$ready_for_download)
      shinyjs::disabled(shiny::downloadButton(ns("download_working"),
        "Download Working Dataset (.zip)",
        style = "color: #fff; background-color: #337ab7; border-color: #2e6da4; margin-bottom: 10px;",
        contentType = "application/zip"
      ))
    })

@JamesBisese
Copy link
Collaborator

JamesBisese commented Dec 27, 2024

I figured out how to disable the button once it is clicked. The part that is not shown on the googles, is that the id for elements in this panel have 2 parts - the id of the panel ('TADA_summary_1') and the id of the button 'download_button'). So the code for disabling and enabling reads

output$download_working <- shiny::downloadHandler(
      filename = function() {
        paste0(tadat$default_outfile, "_working.zip")
      },
      content = function(fname) {
        shinyjs::disable("TADA_summary_1-download_working")
        on.exit(shinyjs::enable("TADA_summary_1-download_working"))
....

Then I realized I should use a spinner to stop the user (just like the write up for the ticket suggests), so the final fix did not really need to turn off the button. Instead freeze the whole app while the file is downloading

output$download_working <- shiny::downloadHandler(
      filename = function() {
        paste0(tadat$default_outfile, "_working.zip")
      },
      content = function(fname) {
        shinybusy::show_modal_spinner(
          spin = "double-bounce",
          color = "#0071bc",
          text = "Downloading Working Dataset...",
          session = shiny::getDefaultReactiveDomain()
        )
        on.exit(shinybusy::remove_modal_spinner(session = shiny::getDefaultReactiveDomain()))
....

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants