# NOT RUN {
# }
# NOT RUN {
if(interactive()){
require(shiny)
# create temporary directory for conf
dir_conf <- paste0(tempdir(), "/conf", round(runif(n = 1, max = 10000)))
dir.create(dir_conf, recursive = TRUE)
# ex fun
fun_path = system.file("ex_fun/sb_fun_ex.R", package = "shinybatch")
fun_name = "sb_fun_ex"
# create 2 confs
conf_1 <- configure_task(dir_path = dir_conf,
conf_descr = list(title = "my_title_1",
description = "my_descr_1"),
fun_path = fun_path,
fun_name = fun_name,,
fun_args = list(x = 1,
y = 0:4,
z = iris),
priority = 1)
conf_2 <- configure_task(dir_path = dir_conf,
conf_descr = list(title = "my_title_2",
description = "my_descr_2"),
fun_path = fun_path,
fun_name = fun_name,
fun_args = list(x = 1,
y = 0:4,
z = iris),
priority = 2)
run_task(paste0(conf_2$dir, "conf.yml"))
# with package ui
ui <- shiny::fluidPage(
tasks_overview_UI("my_id_1"),
hr(),
verbatimTextOutput("info")
)
server <- function(input, output, session) {
selected_task <- callModule(tasks_overview_server, "my_id_1",
dir_path = dir_conf,
allowed_status = c("waiting", "running", "finished", "error"),
allowed_run_info_cols = NULL,
allowed_function_cols = "",
allow_descr = TRUE,
allow_args = TRUE,
table_fun = function(x, y) x[, new_col := y],
y = "created using arg. 'table_fun'")
output$info <- renderPrint({
selected_task()
})
}
shiny::shinyApp(ui = ui, server = server)
# using custom ui
ui <- shiny::fluidPage(
verbatimTextOutput("info")
# and so define what you want !
)
server <- function(input, output, session) {
all_tasks_info <- callModule(tasks_overview_server, "my_id_1",
dir_path = dir_conf,
return_value = "tasks_table"
)
output$info <- renderPrint({
all_tasks_info()
})
}
shiny::shinyApp(ui = ui, server = server)
}
# }
# NOT RUN {
# }
Run the code above in your browser using DataLab