Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migration shiny modules git hub comments #12

Merged
merged 7 commits into from
Aug 17, 2021
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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}: User must send first argument only which is string represents the module id
agenius-mohammed-ali marked this conversation as resolved.
Show resolved Hide resolved
#' @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}: User must send first argument only which is string represents the module id
#' @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}: first argument always must be 'id' string represents the module id
#' @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.

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

if (interactive()) {
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))
})
13 changes: 3 additions & 10 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 Down Expand Up @@ -85,7 +78,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 +93,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 +108,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