Commit 678a40c4 authored by jlopez's avatar jlopez
Browse files

Add global button yml generator

parent 74528799
......@@ -6,6 +6,10 @@ MenuGauche = sidebarMenu(id="sidebarmenu",
tags$br(),
actionButton("runAllPipeline", "Generate", icon("play"), class="btn btn-info"),
tags$br(),tags$br(),
menuItem("Powered by mbb", href="http://mbb.univ-montp2.fr/MBB/index.php", newtab=TRUE, icon=icon("book", lib="font-awesome"), selected=NULL)
)
......
......@@ -55,6 +55,7 @@ tags$head(style),
server <- function( input, output, session) {
source("./server/opt_global.R", local=T)
source("./server/opt_inputs.R", local=T)
source("./server/opt_input2.R", local=T)
......
outil_inputs_panel1: "A"
param1: ""
param2: 50
param3_min: 11.8
param3_max: 19.6
param3_step: 0.1
param8: true
param9: false
mychoose2_left: ["A", "B", "C"]
mychoose2_right: []
outil_inputs_panel1: "A"
param4: "B"
param5: 3
outil_inputs_panel2: "C"
param10: ""
param7: ""
outil_inputs_panel3: "biotoolB"
inputs_param1: ""
inputs_param2: 50
inputs_param3_min: 11.8
inputs_param3_max: 19.6
inputs_param3_step: 0.1
inputs_param8: true
inputs_param9: false
outil_inputs_panel3: "biotoolB"
inputs_param1: ""
inputs_param8: true
inputs_param9: false
outil_input2_informations_user: "D"
first_name: ""
last_name: ""
param1: ""
param2: 50
param3_min: 11.8
param3_max: 19.6
param3_step: 0.1
param8: true
param9: false
mychoose2_left: ["A", "B"]
mychoose2_right: ["C"]
param10: ""
param7: ""
inputs_param1: ""
inputs_param2: 50
inputs_param3_min: 11.8
inputs_param3_max: 19.6
inputs_param3_step: 0.1
inputs_param8: true
inputs_param9: false
#' Event when use last_name button
observeEvent(input$runAllPipeline, {
path_param <- "/home/jimmy/jimmy/projets/sag/app/pipeline/params/params.yml"
res <- ""# Page : inputs
res <- paste(res, "outil_inputs_panel1:", paste0('"', input$selectpanel1, '"'), "\n", sep = " ")
if(!is.na(as.numeric(input$param1))) {
res <- paste(res, "param1:", input$param1, "\n", sep = " ")
} else {
res <- paste(res, "param1:", paste0('"', input$param1, '"'), "\n", sep = " ")
}
res <- paste(res, "param2:", input$param2, "\n", sep = " ")
res <- paste(res, "param3_min:", input$param3[1], "\n", sep = " ")
res <- paste(res, "param3_max:", input$param3[2], "\n", sep = " ")
res <- paste(res, "param3_step:", "0.1", "\n", sep = " ")
if(input$param8) {
res <- paste(res, "param8:", "true", "\n", sep = " ")
} else {
res <- paste(res, "param8:", "false", "\n", sep = " ")
}
if(input$param9) {
res <- paste(res, "param9:", "true", "\n", sep = " ")
} else {
res <- paste(res, "param9:", "false", "\n", sep = " ")
}
res <- paste0(res, " mychoose2" + "_left: [")
if(length(input$mychoose2$left) > 0) {
for(x in 1:length(input$mychoose2$left)) {
res <- paste0(res, '"', input$mychoose2$left[[x]], '"')
if(x < length(input$mychoose2$left)) {
res <- paste0(res, ", ")
}
}
}
res <- paste0(res, "]", "\n")
res <- paste0(res, " mychoose2" + "_right: [")
if(length(input$mychoose2$right) > 0) {
for(x in 1:length(input$mychoose2$right)) {
res <- paste0(res, '"', input$mychoose2$right[[x]], '"')
if(x < length(input$mychoose2$right)) {
res <- paste0(res, ", ")
}
}
}
res <- paste0(res, "]", "\n")
res <- paste(res, "outil_inputs_panel1:", paste0('"', input$selectpanel1, '"'), "\n", sep = " ")
if(!is.na(as.numeric(input$param4))) {
res <- paste(res, "param4:", input$param4, "\n", sep = " ")
} else {
res <- paste(res, "param4:", paste0('"', input$param4, '"'), "\n", sep = " ")
}
if(!is.na(as.numeric(input$param5))) {
res <- paste(res, "param5:", input$param5, "\n", sep = " ")
} else {
res <- paste(res, "param5:", paste0('"', input$param5, '"'), "\n", sep = " ")
}
res <- paste(res, "outil_inputs_panel2:", paste0('"', input$selectpanel2, '"'), "\n", sep = " ")
if(!is.na(as.numeric(input$param10))) {
res <- paste(res, "param10:", input$param10, "\n", sep = " ")
} else {
res <- paste(res, "param10:", paste0('"', input$param10, '"'), "\n", sep = " ")
}
res <- paste(res, "param7:", paste0('"', input$param7$datapath, '"'), "\n", sep = " ")
res <- paste(res, "outil_inputs_panel3:", paste0('"', input$selectpanel3, '"'), "\n", sep = " ")
if(!is.na(as.numeric(input$inputs_param1))) {
res <- paste(res, "inputs_param1:", input$inputs_param1, "\n", sep = " ")
} else {
res <- paste(res, "inputs_param1:", paste0('"', input$inputs_param1, '"'), "\n", sep = " ")
}
res <- paste(res, "inputs_param2:", input$inputs_param2, "\n", sep = " ")
res <- paste(res, "inputs_param3_min:", input$inputs_param3[1], "\n", sep = " ")
res <- paste(res, "inputs_param3_max:", input$inputs_param3[2], "\n", sep = " ")
res <- paste(res, "inputs_param3_step:", "0.1", "\n", sep = " ")
if(input$inputs_param8) {
res <- paste(res, "inputs_param8:", "true", "\n", sep = " ")
} else {
res <- paste(res, "inputs_param8:", "false", "\n", sep = " ")
}
if(input$inputs_param9) {
res <- paste(res, "inputs_param9:", "true", "\n", sep = " ")
} else {
res <- paste(res, "inputs_param9:", "false", "\n", sep = " ")
}
res <- paste(res, "outil_inputs_panel3:", paste0('"', input$selectpanel3, '"'), "\n", sep = " ")
if(!is.na(as.numeric(input$inputs_param1))) {
res <- paste(res, "inputs_param1:", input$inputs_param1, "\n", sep = " ")
} else {
res <- paste(res, "inputs_param1:", paste0('"', input$inputs_param1, '"'), "\n", sep = " ")
}
if(input$inputs_param8) {
res <- paste(res, "inputs_param8:", "true", "\n", sep = " ")
} else {
res <- paste(res, "inputs_param8:", "false", "\n", sep = " ")
}
if(input$inputs_param9) {
res <- paste(res, "inputs_param9:", "true", "\n", sep = " ")
} else {
res <- paste(res, "inputs_param9:", "false", "\n", sep = " ")
}
# Page : input2
res <- paste(res, "outil_input2_informations_user:", paste0('"', input$selectinformations_user, '"'), "\n", sep = " ")
if(!is.na(as.numeric(input$first_name))) {
res <- paste(res, "first_name:", input$first_name, "\n", sep = " ")
} else {
res <- paste(res, "first_name:", paste0('"', input$first_name, '"'), "\n", sep = " ")
}
if(!is.na(as.numeric(input$last_name))) {
res <- paste(res, "last_name:", input$last_name, "\n", sep = " ")
} else {
res <- paste(res, "last_name:", paste0('"', input$last_name, '"'), "\n", sep = " ")
}
write(res, file=path_param)
})
......@@ -33,7 +33,7 @@ observeEvent(input$runApp, {
write(res, file=path_param)
system(paste(" pwd", "", "input$first_name" , "", "input$last_name" , sep = " " ))
system(paste(" pwd", "", input$first_name , "", input$last_name , sep = " " ))
RV_input2$data <- read.csv("/home/jimmy/jimmy/projets/sag/app/cars.csv", header = TRUE)
})
......
......@@ -57,20 +57,24 @@ observeEvent(input$runP, {
}
res <- paste0(res, " mychoose2" + "_left: [")
if(length(input$mychoose2$left) > 0) {
for(x in 1:length(input$mychoose2$left)) {
res <- paste0(res, '"', input$mychoose2$left[[x]], '"')
if(x < length(input$mychoose2$left)) {
res <- paste0(res, ", ")
}
}
}
res <- paste0(res, "]", "\n")
res <- paste0(res, " mychoose2" + "_right: [")
if(length(input$mychoose2$right) > 0) {
for(x in 1:length(input$mychoose2$right)) {
res <- paste0(res, '"', input$mychoose2$right[[x]], '"')
if(x < length(input$mychoose2$right)) {
res <- paste0(res, ", ")
}
}
}
res <- paste0(res, "]", "\n")
......@@ -173,7 +177,7 @@ observeEvent(input$runP, {
# Panel : panel5
write(res, file=path_param)
system(paste(" python", "", "/home/jimmy/jimmy/projets/sag/app/mon_script.py" , "-i3", "input$param6" , "-t", "input$param1" , "", "input$param4" , "-path1", "input$param7$datapath" , "-params_file", "/home/jimmy/jimmy/projets/sag/app/pipeline/params/params_inputs.yml", sep = " " ))
system(paste(" python", "", "/home/jimmy/jimmy/projets/sag/app/mon_script.py" , "-i3", input$param6 , "-t", input$param1 , "", input$param4 , "-path1", input$param7$datapath , "-params_file", "/home/jimmy/jimmy/projets/sag/app/pipeline/params/params_inputs.yml", sep = " " ))
if(file.exists("/home/jimmy/jimmy/projets/sag/app/result.Rmd")) {
output$report_inputs <- renderUI({
......
......@@ -292,15 +292,17 @@ generate_page_box <- function(panel, box, res) {
#============================================================
generate_pages_server <- function() {
resG <- ""
for(x in 1:length(APP$pages)) {
name <- APP$pages[[x]]$name
resG <- resG + "# \tPage : " + name + "\n"
path_page = APP$project+"/pages/pages_def_"+tolower(name)+".R"
file.replace(path_page)
res <- 'tab'+ name + ' = fluidPage(\n\n'
res <- res + 'box(title = "Parameters :", width = 5, status = "primary", collapsible = TRUE, solidHeader = TRUE'
content <- APP$pages[[x]]$content
if(length(content) > 0) {
......@@ -504,6 +506,9 @@ generate_pages_server <- function() {
panel_content = box$content
if(length(panel_content) > 0) {
resG <- resG + '\t\tres <- paste(res, "outil_' + APP$pages[[x]]$name + '_' + panel$name + ':", paste0(\'\"\', input$select' + panel$name + ', \'\"\'), "\\n", sep = " ")\n'
for(z in 1:length(panel_content)) {
......@@ -512,66 +517,75 @@ generate_pages_server <- function() {
type <- cnt$type
id <- cnt$name
genR <- ""
if(type == 'text') {
res <- res + '\t\tif(!is.na(as.numeric(input$' + id + '))) {\n'
res <- res + '\t\t\tres <- paste(res, "' + id + ':", input$' + id + ', "\\n", sep = " ")\n'
res <- res + '\t\t} else {\n'
res <- res + '\t\t\tres <- paste(res, "' + id + ':", paste0(\'\"\', input$' + id + ', \'\"\'), "\\n", sep = " ")\n'
res <- res + '\t\t}'
res <- res + '\t\n\n'
genR <- genR + '\t\tif(!is.na(as.numeric(input$' + id + '))) {\n'
genR <- genR + '\t\t\tres <- paste(res, "' + id + ':", input$' + id + ', "\\n", sep = " ")\n'
genR <- genR + '\t\t} else {\n'
genR <- genR + '\t\t\tres <- paste(res, "' + id + ':", paste0(\'\"\', input$' + id + ', \'\"\'), "\\n", sep = " ")\n'
genR <- genR + '\t\t}'
genR <- genR + '\t\n\n'
} else if(cnt$type == "slider") {
if(length(cnt$value) == 1) {
res <- res + '\t\tres <- paste(res, "' + id + ':", input$' + id + ', "\\n", sep = " ")'
res <- res + '\t\n\n'
genR <- genR + '\t\tres <- paste(res, "' + id + ':", input$' + id + ', "\\n", sep = " ")'
genR <- genR + '\t\n\n'
} else {
res <- res + '\t\tres <- paste(res, "' + id + '_min:", input$' + id + '[1], "\\n", sep = " ")\n'
res <- res + '\t\tres <- paste(res, "' + id + '_max:", input$' + id + '[2], "\\n", sep = " ")\n'
res <- res + '\t\tres <- paste(res, "' + id + '_step:", "' + cnt$step + '", "\\n", sep = " ")\n'
res <- res + '\t\n\n'
genR <- genR + '\t\tres <- paste(res, "' + id + '_min:", input$' + id + '[1], "\\n", sep = " ")\n'
genR <- genR + '\t\tres <- paste(res, "' + id + '_max:", input$' + id + '[2], "\\n", sep = " ")\n'
genR <- genR + '\t\tres <- paste(res, "' + id + '_step:", "' + cnt$step + '", "\\n", sep = " ")\n'
genR <- genR + '\t\n\n'
}
} else if(cnt$type == "select") {
res <- res + '\t\tif(!is.na(as.numeric(input$' + id + '))) {\n'
res <- res + '\t\t\tres <- paste(res, "' + id + ':", input$' + id + ', "\\n", sep = " ")\n'
res <- res + '\t\t} else {\n'
res <- res + '\t\t\tres <- paste(res, "' + id + ':", paste0(\'\"\', input$' + id + ', \'\"\'), "\\n", sep = " ")\n'
res <- res + '\t\t}'
res <- res + '\t\n\n'
genR <- genR + '\t\tif(!is.na(as.numeric(input$' + id + '))) {\n'
genR <- genR + '\t\t\tres <- paste(res, "' + id + ':", input$' + id + ', "\\n", sep = " ")\n'
genR <- genR + '\t\t} else {\n'
genR <- genR + '\t\t\tres <- paste(res, "' + id + ':", paste0(\'\"\', input$' + id + ', \'\"\'), "\\n", sep = " ")\n'
genR <- genR + '\t\t}'
genR <- genR + '\t\n\n'
} else if(cnt$type == "file") {
res <- res + '\t\t\tres <- paste(res, "' + id + ':", paste0(\'\"\', input$' + id + '$datapath, \'\"\'), "\\n", sep = " ")'
res <- res + '\t\n\n'
genR <- genR + '\t\t\tres <- paste(res, "' + id + ':", paste0(\'\"\', input$' + id + '$datapath, \'\"\'), "\\n", sep = " ")'
genR <- genR + '\t\n\n'
} else if(cnt$type == "checkbox") {
res <- res + '\t\tif(input$' + id + ') {\n'
res <- res + '\t\t\tres <- paste(res, "' + id + ':", "true", "\\n", sep = " ")\n'
res <- res + '\t\t} else {\n'
res <- res + '\t\t\tres <- paste(res, "' + id + ':", "false", "\\n", sep = " ")\n'
res <- res + '\t\t}'
res <- res + '\t\n\n'
genR <- genR + '\t\tif(input$' + id + ') {\n'
genR <- genR + '\t\t\tres <- paste(res, "' + id + ':", "true", "\\n", sep = " ")\n'
genR <- genR + '\t\t} else {\n'
genR <- genR + '\t\t\tres <- paste(res, "' + id + ':", "false", "\\n", sep = " ")\n'
genR <- genR + '\t\t}'
genR <- genR + '\t\n\n'
} else if(cnt$type == "chooser") {
res <- res + '\t\tres <- paste0(res, " ' + id + '" + "_left: [")\n'
res <- res + '\t\tfor(x in 1:length(input$'+ id +'$left)) {\n'
res <- res + '\t\t\tres <- paste0(res, \'"\', input$'+ id +'$left[[x]], \'"\')\n'
res <- res + '\t\t\tif(x < length(input$'+ id +'$left)) {\n'
res <- res + '\t\t\t\tres <- paste0(res, ", ")\n'
res <- res + '\t\t\t}\n'
res <- res + '\t\t} \n'
res <- res + '\t\tres <- paste0(res, "]", "\\n")\n\n'
genR <- genR + '\t\tres <- paste0(res, " ' + id + '" + "_left: [")\n'
genR <- genR + '\t\tif(length(input$'+ id +'$left) > 0) {\n'
genR <- genR + '\t\tfor(x in 1:length(input$'+ id +'$left)) {\n'
genR <- genR + '\t\t\tres <- paste0(res, \'"\', input$'+ id +'$left[[x]], \'"\')\n'
genR <- genR + '\t\t\tif(x < length(input$'+ id +'$left)) {\n'
genR <- genR + '\t\t\t\tres <- paste0(res, ", ")\n'
genR <- genR + '\t\t\t}\n'
genR <- genR + '\t\t}\n'
genR <- genR + '\t\t} \n'
genR <- genR + '\t\tres <- paste0(res, "]", "\\n")\n\n'
res <- res + '\t\tres <- paste0(res, " ' + id + '" + "_right: [")\n'
res <- res + '\t\tfor(x in 1:length(input$'+ id +'$right)) {\n'
res <- res + '\t\t\tres <- paste0(res, \'"\', input$'+ id +'$right[[x]], \'"\')\n'
res <- res + '\t\t\tif(x < length(input$'+ id +'$right)) {\n'
res <- res + '\t\t\t\tres <- paste0(res, ", ")\n'
res <- res + '\t\t\t}\n'
res <- res + '\t\t} \n'
res <- res + '\t\tres <- paste0(res, "]", "\\n")\n\n'
genR <- genR + '\t\tres <- paste0(res, " ' + id + '" + "_right: [")\n'
genR <- genR + '\t\tif(length(input$'+ id +'$right) > 0) {\n'
genR <- genR + '\t\tfor(x in 1:length(input$'+ id +'$right)) {\n'
genR <- genR + '\t\t\tres <- paste0(res, \'"\', input$'+ id +'$right[[x]], \'"\')\n'
genR <- genR + '\t\t\tif(x < length(input$'+ id +'$right)) {\n'
genR <- genR + '\t\t\t\tres <- paste0(res, ", ")\n'
genR <- genR + '\t\t\t}\n'
genR <- genR + '\t\t}\n'
genR <- genR + '\t\t} \n'
genR <- genR + '\t\tres <- paste0(res, "]", "\\n")\n\n'
} else {
#TODO
}
res <- res + genR
resG <- resG + genR
}
}
......@@ -601,9 +615,9 @@ generate_pages_server <- function() {
if(option$type == "value") {
res <- res + '"' + option$name + '", "' + option$value + '" '
} else if (option$type == "shiny") {
res <- res + '"' + option$name + '", "input$' + option$value + '" '
res <- res + '"' + option$name + '", input$' + option$value + ' '
} else if(option$type == "shiny-file") {
res <- res + '"' + option$name + '", "input$' + option$value + '$datapath" '
res <- res + '"' + option$name + '", input$' + option$value + '$datapath '
} else if(option$type == "panel") {
res <- res + '"' + option$name + '", "' + APP$project + '/params/params_' + APP$pages[[x]]$name + '.yml"'
}
......@@ -636,6 +650,24 @@ generate_pages_server <- function() {
write(res, file=path_opt)
}
file.replace(APP$project+"/server/opt_global.R")
res <- '#\' Event when use '+ id +' button\n'
res <- res + 'observeEvent(input$runAllPipeline, {\n\n'
panel_path <- APP$project + '/params/' + 'params_' + APP$pages[[x]]$name + '.yml'
res <- res + '\tpath_param <- "' + APP$project + '/params/' + 'params' + '.yml' + '"\n\n'
res <- res + '\tres <- ""'
res <- res + resG # Add content
res <- res + '\twrite(res, file=path_param)'
res <- res + '\n\n'
res <- res + '})\n\n'
write(res, APP$project+"/server/opt_global.R")
}
#============================================================
......@@ -659,6 +691,10 @@ generate_menu <- function() {
res <- res + ' tags$br(),\n\n'
res <- res + ' actionButton("runAllPipeline", "Generate", icon("play"), class="btn btn-info"),\n\n'
res <- res + ' tags$br(),tags$br(),\n\n'
res <- res + ' menuItem("Powered by mbb", href="http://mbb.univ-montp2.fr/MBB/index.php", newtab=TRUE, icon=icon("book", lib="font-awesome"), selected=NULL)\n\n'
res <- res + ')\n\n'
......@@ -818,6 +854,8 @@ generate_app <- function() {
res <- res + 'server <- function( input, output, session) {\n\n'
res <- res + 'source("./server/opt_global.R", local=T)\n'
for(x in 1:length(APP$pages)) {
name <- APP$pages[[x]]$name
res <- res + 'source("./server/opt_'+tolower(name)+'.R", local=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