reportairr / app /main.R
peresay's picture
First app version
7822139
# app/main.R
box::use(
shiny[bootstrapPage, moduleServer, NS, shinyOptions],
shiny.router[router_ui, router_server, route],
htmltools[htmlDependency, tags],
shiny.semantic[grid, grid_template, semanticPage]
)
box::use(
app/view/navigation,
app/view/home,
app/view/multi_sample_report,
app/view/sample_report,
)
# add a cache for the app
shinyOptions(cache = cachem::cache_disk("./app_cache/cache/"))
# shiny.router dependencies do not get picked up because they're added in a non-standard way.
# addResourcePath("shiny.router", system.file("www", package = "shiny.router"))
# shiny_router_js <- file.path("shiny.router", "shiny.router.js")
# ---- router ----
# ---- router-ui ----
#' @export
ui <- function(id) {
ns <- NS(id)
router_page_elements <- list(
route("/", home$ui(ns("home"))),
route("multi_sample_report", multi_sample_report$ui(ns("multi_sample_report"))),
route("sample_report", sample_report$ui(ns("sample_report")))
)
router_page <- do.call(router_ui, router_page_elements)
semanticPage(
shinyjs::useShinyjs(),
tags$script(src = "https://kit.fontawesome.com/4a48dcafa5.js"),
navigation$horizontalMenu(navigation$navigation_links),
router_page
)
}
#' @export
server <- function(id) {
moduleServer(id, function(input, output, session) {
router_server()
home$server("home")
multi_sample_report$server("multi_sample_report")
sample_report$server("sample_report")
})
}