Skip to content
This repository has been archived by the owner. It is now read-only.

download: wait notification #18

Merged
merged 1 commit into from
Jun 4, 2018
Merged
Changes from all 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
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)
}