From 99a55cb081a0fa2969d4e7f232a1982538a83bea Mon Sep 17 00:00:00 2001 From: "Lea@Mac" Date: Mon, 16 Dec 2024 17:42:40 +0100 Subject: [PATCH] changed to show debug text again; to let user know what is going on addresses #421 --- program/shinyApp/R/data_selection/ui.R | 2 ++ program/shinyApp/server.R | 43 +++++++++++++++++--------- 2 files changed, 31 insertions(+), 14 deletions(-) diff --git a/program/shinyApp/R/data_selection/ui.R b/program/shinyApp/R/data_selection/ui.R index 51c2d377..c3c2a091 100644 --- a/program/shinyApp/R/data_selection/ui.R +++ b/program/shinyApp/R/data_selection/ui.R @@ -145,6 +145,7 @@ data_selection_main_panel <- mainPanel( div(id ="InfoBox_DataSelection", htmlOutput(outputId = "debug", container = pre) ), + div(id = "mainPanel_other", # add link to toggle on the div geneAnno_toggle actionButton( inputId = "geneAnno_toggle_button", @@ -222,6 +223,7 @@ data_selection_main_panel <- mainPanel( inputId = "refresh1", label = "YOu should not be seeing this" )) + ) ) diff --git a/program/shinyApp/server.R b/program/shinyApp/server.R index 9fbdccec..a9b3f5fc 100644 --- a/program/shinyApp/server.R +++ b/program/shinyApp/server.R @@ -71,7 +71,7 @@ server <- function(input,output,session){ hideTab(inputId = "tabsetPanel1", target = "Heatmap") hideTab(inputId = "tabsetPanel1", target = "Single Gene Visualisations") hideTab(inputId = "tabsetPanel1", target = "Enrichment Analysis") - shinyjs::hide("mainPanel_DataSelection") + shinyjs::hideElement(id = "mainPanel_other") shinyjs::hideElement(id = "data_summary") shinyjs::hideElement(id = "div_sampleCorrelation_main_panel") shinyjs::hideElement(id = "PCA_main_panel_div") @@ -461,9 +461,11 @@ server <- function(input,output,session){ observe({ if (input$refresh1 > 0) { req(data_input_shiny() == "DataUploadSuccesful") - shinyjs::show("mainPanel_DataSelection") + shinyjs::showElement("InfoBox_DataSelection") + shinyjs::showElement("mainPanel_other") } else { - shinyjs::hide("mainPanel_DataSelection") + shinyjs::showElement("InfoBox_DataSelection") + shinyjs::hideElement("mainPanel_other") } }) @@ -1046,17 +1048,27 @@ server <- function(input,output,session){ data_input <- list() # upload depending on where the button was clicked if(uploaded_from() == "file_input"){ - data_input <- list( - Matrix = read_file(input$data_matrix1$datapath, check.names=T), - sample_table = read_file(input$data_sample_anno1$datapath, check.names=T), - annotation_rows = read_file(input$data_row_anno1$datapath, check.names=T) - ) - # check if only 1 col in anno row, - # add dummy col to ensure R does not turn it into a vector - if(ncol(data_input$annotation_rows) < 2){ - data_input$annotation_rows$origRownames <- rownames(data_input$annotation_rows) - } + tryCatch({ + data_input <- list( + Matrix = read_file(input$data_matrix1$datapath, check.names=T), + sample_table = read_file(input$data_sample_anno1$datapath, check.names=T), + annotation_rows = read_file(input$data_row_anno1$datapath, check.names=T) + ) + # check if only 1 col in anno row, + # add dummy col to ensure R does not turn it into a vector + if(ncol(data_input$annotation_rows) < 2){ + data_input$annotation_rows$origRownames <- rownames(data_input$annotation_rows) + } + },error = function(e){ + output$debug <- renderText({ + "Upload failed, please check your input." + }) + reset('data_matrix1') + reset('data_sample_anno1') + reset('data_row_anno1') + return(NULL) + }) } else if(uploaded_from() == "metadata"){ tmp_sampleTable <- fun_readInSampleTable(input$metadataInput$datapath) test_data_upload <- function(){ @@ -1124,8 +1136,11 @@ server <- function(input,output,session){ }, error = function(e){ print("Error! Uploading via file input failed") + custom_error <- list() + custom_error[["message"]] <- "Uploading via file input failed" + error_modal(custom_error) output$debug <- renderText({ - "Uploading failed: The uplaoded files could not be put into a SummarizedExperiment. Try the 'Inspect data' button for potential errors." + "Uploading failed: The uploaded files could not be put into a SummarizedExperiment. Try the 'Inspect data' button for potential errors." }) NULL }