Skip to content

Commit

Permalink
Advanced Report #322
Browse files Browse the repository at this point in the history
  • Loading branch information
kannanv93 committed Dec 18, 2024
1 parent 15e37a3 commit d884231
Show file tree
Hide file tree
Showing 2 changed files with 83 additions and 27 deletions.
74 changes: 72 additions & 2 deletions app/server.R
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,11 @@ server <- function(input, output, session) {
condition = input$select,
shinyjs::disable("report")
)
toggleState(
id = "advreport",
condition = input$select,
shinyjs::disable("advreport")
)
toggleState(
id = "pptreport",
condition = input$select,
Expand Down Expand Up @@ -929,6 +934,7 @@ server <- function(input, output, session) {
status = "warning",
width = "100%",
shinyjs::disable("report"),
shinyjs::disable("advreport"),
shinyjs::disable("pptreport"),
shinyjs::disable('download_missing'),
shinyjs::disable("download_data_1"),
Expand Down Expand Up @@ -957,6 +963,11 @@ server <- function(input, output, session) {
condition = length(input$countries) >= 10,
shinyjs::disable("report"),
)
toggleState(
id = "select",
condition = length(input$countries) >= 10,
shinyjs::disable("advreport"),
)
toggleState(
id = "select",
condition = length(input$countries) >= 10,
Expand Down Expand Up @@ -2565,7 +2576,7 @@ server <- function(input, output, session) {
family_order = family_order,
global_data = global_data,
family_order = family_order,
download_opt = input$download_Opt,
download_opt = FALSE,
compiled_indicators = raw_data,
db_variables = db_variables
)
Expand All @@ -2580,7 +2591,66 @@ server <- function(input, output, session) {
)
}
)


#Advanced Report
output$advreport <- downloadHandler(
filename =
reactive(
paste0(
"CLIAR-benchmarking-Advanced-Report-",
base_country(),
".docx"
)
),
content = function(file) {
show_modal_spinner(
color = "#17a2b8",
text = "Compiling report",
)

on.exit(remove_modal_spinner())

tmp_dir <- tempdir()

tempReport <- file.path(tmp_dir, "report.Rmd")

file.copy("www/", tmp_dir, recursive = TRUE)
file.copy("report.Rmd", tempReport, overwrite = TRUE)

params <-
list(
base_country = base_country(),
comparison_countries = input$countries,
data = data_avg(),
wb_country_list = country_list,
family_data = data_family(),
data_dyn = data_dyn(),
data_dyn_avg = data_dyn_avg(),
family_data_dyn = data_family_dyn(),
rank = input$rank,
definitions = definitions,
variable_names = variable_names,
dots = input$benchmark_dots,
group_median = input$benchmark_median,
threshold = input$threshold,
family_order = family_order,
global_data = global_data,
family_order = family_order,
download_opt = TRUE,
compiled_indicators = raw_data,
db_variables = db_variables
)


rmarkdown::render(
tempReport,
output_file = file,
params = params,
envir = new.env(parent = globalenv()),
knit_root_dir = getwd()
)
}
)

# Missingness Report ================================================================================

Expand Down
36 changes: 11 additions & 25 deletions app/ui.R
Original file line number Diff line number Diff line change
Expand Up @@ -659,42 +659,28 @@ ui <-
fluidRow(
id = "download_reports",
column(
width = 4,
width = 3,
shinyjs::disabled(
downloadButton(
"report",
"Editable report",
style = "width:100%; background-color: #204d74; color: white"
)
),
shiny::fluidRow(
column(
width = 12,
helper(
shiny_tag = tags$b("Advanced Report Download"),
type = "inline",
icon = "circle-question",
title = "Pre-populated reports and data",
content = c(
"The Advanced Report includes all available dynamic graphs for the selected base country.
These plots take a lot of time to produce, so please wait about 10 minutes for the advanced report to download"
),
buttonLabel = "Close",
fade = T,
size = "s"
),
prettyCheckbox(
inputId = "download_Opt",
label = "Advanced Report (~10min)",
value = FALSE,
icon = icon("check"),
status = "success"
)

),
column(
width = 3,
shinyjs::disabled(
downloadButton(
"advreport",
"Advanced Report",
style = "width:100%; background-color: #204d74; color: white"
)
)
),
column(
width = 4,
width = 3,
shinyjs::disabled(
downloadButton(
"pptreport",
Expand Down

0 comments on commit d884231

Please sign in to comment.