feat: allow passing of global settings launching from R or running docker container.

This commit is contained in:
Andreas Gammelgaard Damsbo 2026-03-11 13:22:54 +01:00
commit 8935b0b2a4
No known key found for this signature in database
5 changed files with 29 additions and 28 deletions

View file

@ -23,11 +23,11 @@ launch_FreesearchR <- function(inlcude_globalenv = TRUE,
data_limit_upper = 100000,
data_limit_lower = 1,
...) {
global_freesearchR <- list(
include_globalenv = include_globalenv,
data_limit_default = data_limit_default,
data_limit_upper = data_limit_upper,
data_limit_lower = data_limit_lower
Sys.setenv(
INCLUDE_GLOBALENV = include_globalenv,
DATA_LIMIT_DEFAULT = data_limit_default,
DATA_LIMIT_UPPER = data_limit_upper,
DATA_LIMIT_LOWER = data_limit_lower
)
appDir <- system.file("apps", "FreesearchR", package = "FreesearchR")
@ -39,3 +39,21 @@ launch_FreesearchR <- function(inlcude_globalenv = TRUE,
a <- shiny::runApp(appDir = paste0(appDir, "/app.R"), ...)
return(invisible(a))
}
## Helper to set env variables
get_config <- function(var_name, default = NULL) {
# First check environment variables (set by Docker)
val <- Sys.getenv(var_name, unset = NA)
if (!is.na(val) && nzchar(val)) {
return(val)
}
# Fall back to default (can be overridden when launching from R)
if (!is.null(default)) {
return(default)
}
stop(paste("Required config variable not set:", var_name))
}

Binary file not shown.

View file

@ -83,9 +83,9 @@ ui_elements <- function(selection) {
layout_params = "dropdown",
# title = "Choose a datafile to upload",
file_extensions = c(".csv", ".tsv", ".txt", ".xls", ".xlsx", ".rds", ".ods", ".dta"),
limit_default = global_freesearchR$data_limit_default,
limit_lower = global_freesearchR$data_limit_lower,
limit_upper = global_freesearchR$data_limit_upper
limit_default = DATA_LIMIT_DEFAULT,
limit_lower = DATA_LIMIT_LOWER,
limit_upper = DATA_LIMIT_UPPER
)
),
@ -107,7 +107,7 @@ ui_elements <- function(selection) {
id = "env",
title = NULL,
packages = c("NHANES", "stRoke", "datasets", "MASS"),
globalenv = global_freesearchR$include_globalenv
globalenv = isTruthy(INCLUDE_GLOBALENV)
)
),
# shiny::conditionalPanel(