# Module UI
#' @title mod_bootstrap_ui and mod_bootstrap_server
#' @description A shiny Module.
#'
#' @param id shiny id
#' @param input internal
#' @param output internal
#' @param session internal
#'
#' @rdname mod_bootstrap
#'
#' @keywords internal
#' @export
#' @include mod_bootstrap_side.R mod_bootstrap_body.R mod_bootstrap_compute.R
#' @importFrom shiny NS tagList
#' @importFrom shinydashboard box
#' @importFrom DT dataTableOutput
mod_bootstrap_ui <- function(id){
ns <- NS(id)
DEV_or_TEST <- isTruthy(get_golem_options("dev_mode")) || isTruthy(get_golem_options("test_mode"))
tabPanel("CL Bootstrap", value = "bootstrap", icon = icon("random", lib = "font-awesome"),
fluidPage(
fluidRow(
# --- Side panel
column(3, mod_bootstrap_side_ui(ns(NULL))),
# --- Main panel
if (!DEV_or_TEST) # DEV/PROD MODE
shinyjs::hidden(column(9, id = ns("content"), mod_bootstrap_body_ui(ns(NULL))))
else
column(9, id = ns("content"), mod_bootstrap_body_ui(ns(NULL)))
,
column(9, id=ns("content-load_data_message"), wellPanel(style="text-align:center", h4("Importer/Sélectionner un jeu de données ", icon("file-download"))))
)
)
)
}
# Module Server
#' @rdname mod_bootstrap
#' @export
#' @keywords internal
mod_bootstrap_server <- function(input, output, session){
# ////////////////////////////////////////////////
#-------------------------------------------------
# Initialisation du module
#-------------------------------------------------
# ////////////////////////////////////////////////
ns <- session$ns
# MVC - Getter et Setter :
# -----------------
mvc <- mvc_init_mod(session)
get <- mvc$get
setInput <- mvc$setInput
getInput <- mvc$getInput
# Local variables :
# -----------------
local <- reactiveValues()
# ////////////////////////////////////////////////
#-------------------------------------------------
# Sous-modules
#-------------------------------------------------
# ////////////////////////////////////////////////
callModule(mod_bootstrap_body_server, NULL)
callModule(mod_bootstrap_side_server, NULL)
# ////////////////////////////////////////////////
#-------------------------------------------------
# Compléments de UI
#-------------------------------------------------
# ////////////////////////////////////////////////
# TODO: Ces éléments pourraient être intégrés directement à l'UI en modifiant l'UI
# > ok done.
# insertUI(selector = "#app-bootstrap-content .nav.nav-tabs",
# ui = shinyjs::disabled(tags$li(actionLink(ns("save-config"), "Enregistrer la config", icon("save")), style="float:right")),
# where = "beforeEnd")
# insertUI(selector = "#app-bootstrap-content .nav.nav-tabs",
# ui = tags$li(exportExcelBtn(ns("export-excel"), "Exporter vers Excel"), style="float:right"),#tags$li(actionLink(ns("export-excel"), "Exporter vers Excel", icon("file-excel")), style="float:right"),
# where = "beforeEnd")
# # TODO : faire dépendre cet input de la sélection
# observe({
# setInput("bootstrap", "triangle", {
# session$userData$state$data$raw
# })
# })
# ////////////////////////////////////////////////
#-------------------------------------------------
# Outputs
#-------------------------------------------------
# ////////////////////////////////////////////////
# export-excel ----
# ---- [Buttons]
output[["export-excel"]] <- downloadHandler(
filename = function() {
paste("export.xlsx", sep = "")
},
content = function(file) {
create_excel_file(system.file("app/www/excel/template_bootstrap.xlsx", package = "triangle.tlbx"), file,
values = list("data_pos" = list("value" = session$userData$state$data$raw,
"colNames" = FALSE,
"rowNames" = TRUE),
"calculation_sigma_mack" = list("value" = get("bootstrap", "sigma_mack"),
"colNames" = FALSE,
"rowNames" = FALSE),
"calculation_unscaled_residuals" = list("value" = get("bootstrap", "residuals_unscaled"),
"colNames" = FALSE,
"rowNames" = TRUE),
"calculation_scaled_residuals" = list("value" = get("bootstrap", "residuals_scaled"),
"colNames" = FALSE,
"rowNames" = TRUE),
"results_summary" = list("value" = get("bootstrap", "summary_table"),
"colNames" = FALSE,
"rowNames" = TRUE),
"results_quantiles" = list("value" = get("bootstrap", "percentile_table"),
"colNames" = FALSE,
"rowNames" = TRUE)
))
}
)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.