R/m_home.R

Defines functions m_home_server m_home_ui

# Module UI
  
#' @title   m_home_ui and mod_home_server
#' @description  A shiny Module.
#'
#' @param id shiny id
#' @param input internal
#' @param output internal
#' @param session internal
#'
#' @rdname mod_home
#'
#' @keywords internal
#' @export 
#' @importFrom shiny NS tagList 
m_home_ui <- function(id){
  ns <- NS(id)
  shinydashboard::tabItem(tabName = "Home", 
                          
                          actionButton(ns("use_demo_data"), "Use demo data", class="btn-success"),
                          textInput(ns("gh_address"), "Github repository"),
                          textInput(ns('study_directory'), "Project directory"),
         
                          htmlOutput(ns("project_info")),
                          actionButton(ns("restart_app"), "Clear and reset app", class="btn-danger")
                          

  )
}
    
# Module Server
    
#' @rdname m_home
#' @export
#' @keywords internal
    
m_home_server <- function(input, output, session){
  ns <- session$ns
  
  project_info <- reactiveValues(
    name = NULL,
    path_bee = NULL,
    github_repo = NULL,
    demo = NULL
  )
  
  info <- reactive ({
    x <- Sys.info()
    list(
      user = x["user"],
      BEE = FALSE
    )
  })
  
  observeEvent(input$use_demo_data, {
    project_info$demo = TRUE
  })

    
  output$project_info <- renderUI({
    req(project_info$demo)

   
    div(
      h2(glue::glue("User: {info()$user}")),
      h2("Study Description: Demo study"),
      p("This is a demo study to explore some functionality within the app. Changes made in this session will not persist once the app is closed"),
      p("Path in BEE: NA")
    )
  })
  
  observe({
    req(project_info$demo)
    shinyjs::hide(id="use_demo_data")
    shinyjs::hide(id="gh_address")
    shinyjs::hide(id="study_directory")
  })
  
}
    
 
kismet303/lopo3000 documentation built on Dec. 5, 2019, 8:40 a.m.