Skip to content

Commit

Permalink
Merge pull request #12 from agenius-mohammed-ali/migration_shiny_modu…
Browse files Browse the repository at this point in the history
…les_GitHub_comments

Migration shiny modules git hub comments
  • Loading branch information
agenius-mohammed-ali authored Aug 17, 2021
2 parents 8ed81d6 + 456517d commit f9428c7
Show file tree
Hide file tree
Showing 13 changed files with 37 additions and 62 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Package: periscope
Type: Package
Title: Enterprise Streamlined 'Shiny' Application Framework
Version: 0.6.3.9002
Version: 1.0.0.9001
Authors@R: c(
person("Constance", "Brett", email="connie@aggregate-genius.com", role = c("aut", "cre")),
person("Isaac", "Neuhaus", role = "aut", comment = "canvasXpress JavaScript Library Maintainer"),
Expand Down
5 changes: 1 addition & 4 deletions R/appReset.R
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
params_length <- length(params)
old_style_call <- call[[1]] == "module" || "periscope" %in% as.character(call[[1]])

# get session parameters
if (old_style_call) {
input <- params[[param_index]]
param_index <- param_index + 1
Expand All @@ -45,7 +44,6 @@
param_index <- param_index + 1
}

# get rest of the function parameters
if (missing(logger) && params_length >= param_index) {
logger <- params[[param_index]]
}
Expand All @@ -54,11 +52,10 @@
app_reset(input, output, session, logger)
}
else {
moduleServer(
shiny::moduleServer(
id,
function(input, output, session) {
app_reset(input, output, session, logger)

})
}
}
Expand Down
10 changes: 4 additions & 6 deletions R/bodyFooter.R
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
params_length <- length(params)
old_style_call <- call[[1]] == "module" || "periscope" %in% as.character(call[[1]])

# get session parameters
if (old_style_call) {
input <- params[[param_index]]
param_index <- param_index + 1
Expand All @@ -39,24 +38,23 @@
param_index <- param_index + 1
}

# get rest of the function parameters
if (missing(logdata) && params_length >= param_index) {
logdata <- params[[param_index]]
}

if (old_style_call) {
boody_footer(input, output, session, logdata)
body_footer(input, output, session, logdata)
}
else {
moduleServer(
shiny::moduleServer(
id,
function(input, output, session) {
boody_footer(input, output, session, logdata)
body_footer(input, output, session, logdata)
})
}
}

