R/mod_Load_Dataset.R

Defines functions mod_Load_Dataset_server mod_Load_Dataset_ui

Documented in mod_Load_Dataset_server mod_Load_Dataset_ui

#' @title mod_Load_Dataset
#' 
#' @description  A shiny Module.
#' @param id xxx
#'
#' @rdname mod_Load_Dataset
#' 
#' @export
#' 
mod_Load_Dataset_ui <- function(id){

}


#' @return xxx 
#' 
#' @rdname mod_Load_Dataset
#' 
#' @export
#' 
mod_Load_Dataset_server <- function(id){
  
  moduleServer(id, function(input, output, session){
    ns <- session$ns
    
    rv <- reactiveValues(data = NULL)

    modal <- function(){
      modalDialog(
        fileInput(ns("file"), "Open file", 
                  multiple = FALSE,
                  accept = ".rds"),
        footer = tagList(
          modalButton('Cancel'),
          actionButton(ns('ok'), 'OK')
        )
      )
    }

    observe({showModal(modal())})
    
    observeEvent(input$Cancel, {removeModal()})
    
    observeEvent(input$ok, { 
      req(input$file)
      #browser()
      rv$data <- readRDS(input$file$datapath)
      #rv$data <- load(input$file$datapath)
      removeModal()
    })
  
    reactive({rv$data})
  })
  
}
samWieczorek/Magellan documentation built on March 30, 2022, 3:40 a.m.