Skip to contents

Merges default app options with the changes made in the UI

Usage

ASM_fetch_state(id, input, session, FM_yaml_file, MOD_yaml_file)

Arguments

id

Shiny module ID

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.

  • ASM:

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

    • checksum: This is an MD5 sum of the loaded state file

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

  • 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

# Within shiny both session and input variables will exist,
# this creates examples here for testing purposes:
sess_res = ASM_test_mksession(session=list(), full_session=FALSE)
#> → 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
#> → DW: including file
#> → DW:   source: file.path(system.file(package="onbrand"), "templates", "report.docx")
#> → DW:   dest:   file.path("config","report.docx")
#> → DW: including file
#> → DW:   source: file.path(system.file(package="onbrand"), "templates", "report.pptx")
#> → DW:   dest:   file.path("config","report.pptx")
#> → DW: including file
#> → DW:   source: file.path(system.file(package="onbrand"), "templates", "report.yaml")
#> → DW:   dest:   file.path("config","report.yaml")
#> → DW: State initialized
#> → DW: module checksum updated:5b0f0b05ee3ac7336a74c564bb6efdad
#> → DW: module checksum updated:65801ab4b3c645aabf7edf91fc2f0d2c
#> → DW: module checksum updated:7fb2dd3b16b1780c4c24f64d658dd7c7
#> → DW: module checksum updated:5ab04ea00be44c0040695a4ed6243c90
#> → DW: module checksum updated:960db107cfe9db93578f79f0ae6283e2
#> → DW: module checksum updated:f0b5d122dcb04f207cba233253b61c4b
#> → DW: module checksum updated:189ed77a84bd9fcdd7b26abff8bea34a
#> → DW: module checksum updated:669ec77d50652669cd3fcfd949469b37
#> → DW: module checksum updated:dd6cafa0be3b6b195d230a11e9f07f9f
#> → DW: module checksum updated:5c2022c376ca8f56b839347156559890
#> → DW: module checksum updated:43640500a04674debd8e2399056c384a
#> → DW: module checksum updated:f81c45ac1ef4e7b43153d8c8eaf7aed6
#> → DW: module checksum updated:207cde891d98e20c4afbb7fb5fb0aba2
#> → DW: module checksum updated:0a673e81c01cbbf33533dd65d6baf9e3
#> → DW: module checksum updated:af3f3aefd0115ed9dfdd4d6ef9d5182f
#> → DW: module checksum updated:b0ccaee21e859322df0bf79d00c4b347
#> → DW: module checksum updated:2d3d6e9e38be6dea813b2d4d679e34b5
#> → DW: module checksum updated:2b60dd49b48a4e65200dc7241ad270e3
#> → DW: module checksum updated:3c92f397181a4fcdbdf2bd7dd7425e77
#> → DW: module checksum updated:92b81d7573def603649370b87c123b55
#> → DW: module checksum updated:9210264aabc0339e832b0c6bcfda32af
#> → DW: module checksum updated:fe62fde1e7e738a1a35c479de9d5007b
#> → DW: module checksum updated:ff3edcd4c1e58c96ea2707361916ffbc
#> → DW: module checksum updated:b6cdfcef0432c5d9b1fa2bd46122ffa2
#> → DW: module checksum updated:4fa4283f1fd8fd6cf6e6e7df0669723a
#> → DW: module checksum updated:cf3e139cef554b2d09dca619ee6aff41
#> → DW: module checksum updated:a9154d91a9e4b5d21f9585a6f68dd083
#> → DW: module checksum updated:4b5c6ad66658ddfa92d10ae1b0b7afa8
#> → DW: module checksum updated:591ac875a490b66a1fa7f4e7d4ba1c62
#> → DW: module checksum updated:afa3ca309cc3e6a48f542f4e8eadd54a
#> → DW: module checksum updated:5c918dd4f53a4f1e56115abb09c4f332
#> → DW: module checksum updated:159ddf8c8cd26b178dfda5434bbecfa1
#> → DW: module checksum updated:8bb3c97e700998f2f73353189bd07831
#> → DW: module checksum updated:a1eceffec3ff7d9f9961683b3d07088b
#> → ASM: including file
#> → ASM:   source: file.path(system.file(package="onbrand"), "templates", "report.docx")
#> → ASM:   dest:   file.path("config","report.docx")
#> → ASM: including file
#> → ASM:   source: file.path(system.file(package="onbrand"), "templates", "report.pptx")
#> → ASM:   dest:   file.path("config","report.pptx")
#> → ASM: including file
#> → ASM:   source: file.path(system.file(package="onbrand"), "templates", "report.yaml")
#> → ASM:   dest:   file.path("config","report.yaml")
#> → ASM: State initialized
session = sess_res$session
input   = sess_res$input

