Commit b3829501 authored by mmassaviol's avatar mmassaviol
Browse files

Update shinyfiles inputs (and reload of them)

parent ae9898cd
......@@ -195,6 +195,21 @@ generate_page_input <- function(res, cnt) {
res <- res + '\t\t\tcolumn(8,textInput("' + cnt$name + '",label=NULL,value=""))\n'
res <- res + '\t\t)\n'
}
if(cnt$type == "input_file"){
res <- res + '\tbox(title = "' + cnt$label + '", width = 12, status = "success", collapsible = TRUE, solidHeader = TRUE,\n'
res <- res + '\t\tselectInput("' + cnt$name + '_select",label = "Select where to find the file", selected = "server", choices = c("On server" = "server", "On your machine" = "local")),\n'
res <- res + '\t\tconditionalPanel(condition = "input.' + cnt$name + '_select == \'server\'",\n'
res <- res + '\t\t\t\ttags$label("' + cnt$label + '"),\n'
res <- res + '\t\t\t\tfluidRow(\n'
res <- res + '\t\t\t\t\tcolumn(4,shinyFilesButton("shinyfiles_' + cnt$name + '",label="Please select a file", title="' + cnt$label + '", multiple=FALSE)),\n'
res <- res + '\t\t\t\t\tcolumn(8,textInput("' + cnt$name + '_server",label=NULL,value=""))\n'
res <- res + '\t\t\t\t)\n'
res <- res + '\t\t\t),\n'
res <- res + '\t\tconditionalPanel(condition = "input.' + cnt$name + '_select == \'local\'",\n'
res <- res + '\t\t\tfileInput("' + cnt$name + '_local",label = "' + cnt$label + '")\n'
res <- res + '\t\t)\n'
res <- res + '\t)\n'
}
return(res)
}
......@@ -395,7 +410,7 @@ generate_pages_server <- function() {
genR <- ""
if(cnt$type == 'text' || cnt$type == "input_file_server" || cnt$type == "input_dir" || cnt$type == "output_dir") {
if(cnt$type == 'text' || cnt$type == "input_dir" || cnt$type == "output_dir") {
genR <- genR + '\t\tif(!is.na(as.numeric(input$' + id + '))) {\n'
genR <- genR + '\t\t\tres = paste0(res, paste("' + id + ':", input$' + id + ', "\\n", sep = " "))\n'
genR <- genR + '\t\t} else {\n'
......@@ -474,6 +489,16 @@ generate_pages_server <- function() {
genR <- genR + '\t\t}'
genR <- genR + '\t\n\n'
}
if(cnt$type == "input_file") {
genR <- genR + '\t\tres = paste0(res, paste("' + id + '_select:", paste0(\'\"\', input$' + id + '_select, \'\"\'), "\\n", sep = " "))\n'
genR <- genR + '\t\tif(input$' + id + '_select == "server") {\n'
genR <- genR + '\t\t\tres = paste0(res, paste("' + id + ':", paste0(\'\"\', input$' + id + '_server, \'\"\'), "\\n", sep = " "))\n'
genR <- genR + '\t\t}\n'
genR <- genR + '\t\tif(input$' + id + '_select == "local"){\n'
genR <- genR + '\t\t\tres = paste0(res, paste("' + id + ':", paste0(\'\"\', input$' + id + '_local$datapath, \'\"\'), "\\n", sep = " "))\n'
genR <- genR + '\t\t}'
genR <- genR + '\t\n\n'
}
else {
#TODO
......@@ -630,10 +655,10 @@ generate_pages_server <- function() {
for(box in page$boxes){
for(cnt in box$content){
volumes = 'c(data="/samples",results="/results")'
if (cnt$type == "input_file_server"){
if (cnt$type == "input_file"){
res <- res + '\t\tshinyFileChoose(input, "shinyfiles_' + cnt$name + '", root=' + volumes + ',session = session)\n'
res <- res + '\t\tobserveEvent({parseFilePaths(' + volumes + ',input$shinyfiles_' + cnt$name + ')$datapath[1]},{\n'
res <- res + '\t\t\tupdateTextInput(session,"' + cnt$name + '",value = parseFilePaths(' + volumes + ',input$shinyfiles_' + cnt$name + ')$datapath[1])\n'
res <- res + '\t\t\tupdateTextInput(session,"' + cnt$name + '_server",value = parseFilePaths(' + volumes + ',input$shinyfiles_' + cnt$name + ')$datapath[1])\n'
res <- res + '\t\t})\n\n'
}
if (cnt$type == "input_dir" || cnt$type == "output_dir"){
......@@ -893,9 +918,12 @@ generate_app <- function() {
res <- res + '\tif (file.exists(paste0(dossierAnalyse,"/params.yml"))){\n'
res <- res + '\t\tparams = read_yaml(paste0(dossierAnalyse,"/params.yml"))\n'
res <- res + '\t\tfor (param in names(params$params_info)){\n'
res <- res + '\t\t\tif (params$params_info[[param]]$type == "text"){\n'
res <- res + '\t\t\tif (params$params_info[[param]]$type == "text" || params$params_info[[param]]$type == "input_dir" || params$params_info[[param]]$type == "output_dir"){\n'
res <- res + '\t\t\t\tupdateTextInput(session, param, value = params[[param]])\n'
res <- res + '\t\t\t}\n'
res <- res + '\t\t\tif (params$params_info[[param]]$type == "input_file" && params[[paste0(param,"_select")]] == "server"){\n'
res <- res + '\t\t\t\tupdateTextInput(session, paste0(param,"_server"), value = params[[param]])\n'
res <- res + '\t\t\t}\n'
res <- res + '\t\t\tif (params$params_info[[param]]$type == "numeric"){\n'
res <- res + '\t\t\t\tupdateNumericInput(session, param, value = params[[param]])\n'
res <- res + '\t\t\t}\n'
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment