Commit c9561c67 authored by jlopez's avatar jlopez
Browse files

simplify yaml

parent ca050946
MenuGauche = sidebarMenu(id="sidebarmenu",
menuItem("Input Pipeline", tabName="inputs", icon=icon("pencil", lib="font-awesome"), newtab=FALSE),
menuItem("", tabName="inputs", icon=icon("pencil", lib="font-awesome"), newtab=FALSE),
menuItem("Input Pipeline 2", tabName="input2", icon=icon("", lib="font-awesome"), newtab=FALSE),
menuItem("", tabName="input2", icon=icon("file", lib="font-awesome"), newtab=FALSE),
tags$br(),
......
tabinputs = fluidPage(
textInput("textInput1", label = "Text input 1 :", value = "", width = "50%"),
textInput("param1", label = "Input Param1 :", value = "", width = "400px"),
textInput("textInput2", label = "Text input 2 :", value = "", width = "300px"),
sliderInput("param2", label = "Slider param2 :", min = 0, max = 100, step = 1, width = "400px", value = 50),
sliderInput("sliderInput1", label = "Slider input 1 :", min = 0, max = 100, step = 1, width = "50%", value = 50),
sliderInput("param3", label = "Slider param3 :", min = 10, max = 20, step = 0.1, width = "400px", value = c(11.8,19.6)),
sliderInput("sliderInput1", label = "Slider input 2 :", min = 10, max = 20, step = 0.1, width = "50%", value = c(11.8,19.6)),
selectInput("param4", label = "Selected param4 :", choices = list("A" = "A", "B" = "B", "C" = "C"), selected = "B", width = "400px"),
selectInput("selectInput1",label = "Select input 1 :", choices = list("Choice 1" = 1, "Choice 2" = 2, "Choice 3" = "dqsdqsd"), selected = "2", width = "30%"),
selectInput("param5", label = "Selected param5 :", choices = list("1" = 1, "2" = 2, "3" = 3), selected = "3", width = "400px"),
radioButtons("radioButtons1",label = "Radio buttons 1 :", choices = list("Choice A" = "A", "Choice B" = "B", "Choice C" = "C"), selected = "C", width = "50%"),
radioButtons("param6", label = "Radio param6 :", choices = list("rad1" = "rad1", "rad2" = "rad2", "rad3" = "rad3"), selected = "rad1", width = "400px"),
checkboxInput("checkboxInput1", label = "Single Checkbox input 1 :", value = TRUE),
fileInput("param7", label = "Chose file :", accept = c(".csv", ".xslx"), multiple = FALSE, width = "400px"),
p("Just simple text for description or help"),
checkboxInput("param8", label = "Checkbox 1", value = TRUE),
fileInput("fileInput2", label = "Chose file", accept = c(".csv", ".xslx"), multiple = FALSE, width = "50%"),
checkboxGroupInput("checkboxGroupInput1",label = "Group checkbox input 1 :", choices = list("Choice A" = "A", "Choice B" = "B", "Choice C" = "C"), selected = "C", width = "50%"),
fileInput("fileInput1", label = "Chose file", accept = c(".csv", ".xslx"), multiple = FALSE, width = "50%"),
checkboxInput("param9", label = "Checkbox 2", value = FALSE),
actionButton("testButton", "Test", class="btn btn-success"),
actionButton("runP", "Run", icon("save"), class="btn btn-primary")
actionButton("runP", "Run", icon("save"), class="btn btn-primary"),
p("Just simple text for description or help")
)
......
......@@ -8,7 +8,7 @@ observeEvent(input$testButton, {
#' Event when use runP button
observeEvent(input$runP, {
print(paste0(" python /home/jimmy/mon_script.py -i1 ", input$radioButtons1, " -path2 ", input$fileInput2$datapath , " ", input$selectInput1, " -path1 ", input$fileInput1$datapath ))
print(paste0(" python /home/jimmy/mon_script.py -i2 ", input$param6, " -t ", input$param1, " ", input$param4, " -path1 ", input$param7$datapath ))
})
......
......@@ -2,172 +2,45 @@ App:
project: "/home/jimmy/jimmy/projets/sag/app/pipeline"
general:
title: "Pipeline in R"
skin: "green"
skin: "green" # other color : https://rstudio.github.io/shinydashboard/appearance.html
menu_width: 230
pages:
-
icon: "pencil"
menu: "Input Pipeline"
name: "inputs"
content:
-
id: "textInput1"
type: "textInput"
width: "50%"
label: "Text input 1 :"
value: ""
-
id: "textInput2"
type: "textInput"
width: "300px"
label: "Text input 2 :"
value: ""
-
id: "sliderInput1"
type: "sliderInput"
min: 0
max: 100
value: [50]
step: 1
width: "50%"
label: "Slider input 1 :"
-
id: "sliderInput1"
type: "sliderInput"
min: 10
max: 20
step: 0.1
value: [11.8, 19.6]
width: "50%"
label: "Slider input 2 :"
-
type: "selectInput"
id: "selectInput1"
label: "Select input 1 :"
width: "30%"
selected: 2
choices:
-
label: "Choice 1"
value: 1
-
label: "Choice 2"
value: 2
-
label: "Choice 3"
value: "dqsdqsd"
-
type: "radioButtons"
id: "radioButtons1"
label: "Radio buttons 1 :"
width: "50%"
selected: "C"
choices:
-
label: "Choice A"
value: "A"
-
label: "Choice B"
value: "B"
-
label: "Choice C"
value: "C"
-
type: "checkboxInput"
id: "checkboxInput1"
label: "Single Checkbox input 1 :"
width: "50%"
value: TRUE
-
id: "p1"
type: "p"
value: "Just simple text for description or help"
-
type: "fileInput"
id: "fileInput2"
label: "Chose file"
multiple: FALSE
width: "50%"
accept: [".csv", ".xslx"]
-
type: "checkboxGroupInput"
id: "checkboxGroupInput1"
label: "Group checkbox input 1 :"
width: "50%"
selected: "C"
choices:
-
label: "Choice A"
value: "A"
-
label: "Choice B"
value: "B"
-
label: "Choice C"
value: "C"
-
type: "fileInput"
id: "fileInput1"
label: "Chose file"
multiple: FALSE
width: "50%"
accept: [".csv", ".xslx"]
-
class: "btn btn-success"
icon: ""
id: "testButton"
label: "Test"
type: "actionButton"
-
class: "btn btn-primary"
icon: "save"
id: "runP"
label: "Run"
type: "actionButton"
pipeline:
shiny_button: "runP"
program: "python"
options:
-
name: "/home/jimmy/mon_script.py"
shiny_name: ""
-
name: "-i1"
shiny_name: "radioButtons1"
-
name: "-path2"
shiny_name: "fileInput2"
-
name: ""
shiny_name: "selectInput1"
-
name: "-path1"
shiny_name: "fileInput1"
-
name: "input2"
con: "file"
menu: "Input Pipeline 2"
content: []
pages: [ # important : no space in 'name' field
{ #Page 1
icon: "pencil", # icon possible : https://fontawesome.com/icons?from=io
label: "Input Pipeline", # the label in left menu
name: "inputs", # the name of the page
content: [ # type possible : text, slider, select, radio, checkbox, file, button, help
{name: "param1", type: "text", value: "", label: "Input Param1 :"},
{name: "param2", type: "slider", min: 0, max: 100, step: 1, value: [50], label: "Slider param2 :"},
{name: "param3", type: "slider", min: 10, max: 20, step: 0.1, value: [11.8, 19.6], label: "Slider param3 :"} , # slider max 2 numeric value
{name: "param4", type: "select", selected: "B", choices: ["A", "B", "C"], label: "Selected param4 :"},
{name: "param5", type: "select", selected: 3, choices: [1, 2, 3], label: "Selected param5 :"},
{name: "param6", type: "radio", selected: "rad1", choices: ["rad1", "rad2", "rad3"], label: "Radio param6 :"},
{name: "param7", type: "file", multiple: FALSE, accept: [".csv", ".xslx"], label: "Chose file :"},
{name: "param8", type: "checkbox", value: TRUE, label: "Checkbox 1"},
{name: "param9", type: "checkbox", value: FALSE, label: "Checkbox 2"},
{name: "testButton", type: "button", icon: "", class: "btn btn-success", label: "Test"}, # class : primary, success, danger, warning, info
{name: "runP", type: "button", icon: "save", class: "btn btn-primary", label: "Run"}, # icon possible : https://fontawesome.com/icons?from=io
{name: "help1", type: "help", label: "Just simple text for description or help"}
],
pipeline: {
shiny_button: "runP",
program: "python",
options: [
{name: "/home/jimmy/mon_script.py", shiny_name: ""},
{name: "-i2", shiny_name: "param6"},
{name: "-t", shiny_name: "param1"},
{name: "", shiny_name: "param4"},
{name: "-path1", shiny_name: "param7"}
]
}
},
{ #Page 2
name: "input2",
icon: "file",
label: "Input Pipeline 2",
content: [],
pipeline: []
}
]
......@@ -33,29 +33,31 @@ generate_pages_server <- function() {
cnt <- content[[y]]
if(cnt$type == "actionButton") {
if(cnt$type == "button") {
if(cnt$icon == "") {
res <- res + '\tactionButton("' + cnt$id + '", "'+ cnt$label +'", class="'+ cnt$class +'")'
res <- res + '\tactionButton("' + cnt$name + '", "'+ cnt$label +'", class="'+ cnt$class +'")'
} else {
res <- res + '\tactionButton("' + cnt$id + '", "'+ cnt$label +'", icon("'+ cnt$icon +'"), class="'+ cnt$class +'")'
res <- res + '\tactionButton("' + cnt$name + '", "'+ cnt$label +'", icon("'+ cnt$icon +'"), class="'+ cnt$class +'")'
}
} else if(cnt$type == "textInput") {
res <- res + '\ttextInput("'+ cnt$id +'", label = "'+ cnt$label +'", value = "'+ cnt$value +'", width = "'+ cnt$width +'")'
} else if(cnt$type == "sliderInput") {
} else if(cnt$type == "text") {
res <- res + '\ttextInput("'+ cnt$name +'", label = "'+ cnt$label +'", value = "'+ cnt$value +'", width = "'+ '400px' +'")'
} else if(cnt$type == "slider") {
if(length(cnt$value) == 1) {
res <- res + '\tsliderInput("'+ cnt$id +'", label = "'+ cnt$label +'", min = '+ cnt$min +', max = '+ cnt$max +', step = '+ cnt$step +', width = "'+ cnt$width +'", value = '+ cnt$value +')'
res <- res + '\tsliderInput("'+ cnt$name +'", label = "'+ cnt$label +'", min = '+ cnt$min +', max = '+ cnt$max +', step = '+ cnt$step +', width = "'+ '400px' +'", value = '+ cnt$value +')'
} else {
res <- res + '\tsliderInput("'+ cnt$id +'", label = "'+ cnt$label +'", min = '+ cnt$min +', max = '+ cnt$max +', step = '+ cnt$step +', width = "'+ cnt$width +'", value = c('+ cnt$value[1] + ',' + cnt$value[2] + '))'
res <- res + '\tsliderInput("'+ cnt$name +'", label = "'+ cnt$label +'", min = '+ cnt$min +', max = '+ cnt$max +', step = '+ cnt$step +', width = "'+ '400px' +'", value = c('+ cnt$value[1] + ',' + cnt$value[2] + '))'
}
} else if(cnt$type == "p") {
res <- res + '\tp("'+cnt$value+'")'
} else if(cnt$type == "selectInput") {
} else if(cnt$type == "help") {
res <- res + '\tp("'+cnt$label+'")'
} else if(cnt$type == "select") {
res <- res + '\tselectInput("'+ cnt$id +'",label = "'+ cnt$label +'", choices = list('
res <- res + '\tselectInput("'+ cnt$name +'", label = "'+ cnt$label +'", choices = list('
if(length(cnt$choices) > 0) {
......@@ -63,55 +65,55 @@ generate_pages_server <- function() {
choices = cnt$choices[[ch]]
value = choices$value
value = choices
if(is.character(choices$value)) {
value = '"' + choices$value + '"'
if(is.character(choices)) {
value = '"' + choices + '"'
}
if(ch < length(cnt$choices)) {
res <- res + '"' + choices$label + '"' + ' = ' + value + ', '
res <- res + '"' + choices + '"' + ' = ' + value + ', '
} else {
res <- res + '"' + choices$label + '"' + ' = ' + value + '), '
res <- res + '"' + choices + '"' + ' = ' + value + '), '
}
}
}
res <- res + ' selected = "'+cnt$selected+'"' + ', width = "'+ cnt$width +'")'
res <- res + ' selected = "'+cnt$selected+'"' + ', width = "'+ '400px' +'")'
} else if(cnt$type == "radioButtons") {
} else if(cnt$type == "radio") {
res <- res + '\tradioButtons("'+ cnt$id +'",label = "'+ cnt$label +'", choices = list('
res <- res + '\tradioButtons("'+ cnt$name +'", label = "'+ cnt$label +'", choices = list('
if(length(cnt$choices) > 0) {
for(ch in 1:length(cnt$choices)){
choices = cnt$choices[[ch]]
value = choices$value
value = choices
if(is.character(choices$value)) {
value = '"' + choices$value + '"'
if(is.character(choices)) {
value = '"' + choices+ '"'
}
if(ch < length(cnt$choices)) {
res <- res + '"' + choices$label + '"' + ' = ' + value + ', '
res <- res + '"' + choices + '"' + ' = ' + value + ', '
} else {
res <- res + '"' + choices$label + '"' + ' = ' + value + '), '
res <- res + '"' + choices + '"' + ' = ' + value + '), '
}
}
}
res <- res + ' selected = "'+cnt$selected+'"' + ', width = "'+ cnt$width +'")'
res <- res + ' selected = "'+cnt$selected+'"' + ', width = "'+ '400px' +'")'
} else if(cnt$type == "checkboxInput") {
} else if(cnt$type == "checkbox") {
res <- res + '\tcheckboxInput("'+ cnt$id +'", label = "'+ cnt$label +'", value = ' + cnt$value + ')'
res <- res + '\tcheckboxInput("'+ cnt$name +'", label = "'+ cnt$label +'", value = ' + cnt$value + ')'
} else if(cnt$type == "checkboxGroupInput") {
res <- res + '\tcheckboxGroupInput("'+ cnt$id +'",label = "'+ cnt$label +'", choices = list('
res <- res + '\tcheckboxGroupInput("'+ cnt$name +'",label = "'+ cnt$label +'", choices = list('
if(length(cnt$choices) > 0) {
for(ch in 1:length(cnt$choices)){
......@@ -132,11 +134,11 @@ generate_pages_server <- function() {
}
}
res <- res + '), selected = "'+cnt$selected+'"' + ', width = "'+ cnt$width +'")'
res <- res + '), selected = "'+cnt$selected+'"' + ', width = "'+ '400px' +'")'
} else if(cnt$type == "fileInput") {
} else if(cnt$type == "file") {
res <- res + '\tfileInput("'+ cnt$id +'", label = "'+ cnt$label + '"'
res <- res + '\tfileInput("'+ cnt$name +'", label = "'+ cnt$label + '"'
if(length(cnt$accept) > 0) {
......@@ -158,7 +160,7 @@ generate_pages_server <- function() {
}
res <- res + ', multiple = ' + cnt$multiple + ', width = "'+ cnt$width + '")'
res <- res + ', multiple = ' + cnt$multiple + ', width = "'+ '400px' + '")'
}
......@@ -193,9 +195,9 @@ generate_pages_server <- function() {
cnt <- content[[y]]
type <- cnt$type
id <- cnt$id
id <- cnt$name
if(type == "actionButton") {
if(type == "button") {
res <- res + '#\' Event when use '+ id +' button\n'
res <- res + 'observeEvent(input$'+id+', {\n\n'
......@@ -219,8 +221,8 @@ generate_pages_server <- function() {
for(yy in 1:length(content)) {
cnt2 <- content[[yy]]
if(pipeline$options[[o]]$shiny_name != "") {
if(cnt2$id == pipeline$options[[o]]$shiny_name) {
if(cnt2$type == "fileInput") {
if(cnt2$name == pipeline$options[[o]]$shiny_name) {
if(cnt2$type == "file") {
not_find <- F
res <- res + pipeline$options[[o]]$name + ' ", input$' + pipeline$options[[o]]$shiny_name+'$datapath '
}
......
App:
project: "/home/jimmy/jimmy/projets/sag/app/pipeline"
general:
title: "Pipeline in R"
skin: "green"
menu_width: 230
pages:
-
icon: "pencil"
menu: "Input Pipeline"
name: "inputs"
content:
-
id: "textInput1"
type: "textInput"
label: "Text input 1 :"
value: ""
-
id: "textInput2"
type: "textInput"
label: "Text input 2 :"
value: ""
-
id: "sliderInput1"
type: "sliderInput"
min: 0
max: 100
value: [50]
step: 1
label: "Slider input 1 :"
-
id: "sliderInput1"
type: "sliderInput"
min: 10
max: 20
step: 0.1
value: [11.8, 19.6]
label: "Slider input 2 :"
-
type: "selectInput"
id: "selectInput1"
label: "Select input 1 :"
selected: 2
choices:
-
label: "Choice 1"
value: 1
-
label: "Choice 2"
value: 2
-
label: "Choice 3"
value: "dqsdqsd"
-
type: "radioButtons"
id: "radioButtons1"
label: "Radio buttons 1 :"
selected: "C"
choices:
-
label: "Choice A"
value: "A"
-
label: "Choice B"
value: "B"
-
label: "Choice C"
value: "C"
-
type: "checkboxInput"
id: "checkboxInput1"
label: "Single Checkbox input 1 :"
value: TRUE
-
id: "p1"
type: "p"
value: "Just simple text for description or help"
-
type: "fileInput"
id: "fileInput2"
label: "Chose file"
multiple: FALSE
accept: [".csv", ".xslx"]
-
type: "checkboxGroupInput"
id: "checkboxGroupInput1"
label: "Group checkbox input 1 :"
width: "50%"
selected: "C"
choices:
-
label: "Choice A"
value: "A"
-
label: "Choice B"
value: "B"
-
label: "Choice C"
value: "C"
-
type: "fileInput"
id: "fileInput1"
label: "Chose file"
multiple: FALSE
accept: [".csv", ".xslx"]
-
class: "btn btn-success"
icon: ""
id: "testButton"
label: "Test"
type: "actionButton"
-
class: "btn btn-primary"
icon: "save"
id: "runP"
label: "Run"
type: "actionButton"
pipeline:
shiny_button: "runP"
program: "python"
options:
-
name: "/home/jimmy/mon_script.py"
shiny_name: ""
-