R/addin-show-templates.R

Defines functions show_templates

Documented in show_templates

#' Show templates.
#'
#' @description `display_template` opens an [RStudio
#'   gadget](https://shiny.rstudio.com/articles/gadgets.html) and
#'   [addin](http://rstudio.github.io/rstudioaddins/) that allows users
#'   to view the available templates.
#'
#' @return Addin has no return
#' @examples
#' \dontrun{
#' show_templates()
#' }
#' @export
show_templates <- function() {
  ui <- miniUI::miniPage(
    miniUI::miniTitleBar("rb3 Templates"),
    miniUI::miniContentPanel(
      DT::dataTableOutput("tableOutput")
    )
  )

  server <- function(input, output, session) {
    output$tableOutput <- DT::renderDataTable({
      df <- MarketData$show_templates()
      DT::datatable(df,
        selection = "none",
        options = list(paging = FALSE)
      )
    })
  }

  app <- shiny::shinyApp(ui = ui, server = server)
  viewer <- shiny::dialogViewer("rb3 Templates", width = 1200, height = 900)

  shiny::runGadget(app, viewer = viewer, stopOnCancel = TRUE)
}

Try the rb3 package in your browser

Any scripts or data that you put into this service are public.

rb3 documentation built on April 14, 2023, 5:10 p.m.