Commit b7fc59fa authored by Loup's avatar Loup
Browse files

Merge remote-tracking branch 'origin/master'

parents e94a5af3 0205b4e4
......@@ -10,9 +10,9 @@ runShinyApp <- function() {
stop("Could not find example directory. Try re-installing `landsepi`.", call. = FALSE)
}
needed_packages <- c("shiny", "shinyBS", "DT", "shinyjs", "gridExtra", "png", "grid", "future", "promises", "tools")
needed_packages <- c("shiny", "shinyBS", "shinyalert", "DT", "shinyjs", "gridExtra", "png", "grid", "future", "promises", "tools")
if( sum(needed_packages %in% utils::installed.packages()[,1] == FALSE) != 0) {
stop('Install packages : install.packages(c("shiny","DT", "shinyjs", "gridExtra", "png", "grid", "future", "promises", "tools"))')
stop('Install packages : install.packages(c("shiny","shinyBS", "shinyalert", "DT", "shinyjs", "gridExtra", "png", "grid", "future", "promises", "tools"))')
}
shiny::runApp(appDir, launch.browser = TRUE, display.mode = "normal")
......
......@@ -12,6 +12,12 @@ library(promises)
library(tools)
library(shinyalert)
# Active debug level
# 0 : no print
# 1 : warning
# 2 : error
# 3 : all
ACTIVE_DEBUG <- 3
library("landsepiDev")
data(package = "landsepiDev")
......@@ -54,6 +60,13 @@ simul_params_genes <- shiny::reactiveVal()
# Functions
##################################################################
# Print message in terminal
# msg : message to print
# level : level of output (0 no output, 3 all output)
printVerbose <- function(msg, level=ACTIVE_DEBUG) {
if(level >= 3) cat(file=stderr(),"### DEBUG ",msg,"\n")
}
## Show message
## id : message id
## selectorafter : id element to place message after
......
......@@ -169,6 +169,7 @@ server <- function(input, output, session) {
observeEvent(input$Mode, {
advanced_mode(!advanced_mode())
if (advanced_mode()) {
printVerbose("enable mode edition", level=3)
shinyjs::disable(id = "demo")
shinyjs::enable(id = "rotationPeriod")
shinyjs::enable(id = "patho_infection_rate")
......@@ -184,6 +185,7 @@ server <- function(input, output, session) {
shinyjs::enable(id = "patho_sigmoid_plateau")
}
else {
printVerbose("disable mode edition", level=3)
shinyjs::disable(id = "rotationPeriod")
shinyjs::enable(id = "demo")
shinyjs::disable(id = "patho_infection_rate")
......@@ -656,23 +658,32 @@ server <- function(input, output, session) {
# Handle the "Run simulation" button
shiny::observeEvent(input$runSimulation, {
shinyjs::click("showOutputside")
withProgress(message = "Running Simulation, please wait...", value = 0, {
print(simul_params)
progressBar <- Progress$new()
progressBar$set(value = NULL, message = "Running Simulation, please wait...")
# setwd(paste0(ROOT_PATH,"/www/tmp/"))
shinyjs::disable(id = "inputpanel")
shinyjs::disable(id = "generateLandscape")
shinyjs::disable(id = "runSimulation")
shinyjs::disable(id = "export")
shinyjs::enable(id = "stopSimulation")
shinyjs::disable("showInputside")
shinyjs::disable("showBothside")
shinyjs::click("showOutputside") # seems not working -> force it
shinyjs::showElement(id = "outputside")
shinyjs::hideElement(id = "inputside")
removeCssClass("inputside", "col-sm-12")
removeCssClass("inputside", "col-sm-6")
addCssClass("inputside", "col-sm-0")
removeCssClass("outputside", "col-sm-0")
removeCssClass("outputside", "col-sm-6")
addCssClass("outputside", "col-sm-12")
progressBar$set(value = 0.4)
plan(list(multicore, multiprocess))
plan(list(multicore, multisession))
future_process <<- future({
res <- landsepiDev::runSimul(simul_params,
......@@ -684,11 +695,10 @@ server <- function(input, output, session) {
onFulfilled = function(value) {
progressBar$set(value = 0.8, message = "Simulation ended : making video...")
shinyjs::enable(id = "inputpanel")
shinyjs::enable(id = "generateLandscape")
# shinyjs::enable(id = "runSimulation")
shinyjs::enable(id = "export")
shinyjs::disable(id = "runSimulation")
shinyjs::enable(id = "runSimulation")
shinyjs::disable(id = "stopSimulation")
output$landscapeimg <- NULL
......@@ -705,6 +715,8 @@ server <- function(input, output, session) {
height = "auto"
)
)
shinyjs::enable("showInputside")
shinyjs::enable("showBothside")
shinyjs::click("showOutputside")
# setwd(dirname(getwd()))
},
......@@ -712,7 +724,9 @@ server <- function(input, output, session) {
setwd(ROOT_PATH)
cat(file = stderr(), "\n ### KILL'EM ALL ### -> Kill simulation \n")
cleanDir(simul_params@OutputDir)
shinyjs::enable(id = "inputpanel")
shinyjs::enable("showInputside")
shinyjs::enable("showBothside")
shinyjs::click("showBothside")
shinyjs::enable(id = "generateLandscape")
can_run_simul$landscape <<- FALSE
future_process <- NULL
......
......@@ -311,9 +311,9 @@ ui <- {
align="center"),
shiny::br(),
fluidRow(
actionButton("showOutputside", label = "", icon = icon("angle-double-left") ),
actionButton("showInputside", label = "", icon = icon("wpforms")),
actionButton("showBothside", label = "", icon = icon("columns")),
actionButton("showInputside", label = "", icon = icon("angle-double-right")),
actionButton("showOutputside", label = "", icon = icon("chart-line") ),
align="center"
),
shiny::br(),
......
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