boody_footer <- function(input, output, session, logdata) {
body_footer <- function(input, output, session, logdata) {
output$dt_userlog <- shiny::renderTable({

lines <- logdata()
Expand Down
7 changes: 3 additions & 4 deletions R/downloadFile.R
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,8 @@ downloadFileButton <- function(id,
#' Server-side function for the downloadFileButton. This is a custom
#' high-functionality button for file downloads supporting single or multiple
#' download types. The server function is used to provide the data for download.
#' @param id string represents the module id
#' @param ... free parameters list for shiny to pass session variables based on the module call(session, input, output)
#' variables. \emph{Note}: The first argument of this function must be the ID of the Module's UI element
#' @param logger logger to use
#' @param filenameroot the base text used for user-downloaded file - can be
#' either a character string or a reactive expression that returns a character
Expand Down Expand Up @@ -154,7 +155,6 @@ downloadFile <- function(...,
params_length <- length(params)
old_style_call <- call[[1]] == "module" || "periscope" %in% as.character(call[[1]])

# get session parameters
if (old_style_call) {
input <- params[[param_index]]
param_index <- param_index + 1
Expand All @@ -167,7 +167,6 @@ downloadFile <- function(...,
param_index <- param_index + 1
}

# get rest of the function parameters
if (missing(logger) && params_length >= param_index) {
logger <- params[[param_index]]
param_index <- param_index + 1
Expand Down Expand Up @@ -198,7 +197,7 @@ downloadFile <- function(...,
aspectratio)
}
else {
moduleServer(
shiny::moduleServer(
id,
function(input, output, session) {
download_file(input,
Expand Down
9 changes: 4 additions & 5 deletions R/downloadablePlot.R
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,8 @@ downloadablePlotUI <- function(id,
#' Server-side function for the downloadablePlotUI. This is a custom
#' plot output paired with a linked downloadFile button.
#'
#' @param id string represents the module id
#' @param ... free parameters list for shiny to pass session variables based on the module call(session, input, output)
#' variables. \emph{Note}: The first argument of this function must be the ID of the Module's UI element
#' @param logger logger to use
#' @param filenameroot the base text used for user-downloaded file - can be
#' either a character string or a reactive expression returning a character
Expand Down Expand Up @@ -181,7 +182,6 @@ downloadablePlot <- function(...,

old_style_call <- call[[1]] == "module" || "periscope" %in% as.character(call[[1]])

# get session parameters
if (old_style_call) {
input <- params[[param_index]]
param_index <- param_index + 1
Expand All @@ -194,7 +194,6 @@ downloadablePlot <- function(...,
param_index <- param_index + 1
}

# get rest of the function parameters
if (missing(logger) && params_length >= param_index) {
logger <- params[[param_index]]
param_index <- param_index + 1
Expand Down Expand Up @@ -231,7 +230,7 @@ downloadablePlot <- function(...,
visibleplot)
}
else {
moduleServer(
shiny::moduleServer(
id,
function(input, output, session) {
download_plot(input,
Expand All @@ -241,7 +240,7 @@ downloadablePlot <- function(...,
filenameroot,
aspectratio,
downloadfxns,
visibleplot)
visibleplot)
})
}
}
Expand Down
7 changes: 3 additions & 4 deletions R/downloadableTable.R
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,8 @@ downloadableTableUI <- function(id,
#' high-functionality table paired with a linked downloadFile
#' button.
#'
#' @param id string represents the module id
#' @param ... free parameters list to pass table customization options. See example below.
#' \emph{Note}: The first argument of this function must be the ID of the Module's UI element
#' @param logger logger to use
#' @param filenameroot the base text used for user-downloaded file - can be
#' either a character string or a reactive expression returning a character
Expand Down Expand Up @@ -151,7 +152,6 @@ downloadableTable <- function(...,
params_length <- length(params)
old_style_call <- call[[1]] == "module" || "periscope" %in% as.character(call[[1]])

# get session parameters
if (old_style_call) {
input <- params[[param_index]]
param_index <- param_index + 1
Expand All @@ -164,7 +164,6 @@ downloadableTable <- function(...,
param_index <- param_index + 1
}

# get rest of the function parameters
if (missing(logger) && params_length >= param_index) {
logger <- params[[param_index]]
param_index <- param_index + 1
Expand Down Expand Up @@ -211,7 +210,7 @@ downloadableTable <- function(...,
selection)
}
else {
moduleServer(id = params[[1]],
shiny::moduleServer(id = params[[1]],
function(input, output, session) {
download_table(input, output, session,
logger,
Expand Down
5 changes: 3 additions & 2 deletions man/downloadFile.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions man/downloadablePlot.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions man/downloadableTable.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 0 additions & 2 deletions tests/testthat/setup.R
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ require(shiny)
require(periscope)
require(shinydashboardPlus)
require(ggplot2)
require(lattice)
require(openxlsx)

if (interactive()) {
test_source_path <- "periscope/R"
Expand Down
18 changes: 9 additions & 9 deletions tests/testthat/test_body_footer.R
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,14 @@ test_that(".bodyFooter", {
expect_equal(class(footer)[[1]], "shiny.render.function")
})

test_that("boody_footer", {
expect_silent(boody_footer(input = list(),
output = list(),
session = MockShinySession$new(),
logdata = data))
test_that("body_footer ", {
expect_silent(body_footer(input = list(),
output = list(),
session = MockShinySession$new(),
logdata = data))

expect_silent(boody_footer(input = list(),
output = list(),
session = MockShinySession$new(),
logdata = data2))
expect_silent(body_footer(input = list(),
output = list(),
session = MockShinySession$new(),
logdata = data2))
})
17 changes: 3 additions & 14 deletions tests/testthat/test_download_file.R
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,6 @@ download_plot <- function() {
ylab("mpg")
}

download_plot_lattice <- function() {
lattice::xyplot(mpg ~ wt , data = mtcars,
pch = 1, groups = factor(cyl),
auto.key = list(corner = c(1, 1)),
main = "Lattice Example")
}

download_data <- function() {
mtcars
}
Expand All @@ -28,10 +21,6 @@ download_data_show_row_names <- function() {
mtcars
}

download_openxlsx_data <- function() {
openxlsx::createWorkbook()
}

download_string_list <- function() {
c("test1", "test2", "tests")
}
Expand Down Expand Up @@ -85,7 +74,7 @@ test_that("download_file", {
png = download_plot,
jpeg = download_plot,
tiff = download_plot,
bmp = download_plot_lattice))
bmp = download_plot))
)

})
Expand All @@ -100,7 +89,7 @@ test_that("downloadFile_callModule", {
png = download_plot,
jpeg = download_plot,
tiff = download_plot,
bmp = download_plot_lattice)
bmp = download_plot)
expect_silent(shiny::callModule(downloadFile,
"download",
input = list(),
Expand All @@ -115,5 +104,5 @@ test_that("downloadFile_callModule", {
png = download_plot,
jpeg = download_plot,
tiff = download_plot,
bmp = download_plot_lattice)))
bmp = download_plot)))
})
7 changes: 0 additions & 7 deletions tests/testthat/test_downloadable_plot.R
Original file line number Diff line number Diff line change
Expand Up @@ -74,13 +74,6 @@ test_that("downloadablePlot", {
ylab("mpg")
}

download_plot_lattice <- function() {
lattice::xyplot(mpg ~ wt , data = mtcars,
pch = 1, groups = factor(cyl),
auto.key = list(corner = c(1, 1)),
main = "Lattice Example")
}

download_data <- function() {
mtcars
}
Expand Down

0 comments on commit f9428c7

Please sign in to comment.