From 57001a2c7d8136768c9ad407966d9f6bdd83225b Mon Sep 17 00:00:00 2001 From: "Lea@Mac" Date: Tue, 29 Oct 2024 14:02:46 +0100 Subject: [PATCH 1/2] add waiters show/hide to all R Code Download --- program/shinyApp/R/enrichment_analysis/server.R | 2 ++ program/shinyApp/R/heatmap/server.R | 2 ++ program/shinyApp/R/pca/server.R | 11 +++++++++-- program/shinyApp/R/sample_correlation/server.R | 2 ++ program/shinyApp/R/significance_analysis/server.R | 2 ++ program/shinyApp/R/significance_analysis/util.R | 8 ++++++++ program/shinyApp/R/single_gene_visualisation/server.R | 2 ++ program/shinyApp/server.R | 2 ++ 8 files changed, 29 insertions(+), 2 deletions(-) diff --git a/program/shinyApp/R/enrichment_analysis/server.R b/program/shinyApp/R/enrichment_analysis/server.R index 89532f44..ae3b79a8 100644 --- a/program/shinyApp/R/enrichment_analysis/server.R +++ b/program/shinyApp/R/enrichment_analysis/server.R @@ -47,6 +47,7 @@ enrichment_analysis_geneset_server <- function( paste0("ShinyOmics_Rcode2Reproduce_", Sys.Date(), ".zip") }, content = function(file){ + waiter$show() # tmp <- getUserReactiveValues(input) # par_tmp$Enrichment[names(tmp)] <<- tmp envList <- list( @@ -81,6 +82,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 7e355439..e3f22d01 100644 --- a/program/shinyApp/R/heatmap/server.R +++ b/program/shinyApp/R/heatmap/server.R @@ -284,6 +284,7 @@ heatmap_server <- function(id, data, params, updates){ paste0("ShinyOmics_Rcode2Reproduce_", Sys.Date(), ".zip") }, content = function(file){ + waiter$show() envList <- list( res_tmp = res_tmp[[session$token]], par_tmp = par_tmp[[session$token]] @@ -311,6 +312,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 07d7b071..ffa0ce65 100644 --- a/program/shinyApp/R/pca/server.R +++ b/program/shinyApp/R/pca/server.R @@ -472,13 +472,12 @@ 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$show() envList <- list( res_tmp = res_tmp[[session$token]], par_tmp = par_tmp[[session$token]] @@ -494,7 +493,9 @@ pca_Server <- function(id, data, params, row_select){ files = dir(temp_directory), root = temp_directory ) + waiter$hide() }, + contentType = "application/zip" ) @@ -574,6 +575,7 @@ pca_Server <- function(id, data, params, row_select){ paste0("ShinyOmics_Rcode2Reproduce_", Sys.Date(), ".zip") }, content = function(file){ + waiter$show() envList <- list( res_tmp = res_tmp[[session$token]], @@ -592,6 +594,7 @@ pca_Server <- function(id, data, params, row_select){ files = dir(temp_directory), root = temp_directory ) + waiter$hide() }, contentType = "application/zip" ) @@ -651,6 +654,7 @@ pca_Server <- function(id, data, params, row_select){ paste0("ShinyOmics_Rcode2Reproduce_", Sys.Date(), ".zip") }, content = function(file){ + waiter$show() envList <- list( res_tmp = res_tmp[[session$token]], @@ -669,6 +673,7 @@ pca_Server <- function(id, data, params, row_select){ files = dir(temp_directory), root = temp_directory ) + waiter$hide() }, contentType = "application/zip" ) @@ -736,6 +741,7 @@ pca_Server <- function(id, data, params, row_select){ paste0("ShinyOmics_Rcode2Reproduce_", Sys.Date(), ".zip") }, content = function(file){ + waiter$show() envList <- list( res_tmp = res_tmp[[session$token]], @@ -754,6 +760,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 f7c6d6dd..d39333a3 100644 --- a/program/shinyApp/R/sample_correlation/server.R +++ b/program/shinyApp/R/sample_correlation/server.R @@ -164,6 +164,7 @@ sample_correlation_server <- function(id, data, params){ output$getR_SampleCorrelation <- downloadHandler( filename = function(){ paste0("ShinyOmics_Rcode2Reproduce_", Sys.Date(), ".zip")}, content = function(file){ + waiter$show() envList <- list( res_tmp = res_tmp[[session$token]], @@ -183,6 +184,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 e3374ca3..74159095 100644 --- a/program/shinyApp/R/significance_analysis/server.R +++ b/program/shinyApp/R/significance_analysis/server.R @@ -520,6 +520,7 @@ significance_analysis_server <- function(id, data, params){ paste0("ShinyOmics_Rcode2Reproduce_", Sys.Date(), ".zip") }, content = function(file){ + waiter$show() tmp <- getUserReactiveValues(input) par_tmp[[session$token]]$SigAna[names(tmp)] <<- tmp @@ -579,6 +580,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..cd7e0e19 100644 --- a/program/shinyApp/R/significance_analysis/util.R +++ b/program/shinyApp/R/significance_analysis/util.R @@ -398,6 +398,7 @@ create_new_tab_manual <- function(title, targetPanel, result, contrast, alpha, n paste0("ShinyOmics_Rcode2Reproduce_", Sys.Date(), ".zip") }, content = function(file){ + waiter$show() tmp <- getUserReactiveValues(input) par_tmp[[session$token]]$SigAna[names(tmp)] <<- tmp par_tmp[[session$token]]$SigAna$contrast <<- contrast @@ -441,6 +442,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 +453,7 @@ create_new_tab_manual <- function(title, targetPanel, result, contrast, alpha, n paste0("ShinyOmics_Rcode2Reproduce_", Sys.Date(), ".zip") }, content = function(file){ + waiter$show() tmp <- getUserReactiveValues(input) par_tmp[[session$token]]$SigAna[names(tmp)] <<- tmp par_tmp[[session$token]]$SigAna$contrast <<- contrast @@ -494,6 +497,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 +934,7 @@ create_new_tab_DESeq <- function(title, targetPanel, result, contrast, alpha, ns paste0("ShinyOmics_Rcode2Reproduce_", Sys.Date(), ".zip") }, content = function(file){ + waiter$show() tmp <- getUserReactiveValues(input) par_tmp[[session$token]]$SigAna[names(tmp)] <<- tmp par_tmp[[session$token]]$SigAna$contrast <<- contrast @@ -973,6 +978,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 +989,7 @@ create_new_tab_DESeq <- function(title, targetPanel, result, contrast, alpha, ns paste0("ShinyOmics_Rcode2Reproduce_", Sys.Date(), ".zip") }, content = function(file){ + waiter$show() tmp <- getUserReactiveValues(input) par_tmp[[session$token]]$SigAna[names(tmp)] <<- tmp par_tmp[[session$token]]$SigAna$contrast <<- contrast @@ -1026,6 +1033,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..fcd33de1 100644 --- a/program/shinyApp/R/single_gene_visualisation/server.R +++ b/program/shinyApp/R/single_gene_visualisation/server.R @@ -265,6 +265,7 @@ single_gene_visualisation_server <- function(id, data){ paste0("ShinyOmics_Rcode2Reproduce_", Sys.Date(), ".zip") }, content = function(file){ + waiter$show() envList <- list( res_tmp = res_tmp[[session$token]], @@ -281,6 +282,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 1736d0b2..7dbc6c2e 100644 --- a/program/shinyApp/server.R +++ b/program/shinyApp/server.R @@ -1247,6 +1247,7 @@ server <- function(input,output,session){ paste0("ShinyOmics_Rcode2Reproduce_", Sys.Date(), ".zip") }, content = function(file) { + waiter$show() envList <- list( res_tmp = res_tmp[[session$token]], par_tmp = par_tmp[[session$token]] @@ -1266,6 +1267,7 @@ server <- function(input,output,session){ files = dir(temp_directory), root = temp_directory ) + waiter$hide() }, contentType = "application/zip" ) From c69a50db222e74106757c373da1b286a9e527b98 Mon Sep 17 00:00:00 2001 From: "Lea@Mac" Date: Wed, 30 Oct 2024 10:11:19 +0100 Subject: [PATCH 2/2] added explicit waiter; tried as reactive with waiter <- reactive({Waiter$new}) and then waiter()$show - did not work --- .../shinyApp/R/enrichment_analysis/server.R | 5 +++++ program/shinyApp/R/heatmap/server.R | 5 +++++ program/shinyApp/R/pca/server.R | 20 +++++++++++++++++++ .../shinyApp/R/sample_correlation/server.R | 5 +++++ .../shinyApp/R/significance_analysis/server.R | 5 +++++ .../shinyApp/R/significance_analysis/util.R | 20 +++++++++++++++++++ .../R/single_gene_visualisation/server.R | 5 +++++ program/shinyApp/server.R | 11 +++++++--- 8 files changed, 73 insertions(+), 3 deletions(-) diff --git a/program/shinyApp/R/enrichment_analysis/server.R b/program/shinyApp/R/enrichment_analysis/server.R index ae3b79a8..29f7b3e9 100644 --- a/program/shinyApp/R/enrichment_analysis/server.R +++ b/program/shinyApp/R/enrichment_analysis/server.R @@ -47,6 +47,11 @@ 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 diff --git a/program/shinyApp/R/heatmap/server.R b/program/shinyApp/R/heatmap/server.R index e3f22d01..46eb9f6c 100644 --- a/program/shinyApp/R/heatmap/server.R +++ b/program/shinyApp/R/heatmap/server.R @@ -284,6 +284,11 @@ 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]], diff --git a/program/shinyApp/R/pca/server.R b/program/shinyApp/R/pca/server.R index ffa0ce65..5aa7ece1 100644 --- a/program/shinyApp/R/pca/server.R +++ b/program/shinyApp/R/pca/server.R @@ -477,6 +477,11 @@ 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]], @@ -575,6 +580,11 @@ 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( @@ -654,6 +664,11 @@ 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( @@ -741,6 +756,11 @@ 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( diff --git a/program/shinyApp/R/sample_correlation/server.R b/program/shinyApp/R/sample_correlation/server.R index d39333a3..2132358e 100644 --- a/program/shinyApp/R/sample_correlation/server.R +++ b/program/shinyApp/R/sample_correlation/server.R @@ -164,6 +164,11 @@ 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( diff --git a/program/shinyApp/R/significance_analysis/server.R b/program/shinyApp/R/significance_analysis/server.R index 74159095..35569361 100644 --- a/program/shinyApp/R/significance_analysis/server.R +++ b/program/shinyApp/R/significance_analysis/server.R @@ -520,6 +520,11 @@ 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 diff --git a/program/shinyApp/R/significance_analysis/util.R b/program/shinyApp/R/significance_analysis/util.R index cd7e0e19..420f1811 100644 --- a/program/shinyApp/R/significance_analysis/util.R +++ b/program/shinyApp/R/significance_analysis/util.R @@ -398,6 +398,11 @@ 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 @@ -453,6 +458,11 @@ 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 @@ -934,6 +944,11 @@ 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 @@ -989,6 +1004,11 @@ 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 diff --git a/program/shinyApp/R/single_gene_visualisation/server.R b/program/shinyApp/R/single_gene_visualisation/server.R index fcd33de1..6e5c2e19 100644 --- a/program/shinyApp/R/single_gene_visualisation/server.R +++ b/program/shinyApp/R/single_gene_visualisation/server.R @@ -265,6 +265,11 @@ 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( diff --git a/program/shinyApp/server.R b/program/shinyApp/server.R index 7dbc6c2e..3561e2c8 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 @@ -906,10 +907,9 @@ server <- function(input,output,session){ # only enter this when you actually click data req(input$Do_preprocessing > 0) waiter <- Waiter$new( - id="data_summary", html = LOADING_SCREEN, - color="#3897F147", - hide_on_render=FALSE + color = "#3897F147", + hide_on_render = FALSE ) waiter$show() print("Do Preprocessing") @@ -1247,6 +1247,11 @@ 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]],