# Configuration files
FM_yaml_file  = system.file(package = "formods", "templates", "formods.yaml")
MOD_yaml_file = system.file(package = "formods", "templates", "ASM.yaml")

# We need to specify the ID of the ASM module
id = "ASM"

state = ASM_fetch_state(id           = id,
                        input        = input,
                        session      = session,
                        FM_yaml_file = FM_yaml_file,
                        MOD_yaml_file = MOD_yaml_file)

state
#> $yaml
#> $yaml$FM
#> $yaml$FM$include
#> $yaml$FM$include$files
#> $yaml$FM$include$files[[1]]
#> $yaml$FM$include$files[[1]]$file
#> $yaml$FM$include$files[[1]]$file$source
#> [1] "file.path(system.file(package=\"onbrand\"), \"templates\", \"report.docx\")"
#> 
#> $yaml$FM$include$files[[1]]$file$dest
#> [1] "file.path(\"config\",\"report.docx\")"
#> 
#> 
#> 
#> $yaml$FM$include$files[[2]]
#> $yaml$FM$include$files[[2]]$file
#> $yaml$FM$include$files[[2]]$file$source
#> [1] "file.path(system.file(package=\"onbrand\"), \"templates\", \"report.pptx\")"
#> 
#> $yaml$FM$include$files[[2]]$file$dest
#> [1] "file.path(\"config\",\"report.pptx\")"
#> 
#> 
#> 
#> $yaml$FM$include$files[[3]]
#> $yaml$FM$include$files[[3]]$file
#> $yaml$FM$include$files[[3]]$file$source
#> [1] "file.path(system.file(package=\"onbrand\"), \"templates\", \"report.yaml\")"
#> 
#> $yaml$FM$include$files[[3]]$file$dest
#> [1] "file.path(\"config\",\"report.yaml\")"
#> 
#> 
#> 
#> 
#> 
#> $yaml$FM$deployed
#> [1] FALSE
#> 
#> $yaml$FM$code
#> $yaml$FM$code$theme
#> [1] "vibrant_ink"
#> 
#> $yaml$FM$code$showLineNumbers
#> [1] TRUE
#> 
#> $yaml$FM$code$gen_file
#> [1] "run_analysis.R"
#> 
#> $yaml$FM$code$gen_preamble
#> [1] "# formods automated output ------------------------------------------------\n# https://formods.ubiquity.tools/\nrm(list=ls())"
#> 
#> $yaml$FM$code$packages
#> [1] "onbrand" "writexl"
#> 
#> 
#> $yaml$FM$notifications
#> $yaml$FM$notifications$config
#> $yaml$FM$notifications$config$success
#> $yaml$FM$notifications$config$success$useFontAwesome
#> [1] FALSE
#> 
#> $yaml$FM$notifications$config$success$useIcon
#> [1] FALSE
#> 
#> $yaml$FM$notifications$config$success$background
#> [1] "#5bb85b"
#> 
#> 
#> $yaml$FM$notifications$config$failure
#> $yaml$FM$notifications$config$failure$useFontAwesome
#> [1] FALSE
#> 
#> $yaml$FM$notifications$config$failure$useIcon
#> [1] FALSE
#> 
#> $yaml$FM$notifications$config$failure$background
#> [1] "#d9534f"
#> 
#> 
#> $yaml$FM$notifications$config$info
#> $yaml$FM$notifications$config$info$useFontAwesome
#> [1] FALSE
#> 
#> $yaml$FM$notifications$config$info$useIcon
#> [1] FALSE
#> 
#> $yaml$FM$notifications$config$info$background
#> [1] "#5bc0de"
#> 
#> 
#> $yaml$FM$notifications$config$warning
#> $yaml$FM$notifications$config$warning$useFontAwesome
#> [1] FALSE
#> 
#> $yaml$FM$notifications$config$warning$useIcon
#> [1] FALSE
#> 
#> $yaml$FM$notifications$config$warning$background
#> [1] "#f0ac4d"
#> 
#> 
#> 
#> 
#> $yaml$FM$reporting
#> $yaml$FM$reporting$enabled
#> [1] TRUE
#> 
#> $yaml$FM$reporting$content_init
#> $yaml$FM$reporting$content_init$xlsx
#> [1] "rpt = list(summary = NULL,\n           sheets  = list())"
#> 
#> $yaml$FM$reporting$content_init$docx
#> [1] "rpt  = onbrand::read_template(\n  template = file.path(\"config\", \"report.docx\"),\n  mapping  = file.path(\"config\", \"report.yaml\"))"
#> 
#> $yaml$FM$reporting$content_init$pptx
#> [1] "rpt  = onbrand::read_template(\n  template = file.path(\"config\", \"report.pptx\"),\n  mapping  = file.path(\"config\", \"report.yaml\"))"
#> 
#> 
#> $yaml$FM$reporting$phs
#> $yaml$FM$reporting$phs[[1]]
#> $yaml$FM$reporting$phs[[1]]$name
#> [1] "HEADERLEFT"
#> 
#> $yaml$FM$reporting$phs[[1]]$location
#> [1] "header"
#> 
#> $yaml$FM$reporting$phs[[1]]$value
#> [1] ""
#> 
#> $yaml$FM$reporting$phs[[1]]$tooltip
#> [1] "left header text"
#> 
#> 
#> $yaml$FM$reporting$phs[[2]]
#> $yaml$FM$reporting$phs[[2]]$name
#> [1] "HEADERRIGHT"
#> 
#> $yaml$FM$reporting$phs[[2]]$location
#> [1] "header"
#> 
#> $yaml$FM$reporting$phs[[2]]$value
#> [1] ""
#> 
#> $yaml$FM$reporting$phs[[2]]$tooltip
#> [1] "right header text"
#> 
#> 
#> $yaml$FM$reporting$phs[[3]]
#> $yaml$FM$reporting$phs[[3]]$name
#> [1] "FOOTERLEFT"
#> 
#> $yaml$FM$reporting$phs[[3]]$location
#> [1] "footer"
#> 
#> $yaml$FM$reporting$phs[[3]]$value
#> [1] ""
#> 
#> $yaml$FM$reporting$phs[[3]]$tooltip
#> [1] "left footer text"
#> 
#> 
#> 
#> $yaml$FM$reporting$phs_formatting
#> $yaml$FM$reporting$phs_formatting$width
#> [1] "100%"
#> 
#> $yaml$FM$reporting$phs_formatting$tt_position
#> [1] "left"
#> 
#> $yaml$FM$reporting$phs_formatting$tt_size
#> [1] "medium"
#> 
#> 
#> 
#> $yaml$FM$ui
#> $yaml$FM$ui$button_style
#> [1] "fill"
#> 
#> $yaml$FM$ui$select_size
#> [1] 10
#> 
#> $yaml$FM$ui$color_green
#> [1] "#00BB8A"
#> 
#> $yaml$FM$ui$color_red
#> [1] "#FF475E"
#> 
#> $yaml$FM$ui$color_blue
#> [1] "#0088FF"
#> 
#> $yaml$FM$ui$color_purple
#> [1] "#bd2cf4"
#> 
#> 
#> $yaml$FM$data_meta
#> $yaml$FM$data_meta$data_header
#> [1] "<span style='color:===COLOR==='><b>===NAME===</b><br/><font size='-3'>===LABEL===</font></span>"
#> 
#> $yaml$FM$data_meta$subtext
#> [1] "===LABEL===: ===RANGE==="
#> 
#> $yaml$FM$data_meta$many_sep
#> [1] ",⋅⋅⋅,"
#> 
#> $yaml$FM$data_meta$data_types
#> $yaml$FM$data_meta$data_types$character
#> $yaml$FM$data_meta$data_types$character$color
#> [1] "#DD4B39"
#> 
#> $yaml$FM$data_meta$data_types$character$label
#> [1] "text"
#> 
#> 
#> $yaml$FM$data_meta$data_types$double
#> $yaml$FM$data_meta$data_types$double$color
#> [1] "#3C8DBC"
#> 
#> $yaml$FM$data_meta$data_types$double$label
#> [1] "num"
#> 
#> 
#> $yaml$FM$data_meta$data_types$integer
#> $yaml$FM$data_meta$data_types$integer$color
#> [1] "#3C8DBC"
#> 
#> $yaml$FM$data_meta$data_types$integer$label
#> [1] "num"
#> 
#> 
#> $yaml$FM$data_meta$data_types$other
#> $yaml$FM$data_meta$data_types$other$color
#> [1] "black"
#> 
#> $yaml$FM$data_meta$data_types$other$label
#> [1] "other"
#> 
#> 
#> 
#> 
#> $yaml$FM$labels
#> $yaml$FM$labels$default_ds
#> [1] "Original data set"
#> 
#> 
#> $yaml$FM$user_files
#> $yaml$FM$user_files$use_tmpdir
#> [1] TRUE
#> 
#> 
#> $yaml$FM$logging
#> $yaml$FM$logging$enabled
#> [1] TRUE
#> 
#> $yaml$FM$logging$timestamp
#> [1] TRUE
#> 
#> $yaml$FM$logging$timestamp_fmt
#> [1] "%Y-%m-%d %H:%M:%S"
#> 
#> $yaml$FM$logging$log_file
#> [1] "formods_log.txt"
#> 
#> $yaml$FM$logging$console
#> [1] TRUE
#> 
#> 
#> 
#> 
#> $MC
#> $MC$code
#> $MC$code$readOnly
#> [1] TRUE
#> 
#> $MC$code$mode
#> [1] "r"
#> 
#> 
#> $MC$show_log
#> [1] 50
#> 
#> $MC$reporting
#> $MC$reporting$enabled
#> [1] FALSE
#> 
#> $MC$reporting$priority
#> [1] 1
#> 
#> 
#> $MC$formatting
#> $MC$formatting$input_load_state
#> $MC$formatting$input_load_state$width
#> [1] "100%"
#> 
#> 
#> $MC$formatting$ui_asm_save_name
#> $MC$formatting$ui_asm_save_name$width
#> [1] "100%"
#> 
#> 
#> $MC$formatting$button_state_save
#> $MC$formatting$button_state_save$size
#> [1] "sm"
#> 
#> $MC$formatting$button_state_save$block
#> [1] TRUE
#> 
#> 
#> $MC$formatting$button_rpt_xlsx
#> $MC$formatting$button_rpt_xlsx$size
#> [1] "sm"
#> 
#> $MC$formatting$button_rpt_xlsx$block
#> [1] TRUE
#> 
#> 
#> $MC$formatting$button_rpt_pptx
#> $MC$formatting$button_rpt_pptx$size
#> [1] "sm"
#> 
#> $MC$formatting$button_rpt_pptx$block
#> [1] TRUE
#> 
#> 
#> $MC$formatting$button_rpt_docx
#> $MC$formatting$button_rpt_docx$size
#> [1] "sm"
#> 
#> $MC$formatting$button_rpt_docx$block
#> [1] TRUE
#> 
#> 
#> $MC$formatting$switch_gen_reports
#> $MC$formatting$switch_gen_reports$default
#> [1] FALSE
#> 
#> $MC$formatting$switch_gen_reports$right
#> [1] TRUE
#> 
#> $MC$formatting$switch_gen_reports$inline
#> [1] TRUE
#> 
#> $MC$formatting$switch_gen_reports$width
#> NULL
#> 
#> 
#> 
#> $MC$labels
#> $MC$labels$ui_asm_save_name
#> [1] "Save Analysis"
#> 
#> $MC$labels$ui_asm_save_name_ph
#> [1] "my_analysis"
#> 
#> $MC$labels$ui_asm_switch_gen_rpts
#> [1] "Generate reports when saving."
#> 
#> $MC$labels$save_state
#> [1] "Save"
#> 
#> $MC$labels$gen_rpt_header
#> [1] "Generate Reports"
#> 
#> $MC$labels$gen_rpt_docx_ph
#> [1] "Word Report Paceholders"
#> 
#> $MC$labels$input_load_state
#> [1] "Load Analysis"
#> 
#> $MC$labels$upload_button
#> [1] "Load"
#> 
#> $MC$labels$upload_placeholder
#> [1] "Select analysis file"
#> 
#> $MC$labels$ui_asm_rpt_xlsx
#> [1] "xlsx"
#> 
#> $MC$labels$ui_asm_rpt_pptx
#> [1] "pptx"
#> 
#> $MC$labels$ui_asm_rpt_docx
#> [1] "docx"
#> 
#> $MC$labels$load_success
#> [1] "Analysis loaded"
#> 
#> $MC$labels$busy
#> $MC$labels$busy$loading_state
#> [1] "Loading analysis"
#> 
#> $MC$labels$busy$saving_state
#> [1] "Saving analysis"
#> 
#> $MC$labels$busy$xlsx
#> [1] "Generating report: Excel"
#> 
#> $MC$labels$busy$docx
#> [1] "Generating report: Word"
#> 
#> $MC$labels$busy$pptx
#> [1] "Generating report: PowerPoint"
#> 
#> 
#> 
#> $MC$errors
#> $MC$errors$bad_input
#> [1] "Input error message"
#> 
#> $MC$errors$load_failed
#> [1] "Failed to load analysis"
#> 
#> 
#> $MC$tooltips
#> $MC$tooltips$include
#> [1] TRUE
#> 
#> $MC$tooltips$components
#> $MC$tooltips$components$input_tip
#> [1] "My tool tip"
#> 
#> 
#> 
#> 
#> $ASM
#> $ASM$button_counters
#> $ASM$button_counters$button_state_save
#> [1] 0
#> 
#> $ASM$button_counters$button_rpt_xlsx
#> [1] 0
#> 
#> $ASM$button_counters$button_rpt_docx
#> [1] 0
#> 
#> $ASM$button_counters$button_rpt_pptx
#> [1] 0
#> 
#> 
#> $ASM$ui_hold
#> list()
#> 
#> $ASM$ui_ids
#> [1] "button_state_save"          "button_rpt_xlsx"           
#> [3] "button_rpt_docx"            "button_rpt_pptx"           
#> [5] "ui_asm_save_name"           "switch_gen_rpts"           
#> [7] "ui_asm_docx_ph_HEADERLEFT"  "ui_asm_docx_ph_HEADERRIGHT"
#> [9] "ui_asm_docx_ph_FOOTERLEFT" 
#> 
#> $ASM$isgood
#> [1] TRUE
#> 
#> $ASM$checksum
#> [1] "f9e884084b84794d762a535f3facec85"
#> 
#> $ASM$ph_uis
#> $ASM$ph_uis$ui_asm_docx_ph_HEADERLEFT
#> $ASM$ph_uis$ui_asm_docx_ph_HEADERLEFT$name
#> [1] "HEADERLEFT"
#> 
#> $ASM$ph_uis$ui_asm_docx_ph_HEADERLEFT$location
#> [1] "header"
#> 
#> $ASM$ph_uis$ui_asm_docx_ph_HEADERLEFT$value
#> [1] ""
#> 
#> $ASM$ph_uis$ui_asm_docx_ph_HEADERLEFT$tooltip
#> [1] "left header text"
#> 
#> $ASM$ph_uis$ui_asm_docx_ph_HEADERLEFT$ph_idx
#> [1] 1
#> 
#> 
#> $ASM$ph_uis$ui_asm_docx_ph_HEADERRIGHT
#> $ASM$ph_uis$ui_asm_docx_ph_HEADERRIGHT$name
#> [1] "HEADERRIGHT"
#> 
#> $ASM$ph_uis$ui_asm_docx_ph_HEADERRIGHT$location
#> [1] "header"
#> 
#> $ASM$ph_uis$ui_asm_docx_ph_HEADERRIGHT$value
#> [1] ""
#> 
#> $ASM$ph_uis$ui_asm_docx_ph_HEADERRIGHT$tooltip
#> [1] "right header text"
#> 
#> $ASM$ph_uis$ui_asm_docx_ph_HEADERRIGHT$ph_idx
#> [1] 2
#> 
#> 
#> $ASM$ph_uis$ui_asm_docx_ph_FOOTERLEFT
#> $ASM$ph_uis$ui_asm_docx_ph_FOOTERLEFT$name
#> [1] "FOOTERLEFT"
#> 
#> $ASM$ph_uis$ui_asm_docx_ph_FOOTERLEFT$location
#> [1] "footer"
#> 
#> $ASM$ph_uis$ui_asm_docx_ph_FOOTERLEFT$value
#> [1] ""
#> 
#> $ASM$ph_uis$ui_asm_docx_ph_FOOTERLEFT$tooltip
#> [1] "left footer text"
#> 
#> $ASM$ph_uis$ui_asm_docx_ph_FOOTERLEFT$ph_idx
#> [1] 3
#> 
#> 
#> 
#> $ASM$ui
#> $ASM$ui$ui_asm_docx_ph_HEADERLEFT
#> [1] ""
#> 
#> $ASM$ui$ui_asm_docx_ph_HEADERRIGHT
#> [1] ""
#> 
#> $ASM$ui$ui_asm_docx_ph_FOOTERLEFT
#> [1] ""
#> 
#> $ASM$ui$button_state_save
#> [1] ""
#> 
#> $ASM$ui$button_rpt_xlsx
#> [1] ""
#> 
#> $ASM$ui$button_rpt_docx
#> [1] ""
#> 
#> $ASM$ui$button_rpt_pptx
#> [1] ""
#> 
#> $ASM$ui$ui_asm_save_name
#> [1] ""
#> 
#> $ASM$ui$switch_gen_rpts
#> [1] ""
#> 
#> 
#> 
#> $MOD_TYPE
#> [1] "ASM"
#> 
#> $id
#> [1] "ASM"
#> 
#> $FM_yaml_file
#> [1] "/private/var/folders/l9/6pm7xq5j1hn6l00zrs22j6mc0000gn/T/RtmpEfG5in/temp_libpath6d4076dedebf/formods/templates/formods.yaml"
#> 
#> $MOD_yaml_file
#> [1] "/private/var/folders/l9/6pm7xq5j1hn6l00zrs22j6mc0000gn/T/RtmpEfG5in/temp_libpath6d4076dedebf/formods/templates/ASM.yaml"
#> 
#> $shiny_token
#> [1] "non_shiny"
#>