Commit e8718e7b authored by Jean-Francois Rey's avatar Jean-Francois Rey
Browse files

shiny apps: start adding values check

parent ff6caad2
......@@ -17,6 +17,9 @@ data(package = "landsepiDev")
source("modules/editableDT.R")
VALUEMAX <- 1000
## del all file and directory of a path
cleanDir <- function(path) {
files <- dir(path, full.names=TRUE, no..=TRUE)
......
......@@ -352,28 +352,28 @@ server <- function(input, output, session) {
})
# repro_sex_prob
shiny::observeEvent(input$patho_repro_sex_prob, {
shiny::removeUI(selector = "#pathoReproSexProbError")
if (input$patho_repro_sex_prob > 1 || input$patho_repro_sex_prob < 0 || is.na(input$patho_repro_sex_prob)) {
showErrorMessage(
id = "pathoReproSexProbError", selectorafter = "#generateLandscape",
message = "The probability for an infectious host to reproduce via sex rather than via cloning should be between 0 and 1"
)
can_run_simul$patho_repro_sex_prob <<- FALSE
}
else {
simul_params@Pathogen$repro_sex_prob <<- input$patho_repro_sex_prob
can_run_simul$patho_repro_sex_prob <<- TRUE
}
})
# shiny::observeEvent(input$patho_repro_sex_prob, {
# shiny::removeUI(selector = "#pathoReproSexProbError")
# if (input$patho_repro_sex_prob > 1 || input$patho_repro_sex_prob < 0 || is.na(input$patho_repro_sex_prob)) {
# showErrorMessage(
# id = "pathoReproSexProbError", selectorafter = "#generateLandscape",
# message = "The probability for an infectious host to reproduce via sex rather than via cloning should be between 0 and 1"
# )
# can_run_simul$patho_repro_sex_prob <<- FALSE
# }
# else {
# simul_params@Pathogen$repro_sex_prob <<- input$patho_repro_sex_prob
# can_run_simul$patho_repro_sex_prob <<- TRUE
# }
# })
# propagule_prod_rate
shiny::observeEvent(input$patho_propagule_prod_rate, {
shiny::removeUI(selector = "#pathoProdRateError")
if (input$patho_propagule_prod_rate > 10 || input$patho_propagule_prod_rate < 0 || is.na(input$patho_propagule_prod_rate)) {
if (input$patho_propagule_prod_rate > VALUEMAX || input$patho_propagule_prod_rate < 0 || is.na(input$patho_propagule_prod_rate)) {
showErrorMessage(
id = "pathoProdRateError", selectorafter = "#generateLandscape",
message = "The maximal expected effective propagule production rate of an infectious host per time step should be between 0 and ?"
message = paste0("The maximal expected effective propagule production rate of an infectious host per time step should be between 0 and ",VALUEMAX)
)
can_run_simul$patho_propagule_prod_rate <<- FALSE
}
......@@ -386,10 +386,10 @@ server <- function(input, output, session) {
# latent_period_exp
shiny::observeEvent(input$patho_latent_period_exp, {
shiny::removeUI(selector = "#pathoLatPerExpError")
if (input$patho_latent_period_exp > 100 || input$patho_latent_period_exp < 0 || is.na(input$patho_latent_period_exp)) {
if (input$patho_latent_period_exp > VALUEMAX || input$patho_latent_period_exp < 0 || is.na(input$patho_latent_period_exp)) {
showErrorMessage(
id = "pathoLatPerExpError", selectorafter = "#generateLandscape",
message = "The minimal expected duration of the latent period should be between 0 and ?"
message = paste0("The minimal expected duration of the latent period should be between 0 and ",VALUEMAX)
)
can_run_simul$patho_latent_period_exp <<- FALSE
}
......@@ -402,10 +402,10 @@ server <- function(input, output, session) {
# latent_period_var
shiny::observeEvent(input$patho_latent_period_var, {
shiny::removeUI(selector = "#pathoLatPerVarError")
if (input$patho_latent_period_var > 10 || input$patho_latent_period_var < 0 || is.na(input$patho_latent_period_var)) {
if (input$patho_latent_period_var > VALUEMAX || input$patho_latent_period_var < 0 || is.na(input$patho_latent_period_var)) {
showErrorMessage(
id = "pathoLatPerVarError", selectorafter = "#generateLandscape",
message = "The variance of the infectious period duration should be between 0 and ?"
message = paste0("The variance of the infectious period duration should be between 0 and ",VALUEMAX)
)
can_run_simul$patho_latent_period_var <<- FALSE
}
......@@ -418,10 +418,10 @@ server <- function(input, output, session) {
# infectious_period_exp
shiny::observeEvent(input$patho_infectious_period_exp, {
shiny::removeUI(selector = "#pathoInfPerExpError")
if (input$patho_infectious_period_exp > 100 || input$patho_infectious_period_exp < 0 || is.na(input$patho_infectious_period_exp)) {
if (input$patho_infectious_period_exp > VALUEMAX || input$patho_infectious_period_exp < 0 || is.na(input$patho_infectious_period_exp)) {
showErrorMessage(
id = "pathoInfPerExpError", selectorafter = "#generateLandscape",
message = "The maximal expected duration of the infectious period should be between 0 and ?"
message = paste0("The maximal expected duration of the infectious period should be between 0 and ",VALUEMAX)
)
can_run_simul$patho_infectious_period_exp <<- FALSE
}
......@@ -434,10 +434,10 @@ server <- function(input, output, session) {
# infectious_period_var
shiny::observeEvent(input$patho_infectious_period_var, {
shiny::removeUI(selector = "#pathoInfPerVarError")
if (input$patho_infectious_period_var > 200 || input$patho_infectious_period_var < 0 || is.na(input$patho_infectious_period_var)) {
if (input$patho_infectious_period_var > VALUEMAX || input$patho_infectious_period_var < 0 || is.na(input$patho_infectious_period_var)) {
showErrorMessage(
id = "pathoInfPerVarError", selectorafter = "#generateLandscape",
message = "The variance of the infectious period duration should be between 0 and ?"
message = paste0("The variance of the infectious period duration should be between 0 and ",VALUEMAX)
)
can_run_simul$patho_infectious_period_var <<- FALSE
}
......@@ -450,10 +450,10 @@ server <- function(input, output, session) {
# sigmoid_kappa
shiny::observeEvent(input$patho_sigmoid_kappa, {
shiny::removeUI(selector = "#pathoSigKapError")
if (input$patho_sigmoid_kappa > 10 || input$patho_sigmoid_kappa < 0 || is.na(input$patho_sigmoid_kappa)) {
if (input$patho_sigmoid_kappa > VALUEMAX || input$patho_sigmoid_kappa < 0 || is.na(input$patho_sigmoid_kappa)) {
showErrorMessage(
id = "pathoSigKapError", selectorafter = "#generateLandscape",
message = "The kappa parameter of the sigmoid contamination function should be between 0 and ?"
message = paste0("The kappa parameter of the sigmoid contamination function should be between 0 and ",VALUEMAX)
)
can_run_simul$patho_sigmoid_kappa <<- FALSE
}
......@@ -466,10 +466,10 @@ server <- function(input, output, session) {
# sigmoid_sigma
shiny::observeEvent(input$patho_sigmoid_sigma, {
shiny::removeUI(selector = "#pathoSigSigError")
if (input$patho_sigmoid_sigma > 10 || input$patho_sigmoid_sigma < 0 || is.na(input$patho_sigmoid_sigma)) {
if (input$patho_sigmoid_sigma > VALUEMAX || input$patho_sigmoid_sigma < 0 || is.na(input$patho_sigmoid_sigma)) {
showErrorMessage(
id = "pathoSigSigError", selectorafter = "#generateLandscape",
message = "The sigma parameter of the sigmoid contamination function should be between 0 and ?"
message = paste0("The sigma parameter of the sigmoid contamination function should be between 0 and ",VALUEMAX)
)
can_run_simul$patho_sigmoid_sigma <<- FALSE
}
......@@ -480,20 +480,20 @@ server <- function(input, output, session) {
})
# sigmoid_plateau
shiny::observeEvent(input$patho_sigmoid_plateau, {
shiny::removeUI(selector = "#pathoSigPlaError")
if (input$patho_sigmoid_plateau > 10 || input$patho_sigmoid_plateau < 0 || is.na(input$patho_sigmoid_plateau)) {
showErrorMessage(
id = "pathoSigPlaError", selectorafter = "#generateLandscape",
message = "The plateau parameter of the sigmoid contamination function should be between 0 and ?"
)
can_run_simul$patho_sigmoid_plateau <<- FALSE
}
else {
simul_params@Pathogen$sigmoid_plateau <<- input$patho_sigmoid_plateau
can_run_simul$patho_sigmoid_plateau <<- TRUE
}
})
# shiny::observeEvent(input$patho_sigmoid_plateau, {
# shiny::removeUI(selector = "#pathoSigPlaError")
# if (input$patho_sigmoid_plateau > 10 || input$patho_sigmoid_plateau < 0 || is.na(input$patho_sigmoid_plateau)) {
# showErrorMessage(
# id = "pathoSigPlaError", selectorafter = "#generateLandscape",
# message = "The plateau parameter of the sigmoid contamination function should be between 0 and ?"
# )
# can_run_simul$patho_sigmoid_plateau <<- FALSE
# }
# else {
# simul_params@Pathogen$sigmoid_plateau <<- input$patho_sigmoid_plateau
# can_run_simul$patho_sigmoid_plateau <<- TRUE
# }
# })
# infection rate validation
shiny::observeEvent(input$patho_infection_rate, {
......@@ -856,7 +856,7 @@ server <- function(input, output, session) {
DTdata = shiny::reactive(simul_params_cultivars()),
disableCol = shiny::reactive({
if (isTRUE(advanced_mode())) {
c()
c("reproduction_rate","death_rate")
} else {
names(simul_params_cultivars())
}
......
......@@ -144,14 +144,14 @@ pathogenTab <- {
max = 1.0,
step = 0.0001
),
shiny::numericInput(
inputId = "patho_repro_sex_prob",
label = "Prob. for an infectious host to reporduce via sex rather than clonal",
value = 0,
min = 0.0,
max = 1.0,
step = 0.10
),
# shiny::numericInput(
# inputId = "patho_repro_sex_prob",
# label = "Prob. for an infectious host to reporduce via sex rather than clonal",
# value = 0,
# min = 0.0,
# max = 1.0,
# step = 0.10
# ),
shiny::numericInput(
inputId = "patho_infection_rate",
label = "Max expected infection rate of a propagule on a healthy host",
......@@ -219,15 +219,16 @@ pathogenTab <- {
min = 0.0,
max = 100,
step = 1
),
shiny::numericInput(
inputId = "patho_sigmoid_plateau",
label = "Plateau parameter of the sigmoid contamination function",
value = 1,
min = 0,
max = 100,
step = 1
)
#,
# shiny::numericInput(
# inputId = "patho_sigmoid_plateau",
# label = "Plateau parameter of the sigmoid contamination function",
# value = 1,
# min = 0,
# max = 100,
# step = 1
# )
)
)
)
......
Supports Markdown
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