Skip to contents

Merges default app options with the changes made in the UI

Usage

UD_fetch_state(id, id_ASM, input, session, FM_yaml_file, MOD_yaml_file)

Arguments

id

Shiny module ID

id_ASM

ID string for the app state management module used to save and load app states

input

Shiny input variable

session

Shiny session variable

FM_yaml_file

App configuration file with FM as main section.

MOD_yaml_file

Module configuration file with MC as main section.

Value

list containing the current state of the app including default values from the yaml file as well as any changes made by the user. The list has the following structure:

  • yaml: Full contents of the supplied yaml file.

  • MC: Module components of the yaml file.

  • DS: Loaded dataset with the following elements

    • isgood: Boolean object indicating if the file was successfully loaded.

    • load_msg: Text message indicated the success or any problems encountered when uploading the file.

    • data_file_local: Full path to the data file on the server.

    • data_file: Dataset file name without the path.

    • data_file_ext: File extension of the uploaded file.

    • sheet: If the uploaded file is an excel file, this is the currently selected sheet.

    • sheets: If the uploaded file is an excel file, this is a character vector of the sheets present in that file.

    • contents: Data frame containting the contents of the data file.

    • checksum: This is an MD5 sum of the contents element and can be used to detect changes in the loaded file.

  • MOD_TYPE: Character data containing the type of module "UD"

  • id: Character data containing the module id module in the session variable.

  • FM_yaml_file: App configuration file with FM as main section.

  • MOD_yaml_file: Module configuration file with MC as main section.

Examples

# YAML configuration files from the package:
FM_yaml_file  = system.file(package = "formods", "templates", "formods.yaml")
MOD_yaml_file = system.file(package = "formods", "templates", "UD.yaml")
# This is the module id:
id = "UD"
# Within shiny both session and input variables will exist,
# this creates examples here for testing purposes:
sess_res = UD_test_mksession(session=list())
#> → UD: including file
#> → UD:   source: file.path(system.file(package="onbrand"), "templates", "report.docx")
#> → UD:   dest:   file.path("config","report.docx")
#> → UD: including file
#> → UD:   source: file.path(system.file(package="onbrand"), "templates", "report.pptx")
#> → UD:   dest:   file.path("config","report.pptx")
#> → UD: including file
#> → UD:   source: file.path(system.file(package="onbrand"), "templates", "report.yaml")
#> → UD:   dest:   file.path("config","report.yaml")
#> → UD: State initialized
#> → UD: module checksum updated:897d952fecbc804999396a96f9df4b20
session = sess_res$session
input   = sess_res$input
state = UD_fetch_state(
           id            = id,
           input         = input,
           session       = session,
           FM_yaml_file  = FM_yaml_file,
           MOD_yaml_file = MOD_yaml_file )
#> → UD: module checksum updated:897d952fecbc804999396a96f9df4b20