#' imports UI Function
#'
#' @description A shiny Module.
#'
#' @param id,input,output,session Internal parameters for {shiny}.
#'
#' @noRd
#'
#' @importFrom shiny NS tagList
mod_imports_ui <- function(id) {
ns <- NS(id)
tagList(
shiny::column(width = 12,
shiny::h5("Select meta and data files"),
shiny::fluidRow(
shinyFiles::shinyFilesButton(
id = ns("meta_file"),
title = "Meta data",
label = "Select a meta data file",
multiple = FALSE,
viewtype = "detail"
),
DT::DTOutput(ns("selected_meta_data"))
),
shiny::fluidRow(
shinyFiles::shinyFilesButton(
id = ns("data_files"),
title = "Data files",
label = "Select data files",
multiple = TRUE,
viewtype = "detail"
),
shiny::verbatimTextOutput(ns("selected_data_files"))
))
)
}
#' imports Server Functions
#'
#' @noRd
mod_imports_server <- function(id, app_data){
moduleServer( id, function(input, output, session){
ns <- session$ns
# volumes <- c(Home = fs::path_home(), "R Installation" = R.home(), getVolumes()())
volumes <- c(app_home = getwd())
shinyFiles::shinyFileChoose(
input = input,
id = "meta_file",
roots = volumes,
session = session,
filetypes = c("RDS", "Rds", "rds")
)
output$selected_meta_data <- DT::renderDT({
shiny::validate(shiny::need(!is.integer(input$meta_file), message = "Please select a meta data file."))
readRDS(parseFilePaths(volumes, input$meta_file)$datapath)
})
#
# shinyFiles::shinyFileChoose(
# input = input,
# id = "data_files",
# roots = volumes,
# session = session,
# filetypes = c("RDS", "Rds", "rds")
# )
#
# output$selected_data_files <- shiny::renderPrint({
# # print(input$data_files)
# })
})
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.