From d55da9a3ea88ebd38daf01c36d05081964f0068b Mon Sep 17 00:00:00 2001 From: Lea Seep <74967328+LeaSeep@users.noreply.github.com> Date: Wed, 30 Oct 2024 13:16:24 +0100 Subject: [PATCH] add waiters show/hide to all R Code Download (#351) * add waiters show/hide to all R Code Download * added explicit waiter; tried as reactive with waiter <- reactive({Waiter$new}) and then waiter()$show - did not work --- .../shinyApp/R/enrichment_analysis/server.R | 7 +++++ program/shinyApp/R/heatmap/server.R | 7 +++++ program/shinyApp/R/pca/server.R | 31 +++++++++++++++++-- .../shinyApp/R/sample_correlation/server.R | 7 +++++ .../shinyApp/R/significance_analysis/server.R | 7 +++++ .../shinyApp/R/significance_analysis/util.R | 28 +++++++++++++++++ .../R/single_gene_visualisation/server.R | 7 +++++ program/shinyApp/server.R | 14 +++++++-- 8 files changed, 103 insertions(+), 5 deletions(-) diff --git a/program/shinyApp/R/enrichment_analysis/server.R b/program/shinyApp/R/enrichment_analysis/server.R index e46d2e39..bb6387a4 100644 --- a/program/shinyApp/R/enrichment_analysis/server.R +++ b/program/shinyApp/R/enrichment_analysis/server.R @@ -47,6 +47,12 @@ enrichment_analysis_geneset_server <- function( paste0("ShinyOmics_Rcode2Reproduce_", Sys.Date(), ".zip") }, content = function(file){ + waiter <- Waiter$new( + html = LOADING_SCREEN, + color = "#3897F147", + hide_on_render = FALSE + ) + waiter$show() # tmp <- getUserReactiveValues(input) # par_tmp$Enrichment[names(tmp)] <<- tmp envList <- list( @@ -81,6 +87,7 @@ enrichment_analysis_geneset_server <- function( files = dir(temp_directory), root = temp_directory ) + waiter$hide() }, contentType = "application/zip" ) diff --git a/program/shinyApp/R/heatmap/server.R b/program/shinyApp/R/heatmap/server.R index 292192e7..32db7923 100644 --- a/program/shinyApp/R/heatmap/server.R +++ b/program/shinyApp/R/heatmap/server.R @@ -283,6 +283,12 @@ heatmap_server <- function(id, data, params, updates){ paste0("ShinyOmics_Rcode2Reproduce_", Sys.Date(), ".zip") }, content = function(file){ + waiter <- Waiter$new( + html = LOADING_SCREEN, + color = "#3897F147", + hide_on_render = FALSE + ) + waiter$show() envList <- list( res_tmp = res_tmp[[session$token]], par_tmp = par_tmp[[session$token]] @@ -310,6 +316,7 @@ heatmap_server <- function(id, data, params, updates){ files = dir(temp_directory), root = temp_directory ) + waiter$hide() }, contentType = "application/zip" ) diff --git a/program/shinyApp/R/pca/server.R b/program/shinyApp/R/pca/server.R index 05c5bf70..7718262e 100644 --- a/program/shinyApp/R/pca/server.R +++ b/program/shinyApp/R/pca/server.R @@ -474,13 +474,17 @@ pca_Server <- function(id, data, params, row_select){ par_tmp[[session$token]]$PCA[names(tmp)] <<- tmp par_tmp[[session$token]]$PCA$colorTheme <<- colorTheme - - output$getR_Code_PCA <- downloadHandler( filename = function(){ paste0("ShinyOmics_Rcode2Reproduce_", Sys.Date(), ".zip") }, content = function(file){ + waiter <- Waiter$new( + html = LOADING_SCREEN, + color = "#3897F147", + hide_on_render = FALSE + ) + waiter$show() envList <- list( res_tmp = res_tmp[[session$token]], par_tmp = par_tmp[[session$token]] @@ -496,7 +500,9 @@ pca_Server <- function(id, data, params, row_select){ files = dir(temp_directory), root = temp_directory ) + waiter$hide() }, + contentType = "application/zip" ) @@ -576,6 +582,12 @@ pca_Server <- function(id, data, params, row_select){ paste0("ShinyOmics_Rcode2Reproduce_", Sys.Date(), ".zip") }, content = function(file){ + waiter <- Waiter$new( + html = LOADING_SCREEN, + color = "#3897F147", + hide_on_render = FALSE + ) + waiter$show() envList <- list( res_tmp = res_tmp[[session$token]], @@ -594,6 +606,7 @@ pca_Server <- function(id, data, params, row_select){ files = dir(temp_directory), root = temp_directory ) + waiter$hide() }, contentType = "application/zip" ) @@ -653,6 +666,12 @@ pca_Server <- function(id, data, params, row_select){ paste0("ShinyOmics_Rcode2Reproduce_", Sys.Date(), ".zip") }, content = function(file){ + waiter <- Waiter$new( + html = LOADING_SCREEN, + color = "#3897F147", + hide_on_render = FALSE + ) + waiter$show() envList <- list( res_tmp = res_tmp[[session$token]], @@ -671,6 +690,7 @@ pca_Server <- function(id, data, params, row_select){ files = dir(temp_directory), root = temp_directory ) + waiter$hide() }, contentType = "application/zip" ) @@ -738,6 +758,12 @@ pca_Server <- function(id, data, params, row_select){ paste0("ShinyOmics_Rcode2Reproduce_", Sys.Date(), ".zip") }, content = function(file){ + waiter <- Waiter$new( + html = LOADING_SCREEN, + color = "#3897F147", + hide_on_render = FALSE + ) + waiter$show() envList <- list( res_tmp = res_tmp[[session$token]], @@ -756,6 +782,7 @@ pca_Server <- function(id, data, params, row_select){ files = dir(temp_directory), root = temp_directory ) + waiter$hide() }, contentType = "application/zip" ) diff --git a/program/shinyApp/R/sample_correlation/server.R b/program/shinyApp/R/sample_correlation/server.R index 88e15bc1..48e441df 100644 --- a/program/shinyApp/R/sample_correlation/server.R +++ b/program/shinyApp/R/sample_correlation/server.R @@ -163,6 +163,12 @@ sample_correlation_server <- function(id, data, params){ output$getR_SampleCorrelation <- downloadHandler( filename = function(){ paste0("ShinyOmics_Rcode2Reproduce_", Sys.Date(), ".zip")}, content = function(file){ + waiter <- Waiter$new( + html = LOADING_SCREEN, + color = "#3897F147", + hide_on_render = FALSE + ) + waiter$show() envList <- list( res_tmp = res_tmp[[session$token]], @@ -182,6 +188,7 @@ sample_correlation_server <- function(id, data, params){ files = dir(temp_directory), root = temp_directory ) + waiter$hdie() }, contentType = "application/zip" ) diff --git a/program/shinyApp/R/significance_analysis/server.R b/program/shinyApp/R/significance_analysis/server.R index 9533adad..c013ba43 100644 --- a/program/shinyApp/R/significance_analysis/server.R +++ b/program/shinyApp/R/significance_analysis/server.R @@ -519,6 +519,12 @@ significance_analysis_server <- function(id, data, params){ paste0("ShinyOmics_Rcode2Reproduce_", Sys.Date(), ".zip") }, content = function(file){ + waiter <- Waiter$new( + html = LOADING_SCREEN, + color = "#3897F147", + hide_on_render = FALSE + ) + waiter$show() tmp <- getUserReactiveValues(input) par_tmp[[session$token]]$SigAna[names(tmp)] <<- tmp @@ -578,6 +584,7 @@ significance_analysis_server <- function(id, data, params){ files = dir(temp_directory), root = temp_directory ) + waiter$hide() }, contentType = "application/zip" ) diff --git a/program/shinyApp/R/significance_analysis/util.R b/program/shinyApp/R/significance_analysis/util.R index cb0d06e3..420f1811 100644 --- a/program/shinyApp/R/significance_analysis/util.R +++ b/program/shinyApp/R/significance_analysis/util.R @@ -398,6 +398,12 @@ create_new_tab_manual <- function(title, targetPanel, result, contrast, alpha, n paste0("ShinyOmics_Rcode2Reproduce_", Sys.Date(), ".zip") }, content = function(file){ + waiter <- Waiter$new( + html = LOADING_SCREEN, + color = "#3897F147", + hide_on_render = FALSE + ) + waiter$show() tmp <- getUserReactiveValues(input) par_tmp[[session$token]]$SigAna[names(tmp)] <<- tmp par_tmp[[session$token]]$SigAna$contrast <<- contrast @@ -441,6 +447,7 @@ create_new_tab_manual <- function(title, targetPanel, result, contrast, alpha, n files = dir(temp_directory), root = temp_directory ) + waiter$hide() }, contentType = "application/zip" ) @@ -451,6 +458,12 @@ create_new_tab_manual <- function(title, targetPanel, result, contrast, alpha, n paste0("ShinyOmics_Rcode2Reproduce_", Sys.Date(), ".zip") }, content = function(file){ + waiter <- Waiter$new( + html = LOADING_SCREEN, + color = "#3897F147", + hide_on_render = FALSE + ) + waiter$show() tmp <- getUserReactiveValues(input) par_tmp[[session$token]]$SigAna[names(tmp)] <<- tmp par_tmp[[session$token]]$SigAna$contrast <<- contrast @@ -494,6 +507,7 @@ create_new_tab_manual <- function(title, targetPanel, result, contrast, alpha, n files = dir(temp_directory), root = temp_directory ) + waiter$hide() }, contentType = "application/zip" ) @@ -930,6 +944,12 @@ create_new_tab_DESeq <- function(title, targetPanel, result, contrast, alpha, ns paste0("ShinyOmics_Rcode2Reproduce_", Sys.Date(), ".zip") }, content = function(file){ + waiter <- Waiter$new( + html = LOADING_SCREEN, + color = "#3897F147", + hide_on_render = FALSE + ) + waiter$show() tmp <- getUserReactiveValues(input) par_tmp[[session$token]]$SigAna[names(tmp)] <<- tmp par_tmp[[session$token]]$SigAna$contrast <<- contrast @@ -973,6 +993,7 @@ create_new_tab_DESeq <- function(title, targetPanel, result, contrast, alpha, ns files = dir(temp_directory), root = temp_directory ) + waiter$hide() }, contentType = "application/zip" ) @@ -983,6 +1004,12 @@ create_new_tab_DESeq <- function(title, targetPanel, result, contrast, alpha, ns paste0("ShinyOmics_Rcode2Reproduce_", Sys.Date(), ".zip") }, content = function(file){ + waiter <- Waiter$new( + html = LOADING_SCREEN, + color = "#3897F147", + hide_on_render = FALSE + ) + waiter$show() tmp <- getUserReactiveValues(input) par_tmp[[session$token]]$SigAna[names(tmp)] <<- tmp par_tmp[[session$token]]$SigAna$contrast <<- contrast @@ -1026,6 +1053,7 @@ create_new_tab_DESeq <- function(title, targetPanel, result, contrast, alpha, ns files = dir(temp_directory), root = temp_directory ) + waiter$hide() }, contentType = "application/zip" ) diff --git a/program/shinyApp/R/single_gene_visualisation/server.R b/program/shinyApp/R/single_gene_visualisation/server.R index 91045f73..6e5c2e19 100644 --- a/program/shinyApp/R/single_gene_visualisation/server.R +++ b/program/shinyApp/R/single_gene_visualisation/server.R @@ -265,6 +265,12 @@ single_gene_visualisation_server <- function(id, data){ paste0("ShinyOmics_Rcode2Reproduce_", Sys.Date(), ".zip") }, content = function(file){ + waiter <- Waiter$new( + html = LOADING_SCREEN, + color = "#3897F147", + hide_on_render = FALSE + ) + waiter$show() envList <- list( res_tmp = res_tmp[[session$token]], @@ -281,6 +287,7 @@ single_gene_visualisation_server <- function(id, data){ files = dir(temp_directory), root = temp_directory ) + waiter$hide() }, contentType = "application/zip" ) diff --git a/program/shinyApp/server.R b/program/shinyApp/server.R index a27b0b57..c71b7355 100644 --- a/program/shinyApp/server.R +++ b/program/shinyApp/server.R @@ -81,6 +81,7 @@ server <- function(input,output,session){ # create an empty list in res/par_tmp[[session$token]] res_tmp[[session$token]] <<- list() par_tmp[[session$token]] <<- list() + # On session end, remove the list from res/par_tmp session$onSessionEnded(function() { res_tmp[[session$token]] <<- NULL @@ -914,9 +915,9 @@ server <- function(input,output,session){ req(input$Do_preprocessing > 0) waiter <- Waiter$new( html = LOADING_SCREEN, - #color="#3897F147", - color = "rgba(255,255,255,0)", - hide_on_render=FALSE + color = "#3897F147", + hide_on_render = FALSE + ) waiter$show() print("Do Preprocessing") @@ -1254,6 +1255,12 @@ server <- function(input,output,session){ paste0("ShinyOmics_Rcode2Reproduce_", Sys.Date(), ".zip") }, content = function(file) { + waiter <- Waiter$new( + html = LOADING_SCREEN, + color = "#3897F147", + hide_on_render = FALSE + ) + waiter$show() envList <- list( res_tmp = res_tmp[[session$token]], par_tmp = par_tmp[[session$token]] @@ -1273,6 +1280,7 @@ server <- function(input,output,session){ files = dir(temp_directory), root = temp_directory ) + waiter$hide() }, contentType = "application/zip" )