From c547ebc4c51678e16df7ceb2f94b45d3711e1fb8 Mon Sep 17 00:00:00 2001 From: Aleksander Chlebowski Date: Wed, 21 Feb 2024 18:37:45 +0100 Subject: [PATCH 1/9] add shinybusy dependency --- .pre-commit-config.yaml | 1 + DESCRIPTION | 10 ++++++---- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 3b16eb4c..b206a2f8 100755 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -26,6 +26,7 @@ repos: - R6 - rmarkdown - shiny + - shinybusy - shinyWidgets - yaml - zip diff --git a/DESCRIPTION b/DESCRIPTION index fcee1658..411caf28 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -32,6 +32,7 @@ Imports: R6, rmarkdown (>= 2.19), shiny (>= 1.6.0), + shinybusy, shinyWidgets (>= 0.5.1), yaml (>= 1.1.0), zip (>= 1.1.0) @@ -50,10 +51,11 @@ RdMacros: lifecycle Config/Needs/verdepcheck: rstudio/bslib, mllg/checkmate, rstudio/htmltools, yihui/knitr, r-lib/lifecycle, r-lib/R6, - rstudio/rmarkdown, rstudio/shiny, dreamRs/shinyWidgets, - yaml=vubiostat/r-yaml, r-lib/zip, davidgohel/flextable, rstudio/DT, - yihui/formatR, tidyverse/ggplot2, deepayan/lattice, cran/png, - insightsengineering/rtables, r-lib/testthat, rstudio/tinytex + rstudio/rmarkdown, rstudio/shiny, dreamRs/shinybusy, + dreamRs/shinyWidgets, yaml=vubiostat/r-yaml, r-lib/zip, + davidgohel/flextable, rstudio/DT, yihui/formatR, tidyverse/ggplot2, + deepayan/lattice, cran/png, insightsengineering/rtables, + r-lib/testthat, rstudio/tinytex Config/Needs/website: insightsengineering/nesttemplate Encoding: UTF-8 Language: en-US From 4d1b743af05d0c86e36c39b38ab3e7278b48ac1f Mon Sep 17 00:00:00 2001 From: Aleksander Chlebowski Date: Wed, 21 Feb 2024 18:38:02 +0100 Subject: [PATCH 2/9] block download button --- R/DownloadModule.R | 2 ++ 1 file changed, 2 insertions(+) diff --git a/R/DownloadModule.R b/R/DownloadModule.R index 3fcca7c2..ec03b066 100644 --- a/R/DownloadModule.R +++ b/R/DownloadModule.R @@ -141,10 +141,12 @@ download_report_button_srv <- function(id, }, content = function(file) { shiny::showNotification("Rendering and Downloading the document.") + shinybusy::block(id = ns("download_data"), text = NULL, type = "dots", messageFontSize = "0px") input_list <- lapply(names(rmd_yaml_args), function(x) input[[x]]) names(input_list) <- names(rmd_yaml_args) if (is.logical(input$showrcode)) global_knitr[["echo"]] <- input$showrcode report_render_and_compress(reporter, input_list, global_knitr, file) + shinybusy::unblock(id = ns("download_data")) }, contentType = "application/zip" ) From abb201706c4e7def5cae7ebbbdd05656ef09c023 Mon Sep 17 00:00:00 2001 From: Aleksander Chlebowski Date: Wed, 21 Feb 2024 18:41:14 +0100 Subject: [PATCH 3/9] block download button in previewer --- R/Previewer.R | 2 ++ 1 file changed, 2 insertions(+) diff --git a/R/Previewer.R b/R/Previewer.R index 1a01f224..52c7fcb9 100644 --- a/R/Previewer.R +++ b/R/Previewer.R @@ -193,10 +193,12 @@ reporter_previewer_srv <- function(id, }, content = function(file) { shiny::showNotification("Rendering and Downloading the document.") + shinybusy::block(id = ns("download_data_prev"), text = NULL, type = "dots", messageFontSize = "0px") input_list <- lapply(names(rmd_yaml_args), function(x) input[[x]]) names(input_list) <- names(rmd_yaml_args) if (is.logical(input$showrcode)) global_knitr[["echo"]] <- input$showrcode report_render_and_compress(reporter, input_list, global_knitr, file) + shinybusy::unblock(id = ns("download_data_prev")) }, contentType = "application/zip" ) From 6df5e4d458c2dde92c1181a568b9d80f601bc828 Mon Sep 17 00:00:00 2001 From: Aleksander Chlebowski Date: Wed, 21 Feb 2024 18:41:41 +0100 Subject: [PATCH 4/9] remove superfluous arguments --- R/DownloadModule.R | 2 +- R/Previewer.R | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/R/DownloadModule.R b/R/DownloadModule.R index ec03b066..107de305 100644 --- a/R/DownloadModule.R +++ b/R/DownloadModule.R @@ -141,7 +141,7 @@ download_report_button_srv <- function(id, }, content = function(file) { shiny::showNotification("Rendering and Downloading the document.") - shinybusy::block(id = ns("download_data"), text = NULL, type = "dots", messageFontSize = "0px") + shinybusy::block(id = ns("download_data"), text = NULL, type = "dots") input_list <- lapply(names(rmd_yaml_args), function(x) input[[x]]) names(input_list) <- names(rmd_yaml_args) if (is.logical(input$showrcode)) global_knitr[["echo"]] <- input$showrcode diff --git a/R/Previewer.R b/R/Previewer.R index 52c7fcb9..15d3cc4d 100644 --- a/R/Previewer.R +++ b/R/Previewer.R @@ -193,7 +193,7 @@ reporter_previewer_srv <- function(id, }, content = function(file) { shiny::showNotification("Rendering and Downloading the document.") - shinybusy::block(id = ns("download_data_prev"), text = NULL, type = "dots", messageFontSize = "0px") + shinybusy::block(id = ns("download_data_prev"), text = NULL, type = "dots") input_list <- lapply(names(rmd_yaml_args), function(x) input[[x]]) names(input_list) <- names(rmd_yaml_args) if (is.logical(input$showrcode)) global_knitr[["echo"]] <- input$showrcode From 85a6c70527a354dd5ad63a769a8b6b5e66bae14c Mon Sep 17 00:00:00 2001 From: Aleksander Chlebowski Date: Wed, 21 Feb 2024 18:43:27 +0100 Subject: [PATCH 5/9] add Sys.sleep for demonstration --- R/DownloadModule.R | 1 + R/Previewer.R | 1 + 2 files changed, 2 insertions(+) diff --git a/R/DownloadModule.R b/R/DownloadModule.R index 107de305..b7c35861 100644 --- a/R/DownloadModule.R +++ b/R/DownloadModule.R @@ -142,6 +142,7 @@ download_report_button_srv <- function(id, content = function(file) { shiny::showNotification("Rendering and Downloading the document.") shinybusy::block(id = ns("download_data"), text = NULL, type = "dots") + Sys.sleep(3) input_list <- lapply(names(rmd_yaml_args), function(x) input[[x]]) names(input_list) <- names(rmd_yaml_args) if (is.logical(input$showrcode)) global_knitr[["echo"]] <- input$showrcode diff --git a/R/Previewer.R b/R/Previewer.R index 15d3cc4d..f035ebc4 100644 --- a/R/Previewer.R +++ b/R/Previewer.R @@ -194,6 +194,7 @@ reporter_previewer_srv <- function(id, content = function(file) { shiny::showNotification("Rendering and Downloading the document.") shinybusy::block(id = ns("download_data_prev"), text = NULL, type = "dots") + Sys.sleep(3) input_list <- lapply(names(rmd_yaml_args), function(x) input[[x]]) names(input_list) <- names(rmd_yaml_args) if (is.logical(input$showrcode)) global_knitr[["echo"]] <- input$showrcode From 0a61fee5662b394e3bd7fa050bd339b56c64f98a Mon Sep 17 00:00:00 2001 From: Aleksander Chlebowski Date: Fri, 23 Feb 2024 11:59:03 +0100 Subject: [PATCH 6/9] change NULL to empty string in text --- R/DownloadModule.R | 2 +- R/Previewer.R | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/R/DownloadModule.R b/R/DownloadModule.R index b7c35861..fd23f04b 100644 --- a/R/DownloadModule.R +++ b/R/DownloadModule.R @@ -141,7 +141,7 @@ download_report_button_srv <- function(id, }, content = function(file) { shiny::showNotification("Rendering and Downloading the document.") - shinybusy::block(id = ns("download_data"), text = NULL, type = "dots") + shinybusy::block(id = ns("download_data"), text = "", type = "dots") Sys.sleep(3) input_list <- lapply(names(rmd_yaml_args), function(x) input[[x]]) names(input_list) <- names(rmd_yaml_args) diff --git a/R/Previewer.R b/R/Previewer.R index f035ebc4..2cb9b88d 100644 --- a/R/Previewer.R +++ b/R/Previewer.R @@ -193,7 +193,7 @@ reporter_previewer_srv <- function(id, }, content = function(file) { shiny::showNotification("Rendering and Downloading the document.") - shinybusy::block(id = ns("download_data_prev"), text = NULL, type = "dots") + shinybusy::block(id = ns("download_data_prev"), text = "", type = "dots") Sys.sleep(3) input_list <- lapply(names(rmd_yaml_args), function(x) input[[x]]) names(input_list) <- names(rmd_yaml_args) From b77307bf3373b7431245dd6ad889cb4d8e549744 Mon Sep 17 00:00:00 2001 From: Aleksander Chlebowski Date: Fri, 23 Feb 2024 12:12:17 +0100 Subject: [PATCH 7/9] prevent oversizing blocked element --- inst/css/Previewer.css | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/inst/css/Previewer.css b/inst/css/Previewer.css index 20048eee..ee4ff195 100644 --- a/inst/css/Previewer.css +++ b/inst/css/Previewer.css @@ -22,3 +22,8 @@ a.disabled { margin-top:10px; color:#337ab7; } + +/* prevents oversizing elements covered by shinybusy::block */ +.nx-block-temporary-position { + min-height: 0 !important; +} From f788e51ea5f90f69d0f7aa11604e5a1e99271453 Mon Sep 17 00:00:00 2001 From: Aleksander Chlebowski Date: Fri, 23 Feb 2024 12:38:44 +0100 Subject: [PATCH 8/9] amend NEWS --- NEWS.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/NEWS.md b/NEWS.md index b6c4a5b8..f240c931 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,5 +1,9 @@ # teal.reporter 0.3.0.9003 +### Enhancements + +* Added blocking of "Download" buttons while report is rendering, using the `shinybusy` package. + # teal.reporter 0.3.0 ### Enhancements From 09f7d655a027c1423b968fec4d5763ab803548d3 Mon Sep 17 00:00:00 2001 From: Aleksander Chlebowski Date: Wed, 28 Feb 2024 09:23:52 +0100 Subject: [PATCH 9/9] remove Sys.sleep --- R/DownloadModule.R | 1 - R/Previewer.R | 1 - 2 files changed, 2 deletions(-) diff --git a/R/DownloadModule.R b/R/DownloadModule.R index fd23f04b..c0e8f3b3 100644 --- a/R/DownloadModule.R +++ b/R/DownloadModule.R @@ -142,7 +142,6 @@ download_report_button_srv <- function(id, content = function(file) { shiny::showNotification("Rendering and Downloading the document.") shinybusy::block(id = ns("download_data"), text = "", type = "dots") - Sys.sleep(3) input_list <- lapply(names(rmd_yaml_args), function(x) input[[x]]) names(input_list) <- names(rmd_yaml_args) if (is.logical(input$showrcode)) global_knitr[["echo"]] <- input$showrcode diff --git a/R/Previewer.R b/R/Previewer.R index 2cb9b88d..883ad02f 100644 --- a/R/Previewer.R +++ b/R/Previewer.R @@ -194,7 +194,6 @@ reporter_previewer_srv <- function(id, content = function(file) { shiny::showNotification("Rendering and Downloading the document.") shinybusy::block(id = ns("download_data_prev"), text = "", type = "dots") - Sys.sleep(3) input_list <- lapply(names(rmd_yaml_args), function(x) input[[x]]) names(input_list) <- names(rmd_yaml_args) if (is.logical(input$showrcode)) global_knitr[["echo"]] <- input$showrcode