R/m_overview.R

Defines functions m_overview_ui m_overview_server

# Module UI
  
#' @title   m_overview_ui and mod_overview_server
#' @description  A shiny Module.
#'
#' @param id shiny id
#' @param input internal
#' @param output internal
#' @param session internal
#'
#' @rdname m_overview
#'
#' @keywords internal
#' @export 
#' @importFrom shiny NS tagList 
m_overview_ui <- function(id){
  ns <- NS(id)
 
  shinydashboard::tabItem(
    tabName = "OVERVIEW", 
    uiOutput(ns("lopo_overview_txt")),
      
    shinydashboard::valueBox(textOutput(ns("num_of_table")), 
                             "Tables", 
                             icon = icon("list"), 
                             color = "aqua", 
                             width = 3,
                             href = NULL),
    shinydashboard::valueBox(textOutput(ns("num_of_figure")), 
                             "Figures", 
                             icon = icon("chart-bar"), 
                             color = "aqua", 
                             width = 3,
                             href = NULL),
    shinydashboard::valueBox(textOutput(ns("num_of_listing")), 
                             "Listings", 
                             icon = icon("align-justify"), 
                             color = "aqua", 
                             width = 3,
                             href = NULL),
    shinydashboard::valueBox("12", "ADAMs", 
                             icon = icon("plus-square"), 
                             color = "aqua", 
                             width = 3,
                             href = NULL) 
    
  )
}
    
# Module Server
    
#' @rdname m_overview
#' @export
#' @keywords internal
    
m_overview_server <- function(input, output, session, state){
  ns <- session$ns
  
  output$lopo_overview_txt <- renderUI({
    tagList(
      h4(glue::glue("Overview of Lopo for study: {state$study}")),
      h4(glue::glue("Reporting activity: {state$reporting_activity}"))
    )
  })
  
  lopo_info <- reactive({
    # browser()
    req(state$lopo)
    mylopo <- state$lopo
    list(
      num_of_table = nrow(dplyr::filter(mylopo, outType == "Table")),
      num_of_figure = nrow(dplyr::filter(mylopo, outType == "Figure")),
      num_of_listing = nrow(dplyr::filter(mylopo, outType == "Listing")) 
    )
  })
  
  output$num_of_table <- renderText({paste0(lopo_info()$num_of_table, "")})
  output$num_of_figure <- renderText({paste0(lopo_info()$num_of_figure, "")})
  output$num_of_listing <- renderText({ paste0(lopo_info()$num_of_listing, "")})
}
    
kismet303/lopo3000 documentation built on Dec. 15, 2019, 12:31 a.m.