Skip to content

Commit

Permalink
Merge pull request loosolab#18 from HendrikSchultheis/download
Browse files Browse the repository at this point in the history
download: wait notification
  • Loading branch information
HendrikSchultheis authored Jun 4, 2018
2 parents bb774dc + 210dbac commit d38d536
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion R/function.R
Original file line number Diff line number Diff line change
Expand Up @@ -1117,6 +1117,18 @@ searchData <- function(input, choices, options = c("=", "<", ">"), min. = min(ch
#'
#' @return See \code{\link[utils]{zip}}.
download <- function(file, filename, plot, width, height, ppi = 72, save_plot = TRUE, ui = NULL) {
session <- shiny::getDefaultReactiveDomain()

# show notification
shiny::showNotification(
id = session$ns("download-note"),
shiny::tags$b("Preparing download files. Please wait..."),
duration = NULL,
closeButton = FALSE,
type = "message"
)
shinyjs::runjs(paste0("$(document.getElementById('", paste0("shiny-notification-", session$ns("download-note")), "')).addClass('notification-position-center');"))

# cut off file extension
name <- sub("(.*)\\..*$", replacement = "\\1", filename)

Expand Down Expand Up @@ -1179,5 +1191,10 @@ download <- function(file, filename, plot, width, height, ppi = 72, save_plot =
}

# create zip file
utils::zip(zipfile = file, files = files, flags = "-j") # discard file path
out <- utils::zip(zipfile = file, files = files, flags = "-j") # discard file path

# remove notification
shiny::removeNotification(session$ns("download-note"))

return(out)
}

0 comments on commit d38d536

Please sign in to comment.