Commit 4f770561 authored by jlopez's avatar jlopez
Browse files

fix system cmd

parent 3fa421e0
MenuGauche = sidebarMenu(id="sidebarmenu",
menuItem("Input Pipeline", tabName="inputs", icon=icon("pencil", lib="font-awesome"), newtab=FALSE),
menuItem("Input Pipeline 2", tabName="input2", icon=icon("", lib="font-awesome"), newtab=FALSE),
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)
)
#@author jimmy.lopez@univ-montp2.fr
library(shiny)
library(shinydashboard)
library(shinyjs)
......@@ -8,30 +10,53 @@ library(stringr)
library(shinyFiles)
library(tools)
source("./pages/pages_def_inputs.R", local=T)
source("./pages/pages_def_input2.R", local=T)
source("./R/menugauche.R", local=T)
style <- tags$style(HTML(readLines("www/added_styles.css")))
UI <- dashboardPage(
skin="green",
dashboardHeader(title="Pipeline in R", titleWidth=230),
dashboardSidebar(width=230, MenuGauche),
dashboardBody(
shinyjs::useShinyjs(),
tags$head(tags$link(rel="stylesheet", type="text/css", href="bootstrap.min.readable.css")),
tags$head(style),
tabItems(
tabItem(tabName = "inputs", tabinputs),
tabItem(tabName = "input2", tabinput2)
tabItems(
tabItem(tabName = "inputs", tabinputs),
tabItem(tabName = "input2", tabinput2)
)
)
)
server <- function( input, output, session) {
source("./server/opt_inputs.R", local=T)
source("./server/opt_input2.R", local=T)
}
shinyApp(ui = UI, server = server)
tabinputs = fluidPage(
textInput("textInput1", label = "Text input 1 :", value = "", width = "50%"),
textInput("textInput2", label = "Text input 2 :", value = "", width = "300px"),
sliderInput("sliderInput1", label = "Slider input 1 :", min = 0, max = 100, step = 1, width = "50%", value = 50),
sliderInput("sliderInput1", label = "Slider input 2 :", min = 10, max = 20, step = 0.1, width = "50%", value = c(11.8,19.6)),
selectInput("selectInput1",label = "Select input 1 :", choices = list("Choice 1" = 1, "Choice 2" = 2, "Choice 3" = "dqsdqsd"), selected = "2", width = "30%"),
radioButtons("radioButtons1",label = "Radio buttons 1 :", choices = list("Choice A" = "A", "Choice B" = "B", "Choice C" = "C"), selected = "C", width = "50%"),
checkboxInput("checkboxInput1", label = "Single Checkbox input 1 :", value = TRUE),
p("Just simple text for description or help"),
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%"),
actionButton("runP", "Run", icon("save"), class="btn btn-primary")
)
#' Event when use runP button
observeEvent(input$runP, {
print(input$fileInput1)
print(paste0(" python /home/jimmy/mon_script.py -i1 ", input$radioButtons1, " -path2 ", input$fileInput2$datapath , " ", input$selectInput1, " -path1 ", input$fileInput1$datapath ))
})
......@@ -43,9 +43,6 @@ App:
value: [11.8, 19.6]
width: "50%"
label: "Slider input 2 :"
-
type: "selectInput"
id: "selectInput1"
......@@ -92,9 +89,18 @@ App:
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"
......@@ -128,6 +134,30 @@ App:
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"
......
......@@ -5,6 +5,8 @@ path_yml <- "/home/jimmy/jimmy/projets/sag/app/pipelineR.yml"
APP <<- yaml.load_file(path_yml)$App
#============================================================
generate_added_styles <- function () {
path_css = APP$project + "/www/added_styles.css"
......@@ -21,7 +23,7 @@ generate_pages_server <- function() {
path_page = APP$project+"/pages/pages_def_"+tolower(name)+".R"
file.create(path_page)
res <- 'tab'+ name + ' = fluidPage(\n'
res <- 'tab'+ name + ' = fluidPage(\n\n'
content <- APP$pages[[x]]$content
......@@ -163,9 +165,9 @@ generate_pages_server <- function() {
if(y < length(content)) {
res <- res + ",\n"
res <- res + ",\n\n"
} else {
res <- res + "\n"
res <- res + "\n\n"
}
}
......@@ -173,7 +175,7 @@ generate_pages_server <- function() {
}
res <- res + ')\n'
res <- res + ')\n\n'
write(res, file=path_page)
......@@ -188,17 +190,77 @@ generate_pages_server <- function() {
for(y in 1:length(content)) {
type <- content[[y]]$type
id <- content[[y]]$id
cnt <- content[[y]]
type <- cnt$type
id <- cnt$id
if(type == "actionButton") {
res <- res + '#\' Event when use '+ id +' button\n'
res <- res + 'observeEvent(input$'+id+', {'
res <- res + '\n\n'
res <- res + '})\n'
res <- res + 'observeEvent(input$'+id+', {\n\n'
if(APP$pages[[x]]$pipeline$shiny_button == id) {
pipeline <- APP$pages[[x]]$pipeline
res <- res + '\tprint(paste0(" '
# if debug use print & real use system fon run cmd
#res <- res + '\tsystem(paste0(" '
if(length(pipeline$options) > 0) {
res <- res + pipeline$program + ' '
for(o in 1:length(pipeline$options)) {
if(pipeline$options[[o]]$shiny_name != "") {
not_find <- T
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") {
not_find <- F
res <- res + pipeline$options[[o]]$name + ' ", input$' + pipeline$options[[o]]$shiny_name+'$datapath '
}
}
}
}
if(not_find) {
res <- res + pipeline$options[[o]]$name + ' ", input$' + pipeline$options[[o]]$shiny_name
}
if(o < length(pipeline$options)) {
res <- res + ', " '
} else {
res <- res + ' '
}
} else {
res <- res + pipeline$options[[o]]$name + ' '
}
}
}
res <- res + ' ))\n\n'
} else {
res <- res + '\n\n'
}
res <- res + '})\n\n'
}
}
write(res, file=path_opt)
......@@ -219,20 +281,20 @@ generate_menu <- function() {
res <- ""
res <- res + 'MenuGauche = sidebarMenu(id="sidebarmenu",\n'
res <- res + 'MenuGauche = sidebarMenu(id="sidebarmenu",\n\n'
for(x in 1:length(APP$pages)) {
name <- APP$pages[[x]]$name
icon <- APP$pages[[x]]$icon
menu <- APP$pages[[x]]$menu
res <- res + ' menuItem("'+menu+'", tabName="'+name+'", icon=icon("'+icon+'", lib="font-awesome"), newtab=FALSE),\n'
res <- res + ' menuItem("'+menu+'", tabName="'+name+'", icon=icon("'+icon+'", lib="font-awesome"), newtab=FALSE),\n\n'
}
res <- res + ' tags$br(),\n'
res <- res + ' 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'
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'
res <- res + ')\n\n'
write(res, file = path_file)
......@@ -275,7 +337,7 @@ generate_app <- function() {
file.create(path_project)
res <- "#@author jimmy.lopez@univ-montp2.fr\n\n"
res <- "#@author jimmy.lopez@univ-montp2.fr\n\n\n\n"
res <- res + 'library(shiny)\n'
res <- res + 'library(shinydashboard)\n'
......@@ -285,63 +347,63 @@ generate_app <- function() {
res <- res + 'library(shinyFiles)\n'
res <- res + 'library(tools)\n'
res <- res + '\n'
res <- res + '\n\n'
for(x in 1:length(APP$pages)) {
name <- APP$pages[[x]]$name
res <- res + 'source("./pages/pages_def_'+tolower(name)+'.R", local=T)\n'
}
res <- res + 'source("./R/menugauche.R", local=T)\n'
res <- res + 'source("./R/menugauche.R", local=T)\n\n'
res <- res + '\n'
res <- res + '\n\n'
res <- res + 'style <- tags$style(HTML(readLines("www/added_styles.css")))\n'
res <- res + 'style <- tags$style(HTML(readLines("www/added_styles.css")))\n\n'
res <- res + 'UI <- dashboardPage(\n'
res <- res + ' skin="' + main$skin + '",\n'
res <- res + ' dashboardHeader(title="'+ main$title + '", titleWidth='+main$menu_width+'),\n'
res <- res + ' dashboardSidebar(width='+main$menu_width+', MenuGauche),\n'
res <- res + ' dashboardBody(\n'
res <- res + ' shinyjs::useShinyjs(),\n'
res <- res + ' tags$head(tags$link(rel="stylesheet", type="text/css", href="bootstrap.min.readable.css")),\n'
res <- res + 'UI <- dashboardPage(\n\n'
res <- res + ' skin="' + main$skin + '",\n\n'
res <- res + ' dashboardHeader(title="'+ main$title + '", titleWidth='+main$menu_width+'),\n\n'
res <- res + ' dashboardSidebar(width='+main$menu_width+', MenuGauche),\n\n'
res <- res + ' dashboardBody(\n\n'
res <- res + ' shinyjs::useShinyjs(),\n\n'
res <- res + ' tags$head(tags$link(rel="stylesheet", type="text/css", href="bootstrap.min.readable.css")),\n\n'
#tags$head(tags$script(src="message-handler.js")),
res <- res + 'tags$head(style),\n'
res <- res + ' tabItems(\n'
res <- res + 'tags$head(style),\n\n'
res <- res + '\ttabItems(\n\n'
for(x in 1:length(APP$pages)) {
name <- APP$pages[[x]]$name
res <- res + 'tabItem(tabName = "' + name + '", tab'+ name +')'
res <- res + '\ttabItem(tabName = "' + name + '", tab'+ name +')'
if(x < length(APP$pages)) {
res <- res + ",\n"
res <- res + ",\n\n"
} else {
res <- res + "\n"
res <- res + "\n\n"
}
}
res <- res + ' )\n'
res <- res + ')\n'
res <- res + ')\n'
res <- res + ' )\n\n'
res <- res + ')\n\n'
res <- res + ')\n\n'
res <- res + '\n'
res <- res + '\n\n'
res <- res + 'server <- function( input, output, session) {\n'
res <- res + 'server <- function( input, output, session) {\n\n'
for(x in 1:length(APP$pages)) {
name <- APP$pages[[x]]$name
res <- res + 'source("./server/opt_'+tolower(name)+'.R", local=T)\n'
}
res <- res + '\n'
res <- res + '\n\n'
res <- res + '}\n'
res <- res + '}\n\n'
res <- res + '\n'
res <- res + '\n\n'
res <- res + 'shinyApp(ui = UI, server = server)'
......
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