Documentation added
This commit is contained in:
@@ -1,9 +1,15 @@
|
||||
|
||||
#' Basic R shiny application
|
||||
#'
|
||||
#' @export
|
||||
# nolint next: object_name_linter. R6Class
|
||||
FrameApplication <- R6::R6Class(
|
||||
"FrameApplication",
|
||||
public = list(
|
||||
#' @description Creates a new R Shiny application
|
||||
#' @param appPage <module> An application module (attempts to load
|
||||
#' pages/application.R if not supplied)
|
||||
#' @param language <character> The language to use for the HTML page
|
||||
#' (defaults to "en")
|
||||
initialize = function(appPage = NULL, language = NULL) {
|
||||
if (!is.null(appPage)) {
|
||||
private$appPage <- appPage
|
||||
@@ -15,6 +21,8 @@ FrameApplication <- R6::R6Class(
|
||||
}
|
||||
invisible(self)
|
||||
},
|
||||
#' @description Binds the application to a session logger
|
||||
#' @param sessionLogger The session logger instance to use
|
||||
withSessionLogger = function(sessionLogger) {
|
||||
if (!inherits(sessionLogger, "SessionLogger")) {
|
||||
rlang::abort("sessionLogger is not an instance of SessionLogger class")
|
||||
@@ -22,10 +30,18 @@ FrameApplication <- R6::R6Class(
|
||||
private$sessionLogger <- sessionLogger
|
||||
invisible(self)
|
||||
},
|
||||
#' @description Loads with the Bootstrap 4 shim CSS file
|
||||
withBootstrap4Shim = function() {
|
||||
private$withBS4 <- TRUE
|
||||
invisible(self)
|
||||
},
|
||||
#' @description Returns a DBClient instance for the current session
|
||||
#' @param session An R Shiny session
|
||||
#' @param db_config The database configuration to use (will attempt to find
|
||||
#' and load a global.R or .env.R file if not supploed)
|
||||
#' @param allowFailure If a configuration cannot be loaded or a connection
|
||||
#' to the database cannot be made, do not abort
|
||||
#' @returns A DBClient instance which is useable for the session
|
||||
getSessionDBClient = function(
|
||||
session, db_config = NULL, allowFailure = FALSE
|
||||
) {
|
||||
@@ -59,6 +75,7 @@ FrameApplication <- R6::R6Class(
|
||||
# Create the client instance
|
||||
AVSDevR.DBClient::DBClient$new(db_conn)
|
||||
},
|
||||
#' @description Creates the UI component for an R Shiny application
|
||||
ui = function() {
|
||||
if (file.exists("widgets/menu.R")) {
|
||||
# Multi-frame application
|
||||
@@ -119,6 +136,11 @@ FrameApplication <- R6::R6Class(
|
||||
# Set the language
|
||||
shiny:::setLang(ui, private$language)
|
||||
},
|
||||
#' @description Creates the server component for an R Shiny application
|
||||
#' @param input The UI inputs bound for the session
|
||||
#' @param output The UI outputs bound for the session
|
||||
#' @param session The current session
|
||||
#' @param ... Parameters passed into the inner application
|
||||
server = function(input, output, session, ...) {
|
||||
if (!is.null(private$sessionLogger)) {
|
||||
private$sessionLogger$attachSession(session)
|
||||
@@ -131,6 +153,8 @@ FrameApplication <- R6::R6Class(
|
||||
...
|
||||
)
|
||||
},
|
||||
#' @description Instantiates an R Shiny application
|
||||
#' @returns An R Shiny application suitable for \link[shiny]{runApp}
|
||||
app = function() {
|
||||
shiny::shinyApp(self$ui(), self$server)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user