The primary purpose of this Shiny module is to provide a framework to get parameters from a user required for the Shiny application to run.
Usage
userParamServer(
id,
params,
param_labels = params,
param_types = rep("character", length(params)),
param_defaults = rep("", length(params)),
modal_title = "Application Settings",
intro_message = "",
modal_size = "l",
save_label = "Save",
cancel_label = NULL,
allow_cookies = TRUE,
save_cookie_label = "Save parameters as cookies.",
validator = simple_parameter_validator,
open_on_startup = TRUE,
cookie_password = NULL,
cookie_expiration = 30,
input_params = list()
)
Arguments
- id
unique ID for the Shiny Login module.
- params
a character vector with the name of the parameters. This should be valid R names (i.e. start with a letter, do not contain any spaces, etc.).
- param_labels
labels used for the user inputs.
- param_types
the type of value. Valid types include
character
,numeric
,date
,file
,logical
,password
, orselect
. Note that forselect
you must specify thechoices
parameter in theinput_params
. For example,input_params <- list('param_name' = c('Option A', 'Option B'))
- param_defaults
default values for the params.
- modal_title
title for the modal dialog.
- intro_message
A message that is displayed at the top of the modal dialog. This can be a character string or any valid Shiny container (e.g.
shiny::div
).- modal_size
One of "s" for small, "m" (the default) for medium, "l" for large, or "xl" for extra large. See
shiny::modalDialog()
for more info.- save_label
label for the save button in the modal dialog.
- cancel_label
label for the cancel button in the modal dialog, or
NULL
to exclude. If available a user clicking the cancel button will bypass any validation checks.if
TRUE
the user can opt to save the values as cookies. The user will still be presented with a checkbox to not save parameters as cookies.label for the check box where the user can opt to save the parameter values as cookies.
- validator
a function to validate the user inputs. See
simple_parameter_validator()
for an example. The function should take two parameters: a named list of values to check and a vector of value types (seeparam_types
). The function should return eitherTRUE
if the validation passes or a character string indicating why the validation failed. Set toNULL
to disable validation.- open_on_startup
if
TRUE
the modal dialog will be shown if the parameters could not be read from cookies (i.e. they have not been set yet).key used to encrypt/decrypt cookies. See
encrypt_cookie()
anddecrypt_cookie()
.the number of days after which the cookie will expire.
- input_params
additional parameters passed to the Shiny input. This should be a named list where names correspond to
params
.
Value
a shiny::reactiveValues object.