Type: | Package |
Title: | Progress Bars for Downloads in 'shiny' Apps |
Version: | 1.1.0 |
Description: | Modifies the progress() function from 'httr' package to let it send output to progressBar() function from 'shinyWidgets' package. It is just a tweak at the original functions from 'httr' package to make it smooth for 'shiny' developers. |
License: | MIT + file LICENSE |
BugReports: | https://github.com/curso-r/shinyhttr/issues |
URL: | https://github.com/curso-r/shinyhttr |
Encoding: | UTF-8 |
LazyData: | true |
Imports: | shinyWidgets, utils, httr |
RoxygenNote: | 7.1.1 |
Enhances: | shiny |
NeedsCompilation: | no |
Packaged: | 2020-07-16 15:24:02 UTC; ap_da |
Author: | Athos Damiani [aut, cre], Hadley Wickham [aut], RStudio [cph] |
Maintainer: | Athos Damiani <athos.damiani@curso-r.com> |
Repository: | CRAN |
Date/Publication: | 2020-07-16 15:30:02 UTC |
Add a progress bar compatible with 'shinyWidgets::updateProgressBar()'.
Description
Add a progress bar to request just like the vanilla 'httr::progress()' but with capability to talk to 'shinyWidgets::updateProgressBar()' by giving the session and id arguments to it.
Usage
progress(
session,
id,
type = c("down", "up"),
con = stdout(),
title = NULL,
status = NULL,
range_value = NULL,
unit_mark = "%"
)
Arguments
session |
(from ‘shinyWidgets::updateProgressBar()“ doc) The ’session' object passed to function given to shinyServer. |
id |
(from 'shinyWidgets::updateProgressBar()' doc) An id used to update the progress bar. |
type |
(from 'httr::progress()“ doc) Type of progress to display: either number of bytes uploaded or downloaded. |
con |
(from 'httr::progress()' doc) Connection to send output too. Usually |
title |
(from 'shinyWidgets::updateProgressBar()' doc) character, optional title. |
status |
(from 'shinyWidgets::updateProgressBar()' doc) Color, must be a valid Bootstrap status : primary, info, success, warning, danger. |
range_value |
(from 'shinyWidgets::updateProgressBar()' doc) Default is to display percentage ([0, 100]), but you can specify a custom range, e.g. -50, 50. |
unit_mark |
(from 'shinyWidgets::updateProgressBar()' doc) Unit for value displayed on the progress bar, default to "%". |
See Also
progress
, progressBar
, updateProgressBar
Examples
if (interactive()) {
library(shiny)
library(shinyWidgets)
library(shinyhttr)
ui <- fluidPage(
sidebarLayout(
NULL,
mainPanel(
actionButton('download', 'Download 100MB file...'),
tags$p("see R console to compare both progress bars."),
progressBar(
id = "pb",
value = 0,
title = "",
display_pct = TRUE
)
)
)
)
server <- function(input, output, session) {
observeEvent(input$download, {
httr::GET(
url = "https://speed.hetzner.de/100MB.bin",
progress(session, id = "pb")
)
})
}
shinyApp(ui, server)
}
progress_bar
Description
Same as 'httr:::progress_bar()' but with capability to talk to 'shinyWidgets::progressBar()'.
Usage
progress_bar(
type,
con,
session,
id,
title = NULL,
status = NULL,
range_value = NULL,
unit_mark = "%"
)
Arguments
type |
(from 'httr::progress()' doc) Type of progress to display: either number of bytes uploaded or downloaded. |
con |
(from 'httr::progress()' doc) Connection to send output too. Usually |
session |
(from ‘shinyWidgets::updateProgressBar()' doc) The ’session' object passed to function given to shinyServer. |
id |
(from 'shinyWidgets::updateProgressBar()' doc) An id used to update the progress bar. |
title |
(from 'shinyWidgets::updateProgressBar()' doc) character, optional title. |
status |
(from 'shinyWidgets::updateProgressBar()' doc) Color, must be a valid Bootstrap status : primary, info, success, warning, danger. |
range_value |
(from 'shinyWidgets::updateProgressBar()' doc) Default is to display percentage ([0, 100]), but you can specify a custom range, e.g. -50, 50. |
unit_mark |
(from 'shinyWidgets::updateProgressBar()' doc) Unit for value displayed on the progress bar, default to "%". |
Value
a function with rules to print out the progress.
See Also
runExample
Description
Launch shiny example application using shinyhttr::progress_bar. This app also uses module to show that it works with it too.
Usage
runExample(display.mode = "showcase")
Arguments
display.mode |
The mode in which to display the example. Defaults to showcase, but may be set to normal to see the example without code or commentary. |